Fossil SCM
Changes from Isaac Jurado that record renames on an import from git.
Commit
97d8a08ac95366182d9ff4244a714529b4c908be
Parent
a6dad6508c0e95b…
1 file changed
+16
-24
+16
-24
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -107,10 +107,11 @@ | ||
| 107 | 107 | gg.nMerge = 0; |
| 108 | 108 | for(i=0; i<gg.nFile; i++){ |
| 109 | 109 | fossil_free(gg.aFile[i].zName); |
| 110 | 110 | fossil_free(gg.aFile[i].zUuid); |
| 111 | 111 | fossil_free(gg.aFile[i].zPrior); |
| 112 | + gg.aFile[i].zPrior = 0; | |
| 112 | 113 | } |
| 113 | 114 | memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); |
| 114 | 115 | gg.nFile = 0; |
| 115 | 116 | if( freeAll ){ |
| 116 | 117 | fossil_free(gg.zPrevBranch); |
| @@ -243,17 +244,22 @@ | ||
| 243 | 244 | for(i=0; i<gg.nFile; i++){ |
| 244 | 245 | const char *zUuid = gg.aFile[i].zUuid; |
| 245 | 246 | if( zUuid==0 ) continue; |
| 246 | 247 | blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid); |
| 247 | 248 | if( gg.aFile[i].isExe ){ |
| 248 | - blob_append(&record, " x\n", 3); | |
| 249 | + blob_append(&record, " x", 2); | |
| 249 | 250 | }else if( gg.aFile[i].isLink ){ |
| 250 | - blob_append(&record, " l\n", 3); | |
| 251 | + blob_append(&record, " l", 2); | |
| 251 | 252 | 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); | |
| 254 | 259 | } |
| 260 | + blob_append(&record, "\n", 1); | |
| 255 | 261 | } |
| 256 | 262 | if( gg.zFrom ){ |
| 257 | 263 | blob_appendf(&record, "P %s", gg.zFrom); |
| 258 | 264 | for(i=0; i<gg.nMerge; i++){ |
| 259 | 265 | blob_appendf(&record, " %s", gg.azMerge[i]); |
| @@ -636,10 +642,11 @@ | ||
| 636 | 642 | i = 0; |
| 637 | 643 | while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){ |
| 638 | 644 | if( pFile->isFrom==0 ) continue; |
| 639 | 645 | fossil_free(pFile->zName); |
| 640 | 646 | fossil_free(pFile->zPrior); |
| 647 | + pFile->zPrior = 0; | |
| 641 | 648 | fossil_free(pFile->zUuid); |
| 642 | 649 | *pFile = gg.aFile[--gg.nFile]; |
| 643 | 650 | i--; |
| 644 | 651 | } |
| 645 | 652 | }else |
| @@ -651,51 +658,36 @@ | ||
| 651 | 658 | zTo = rest_of_line(&z); |
| 652 | 659 | i = 0; |
| 653 | 660 | mx = gg.nFile; |
| 654 | 661 | nFrom = strlen(zFrom); |
| 655 | 662 | while( (pFile = import_find_file(zFrom, &i, mx))!=0 ){ |
| 656 | - if( pFile->isFrom==0 ) continue; | |
| 657 | 663 | pNew = import_add_file(); |
| 658 | 664 | pFile = &gg.aFile[i-1]; |
| 659 | 665 | if( strlen(pFile->zName)>nFrom ){ |
| 660 | 666 | pNew->zName = mprintf("%s%s", zTo, pFile->zName[nFrom]); |
| 661 | 667 | }else{ |
| 662 | - pNew->zName = fossil_strdup(pFile->zName); | |
| 668 | + pNew->zName = fossil_strdup(zTo); | |
| 663 | 669 | } |
| 664 | 670 | pNew->isExe = pFile->isExe; |
| 665 | 671 | pNew->isLink = pFile->isLink; |
| 666 | 672 | pNew->zUuid = fossil_strdup(pFile->zUuid); |
| 667 | 673 | pNew->isFrom = 0; |
| 668 | 674 | } |
| 669 | 675 | }else |
| 670 | 676 | if( memcmp(zLine, "R ", 2)==0 ){ |
| 671 | - int nFrom; | |
| 672 | 677 | import_prior_files(); |
| 673 | 678 | z = &zLine[2]; |
| 674 | 679 | zFrom = next_token(&z); |
| 675 | 680 | zTo = rest_of_line(&z); |
| 676 | 681 | i = 0; |
| 677 | - nFrom = strlen(zFrom); | |
| 678 | 682 | while( (pFile = import_find_file(zFrom, &i, gg.nFile))!=0 ){ |
| 679 | 683 | if( pFile->isFrom==0 ) continue; |
| 680 | - pNew = import_add_file(); | |
| 681 | 684 | 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 | + } | |
| 697 | 689 | }else |
| 698 | 690 | if( memcmp(zLine, "deleteall", 9)==0 ){ |
| 699 | 691 | gg.fromLoaded = 1; |
| 700 | 692 | }else |
| 701 | 693 | if( memcmp(zLine, "N ", 2)==0 ){ |
| 702 | 694 |
| --- 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 |