Fossil SCM

Changes from Isaac Jurado that record renames on an import from git.

drh 2013-06-17 21:44 trunk
Commit 97d8a08ac95366182d9ff4244a714529b4c908be
1 file changed +16 -24
+16 -24
--- src/import.c
+++ src/import.c
@@ -107,10 +107,11 @@
107107
gg.nMerge = 0;
108108
for(i=0; i<gg.nFile; i++){
109109
fossil_free(gg.aFile[i].zName);
110110
fossil_free(gg.aFile[i].zUuid);
111111
fossil_free(gg.aFile[i].zPrior);
112
+ gg.aFile[i].zPrior = 0;
112113
}
113114
memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0]));
114115
gg.nFile = 0;
115116
if( freeAll ){
116117
fossil_free(gg.zPrevBranch);
@@ -243,17 +244,22 @@
243244
for(i=0; i<gg.nFile; i++){
244245
const char *zUuid = gg.aFile[i].zUuid;
245246
if( zUuid==0 ) continue;
246247
blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
247248
if( gg.aFile[i].isExe ){
248
- blob_append(&record, " x\n", 3);
249
+ blob_append(&record, " x", 2);
249250
}else if( gg.aFile[i].isLink ){
250
- blob_append(&record, " l\n", 3);
251
+ blob_append(&record, " l", 2);
251252
gg.hasLinks = 1;
252
- }else{
253
- blob_append(&record, "\n", 1);
253
+ }
254
+ if( gg.aFile[i].zPrior ){
255
+ if( !gg.aFile[i].isExe && !gg.aFile[i].isLink ){
256
+ blob_append(&record, " w", 2);
257
+ }
258
+ blob_appendf(&record, " %F", gg.aFile[i].zPrior);
254259
}
260
+ blob_append(&record, "\n", 1);
255261
}
256262
if( gg.zFrom ){
257263
blob_appendf(&record, "P %s", gg.zFrom);
258264
for(i=0; i<gg.nMerge; i++){
259265
blob_appendf(&record, " %s", gg.azMerge[i]);
@@ -636,10 +642,11 @@
636642
i = 0;
637643
while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){
638644
if( pFile->isFrom==0 ) continue;
639645
fossil_free(pFile->zName);
640646
fossil_free(pFile->zPrior);
647
+ pFile->zPrior = 0;
641648
fossil_free(pFile->zUuid);
642649
*pFile = gg.aFile[--gg.nFile];
643650
i--;
644651
}
645652
}else
@@ -651,51 +658,36 @@
651658
zTo = rest_of_line(&z);
652659
i = 0;
653660
mx = gg.nFile;
654661
nFrom = strlen(zFrom);
655662
while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){
656
- if( pFile->isFrom==0 ) continue;
657663
pNew = import_add_file();
658664
pFile = &gg.aFile[i-1];
659665
if( strlen(pFile->zName)>nFrom ){
660666
pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]);
661667
}else{
662
- pNew->zName = fossil_strdup(pFile->zName);
668
+ pNew->zName = fossil_strdup(zTo);
663669
}
664670
pNew->isExe = pFile->isExe;
665671
pNew->isLink = pFile->isLink;
666672
pNew->zUuid = fossil_strdup(pFile->zUuid);
667673
pNew->isFrom = 0;
668674
}
669675
}else
670676
if( memcmp(zLine, "R ", 2)==0 ){
671
- int nFrom;
672677
import_prior_files();
673678
z = &zLine[2];
674679
zFrom = next_token(&z);
675680
zTo = rest_of_line(&z);
676681
i = 0;
677
- nFrom = strlen(zFrom);
678682
while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){
679683
if( pFile->isFrom==0 ) continue;
680
- pNew = import_add_file();
681684
pFile = &gg.aFile[i-1];
682
- if( strlen(pFile->zName)>nFrom ){
683
- pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]);
684
- }else{
685
- pNew->zName = fossil_strdup(pFile->zName);
686
- }
687
- pNew->zPrior = pFile->zName;
688
- pNew->isExe = pFile->isExe;
689
- pNew->isLink = pFile->isLink;
690
- pNew->zUuid = pFile->zUuid;
691
- pNew->isFrom = 0;
692
- gg.nFile--;
693
- *pFile = *pNew;
694
- memset(pNew, 0, sizeof(*pNew));
695
- }
696
- fossil_fatal("cannot handle R records, use --full-tree");
685
+ pFile->zPrior = pFile->zName;
686
+ pFile->zName = fossil_strdup(zTo);
687
+ pFile->isFrom = 0;
688
+ }
697689
}else
698690
if( memcmp(zLine, "deleteall", 9)==0 ){
699691
gg.fromLoaded = 1;
700692
}else
701693
if( memcmp(zLine, "N ", 2)==0 ){
702694
--- src/import.c
+++ src/import.c
@@ -107,10 +107,11 @@
107 gg.nMerge = 0;
108 for(i=0; i<gg.nFile; i++){
109 fossil_free(gg.aFile[i].zName);
110 fossil_free(gg.aFile[i].zUuid);
111 fossil_free(gg.aFile[i].zPrior);
 
112 }
113 memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0]));
114 gg.nFile = 0;
115 if( freeAll ){
116 fossil_free(gg.zPrevBranch);
@@ -243,17 +244,22 @@
243 for(i=0; i<gg.nFile; i++){
244 const char *zUuid = gg.aFile[i].zUuid;
245 if( zUuid==0 ) continue;
246 blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
247 if( gg.aFile[i].isExe ){
248 blob_append(&record, " x\n", 3);
249 }else if( gg.aFile[i].isLink ){
250 blob_append(&record, " l\n", 3);
251 gg.hasLinks = 1;
252 }else{
253 blob_append(&record, "\n", 1);
 
 
 
 
254 }
 
255 }
256 if( gg.zFrom ){
257 blob_appendf(&record, "P %s", gg.zFrom);
258 for(i=0; i<gg.nMerge; i++){
259 blob_appendf(&record, " %s", gg.azMerge[i]);
@@ -636,10 +642,11 @@
636 i = 0;
637 while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){
638 if( pFile->isFrom==0 ) continue;
639 fossil_free(pFile->zName);
640 fossil_free(pFile->zPrior);
 
641 fossil_free(pFile->zUuid);
642 *pFile = gg.aFile[--gg.nFile];
643 i--;
644 }
645 }else
@@ -651,51 +658,36 @@
651 zTo = rest_of_line(&z);
652 i = 0;
653 mx = gg.nFile;
654 nFrom = strlen(zFrom);
655 while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){
656 if( pFile->isFrom==0 ) continue;
657 pNew = import_add_file();
658 pFile = &gg.aFile[i-1];
659 if( strlen(pFile->zName)>nFrom ){
660 pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]);
661 }else{
662 pNew->zName = fossil_strdup(pFile->zName);
663 }
664 pNew->isExe = pFile->isExe;
665 pNew->isLink = pFile->isLink;
666 pNew->zUuid = fossil_strdup(pFile->zUuid);
667 pNew->isFrom = 0;
668 }
669 }else
670 if( memcmp(zLine, "R ", 2)==0 ){
671 int nFrom;
672 import_prior_files();
673 z = &zLine[2];
674 zFrom = next_token(&z);
675 zTo = rest_of_line(&z);
676 i = 0;
677 nFrom = strlen(zFrom);
678 while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){
679 if( pFile->isFrom==0 ) continue;
680 pNew = import_add_file();
681 pFile = &gg.aFile[i-1];
682 if( strlen(pFile->zName)>nFrom ){
683 pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]);
684 }else{
685 pNew->zName = fossil_strdup(pFile->zName);
686 }
687 pNew->zPrior = pFile->zName;
688 pNew->isExe = pFile->isExe;
689 pNew->isLink = pFile->isLink;
690 pNew->zUuid = pFile->zUuid;
691 pNew->isFrom = 0;
692 gg.nFile--;
693 *pFile = *pNew;
694 memset(pNew, 0, sizeof(*pNew));
695 }
696 fossil_fatal("cannot handle R records, use --full-tree");
697 }else
698 if( memcmp(zLine, "deleteall", 9)==0 ){
699 gg.fromLoaded = 1;
700 }else
701 if( memcmp(zLine, "N ", 2)==0 ){
702
--- src/import.c
+++ src/import.c
@@ -107,10 +107,11 @@
107 gg.nMerge = 0;
108 for(i=0; i<gg.nFile; i++){
109 fossil_free(gg.aFile[i].zName);
110 fossil_free(gg.aFile[i].zUuid);
111 fossil_free(gg.aFile[i].zPrior);
112 gg.aFile[i].zPrior = 0;
113 }
114 memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0]));
115 gg.nFile = 0;
116 if( freeAll ){
117 fossil_free(gg.zPrevBranch);
@@ -243,17 +244,22 @@
244 for(i=0; i<gg.nFile; i++){
245 const char *zUuid = gg.aFile[i].zUuid;
246 if( zUuid==0 ) continue;
247 blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
248 if( gg.aFile[i].isExe ){
249 blob_append(&record, " x", 2);
250 }else if( gg.aFile[i].isLink ){
251 blob_append(&record, " l", 2);
252 gg.hasLinks = 1;
253 }
254 if( gg.aFile[i].zPrior ){
255 if( !gg.aFile[i].isExe && !gg.aFile[i].isLink ){
256 blob_append(&record, " w", 2);
257 }
258 blob_appendf(&record, " %F", gg.aFile[i].zPrior);
259 }
260 blob_append(&record, "\n", 1);
261 }
262 if( gg.zFrom ){
263 blob_appendf(&record, "P %s", gg.zFrom);
264 for(i=0; i<gg.nMerge; i++){
265 blob_appendf(&record, " %s", gg.azMerge[i]);
@@ -636,10 +642,11 @@
642 i = 0;
643 while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){
644 if( pFile->isFrom==0 ) continue;
645 fossil_free(pFile->zName);
646 fossil_free(pFile->zPrior);
647 pFile->zPrior = 0;
648 fossil_free(pFile->zUuid);
649 *pFile = gg.aFile[--gg.nFile];
650 i--;
651 }
652 }else
@@ -651,51 +658,36 @@
658 zTo = rest_of_line(&z);
659 i = 0;
660 mx = gg.nFile;
661 nFrom = strlen(zFrom);
662 while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){
 
663 pNew = import_add_file();
664 pFile = &gg.aFile[i-1];
665 if( strlen(pFile->zName)>nFrom ){
666 pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]);
667 }else{
668 pNew->zName = fossil_strdup(zTo);
669 }
670 pNew->isExe = pFile->isExe;
671 pNew->isLink = pFile->isLink;
672 pNew->zUuid = fossil_strdup(pFile->zUuid);
673 pNew->isFrom = 0;
674 }
675 }else
676 if( memcmp(zLine, "R ", 2)==0 ){
 
677 import_prior_files();
678 z = &zLine[2];
679 zFrom = next_token(&z);
680 zTo = rest_of_line(&z);
681 i = 0;
 
682 while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){
683 if( pFile->isFrom==0 ) continue;
 
684 pFile = &gg.aFile[i-1];
685 pFile->zPrior = pFile->zName;
686 pFile->zName = fossil_strdup(zTo);
687 pFile->isFrom = 0;
688 }
 
 
 
 
 
 
 
 
 
 
 
689 }else
690 if( memcmp(zLine, "deleteall", 9)==0 ){
691 gg.fromLoaded = 1;
692 }else
693 if( memcmp(zLine, "N ", 2)==0 ){
694

Keyboard Shortcuts

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