Fossil SCM

merge trunk

jan.nijtmans 2012-11-07 08:30 convert_before_commit merge
Commit 82506434d5056c0fded6d60bb5ad2381bfb2e81b
+1 -1
--- src/blob.c
+++ src/blob.c
@@ -800,11 +800,11 @@
800800
** The if stops us from trying to create a directory of a drive letter
801801
** C: in this example.
802802
*/
803803
if( !(i==2 && zName[1]==':') ){
804804
#endif
805
- if( file_mkdir(zName, 1) ){
805
+ if( file_mkdir(zName, 1) && file_isdir(zName)!=1 ){
806806
fossil_fatal_recursive("unable to create directory %s", zName);
807807
return 0;
808808
}
809809
#if defined(_WIN32)
810810
}
811811
--- src/blob.c
+++ src/blob.c
@@ -800,11 +800,11 @@
800 ** The if stops us from trying to create a directory of a drive letter
801 ** C: in this example.
802 */
803 if( !(i==2 && zName[1]==':') ){
804 #endif
805 if( file_mkdir(zName, 1) ){
806 fossil_fatal_recursive("unable to create directory %s", zName);
807 return 0;
808 }
809 #if defined(_WIN32)
810 }
811
--- src/blob.c
+++ src/blob.c
@@ -800,11 +800,11 @@
800 ** The if stops us from trying to create a directory of a drive letter
801 ** C: in this example.
802 */
803 if( !(i==2 && zName[1]==':') ){
804 #endif
805 if( file_mkdir(zName, 1) && file_isdir(zName)!=1 ){
806 fossil_fatal_recursive("unable to create directory %s", zName);
807 return 0;
808 }
809 #if defined(_WIN32)
810 }
811
+6 -2
--- src/diff.c
+++ src/diff.c
@@ -154,11 +154,11 @@
154154
for(i=0; i<nLine; i++){
155155
a[i].z = z;
156156
for(j=0; z[j] && z[j]!='\n'; j++){}
157157
k = j;
158158
while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
159
- for(h=0, x=0; x<k; x++){
159
+ for(h=0, x=0; x<=k; x++){
160160
h = h ^ (h<<2) ^ z[x];
161161
}
162162
a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
163163
h2 = h % nLine;
164164
a[i].iNext = a[h2].iHash;
@@ -787,11 +787,15 @@
787787
if( nPrefix+nSuffix==nLeft ){
788788
sbsWriteLineno(p, lnLeft);
789789
p->iStart2 = p->iEnd2 = 0;
790790
p->iStart = p->iEnd = -1;
791791
sbsWriteText(p, pLeft, SBS_PAD);
792
- sbsWrite(p, nLeft==nRight ? " " : " | ", 3);
792
+ if( nLeft==nRight && zLeft[nLeft]==zRight[nRight] ){
793
+ sbsWrite(p, " ", 3);
794
+ }else{
795
+ sbsWrite(p, " | ", 3);
796
+ }
793797
sbsWriteLineno(p, lnRight);
794798
p->iStart = nPrefix;
795799
p->iEnd = nRight - nSuffix;
796800
p->zStart = zClassAdd;
797801
sbsWriteText(p, pRight, SBS_NEWLINE);
798802
--- src/diff.c
+++ src/diff.c
@@ -154,11 +154,11 @@
154 for(i=0; i<nLine; i++){
155 a[i].z = z;
156 for(j=0; z[j] && z[j]!='\n'; j++){}
157 k = j;
158 while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
159 for(h=0, x=0; x<k; x++){
160 h = h ^ (h<<2) ^ z[x];
161 }
162 a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
163 h2 = h % nLine;
164 a[i].iNext = a[h2].iHash;
@@ -787,11 +787,15 @@
787 if( nPrefix+nSuffix==nLeft ){
788 sbsWriteLineno(p, lnLeft);
789 p->iStart2 = p->iEnd2 = 0;
790 p->iStart = p->iEnd = -1;
791 sbsWriteText(p, pLeft, SBS_PAD);
792 sbsWrite(p, nLeft==nRight ? " " : " | ", 3);
 
 
 
 
793 sbsWriteLineno(p, lnRight);
794 p->iStart = nPrefix;
795 p->iEnd = nRight - nSuffix;
796 p->zStart = zClassAdd;
797 sbsWriteText(p, pRight, SBS_NEWLINE);
798
--- src/diff.c
+++ src/diff.c
@@ -154,11 +154,11 @@
154 for(i=0; i<nLine; i++){
155 a[i].z = z;
156 for(j=0; z[j] && z[j]!='\n'; j++){}
157 k = j;
158 while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
159 for(h=0, x=0; x<=k; x++){
160 h = h ^ (h<<2) ^ z[x];
161 }
162 a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
163 h2 = h % nLine;
164 a[i].iNext = a[h2].iHash;
@@ -787,11 +787,15 @@
787 if( nPrefix+nSuffix==nLeft ){
788 sbsWriteLineno(p, lnLeft);
789 p->iStart2 = p->iEnd2 = 0;
790 p->iStart = p->iEnd = -1;
791 sbsWriteText(p, pLeft, SBS_PAD);
792 if( nLeft==nRight && zLeft[nLeft]==zRight[nRight] ){
793 sbsWrite(p, " ", 3);
794 }else{
795 sbsWrite(p, " | ", 3);
796 }
797 sbsWriteLineno(p, lnRight);
798 p->iStart = nPrefix;
799 p->iEnd = nRight - nSuffix;
800 p->zStart = zClassAdd;
801 sbsWriteText(p, pRight, SBS_NEWLINE);
802
+34 -35
--- src/merge3.c
+++ src/merge3.c
@@ -59,11 +59,11 @@
5959
6060
/*
6161
** Look at the next edit triple in both aC1 and aC2. (An "edit triple" is
6262
** three integers describing the number of copies, deletes, and inserts in
6363
** moving from the original to the edited copy of the file.) If the three
64
-** integers of the edit triples describe an identical edit, then return 1.
64
+** integers of the edit triples describe an identical edit, then return 1.
6565
** If the edits are different, return 0.
6666
*/
6767
static int sameEdit(
6868
int *aC1, /* Array of edit integers for file 1 */
6969
int *aC2, /* Array of edit integers for file 2 */
@@ -154,11 +154,11 @@
154154
** common origin at pPivot. Apply the changes of pPivot ==> pV1
155155
** to pV2.
156156
**
157157
** The return is 0 upon complete success. If any input file is binary,
158158
** -1 is returned and pOut is unmodified. If there are merge
159
-** conflicts, the merge proceeds as best as it can and the number
159
+** conflicts, the merge proceeds as best as it can and the number
160160
** of conflicts is returns
161161
*/
162162
static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
163163
int *aC1; /* Changes from pPivot to pV1 */
164164
int *aC2; /* Changes from pPivot to pV2 */
@@ -440,55 +440,54 @@
440440
Blob *pOut, /* Output written here */
441441
unsigned mergeFlags /* Flags that control operation */
442442
){
443443
Blob v1; /* Content of zV1 */
444444
int rc; /* Return code of subroutines and this routine */
445
- char *zPivot; /* Name of the pivot file */
446
- char *zOrig; /* Name of the original content file */
447
- char *zOther; /* Name of the merge file */
448445
449446
blob_read_from_file(&v1, zV1);
450447
rc = blob_merge(pPivot, &v1, pV2, pOut);
451448
if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
449
+ char *zPivot; /* Name of the pivot file */
450
+ char *zOrig; /* Name of the original content file */
451
+ char *zOther; /* Name of the merge file */
452
+
452453
zPivot = file_newname(zV1, "baseline", 1);
453454
blob_write_to_file(pPivot, zPivot);
454455
zOrig = file_newname(zV1, "original", 1);
455456
blob_write_to_file(&v1, zOrig);
456457
zOther = file_newname(zV1, "merge", 1);
457458
blob_write_to_file(pV2, zOther);
458
- }
459
- if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){
460
- const char *zGMerge; /* Name of the gmerge command */
461
-
462
- zGMerge = db_get("gmerge-command", 0);
463
- if( zGMerge && zGMerge[0] ){
464
- char *zOut; /* Temporary output file */
465
- char *zCmd; /* Command to invoke */
466
- const char *azSubst[8]; /* Strings to be substituted */
467
-
468
- zOut = file_newname(zV1, "output", 1);
469
- azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470
- azSubst[2] = "%original"; azSubst[3] = zOrig;
471
- azSubst[4] = "%merge"; azSubst[5] = zOther;
472
- azSubst[6] = "%output"; azSubst[7] = zOut;
473
- zCmd = string_subst(zGMerge, 8, azSubst);
474
- printf("%s\n", zCmd); fflush(stdout);
475
- fossil_system(zCmd);
476
- if( file_wd_size(zOut)>=0 ){
477
- blob_read_from_file(pOut, zOut);
478
- file_delete(zPivot);
479
- file_delete(zOrig);
480
- file_delete(zOther);
481
- file_delete(zOut);
482
- }
483
- fossil_free(zCmd);
484
- fossil_free(zOut);
485
- }
486
- }
487
- if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
459
+ if( rc>0 ){
460
+ const char *zGMerge; /* Name of the gmerge command */
461
+
462
+ zGMerge = db_get("gmerge-command", 0);
463
+ if( zGMerge && zGMerge[0] ){
464
+ char *zOut; /* Temporary output file */
465
+ char *zCmd; /* Command to invoke */
466
+ const char *azSubst[8]; /* Strings to be substituted */
467
+
468
+ zOut = file_newname(zV1, "output", 1);
469
+ azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470
+ azSubst[2] = "%original"; azSubst[3] = zOrig;
471
+ azSubst[4] = "%merge"; azSubst[5] = zOther;
472
+ azSubst[6] = "%output"; azSubst[7] = zOut;
473
+ zCmd = string_subst(zGMerge, 8, azSubst);
474
+ printf("%s\n", zCmd); fflush(stdout);
475
+ fossil_system(zCmd);
476
+ if( file_wd_size(zOut)>=0 ){
477
+ blob_read_from_file(pOut, zOut);
478
+ file_delete(zPivot);
479
+ file_delete(zOrig);
480
+ file_delete(zOther);
481
+ file_delete(zOut);
482
+ }
483
+ fossil_free(zCmd);
484
+ fossil_free(zOut);
485
+ }
486
+ }
488487
fossil_free(zPivot);
489488
fossil_free(zOrig);
490489
fossil_free(zOther);
491490
}
492491
blob_reset(&v1);
493492
return rc;
494493
}
495494
--- src/merge3.c
+++ src/merge3.c
@@ -59,11 +59,11 @@
59
60 /*
61 ** Look at the next edit triple in both aC1 and aC2. (An "edit triple" is
62 ** three integers describing the number of copies, deletes, and inserts in
63 ** moving from the original to the edited copy of the file.) If the three
64 ** integers of the edit triples describe an identical edit, then return 1.
65 ** If the edits are different, return 0.
66 */
67 static int sameEdit(
68 int *aC1, /* Array of edit integers for file 1 */
69 int *aC2, /* Array of edit integers for file 2 */
@@ -154,11 +154,11 @@
154 ** common origin at pPivot. Apply the changes of pPivot ==> pV1
155 ** to pV2.
156 **
157 ** The return is 0 upon complete success. If any input file is binary,
158 ** -1 is returned and pOut is unmodified. If there are merge
159 ** conflicts, the merge proceeds as best as it can and the number
160 ** of conflicts is returns
161 */
162 static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
163 int *aC1; /* Changes from pPivot to pV1 */
164 int *aC2; /* Changes from pPivot to pV2 */
@@ -440,55 +440,54 @@
440 Blob *pOut, /* Output written here */
441 unsigned mergeFlags /* Flags that control operation */
442 ){
443 Blob v1; /* Content of zV1 */
444 int rc; /* Return code of subroutines and this routine */
445 char *zPivot; /* Name of the pivot file */
446 char *zOrig; /* Name of the original content file */
447 char *zOther; /* Name of the merge file */
448
449 blob_read_from_file(&v1, zV1);
450 rc = blob_merge(pPivot, &v1, pV2, pOut);
451 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
 
 
 
 
452 zPivot = file_newname(zV1, "baseline", 1);
453 blob_write_to_file(pPivot, zPivot);
454 zOrig = file_newname(zV1, "original", 1);
455 blob_write_to_file(&v1, zOrig);
456 zOther = file_newname(zV1, "merge", 1);
457 blob_write_to_file(pV2, zOther);
458 }
459 if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){
460 const char *zGMerge; /* Name of the gmerge command */
461
462 zGMerge = db_get("gmerge-command", 0);
463 if( zGMerge && zGMerge[0] ){
464 char *zOut; /* Temporary output file */
465 char *zCmd; /* Command to invoke */
466 const char *azSubst[8]; /* Strings to be substituted */
467
468 zOut = file_newname(zV1, "output", 1);
469 azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470 azSubst[2] = "%original"; azSubst[3] = zOrig;
471 azSubst[4] = "%merge"; azSubst[5] = zOther;
472 azSubst[6] = "%output"; azSubst[7] = zOut;
473 zCmd = string_subst(zGMerge, 8, azSubst);
474 printf("%s\n", zCmd); fflush(stdout);
475 fossil_system(zCmd);
476 if( file_wd_size(zOut)>=0 ){
477 blob_read_from_file(pOut, zOut);
478 file_delete(zPivot);
479 file_delete(zOrig);
480 file_delete(zOther);
481 file_delete(zOut);
482 }
483 fossil_free(zCmd);
484 fossil_free(zOut);
485 }
486 }
487 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
488 fossil_free(zPivot);
489 fossil_free(zOrig);
490 fossil_free(zOther);
491 }
492 blob_reset(&v1);
493 return rc;
494 }
495
--- src/merge3.c
+++ src/merge3.c
@@ -59,11 +59,11 @@
59
60 /*
61 ** Look at the next edit triple in both aC1 and aC2. (An "edit triple" is
62 ** three integers describing the number of copies, deletes, and inserts in
63 ** moving from the original to the edited copy of the file.) If the three
64 ** integers of the edit triples describe an identical edit, then return 1.
65 ** If the edits are different, return 0.
66 */
67 static int sameEdit(
68 int *aC1, /* Array of edit integers for file 1 */
69 int *aC2, /* Array of edit integers for file 2 */
@@ -154,11 +154,11 @@
154 ** common origin at pPivot. Apply the changes of pPivot ==> pV1
155 ** to pV2.
156 **
157 ** The return is 0 upon complete success. If any input file is binary,
158 ** -1 is returned and pOut is unmodified. If there are merge
159 ** conflicts, the merge proceeds as best as it can and the number
160 ** of conflicts is returns
161 */
162 static int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
163 int *aC1; /* Changes from pPivot to pV1 */
164 int *aC2; /* Changes from pPivot to pV2 */
@@ -440,55 +440,54 @@
440 Blob *pOut, /* Output written here */
441 unsigned mergeFlags /* Flags that control operation */
442 ){
443 Blob v1; /* Content of zV1 */
444 int rc; /* Return code of subroutines and this routine */
 
 
 
445
446 blob_read_from_file(&v1, zV1);
447 rc = blob_merge(pPivot, &v1, pV2, pOut);
448 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
449 char *zPivot; /* Name of the pivot file */
450 char *zOrig; /* Name of the original content file */
451 char *zOther; /* Name of the merge file */
452
453 zPivot = file_newname(zV1, "baseline", 1);
454 blob_write_to_file(pPivot, zPivot);
455 zOrig = file_newname(zV1, "original", 1);
456 blob_write_to_file(&v1, zOrig);
457 zOther = file_newname(zV1, "merge", 1);
458 blob_write_to_file(pV2, zOther);
459 if( rc>0 ){
460 const char *zGMerge; /* Name of the gmerge command */
461
462 zGMerge = db_get("gmerge-command", 0);
463 if( zGMerge && zGMerge[0] ){
464 char *zOut; /* Temporary output file */
465 char *zCmd; /* Command to invoke */
466 const char *azSubst[8]; /* Strings to be substituted */
467
468 zOut = file_newname(zV1, "output", 1);
469 azSubst[0] = "%baseline"; azSubst[1] = zPivot;
470 azSubst[2] = "%original"; azSubst[3] = zOrig;
471 azSubst[4] = "%merge"; azSubst[5] = zOther;
472 azSubst[6] = "%output"; azSubst[7] = zOut;
473 zCmd = string_subst(zGMerge, 8, azSubst);
474 printf("%s\n", zCmd); fflush(stdout);
475 fossil_system(zCmd);
476 if( file_wd_size(zOut)>=0 ){
477 blob_read_from_file(pOut, zOut);
478 file_delete(zPivot);
479 file_delete(zOrig);
480 file_delete(zOther);
481 file_delete(zOut);
482 }
483 fossil_free(zCmd);
484 fossil_free(zOut);
485 }
486 }
 
 
487 fossil_free(zPivot);
488 fossil_free(zOrig);
489 fossil_free(zOther);
490 }
491 blob_reset(&v1);
492 return rc;
493 }
494
--- src/style.c
+++ src/style.c
@@ -667,10 +667,11 @@
667667
},
668668
{ "ul.browser",
669669
"format for the list in the file browser",
670670
@ margin-left: 0.5em;
671671
@ padding-left: 0.5em;
672
+ @ white-space: nowrap;
672673
},
673674
{ "table.login_out",
674675
"table format for login/out label/input table",
675676
@ text-align: left;
676677
@ margin-right: 10px;
677678
--- src/style.c
+++ src/style.c
@@ -667,10 +667,11 @@
667 },
668 { "ul.browser",
669 "format for the list in the file browser",
670 @ margin-left: 0.5em;
671 @ padding-left: 0.5em;
 
672 },
673 { "table.login_out",
674 "table format for login/out label/input table",
675 @ text-align: left;
676 @ margin-right: 10px;
677
--- src/style.c
+++ src/style.c
@@ -667,10 +667,11 @@
667 },
668 { "ul.browser",
669 "format for the list in the file browser",
670 @ margin-left: 0.5em;
671 @ padding-left: 0.5em;
672 @ white-space: nowrap;
673 },
674 { "table.login_out",
675 "table format for login/out label/input table",
676 @ text-align: left;
677 @ margin-right: 10px;
678
+17 -7
--- src/update.c
+++ src/update.c
@@ -217,19 +217,20 @@
217217
" islinkv BOOLEAN," /* True if current file is a link */
218218
" islinkt BOOLEAN," /* True if target file is a link */
219219
" ridv INTEGER," /* Record ID for current version */
220220
" ridt INTEGER," /* Record ID for target */
221221
" isexe BOOLEAN," /* Does target have execute permission? */
222
+ " deleted BOOLEAN DEFAULT 0,"/* File marke by "rm" to become unmanaged */
222223
" fnt TEXT" /* Filename of same file on target version */
223224
");"
224225
);
225226
226227
/* Add files found in the current version
227228
*/
228229
db_multi_exec(
229
- "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
230
- " SELECT pathname, pathname, id, 0, rid, 0, isexe, chnged"
230
+ "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged,deleted)"
231
+ " SELECT pathname, pathname, id, 0, rid, 0, isexe, chnged, deleted"
231232
" FROM vfile WHERE vid=%d",
232233
vid
233234
);
234235
235236
/* Compute file name changes on V->T. Record name changes in files that
@@ -339,11 +340,11 @@
339340
** Alter the content of the checkout so that it conforms with the
340341
** target
341342
*/
342343
db_prepare(&q,
343344
"SELECT fn, idv, ridv, idt, ridt, chnged, fnt,"
344
- " isexe, islinkv, islinkt FROM fv ORDER BY 1"
345
+ " isexe, islinkv, islinkt, deleted FROM fv ORDER BY 1"
345346
);
346347
db_prepare(&mtimeXfer,
347348
"UPDATE vfile SET mtime=(SELECT mtime FROM vfile WHERE id=:idv)"
348349
" WHERE id=:idt"
349350
);
@@ -359,43 +360,52 @@
359360
int chnged = db_column_int(&q, 5); /* Current is edited */
360361
const char *zNewName = db_column_text(&q,6);/* New filename */
361362
int isexe = db_column_int(&q, 7); /* EXE perm for new file */
362363
int islinkv = db_column_int(&q, 8); /* Is current file is a link */
363364
int islinkt = db_column_int(&q, 9); /* Is target file is a link */
365
+ int deleted = db_column_int(&q, 10); /* Marked for deletion */
364366
char *zFullPath; /* Full pathname of the file */
365367
char *zFullNewPath; /* Full pathname of dest */
366368
char nameChng; /* True if the name changed */
367369
368370
zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
369371
zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
370372
nameChng = fossil_strcmp(zName, zNewName);
371373
nUpdate++;
374
+ if( deleted ){
375
+ db_multi_exec("UPDATE vfile SET deleted=1 WHERE id=%d", idt);
376
+ }
372377
if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
373378
/* Conflict. This file has been added to the current checkout
374379
** but also exists in the target checkout. Use the current version.
375380
*/
376381
fossil_print("CONFLICT %s\n", zName);
377382
nConflict++;
378383
}else if( idt>0 && idv==0 ){
379384
/* File added in the target. */
380385
if( file_wd_isfile_or_link(zFullPath) ){
381
- fossil_print("ADD %s (overwrites an unmanaged file)\n", zName);
386
+ fossil_print("ADD %s - overwrites an unmanaged file\n", zName);
382387
nOverwrite++;
383388
}else{
384389
fossil_print("ADD %s\n", zName);
385390
}
386391
undo_save(zName);
387392
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
388
- }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
393
+ }else if( idt>0 && idv>0 && ridt!=ridv && (chnged==0 || deleted) ){
389394
/* The file is unedited. Change it to the target version */
390395
undo_save(zName);
391
- fossil_print("UPDATE %s\n", zName);
396
+ if( deleted ){
397
+ fossil_print("UPDATE %s - change to unmanged file\n", zName);
398
+ }else{
399
+ fossil_print("UPDATE %s\n", zName);
400
+ }
392401
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
393402
}else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){
394403
/* The file missing from the local check-out. Restore it to the
395404
** version that appears in the target. */
396
- fossil_print("UPDATE %s\n", zName);
405
+ fossil_print("UPDATE %s%s\n", zName,
406
+ deleted?" - change to unmanaged file":"");
397407
undo_save(zName);
398408
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
399409
}else if( idt==0 && idv>0 ){
400410
if( ridv==0 ){
401411
/* Added in current checkout. Continue to hold the file as
402412
403413
ADDED test/update-test-1.sh
404414
ADDED test/update-test-2.sh
--- src/update.c
+++ src/update.c
@@ -217,19 +217,20 @@
217 " islinkv BOOLEAN," /* True if current file is a link */
218 " islinkt BOOLEAN," /* True if target file is a link */
219 " ridv INTEGER," /* Record ID for current version */
220 " ridt INTEGER," /* Record ID for target */
221 " isexe BOOLEAN," /* Does target have execute permission? */
 
222 " fnt TEXT" /* Filename of same file on target version */
223 ");"
224 );
225
226 /* Add files found in the current version
227 */
228 db_multi_exec(
229 "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
230 " SELECT pathname, pathname, id, 0, rid, 0, isexe, chnged"
231 " FROM vfile WHERE vid=%d",
232 vid
233 );
234
235 /* Compute file name changes on V->T. Record name changes in files that
@@ -339,11 +340,11 @@
339 ** Alter the content of the checkout so that it conforms with the
340 ** target
341 */
342 db_prepare(&q,
343 "SELECT fn, idv, ridv, idt, ridt, chnged, fnt,"
344 " isexe, islinkv, islinkt FROM fv ORDER BY 1"
345 );
346 db_prepare(&mtimeXfer,
347 "UPDATE vfile SET mtime=(SELECT mtime FROM vfile WHERE id=:idv)"
348 " WHERE id=:idt"
349 );
@@ -359,43 +360,52 @@
359 int chnged = db_column_int(&q, 5); /* Current is edited */
360 const char *zNewName = db_column_text(&q,6);/* New filename */
361 int isexe = db_column_int(&q, 7); /* EXE perm for new file */
362 int islinkv = db_column_int(&q, 8); /* Is current file is a link */
363 int islinkt = db_column_int(&q, 9); /* Is target file is a link */
 
364 char *zFullPath; /* Full pathname of the file */
365 char *zFullNewPath; /* Full pathname of dest */
366 char nameChng; /* True if the name changed */
367
368 zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
369 zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
370 nameChng = fossil_strcmp(zName, zNewName);
371 nUpdate++;
 
 
 
372 if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
373 /* Conflict. This file has been added to the current checkout
374 ** but also exists in the target checkout. Use the current version.
375 */
376 fossil_print("CONFLICT %s\n", zName);
377 nConflict++;
378 }else if( idt>0 && idv==0 ){
379 /* File added in the target. */
380 if( file_wd_isfile_or_link(zFullPath) ){
381 fossil_print("ADD %s (overwrites an unmanaged file)\n", zName);
382 nOverwrite++;
383 }else{
384 fossil_print("ADD %s\n", zName);
385 }
386 undo_save(zName);
387 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
388 }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
389 /* The file is unedited. Change it to the target version */
390 undo_save(zName);
391 fossil_print("UPDATE %s\n", zName);
 
 
 
 
392 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
393 }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){
394 /* The file missing from the local check-out. Restore it to the
395 ** version that appears in the target. */
396 fossil_print("UPDATE %s\n", zName);
 
397 undo_save(zName);
398 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
399 }else if( idt==0 && idv>0 ){
400 if( ridv==0 ){
401 /* Added in current checkout. Continue to hold the file as
402
403 DDED test/update-test-1.sh
404 DDED test/update-test-2.sh
--- src/update.c
+++ src/update.c
@@ -217,19 +217,20 @@
217 " islinkv BOOLEAN," /* True if current file is a link */
218 " islinkt BOOLEAN," /* True if target file is a link */
219 " ridv INTEGER," /* Record ID for current version */
220 " ridt INTEGER," /* Record ID for target */
221 " isexe BOOLEAN," /* Does target have execute permission? */
222 " deleted BOOLEAN DEFAULT 0,"/* File marke by "rm" to become unmanaged */
223 " fnt TEXT" /* Filename of same file on target version */
224 ");"
225 );
226
227 /* Add files found in the current version
228 */
229 db_multi_exec(
230 "INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged,deleted)"
231 " SELECT pathname, pathname, id, 0, rid, 0, isexe, chnged, deleted"
232 " FROM vfile WHERE vid=%d",
233 vid
234 );
235
236 /* Compute file name changes on V->T. Record name changes in files that
@@ -339,11 +340,11 @@
340 ** Alter the content of the checkout so that it conforms with the
341 ** target
342 */
343 db_prepare(&q,
344 "SELECT fn, idv, ridv, idt, ridt, chnged, fnt,"
345 " isexe, islinkv, islinkt, deleted FROM fv ORDER BY 1"
346 );
347 db_prepare(&mtimeXfer,
348 "UPDATE vfile SET mtime=(SELECT mtime FROM vfile WHERE id=:idv)"
349 " WHERE id=:idt"
350 );
@@ -359,43 +360,52 @@
360 int chnged = db_column_int(&q, 5); /* Current is edited */
361 const char *zNewName = db_column_text(&q,6);/* New filename */
362 int isexe = db_column_int(&q, 7); /* EXE perm for new file */
363 int islinkv = db_column_int(&q, 8); /* Is current file is a link */
364 int islinkt = db_column_int(&q, 9); /* Is target file is a link */
365 int deleted = db_column_int(&q, 10); /* Marked for deletion */
366 char *zFullPath; /* Full pathname of the file */
367 char *zFullNewPath; /* Full pathname of dest */
368 char nameChng; /* True if the name changed */
369
370 zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
371 zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
372 nameChng = fossil_strcmp(zName, zNewName);
373 nUpdate++;
374 if( deleted ){
375 db_multi_exec("UPDATE vfile SET deleted=1 WHERE id=%d", idt);
376 }
377 if( idv>0 && ridv==0 && idt>0 && ridt>0 ){
378 /* Conflict. This file has been added to the current checkout
379 ** but also exists in the target checkout. Use the current version.
380 */
381 fossil_print("CONFLICT %s\n", zName);
382 nConflict++;
383 }else if( idt>0 && idv==0 ){
384 /* File added in the target. */
385 if( file_wd_isfile_or_link(zFullPath) ){
386 fossil_print("ADD %s - overwrites an unmanaged file\n", zName);
387 nOverwrite++;
388 }else{
389 fossil_print("ADD %s\n", zName);
390 }
391 undo_save(zName);
392 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
393 }else if( idt>0 && idv>0 && ridt!=ridv && (chnged==0 || deleted) ){
394 /* The file is unedited. Change it to the target version */
395 undo_save(zName);
396 if( deleted ){
397 fossil_print("UPDATE %s - change to unmanged file\n", zName);
398 }else{
399 fossil_print("UPDATE %s\n", zName);
400 }
401 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
402 }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){
403 /* The file missing from the local check-out. Restore it to the
404 ** version that appears in the target. */
405 fossil_print("UPDATE %s%s\n", zName,
406 deleted?" - change to unmanaged file":"");
407 undo_save(zName);
408 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
409 }else if( idt==0 && idv>0 ){
410 if( ridv==0 ){
411 /* Added in current checkout. Continue to hold the file as
412
413 DDED test/update-test-1.sh
414 DDED test/update-test-2.sh
--- a/test/update-test-1.sh
+++ b/test/update-test-1.sh
@@ -0,0 +1,44 @@
1
+#!/bin/sh
2
+#
3
+# Run this script in an empty directory. A single argument is the full
4
+# pathname of the fossil binary. Example:
5
+#
6
+# sh update-test-1.sh /home/drh/fossil/m1/fossil
7
+#
8
+export FOSSIL=$1
9
+rm -rf aaa bbb update-test-1.fossil
10
+
11
+# Create a test repository
12
+$FOSSIL new update-test-1.fossil
13
+
14
+# In checkout aaa, add file one.txt
15
+mkdir aaa
16
+cd aaa
17
+$FOSSIL open ../update-test-1.fossil
18
+echo one >one.txt
19
+$FOSSIL add one.txt
20
+$FOSSIL commit -m add-one --tag add-one
21
+
22
+# Open checkout bbb.
23
+mkdir ../bbb
24
+cd ../bbb
25
+$FOSSIL open ../update-test-1.fossil
26
+
27
+# Back in aaa, add file two.txt
28
+cd ../aaa
29
+echo two >two.txt
30
+$FOSSIL add two.txt
31
+$FOSSIL commit -m add-two --tag add-two
32
+
33
+# In bbb, delete file one.txt. Then update the change from aaa that
34
+# adds file two. Verify that one.txt says deleted.
35
+cd ../bbb
36
+$FOSSIL rm one.txt
37
+$FOSSIL changes
38
+echo '========================================================================'
39
+$FOSSIL update
40
+echo '======== The previous should show "ADD two.txt" ========================'
41
+$FOSSIL changes
42
+echo '======== The previous should show "DELETE one.txt" ====================='
43
+$FOSSIL commit --test -m check-in
44
+echo '======== Only file two.txt is checked in ==============================='
--- a/test/update-test-1.sh
+++ b/test/update-test-1.sh
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/update-test-1.sh
+++ b/test/update-test-1.sh
@@ -0,0 +1,44 @@
1 #!/bin/sh
2 #
3 # Run this script in an empty directory. A single argument is the full
4 # pathname of the fossil binary. Example:
5 #
6 # sh update-test-1.sh /home/drh/fossil/m1/fossil
7 #
8 export FOSSIL=$1
9 rm -rf aaa bbb update-test-1.fossil
10
11 # Create a test repository
12 $FOSSIL new update-test-1.fossil
13
14 # In checkout aaa, add file one.txt
15 mkdir aaa
16 cd aaa
17 $FOSSIL open ../update-test-1.fossil
18 echo one >one.txt
19 $FOSSIL add one.txt
20 $FOSSIL commit -m add-one --tag add-one
21
22 # Open checkout bbb.
23 mkdir ../bbb
24 cd ../bbb
25 $FOSSIL open ../update-test-1.fossil
26
27 # Back in aaa, add file two.txt
28 cd ../aaa
29 echo two >two.txt
30 $FOSSIL add two.txt
31 $FOSSIL commit -m add-two --tag add-two
32
33 # In bbb, delete file one.txt. Then update the change from aaa that
34 # adds file two. Verify that one.txt says deleted.
35 cd ../bbb
36 $FOSSIL rm one.txt
37 $FOSSIL changes
38 echo '========================================================================'
39 $FOSSIL update
40 echo '======== The previous should show "ADD two.txt" ========================'
41 $FOSSIL changes
42 echo '======== The previous should show "DELETE one.txt" ====================='
43 $FOSSIL commit --test -m check-in
44 echo '======== Only file two.txt is checked in ==============================='
--- a/test/update-test-2.sh
+++ b/test/update-test-2.sh
@@ -0,0 +1,44 @@
1
+#!/bin/sh
2
+#
3
+# Run this script in an empty directory. A single argument is the full
4
+# pathname of the fossil binary. Example:
5
+#
6
+# sh update-test-2.sh /home/drh/fossil/m1/fossil
7
+#
8
+export FOSSIL=$1
9
+rm -rf aaa bbb update-test-2.fossil
10
+
11
+# Create a test repository
12
+$FOSSIL new update-test-2.fossil
13
+
14
+# In checkout aaa, add file one.txt.
15
+mkdir aaa
16
+cd aaa
17
+$FOSSIL open ../update-test-2.fossil
18
+echo one >one.txt
19
+$FOSSIL add one.txt
20
+$FOSSIL commit -m add-one --tag add-one
21
+
22
+# Create checkout bbb.
23
+mkdir ../bbb
24
+cd ../bbb
25
+$FOSSIL open ../update-test-2.fossil
26
+
27
+# Back in aaa, make changes to one.txt. Add file two.txt.
28
+cd ../aaa
29
+echo change >>one.txt
30
+echo two >two.txt
31
+$FOSSIL add two.txt
32
+$FOSSIL commit -m 'chng one and add two' --tag add-two
33
+
34
+# In bbb, remove one.txt, then update.
35
+cd ../bbb
36
+$FOSSIL rm one.txt
37
+$FOSSIL changes
38
+echo '========================================================================'
39
+$FOSSIL update
40
+echo '======== Previous should show "ADD two.txt" and conflict on one.txt ===='
41
+$FOSSIL changes
42
+echo '======== The previous should show "DELETE one.txt" ====================='
43
+$FOSSIL commit --test -m 'check-in'
44
+echo '======== Only file two.txt is checked in ==============================='
--- a/test/update-test-2.sh
+++ b/test/update-test-2.sh
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/update-test-2.sh
+++ b/test/update-test-2.sh
@@ -0,0 +1,44 @@
1 #!/bin/sh
2 #
3 # Run this script in an empty directory. A single argument is the full
4 # pathname of the fossil binary. Example:
5 #
6 # sh update-test-2.sh /home/drh/fossil/m1/fossil
7 #
8 export FOSSIL=$1
9 rm -rf aaa bbb update-test-2.fossil
10
11 # Create a test repository
12 $FOSSIL new update-test-2.fossil
13
14 # In checkout aaa, add file one.txt.
15 mkdir aaa
16 cd aaa
17 $FOSSIL open ../update-test-2.fossil
18 echo one >one.txt
19 $FOSSIL add one.txt
20 $FOSSIL commit -m add-one --tag add-one
21
22 # Create checkout bbb.
23 mkdir ../bbb
24 cd ../bbb
25 $FOSSIL open ../update-test-2.fossil
26
27 # Back in aaa, make changes to one.txt. Add file two.txt.
28 cd ../aaa
29 echo change >>one.txt
30 echo two >two.txt
31 $FOSSIL add two.txt
32 $FOSSIL commit -m 'chng one and add two' --tag add-two
33
34 # In bbb, remove one.txt, then update.
35 cd ../bbb
36 $FOSSIL rm one.txt
37 $FOSSIL changes
38 echo '========================================================================'
39 $FOSSIL update
40 echo '======== Previous should show "ADD two.txt" and conflict on one.txt ===='
41 $FOSSIL changes
42 echo '======== The previous should show "DELETE one.txt" ====================='
43 $FOSSIL commit --test -m 'check-in'
44 echo '======== Only file two.txt is checked in ==============================='

Keyboard Shortcuts

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