Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch git-better-import Excluding Merge-Ins
This is equivalent to a diff from 0e822db7f1 to 9a023e0d6c
2013-08-09
| ||
18:35 | Removed an unused struct member contentCache::skipCnt. ... (check-in: 65f49c99d0 user: stephan tags: trunk) | |
04:38 | Get capabilities fix et al. ... (check-in: ebafd0c335 user: andybradford tags: ssh-shared-account) | |
01:09 | Fix incorrect wrapping of brief finfo output by simply reducing the size of the buffer passed to comment_print(). ... (Closed-Leaf check-in: bdbf144ed3 user: andybradford tags: pending-review) | |
2013-08-08
| ||
21:32 | merge trunk. Adapt patch to latest SQLite changes (the MAX_PATH fix in os_win.c) ... (Closed-Leaf check-in: 13594a125a user: jan.nijtmans tags: possible-cygwin-fix) | |
18:57 | Merge with trunk. ... (Closed-Leaf check-in: 9a023e0d6c user: isaac.jurado tags: git-better-import) | |
14:00 | Merge the fork in trunk. ... (check-in: 0e822db7f1 user: drh tags: trunk) | |
08:42 | Fixed /reports menu buttons broken by renaming of the link. Removed a target=... from one of the /reports hrefs, for consistency. ... (check-in: 00630581c4 user: stephan tags: trunk) | |
2013-08-06
| ||
14:33 | When resetting capabilities, make sure that "anonymous" and "nobody" can be reapplied afterwards. ... (check-in: b1ffbfa4bc user: drh tags: trunk) | |
2013-07-14
| ||
22:25 | Merge with trunk. ... (check-in: 3c777c4b6a user: isaac.jurado tags: git-better-import) | |
Changes to src/import.c.
︙ | ︙ | |||
26 27 28 29 30 31 32 | /* ** A single file change record. */ struct ImportFile { char *zName; /* Name of a file */ char *zUuid; /* UUID of the file */ char *zPrior; /* Prior name if the name was changed */ | < > > > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* ** A single file change record. */ struct ImportFile { char *zName; /* Name of a file */ char *zUuid; /* UUID of the file */ char *zPrior; /* Prior name if the name was changed */ char isExe; /* True if executable */ char isLink; /* True if symlink */ char hasChanged; /* True when different than baseline */ }; #endif /* ** State information about an on-going fast-import parse. */ static struct { void (*xFinish)(void); /* Function to finish a prior record */ int nData; /* Bytes of data */ char *zBaseline; /* Baseline manifest. The B card. */ char *zTag; /* Name of a tag */ char *zBranch; /* Name of a branch for a commit */ char *zPrevBranch; /* The branch of the previous check-in */ char *aData; /* Data content */ char *zMark; /* The current mark */ char *zDate; /* Date/time stamp */ char *zUser; /* User name */ char *zComment; /* Comment of a commit */ char *zFrom; /* from value as a UUID */ char *zPrevCheckin; /* Name of the previous check-in */ char *zFromMark; /* The mark of the "from" field */ int nMerge; /* Number of merge values */ int nMergeAlloc; /* Number of slots in azMerge[] */ char **azMerge; /* Merge values */ int nFile; /* Number of aFile values */ int nFileAlloc; /* Number of slots in aFile[] */ int nFileEffective; /* Number of aFile items with zUuid != 0 */ int nChanged; /* Number of aFile that differ from baseline */ ImportFile *aFile; /* Information about files in a commit */ int fromLoaded; /* True zFrom content loaded into aFile[] */ int hasLinks; /* True if git repository contains symlinks */ int tagCommit; /* True if the commit adds a tag */ int tryDelta; /* Attempt to generate delta manifests */ } gg; /* ** Duplicate a string. */ char *fossil_strdup(const char *zOrig){ char *z = 0; |
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | ** ** The azMerge[] and aFile[] arrays are zeroed by allocated space is ** retained unless the freeAll flag is set. */ static void import_reset(int freeAll){ int i; gg.xFinish = 0; fossil_free(gg.zTag); gg.zTag = 0; fossil_free(gg.zBranch); gg.zBranch = 0; fossil_free(gg.aData); gg.aData = 0; fossil_free(gg.zMark); gg.zMark = 0; fossil_free(gg.zDate); gg.zDate = 0; fossil_free(gg.zUser); gg.zUser = 0; fossil_free(gg.zComment); gg.zComment = 0; fossil_free(gg.zFrom); gg.zFrom = 0; fossil_free(gg.zFromMark); gg.zFromMark = 0; for(i=0; i<gg.nMerge; i++){ fossil_free(gg.azMerge[i]); gg.azMerge[i] = 0; } gg.nMerge = 0; for(i=0; i<gg.nFile; i++){ fossil_free(gg.aFile[i].zName); fossil_free(gg.aFile[i].zUuid); fossil_free(gg.aFile[i].zPrior); } memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); gg.nFile = 0; if( freeAll ){ fossil_free(gg.zPrevBranch); fossil_free(gg.zPrevCheckin); fossil_free(gg.azMerge); fossil_free(gg.aFile); memset(&gg, 0, sizeof(gg)); | > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | ** ** The azMerge[] and aFile[] arrays are zeroed by allocated space is ** retained unless the freeAll flag is set. */ static void import_reset(int freeAll){ int i; gg.xFinish = 0; fossil_free(gg.zBaseline); gg.zBaseline = 0; fossil_free(gg.zTag); gg.zTag = 0; fossil_free(gg.zBranch); gg.zBranch = 0; fossil_free(gg.aData); gg.aData = 0; fossil_free(gg.zMark); gg.zMark = 0; fossil_free(gg.zDate); gg.zDate = 0; fossil_free(gg.zUser); gg.zUser = 0; fossil_free(gg.zComment); gg.zComment = 0; fossil_free(gg.zFrom); gg.zFrom = 0; fossil_free(gg.zFromMark); gg.zFromMark = 0; for(i=0; i<gg.nMerge; i++){ fossil_free(gg.azMerge[i]); gg.azMerge[i] = 0; } gg.nMerge = 0; for(i=0; i<gg.nFile; i++){ fossil_free(gg.aFile[i].zName); fossil_free(gg.aFile[i].zUuid); fossil_free(gg.aFile[i].zPrior); gg.aFile[i].zPrior = 0; } memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); gg.nChanged = 0; gg.nFileEffective = 0; gg.nFile = 0; if( freeAll ){ fossil_free(gg.zPrevBranch); fossil_free(gg.zPrevCheckin); fossil_free(gg.azMerge); fossil_free(gg.aFile); memset(&gg, 0, sizeof(gg)); |
︙ | ︙ | |||
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | /* ** Use data accumulated in gg from a "commit" record to add a new ** manifest artifact to the BLOB table. */ static void finish_commit(void){ int i; char *zFromBranch; char *aTCard[4]; /* Array of T cards for manifest */ int nTCard = 0; /* Entries used in aTCard[] */ Blob record, cksum; import_prior_files(); qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp); blob_zero(&record); blob_appendf(&record, "C %F\n", gg.zComment); blob_appendf(&record, "D %s\n", gg.zDate); for(i=0; i<gg.nFile; i++){ | > > > > > > > > > > > | | | > > | | | | > > | < | | > > > > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | /* ** Use data accumulated in gg from a "commit" record to add a new ** manifest artifact to the BLOB table. */ static void finish_commit(void){ int i; int delta; char *zFromBranch; char *aTCard[4]; /* Array of T cards for manifest */ int nTCard = 0; /* Entries used in aTCard[] */ Blob record, cksum; import_prior_files(); qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp); /* ** This is the same mechanism used by the commit command to decide whether to ** generate a delta manifest or not. It is evaluated and saved for later ** uses. */ delta = gg.tryDelta && (gg.zBaseline!=0 || gg.zFrom!=0) && (gg.nChanged*gg.nChanged)<(gg.nFileEffective*3-9); blob_zero(&record); if( delta ){ blob_appendf(&record, "B %s\n", gg.zBaseline!=0 ? gg.zBaseline : gg.zFrom); } blob_appendf(&record, "C %F\n", gg.zComment); blob_appendf(&record, "D %s\n", gg.zDate); for(i=0; i<gg.nFile; i++){ const struct ImportFile *pFile = &gg.aFile[i]; if( (!delta && pFile->zUuid==0) || (delta && !pFile->hasChanged) ) continue; blob_appendf(&record, "F %F", pFile->zName); if( pFile->zUuid!=0 ) { blob_appendf(&record, " %s", pFile->zUuid); if( pFile->isExe ){ blob_append(&record, " x", 2); }else if( pFile->isLink ){ blob_append(&record, " l", 2); } if( pFile->zPrior!=0 ){ if( !pFile->isExe && !pFile->isLink ){ blob_append(&record, " w", 2); } blob_appendf(&record, " %F", pFile->zPrior); } } blob_append(&record, "\n", 1); } if( gg.zFrom ){ blob_appendf(&record, "P %s", gg.zFrom); for(i=0; i<gg.nMerge; i++){ blob_appendf(&record, " %s", gg.azMerge[i]); } blob_append(&record, "\n", 1); |
︙ | ︙ | |||
338 339 340 341 342 343 344 | ** Get a token from a line of text. Return a pointer to the first ** character of the token and zero-terminate the token. Make ** *pzIn point to the first character past the end of the zero ** terminator, or at the zero-terminator at EOL. */ static char *next_token(char **pzIn){ char *z = *pzIn; | | < | > | > | > > | > > > > > > > > > > | < | < > > > > > > > > > > > | < < < < < | < < < > > | < < < | > | | > > | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | ** Get a token from a line of text. Return a pointer to the first ** character of the token and zero-terminate the token. Make ** *pzIn point to the first character past the end of the zero ** terminator, or at the zero-terminator at EOL. */ static char *next_token(char **pzIn){ char *z = *pzIn; int i, j; if( z[0]==0 ) return z; if( z[0]=='"' ){ /* Quoted path name */ z++; for(i=0, j=0; z[i] && z[i]!='"' && z[i]!='\n'; i++, j++){ if( z[i]=='\\' && z[i+1] ){ char v, c = z[++i]; switch( c ){ case 0: case '"': c = '"'; break; case '\\': c = '\\'; break; case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case '0': case '1': case '2': case '3': v = (c - '0') << 6; c = z[++i]; if( c < '0' || c > '7' ) fossil_fatal("Invalid octal digit '%c' in sequence", c); v |= (c - '0') << 3; c = z[++i]; if( c < '0' || c > '7' ) fossil_fatal("Invalid octal digit '%c' in sequence", c); v |= (c - '0'); c = v; break; default: fossil_fatal("Unrecognized escape sequence \"\\%c\"", c); } z[j] = c; } } if( z[i]=='"' ) z[i++] = 0; }else{ /* Unquoted path name or generic token */ for(i=0; z[i] && z[i]!=' ' && z[i]!='\n'; i++){} } if( z[i] ){ z[i] = 0; *pzIn = &z[i+1]; }else{ *pzIn = &z[i]; } return z; } |
︙ | ︙ | |||
420 421 422 423 424 425 426 | } if( gg.zFrom==0 ) return; rid = fast_uuid_to_rid(gg.zFrom); if( rid==0 ) return; p = manifest_get(rid, CFTYPE_MANIFEST); if( p==0 ) return; manifest_file_rewind(p); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | } if( gg.zFrom==0 ) return; rid = fast_uuid_to_rid(gg.zFrom); if( rid==0 ) return; p = manifest_get(rid, CFTYPE_MANIFEST); if( p==0 ) return; manifest_file_rewind(p); if( gg.tryDelta && p->pBaseline ){ /* ** The manifest_file_next() iterator skips deletion "F" cards in delta ** manifests. But, in order to build more delta manifests, this information ** is necessary because it propagates. Therefore, in this case, the ** manifest has to be traversed "manually". */ Manifest *pB = p->pBaseline; gg.zBaseline = fossil_strdup(p->zBaseline); while( p->iFile<p->nFile || pB->iFile<pB->nFile ){ pNew = import_add_file(); if( p->iFile>=p->nFile ){ /* No more "F" cards in delta manifest, finish the baseline */ pOld = &pB->aFile[pB->iFile++]; }else if( pB->iFile>=pB->nFile ){ /* No more "F" cards in baseline, finish the delta manifest */ pOld = &p->aFile[p->iFile++]; pNew->hasChanged = 1; }else{ int cmp = fossil_strcmp(pB->aFile[pB->iFile].zName, p->aFile[p->iFile].zName); if( cmp < 0 ){ pOld = &pB->aFile[pB->iFile++]; }else if( cmp >= 0 ){ pOld = &p->aFile[p->iFile++]; pNew->hasChanged = 1; if( cmp==0 ) pB->iFile++; } } pNew->zName = fossil_strdup(pOld->zName); pNew->isExe = pOld->zPerm && strstr(pOld->zPerm, "x")!=0; pNew->isLink = pOld->zPerm && strstr(pOld->zPerm, "l")!=0; pNew->zUuid = fossil_strdup(pOld->zUuid); gg.nChanged += pNew->hasChanged; if( pNew->zUuid!=0 ) gg.nFileEffective++; } }else{ while( (pOld = manifest_file_next(p, 0))!=0 ){ pNew = import_add_file(); pNew->zName = fossil_strdup(pOld->zName); pNew->isExe = pOld->zPerm && strstr(pOld->zPerm, "x")!=0; pNew->isLink = pOld->zPerm && strstr(pOld->zPerm, "l")!=0; pNew->zUuid = fossil_strdup(pOld->zUuid); if( pNew->zUuid!=0 ) gg.nFileEffective++; } } manifest_destroy(p); } /* ** Locate a file in the gg.aFile[] array by its name. Begin the search ** with the *pI-th file. Update *pI to be one past the file found. |
︙ | ︙ | |||
450 451 452 453 454 455 456 | return &gg.aFile[i]; } i++; } return 0; } | < < < < < < < < < < < < < < < < < | | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | return &gg.aFile[i]; } i++; } return 0; } /* ** Read the git-fast-import format from pIn and insert the corresponding ** content into the database. */ static void git_fast_import(FILE *pIn){ ImportFile *pFile, *pNew; int i; char *z; char *zUuid; char *zName; char *zPerm; char *zFrom; char *zTo; char zLine[1000]; |
︙ | ︙ | |||
610 611 612 613 614 615 616 | if( gg.azMerge[gg.nMerge] ) gg.nMerge++; }else if( memcmp(zLine, "M ", 2)==0 ){ import_prior_files(); z = &zLine[2]; zPerm = next_token(&z); zUuid = next_token(&z); | | < > > > > > > > | | < | | > | | | | | < | < < | | > > > | | < | > | > | < | < | | > > > > > > > > > > > | | < | | < > | | > | < < | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | if( gg.azMerge[gg.nMerge] ) gg.nMerge++; }else if( memcmp(zLine, "M ", 2)==0 ){ import_prior_files(); z = &zLine[2]; zPerm = next_token(&z); zUuid = next_token(&z); zName = next_token(&z); i = 0; pFile = import_find_file(zName, &i, gg.nFile); if( pFile==0 ){ pFile = import_add_file(); pFile->zName = fossil_strdup(zName); gg.nFileEffective++; } pFile->isExe = (fossil_strcmp(zPerm, "100755")==0); pFile->isLink = (fossil_strcmp(zPerm, "120000")==0); fossil_free(pFile->zUuid); pFile->zUuid = resolve_committish(zUuid); /* ** This trick avoids counting multiple changes on the same filename as ** changes to multiple filenames. When an entry in gg.aFile is already ** different from its baseline, it is not counted again. */ gg.nChanged += 1 - pFile->hasChanged; pFile->hasChanged = 1; }else if( memcmp(zLine, "D ", 2)==0 ){ import_prior_files(); z = &zLine[2]; zName = next_token(&z); i = 0; pFile = import_find_file(zName, &i, gg.nFile); if( pFile!=0 ){ /* Do not remove the item from gg.aFile, just mark as deleted */ fossil_free(pFile->zUuid); pFile->zUuid = 0; gg.nChanged += 1 - pFile->hasChanged; pFile->hasChanged = 1; gg.nFileEffective--; } }else if( memcmp(zLine, "C ", 2)==0 ){ import_prior_files(); z = &zLine[2]; zFrom = next_token(&z); zTo = next_token(&z); i = 0; pFile = import_find_file(zFrom, &i, gg.nFile); if( pFile!=0 ){ int j = 0; pNew = import_find_file(zTo, &j, gg.nFile); if( pNew==0 ){ pNew = import_add_file(); pFile = &gg.aFile[i-1]; /* gg.aFile may have been realloc()-ed */ pNew->zName = fossil_strdup(zTo); gg.nFileEffective++; }else{ fossil_free(pNew->zUuid); } pNew->isExe = pFile->isExe; pNew->isLink = pFile->isLink; pNew->zUuid = fossil_strdup(pFile->zUuid); gg.nChanged += 1 - pNew->hasChanged; pNew->hasChanged = 1; } }else if( memcmp(zLine, "R ", 2)==0 ){ import_prior_files(); z = &zLine[2]; zFrom = next_token(&z); zTo = next_token(&z); i = 0; pFile = import_find_file(zFrom, &i, gg.nFile); if( pFile!=0 ){ /* ** File renames in delta manifests require two "F" cards: one to ** delete the old file (without UUID) and another with the rename ** (with prior name equals to the name in the other card). ** ** This forces us to also lookup by the destination name, as it may ** already exist in the form of a delta manifest deletion "F" card. */ int j = 0; pNew = import_find_file(zTo, &j, gg.nFile); if( pNew==0 ){ pNew = import_add_file(); pFile = &gg.aFile[i-1]; pNew->zName = fossil_strdup(zTo); }else{ fossil_free(pNew->zUuid); /* Just in case */ } pNew->isExe = pFile->isExe; pNew->isLink = pFile->isLink; pNew->zPrior = fossil_strdup(zFrom); pNew->zUuid = pFile->zUuid; pFile->zUuid = 0; gg.nChanged += 2 - (pNew->hasChanged + pFile->hasChanged); pNew->hasChanged = 1; pFile->hasChanged = 1; } }else if( memcmp(zLine, "deleteall", 9)==0 ){ gg.fromLoaded = 1; }else if( memcmp(zLine, "N ", 2)==0 ){ /* No-op */ }else |
︙ | ︙ | |||
718 719 720 721 722 723 724 | fossil_fatal("bad fast-import line: [%s]", zLine); return; } /* ** COMMAND: import ** | | > | | > > > > > > > > > | > | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | fossil_fatal("bad fast-import line: [%s]", zLine); return; } /* ** COMMAND: import ** ** Usage: %fossil import --git ?OPTIONS? NEW-REPOSITORY ?FILE? ** ** Read text generated by the git-fast-export command and use it to ** construct a new Fossil repository named by the NEW-REPOSITORY ** argument. If given, the git-fast-export text is read from the FILE argument, ** otherwise text is read from standard input. ** ** The git-fast-export file format is currently the only VCS interchange ** format that is understood, though other interchange formats may be added ** in the future. ** ** The --incremental option allows an existing repository to be extended ** with new content. Otherwise, if a file with the same name as NEW-REPOSITORY ** is found, the command fails unless the --force option is used. ** ** When the --delta option is used, delta manifests will be generated when they ** are smaller than the equivalent baseline manifest. Please beware that delta ** manifests are not understood by older versions of Fossil. Therefore, only ** use this option when it can be assured that only newer clients will pull or ** read from it. ** ** Options: ** -d|--delta enable delta manifest generation ** -f|--force remove existing file ** -i|--incremental allow importing into an existing repository ** ** See also: export */ void git_import_cmd(void){ char *zPassword; FILE *pIn; Stmt q; int forceFlag = find_option("force", "f", 0)!=0; int incrFlag = find_option("incremental", "i", 0)!=0; find_option("git",0,0); /* Skip the --git option for now */ gg.tryDelta = find_option("delta", "d", 0)!=0; verify_all_options(); if( g.argc!=3 && g.argc!=4 ){ usage("REPOSITORY-NAME"); } if( g.argc==4 ){ pIn = fossil_fopen(g.argv[3], "rb"); }else{ |
︙ | ︙ |