Fossil SCM

Merge from trunk + minor changes to update.c to work with new . return from file_tree_name for fossil root.

venkat 2010-11-09 01:06 venks-emacs merge
Commit a9407bc82f350337d520f33232b076b14e285c89
+21 -9
--- src/file.c
+++ src/file.c
@@ -429,24 +429,36 @@
429429
** The root of the tree is defined by the g.zLocalRoot variable.
430430
*/
431431
int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
432432
int n;
433433
Blob full;
434
+ int nFull;
435
+ char *zFull;
436
+
437
+ blob_zero(pOut);
434438
db_must_be_within_tree();
435439
file_canonical_name(zOrigName, &full);
436440
n = strlen(g.zLocalRoot);
437
- if((blob_size(&full) == n-1 && !memcmp(g.zLocalRoot, blob_buffer(&full), n-1)) ||
438
- (blob_size(&full) >= n && !memcmp(g.zLocalRoot, blob_buffer(&full), n))){
439
- blob_zero(pOut);
440
- blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
441
- return 1;
442
- }
443
- blob_reset(&full);
444
- if( errFatal ){
441
+ assert( n>0 && g.zLocalRoot[n-1]=='/' );
442
+ nFull = blob_size(&full);
443
+ zFull = blob_buffer(&full);
444
+
445
+ /* Special case. zOrigName refers to g.zLocalRoot directory. */
446
+ if( nFull==n-1 && memcmp(g.zLocalRoot, zFull, nFull)==0 ){
447
+ blob_append(pOut, ".", 1);
448
+ return 1;
449
+ }
450
+
451
+ if( nFull<=n || memcmp(g.zLocalRoot, zFull, n) ){
452
+ blob_reset(&full);
453
+ if( errFatal ){
445454
fossil_fatal("file outside of checkout tree: %s", zOrigName);
455
+ }
456
+ return 0;
446457
}
447
- return 0;
458
+ blob_append(pOut, &zFull[n], nFull-n);
459
+ return 1;
448460
}
449461
450462
/*
451463
** COMMAND: test-tree-name
452464
**
453465
--- src/file.c
+++ src/file.c
@@ -429,24 +429,36 @@
429 ** The root of the tree is defined by the g.zLocalRoot variable.
430 */
431 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
432 int n;
433 Blob full;
 
 
 
 
434 db_must_be_within_tree();
435 file_canonical_name(zOrigName, &full);
436 n = strlen(g.zLocalRoot);
437 if((blob_size(&full) == n-1 && !memcmp(g.zLocalRoot, blob_buffer(&full), n-1)) ||
438 (blob_size(&full) >= n && !memcmp(g.zLocalRoot, blob_buffer(&full), n))){
439 blob_zero(pOut);
440 blob_append(pOut, blob_buffer(&full)+n, blob_size(&full)-n);
441 return 1;
442 }
443 blob_reset(&full);
444 if( errFatal ){
 
 
 
 
 
445 fossil_fatal("file outside of checkout tree: %s", zOrigName);
 
 
446 }
447 return 0;
 
448 }
449
450 /*
451 ** COMMAND: test-tree-name
452 **
453
--- src/file.c
+++ src/file.c
@@ -429,24 +429,36 @@
429 ** The root of the tree is defined by the g.zLocalRoot variable.
430 */
431 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
432 int n;
433 Blob full;
434 int nFull;
435 char *zFull;
436
437 blob_zero(pOut);
438 db_must_be_within_tree();
439 file_canonical_name(zOrigName, &full);
440 n = strlen(g.zLocalRoot);
441 assert( n>0 && g.zLocalRoot[n-1]=='/' );
442 nFull = blob_size(&full);
443 zFull = blob_buffer(&full);
444
445 /* Special case. zOrigName refers to g.zLocalRoot directory. */
446 if( nFull==n-1 && memcmp(g.zLocalRoot, zFull, nFull)==0 ){
447 blob_append(pOut, ".", 1);
448 return 1;
449 }
450
451 if( nFull<=n || memcmp(g.zLocalRoot, zFull, n) ){
452 blob_reset(&full);
453 if( errFatal ){
454 fossil_fatal("file outside of checkout tree: %s", zOrigName);
455 }
456 return 0;
457 }
458 blob_append(pOut, &zFull[n], nFull-n);
459 return 1;
460 }
461
462 /*
463 ** COMMAND: test-tree-name
464 **
465
+12 -1
--- src/manifest.c
+++ src/manifest.c
@@ -184,20 +184,31 @@
184184
185185
#ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
186186
# define md5sum_init(X)
187187
# define md5sum_step_text(X,Y)
188188
#endif
189
+
190
+/*
191
+** Return true if z points to the first character after a blank line.
192
+** Tolerate either \r\n or \n line endings.
193
+*/
194
+static int after_blank_line(const char *z){
195
+ if( z[-1]!='\n' ) return 0;
196
+ if( z[-2]=='\n' ) return 1;
197
+ if( z[-2]=='\r' && z[-3]=='\n' ) return 1;
198
+ return 0;
199
+}
189200
190201
/*
191202
** Remove the PGP signature from the artifact, if there is one.
192203
*/
193204
static void remove_pgp_signature(char **pz, int *pn){
194205
char *z = *pz;
195206
int n = *pn;
196207
int i;
197208
if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
198
- for(i=34; i<n && (z[i-1]!='\n' || z[i-2]!='\n'); i++){}
209
+ for(i=34; i<n && !after_blank_line(z+i); i++){}
199210
if( i>=n ) return;
200211
z += i;
201212
n -= i;
202213
*pz = z;
203214
for(i=n-1; i>=0; i--){
204215
--- src/manifest.c
+++ src/manifest.c
@@ -184,20 +184,31 @@
184
185 #ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
186 # define md5sum_init(X)
187 # define md5sum_step_text(X,Y)
188 #endif
 
 
 
 
 
 
 
 
 
 
 
189
190 /*
191 ** Remove the PGP signature from the artifact, if there is one.
192 */
193 static void remove_pgp_signature(char **pz, int *pn){
194 char *z = *pz;
195 int n = *pn;
196 int i;
197 if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
198 for(i=34; i<n && (z[i-1]!='\n' || z[i-2]!='\n'); i++){}
199 if( i>=n ) return;
200 z += i;
201 n -= i;
202 *pz = z;
203 for(i=n-1; i>=0; i--){
204
--- src/manifest.c
+++ src/manifest.c
@@ -184,20 +184,31 @@
184
185 #ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
186 # define md5sum_init(X)
187 # define md5sum_step_text(X,Y)
188 #endif
189
190 /*
191 ** Return true if z points to the first character after a blank line.
192 ** Tolerate either \r\n or \n line endings.
193 */
194 static int after_blank_line(const char *z){
195 if( z[-1]!='\n' ) return 0;
196 if( z[-2]=='\n' ) return 1;
197 if( z[-2]=='\r' && z[-3]=='\n' ) return 1;
198 return 0;
199 }
200
201 /*
202 ** Remove the PGP signature from the artifact, if there is one.
203 */
204 static void remove_pgp_signature(char **pz, int *pn){
205 char *z = *pz;
206 int n = *pn;
207 int i;
208 if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
209 for(i=34; i<n && !after_blank_line(z+i); i++){}
210 if( i>=n ) return;
211 z += i;
212 n -= i;
213 *pz = z;
214 for(i=n-1; i>=0; i--){
215
+4 -4
--- src/merge.c
+++ src/merge.c
@@ -73,11 +73,11 @@
7373
}
7474
mid = name_to_rid(g.argv[2]);
7575
if( mid==0 ){
7676
fossil_fatal("not a version: %s", g.argv[2]);
7777
}
78
- if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){
78
+ if( !is_a_version(mid) ){
7979
fossil_fatal("not a version: %s", g.argv[2]);
8080
}
8181
if( pickFlag || backoutFlag ){
8282
pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
8383
if( pid<=0 ){
@@ -96,16 +96,16 @@
9696
pivot_set_secondary(db_column_int(&q,0));
9797
}
9898
db_finalize(&q);
9999
pid = pivot_find();
100100
if( pid<=0 ){
101
- fossil_fatal("cannot find a common ancestor between the current"
101
+ fossil_fatal("cannot find a common ancestor between the current "
102102
"checkout and %s", g.argv[2]);
103103
}
104104
}
105
- if( pid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", pid) ){
106
- fossil_fatal("not a version: record #%d", mid);
105
+ if( !is_a_version(pid) ){
106
+ fossil_fatal("not a version: record #%d", pid);
107107
}
108108
vfile_check_signature(vid, 1);
109109
db_begin_transaction();
110110
undo_begin();
111111
load_vfile_from_rid(mid);
112112
--- src/merge.c
+++ src/merge.c
@@ -73,11 +73,11 @@
73 }
74 mid = name_to_rid(g.argv[2]);
75 if( mid==0 ){
76 fossil_fatal("not a version: %s", g.argv[2]);
77 }
78 if( mid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", mid) ){
79 fossil_fatal("not a version: %s", g.argv[2]);
80 }
81 if( pickFlag || backoutFlag ){
82 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
83 if( pid<=0 ){
@@ -96,16 +96,16 @@
96 pivot_set_secondary(db_column_int(&q,0));
97 }
98 db_finalize(&q);
99 pid = pivot_find();
100 if( pid<=0 ){
101 fossil_fatal("cannot find a common ancestor between the current"
102 "checkout and %s", g.argv[2]);
103 }
104 }
105 if( pid>1 && !db_exists("SELECT 1 FROM plink WHERE cid=%d", pid) ){
106 fossil_fatal("not a version: record #%d", mid);
107 }
108 vfile_check_signature(vid, 1);
109 db_begin_transaction();
110 undo_begin();
111 load_vfile_from_rid(mid);
112
--- src/merge.c
+++ src/merge.c
@@ -73,11 +73,11 @@
73 }
74 mid = name_to_rid(g.argv[2]);
75 if( mid==0 ){
76 fossil_fatal("not a version: %s", g.argv[2]);
77 }
78 if( !is_a_version(mid) ){
79 fossil_fatal("not a version: %s", g.argv[2]);
80 }
81 if( pickFlag || backoutFlag ){
82 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
83 if( pid<=0 ){
@@ -96,16 +96,16 @@
96 pivot_set_secondary(db_column_int(&q,0));
97 }
98 db_finalize(&q);
99 pid = pivot_find();
100 if( pid<=0 ){
101 fossil_fatal("cannot find a common ancestor between the current "
102 "checkout and %s", g.argv[2]);
103 }
104 }
105 if( !is_a_version(pid) ){
106 fossil_fatal("not a version: record #%d", pid);
107 }
108 vfile_check_signature(vid, 1);
109 db_begin_transaction();
110 undo_begin();
111 load_vfile_from_rid(mid);
112
+2 -2
--- src/pivot.c
+++ src/pivot.c
@@ -50,11 +50,11 @@
5050
);
5151
5252
/* Insert the primary record */
5353
db_multi_exec(
5454
"INSERT INTO aqueue(rid, mtime, pending, src)"
55
- " SELECT %d, mtime, 1, 1 FROM plink WHERE cid=%d LIMIT 1",
55
+ " SELECT %d, mtime, 1, 1 FROM event WHERE objid=%d AND type='ci' LIMIT 1",
5656
rid, rid
5757
);
5858
}
5959
6060
/*
@@ -64,11 +64,11 @@
6464
*/
6565
void pivot_set_secondary(int rid){
6666
/* Insert the primary record */
6767
db_multi_exec(
6868
"INSERT OR IGNORE INTO aqueue(rid, mtime, pending, src)"
69
- " SELECT %d, mtime, 1, 0 FROM plink WHERE cid=%d",
69
+ " SELECT %d, mtime, 1, 0 FROM event WHERE objid=%d AND type='ci'",
7070
rid, rid
7171
);
7272
}
7373
7474
/*
7575
--- src/pivot.c
+++ src/pivot.c
@@ -50,11 +50,11 @@
50 );
51
52 /* Insert the primary record */
53 db_multi_exec(
54 "INSERT INTO aqueue(rid, mtime, pending, src)"
55 " SELECT %d, mtime, 1, 1 FROM plink WHERE cid=%d LIMIT 1",
56 rid, rid
57 );
58 }
59
60 /*
@@ -64,11 +64,11 @@
64 */
65 void pivot_set_secondary(int rid){
66 /* Insert the primary record */
67 db_multi_exec(
68 "INSERT OR IGNORE INTO aqueue(rid, mtime, pending, src)"
69 " SELECT %d, mtime, 1, 0 FROM plink WHERE cid=%d",
70 rid, rid
71 );
72 }
73
74 /*
75
--- src/pivot.c
+++ src/pivot.c
@@ -50,11 +50,11 @@
50 );
51
52 /* Insert the primary record */
53 db_multi_exec(
54 "INSERT INTO aqueue(rid, mtime, pending, src)"
55 " SELECT %d, mtime, 1, 1 FROM event WHERE objid=%d AND type='ci' LIMIT 1",
56 rid, rid
57 );
58 }
59
60 /*
@@ -64,11 +64,11 @@
64 */
65 void pivot_set_secondary(int rid){
66 /* Insert the primary record */
67 db_multi_exec(
68 "INSERT OR IGNORE INTO aqueue(rid, mtime, pending, src)"
69 " SELECT %d, mtime, 1, 0 FROM event WHERE objid=%d AND type='ci'",
70 rid, rid
71 );
72 }
73
74 /*
75
+2 -4
--- src/update.c
+++ src/update.c
@@ -71,11 +71,11 @@
7171
db_must_be_within_tree();
7272
vid = db_lget_int("checkout", 0);
7373
if( vid==0 ){
7474
fossil_fatal("cannot find current version");
7575
}
76
- if( db_exists("SELECT 1 FROM vmerge") ){
76
+ if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
7777
fossil_fatal("cannot update an uncommitted merge");
7878
}
7979
if( !nochangeFlag ) autosync(AUTOSYNC_PULL);
8080
8181
if( g.argc>=3 ){
@@ -182,13 +182,12 @@
182182
blob_zero(&sql);
183183
blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184184
zSep = "";
185185
for(i=3; i<g.argc; i++){
186186
file_tree_name(g.argv[i], &treename, 1);
187
- fprintf(stderr,"%s , %s\n",g.argv[i], blob_str(&treename));
188187
if( file_isdir(g.argv[i])==1 ){
189
- if( blob_size(&treename)>0 ){
188
+ if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
190189
blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
191190
}else{
192191
blob_reset(&sql);
193192
break;
194193
}
@@ -196,11 +195,10 @@
196195
blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197196
}
198197
zSep = "AND ";
199198
blob_reset(&treename);
200199
}
201
- /* fprintf(stderr, "%s\n", blob_str(&sql)); */
202200
db_multi_exec(blob_str(&sql));
203201
blob_reset(&sql);
204202
}
205203
206204
db_prepare(&q,
207205
--- src/update.c
+++ src/update.c
@@ -71,11 +71,11 @@
71 db_must_be_within_tree();
72 vid = db_lget_int("checkout", 0);
73 if( vid==0 ){
74 fossil_fatal("cannot find current version");
75 }
76 if( db_exists("SELECT 1 FROM vmerge") ){
77 fossil_fatal("cannot update an uncommitted merge");
78 }
79 if( !nochangeFlag ) autosync(AUTOSYNC_PULL);
80
81 if( g.argc>=3 ){
@@ -182,13 +182,12 @@
182 blob_zero(&sql);
183 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184 zSep = "";
185 for(i=3; i<g.argc; i++){
186 file_tree_name(g.argv[i], &treename, 1);
187 fprintf(stderr,"%s , %s\n",g.argv[i], blob_str(&treename));
188 if( file_isdir(g.argv[i])==1 ){
189 if( blob_size(&treename)>0 ){
190 blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
191 }else{
192 blob_reset(&sql);
193 break;
194 }
@@ -196,11 +195,10 @@
196 blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197 }
198 zSep = "AND ";
199 blob_reset(&treename);
200 }
201 /* fprintf(stderr, "%s\n", blob_str(&sql)); */
202 db_multi_exec(blob_str(&sql));
203 blob_reset(&sql);
204 }
205
206 db_prepare(&q,
207
--- src/update.c
+++ src/update.c
@@ -71,11 +71,11 @@
71 db_must_be_within_tree();
72 vid = db_lget_int("checkout", 0);
73 if( vid==0 ){
74 fossil_fatal("cannot find current version");
75 }
76 if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
77 fossil_fatal("cannot update an uncommitted merge");
78 }
79 if( !nochangeFlag ) autosync(AUTOSYNC_PULL);
80
81 if( g.argc>=3 ){
@@ -182,13 +182,12 @@
182 blob_zero(&sql);
183 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184 zSep = "";
185 for(i=3; i<g.argc; i++){
186 file_tree_name(g.argv[i], &treename, 1);
 
187 if( file_isdir(g.argv[i])==1 ){
188 if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
189 blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
190 }else{
191 blob_reset(&sql);
192 break;
193 }
@@ -196,11 +195,10 @@
195 blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
196 }
197 zSep = "AND ";
198 blob_reset(&treename);
199 }
 
200 db_multi_exec(blob_str(&sql));
201 blob_reset(&sql);
202 }
203
204 db_prepare(&q,
205
+2 -4
--- src/update.c
+++ src/update.c
@@ -71,11 +71,11 @@
7171
db_must_be_within_tree();
7272
vid = db_lget_int("checkout", 0);
7373
if( vid==0 ){
7474
fossil_fatal("cannot find current version");
7575
}
76
- if( db_exists("SELECT 1 FROM vmerge") ){
76
+ if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
7777
fossil_fatal("cannot update an uncommitted merge");
7878
}
7979
if( !nochangeFlag ) autosync(AUTOSYNC_PULL);
8080
8181
if( g.argc>=3 ){
@@ -182,13 +182,12 @@
182182
blob_zero(&sql);
183183
blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184184
zSep = "";
185185
for(i=3; i<g.argc; i++){
186186
file_tree_name(g.argv[i], &treename, 1);
187
- fprintf(stderr,"%s , %s\n",g.argv[i], blob_str(&treename));
188187
if( file_isdir(g.argv[i])==1 ){
189
- if( blob_size(&treename)>0 ){
188
+ if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
190189
blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
191190
}else{
192191
blob_reset(&sql);
193192
break;
194193
}
@@ -196,11 +195,10 @@
196195
blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197196
}
198197
zSep = "AND ";
199198
blob_reset(&treename);
200199
}
201
- /* fprintf(stderr, "%s\n", blob_str(&sql)); */
202200
db_multi_exec(blob_str(&sql));
203201
blob_reset(&sql);
204202
}
205203
206204
db_prepare(&q,
207205
--- src/update.c
+++ src/update.c
@@ -71,11 +71,11 @@
71 db_must_be_within_tree();
72 vid = db_lget_int("checkout", 0);
73 if( vid==0 ){
74 fossil_fatal("cannot find current version");
75 }
76 if( db_exists("SELECT 1 FROM vmerge") ){
77 fossil_fatal("cannot update an uncommitted merge");
78 }
79 if( !nochangeFlag ) autosync(AUTOSYNC_PULL);
80
81 if( g.argc>=3 ){
@@ -182,13 +182,12 @@
182 blob_zero(&sql);
183 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184 zSep = "";
185 for(i=3; i<g.argc; i++){
186 file_tree_name(g.argv[i], &treename, 1);
187 fprintf(stderr,"%s , %s\n",g.argv[i], blob_str(&treename));
188 if( file_isdir(g.argv[i])==1 ){
189 if( blob_size(&treename)>0 ){
190 blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
191 }else{
192 blob_reset(&sql);
193 break;
194 }
@@ -196,11 +195,10 @@
196 blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
197 }
198 zSep = "AND ";
199 blob_reset(&treename);
200 }
201 /* fprintf(stderr, "%s\n", blob_str(&sql)); */
202 db_multi_exec(blob_str(&sql));
203 blob_reset(&sql);
204 }
205
206 db_prepare(&q,
207
--- src/update.c
+++ src/update.c
@@ -71,11 +71,11 @@
71 db_must_be_within_tree();
72 vid = db_lget_int("checkout", 0);
73 if( vid==0 ){
74 fossil_fatal("cannot find current version");
75 }
76 if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
77 fossil_fatal("cannot update an uncommitted merge");
78 }
79 if( !nochangeFlag ) autosync(AUTOSYNC_PULL);
80
81 if( g.argc>=3 ){
@@ -182,13 +182,12 @@
182 blob_zero(&sql);
183 blob_append(&sql, "DELETE FROM fv WHERE ", -1);
184 zSep = "";
185 for(i=3; i<g.argc; i++){
186 file_tree_name(g.argv[i], &treename, 1);
 
187 if( file_isdir(g.argv[i])==1 ){
188 if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
189 blob_appendf(&sql, "%sfn NOT GLOB '%b/*' ", zSep, &treename);
190 }else{
191 blob_reset(&sql);
192 break;
193 }
@@ -196,11 +195,10 @@
195 blob_appendf(&sql, "%sfn<>%B ", zSep, &treename);
196 }
197 zSep = "AND ";
198 blob_reset(&treename);
199 }
 
200 db_multi_exec(blob_str(&sql));
201 blob_reset(&sql);
202 }
203
204 db_prepare(&q,
205

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button