Fossil SCM
Fix the export so that it is able to handle phantom check-ins.
Commit
4a480954e7335eeab0e8dfa7c3b481d92cba718f987dfdcf555d1f0f5fc9dec4
Parent
11bcc4eb108cf98…
1 file changed
+14
-10
+14
-10
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -949,22 +949,21 @@ | ||
| 949 | 949 | int rid, /* BLOB.RID for the check-in to export */ |
| 950 | 950 | const char *zUuid, /* BLOB.UUID for the check-in to export */ |
| 951 | 951 | int *pnLimit /* Stop when the counter reaches zero */ |
| 952 | 952 | ){ |
| 953 | 953 | Manifest *pMan; |
| 954 | - int i; | |
| 955 | - Blob err; | |
| 954 | + int i, iParent; | |
| 956 | 955 | Stmt q; |
| 957 | 956 | char *zBranch; |
| 958 | 957 | int iMark; |
| 959 | 958 | Blob sql; |
| 960 | 959 | |
| 961 | - blob_init(&err, 0, 0); | |
| 962 | - pMan = manifest_get(rid, CFTYPE_MANIFEST, &err); | |
| 960 | + pMan = manifest_get(rid, CFTYPE_MANIFEST, 0); | |
| 963 | 961 | if( pMan==0 ){ |
| 964 | - fossil_fatal("cannot fetch manifest for check-in %d: %s", rid, | |
| 965 | - blob_str(&err)); | |
| 962 | + /* Must be a phantom. Return without doing anything, and in particular | |
| 963 | + ** without creating a mark for this check-in. */ | |
| 964 | + return; | |
| 966 | 965 | } |
| 967 | 966 | |
| 968 | 967 | /* Check to see if any parent logins have not yet been processed, and |
| 969 | 968 | ** if so, create them */ |
| 970 | 969 | for(i=0; i<pMan->nParent; i++){ |
| @@ -998,10 +997,12 @@ | ||
| 998 | 997 | TAG_BRANCH, rid |
| 999 | 998 | ); |
| 1000 | 999 | if( fossil_strcmp(zBranch,"trunk")==0 ){ |
| 1001 | 1000 | fossil_free(zBranch); |
| 1002 | 1001 | zBranch = mprintf("master"); |
| 1002 | + }else if( zBranch==0 ){ | |
| 1003 | + zBranch = mprintf("unknown"); | |
| 1003 | 1004 | }else{ |
| 1004 | 1005 | mirror_sanitize_git_name(zBranch); |
| 1005 | 1006 | } |
| 1006 | 1007 | |
| 1007 | 1008 | /* Export the check-in */ |
| @@ -1013,23 +1014,26 @@ | ||
| 1013 | 1014 | pMan->zUser, pMan->zUser, |
| 1014 | 1015 | (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0) |
| 1015 | 1016 | ); |
| 1016 | 1017 | fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment)); |
| 1017 | 1018 | fprintf(xCmd, "%s\n", pMan->zComment); |
| 1019 | + iParent = -1; /* Which ancestor is the primary parent */ | |
| 1018 | 1020 | for(i=0; i<pMan->nParent; i++){ |
| 1019 | 1021 | int iOther = mirror_find_mark(pMan->azParent[i], 0); |
| 1020 | - if( i==0 ){ | |
| 1022 | + if( iOther==0 ) continue; | |
| 1023 | + if( iParent<0 ){ | |
| 1024 | + iParent = i; | |
| 1021 | 1025 | fprintf(xCmd, "from :%d\n", iOther); |
| 1022 | 1026 | }else{ |
| 1023 | 1027 | fprintf(xCmd, "merge :%d\n", iOther); |
| 1024 | 1028 | } |
| 1025 | 1029 | } |
| 1026 | - if( pMan->nParent ){ | |
| 1030 | + if( iParent>=0 ){ | |
| 1027 | 1031 | db_prepare(&q, |
| 1028 | 1032 | "SELECT filename FROM files_of_checkin(%Q)" |
| 1029 | 1033 | " EXCEPT SELECT filename FROM files_of_checkin(%Q)", |
| 1030 | - pMan->azParent[0], zUuid | |
| 1034 | + pMan->azParent[iParent], zUuid | |
| 1031 | 1035 | ); |
| 1032 | 1036 | while( db_step(&q)==SQLITE_ROW ){ |
| 1033 | 1037 | fprintf(xCmd, "D %s\n", db_column_text(&q,0)); |
| 1034 | 1038 | } |
| 1035 | 1039 | db_finalize(&q); |
| @@ -1123,11 +1127,11 @@ | ||
| 1123 | 1127 | Stmt q; |
| 1124 | 1128 | char zLine[200]; |
| 1125 | 1129 | |
| 1126 | 1130 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| 1127 | 1131 | zDebug = find_option("debug",0,1); |
| 1128 | - db_find_and_open_repository(0, 2); | |
| 1132 | + db_find_and_open_repository(0, 0); | |
| 1129 | 1133 | zLimit = find_option("limit", 0, 1); |
| 1130 | 1134 | if( zLimit ){ |
| 1131 | 1135 | nLimit = (unsigned int)atoi(zLimit); |
| 1132 | 1136 | if( nLimit<=0 ) fossil_fatal("--limit must be positive"); |
| 1133 | 1137 | } |
| 1134 | 1138 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -949,22 +949,21 @@ | |
| 949 | int rid, /* BLOB.RID for the check-in to export */ |
| 950 | const char *zUuid, /* BLOB.UUID for the check-in to export */ |
| 951 | int *pnLimit /* Stop when the counter reaches zero */ |
| 952 | ){ |
| 953 | Manifest *pMan; |
| 954 | int i; |
| 955 | Blob err; |
| 956 | Stmt q; |
| 957 | char *zBranch; |
| 958 | int iMark; |
| 959 | Blob sql; |
| 960 | |
| 961 | blob_init(&err, 0, 0); |
| 962 | pMan = manifest_get(rid, CFTYPE_MANIFEST, &err); |
| 963 | if( pMan==0 ){ |
| 964 | fossil_fatal("cannot fetch manifest for check-in %d: %s", rid, |
| 965 | blob_str(&err)); |
| 966 | } |
| 967 | |
| 968 | /* Check to see if any parent logins have not yet been processed, and |
| 969 | ** if so, create them */ |
| 970 | for(i=0; i<pMan->nParent; i++){ |
| @@ -998,10 +997,12 @@ | |
| 998 | TAG_BRANCH, rid |
| 999 | ); |
| 1000 | if( fossil_strcmp(zBranch,"trunk")==0 ){ |
| 1001 | fossil_free(zBranch); |
| 1002 | zBranch = mprintf("master"); |
| 1003 | }else{ |
| 1004 | mirror_sanitize_git_name(zBranch); |
| 1005 | } |
| 1006 | |
| 1007 | /* Export the check-in */ |
| @@ -1013,23 +1014,26 @@ | |
| 1013 | pMan->zUser, pMan->zUser, |
| 1014 | (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0) |
| 1015 | ); |
| 1016 | fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment)); |
| 1017 | fprintf(xCmd, "%s\n", pMan->zComment); |
| 1018 | for(i=0; i<pMan->nParent; i++){ |
| 1019 | int iOther = mirror_find_mark(pMan->azParent[i], 0); |
| 1020 | if( i==0 ){ |
| 1021 | fprintf(xCmd, "from :%d\n", iOther); |
| 1022 | }else{ |
| 1023 | fprintf(xCmd, "merge :%d\n", iOther); |
| 1024 | } |
| 1025 | } |
| 1026 | if( pMan->nParent ){ |
| 1027 | db_prepare(&q, |
| 1028 | "SELECT filename FROM files_of_checkin(%Q)" |
| 1029 | " EXCEPT SELECT filename FROM files_of_checkin(%Q)", |
| 1030 | pMan->azParent[0], zUuid |
| 1031 | ); |
| 1032 | while( db_step(&q)==SQLITE_ROW ){ |
| 1033 | fprintf(xCmd, "D %s\n", db_column_text(&q,0)); |
| 1034 | } |
| 1035 | db_finalize(&q); |
| @@ -1123,11 +1127,11 @@ | |
| 1123 | Stmt q; |
| 1124 | char zLine[200]; |
| 1125 | |
| 1126 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| 1127 | zDebug = find_option("debug",0,1); |
| 1128 | db_find_and_open_repository(0, 2); |
| 1129 | zLimit = find_option("limit", 0, 1); |
| 1130 | if( zLimit ){ |
| 1131 | nLimit = (unsigned int)atoi(zLimit); |
| 1132 | if( nLimit<=0 ) fossil_fatal("--limit must be positive"); |
| 1133 | } |
| 1134 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -949,22 +949,21 @@ | |
| 949 | int rid, /* BLOB.RID for the check-in to export */ |
| 950 | const char *zUuid, /* BLOB.UUID for the check-in to export */ |
| 951 | int *pnLimit /* Stop when the counter reaches zero */ |
| 952 | ){ |
| 953 | Manifest *pMan; |
| 954 | int i, iParent; |
| 955 | Stmt q; |
| 956 | char *zBranch; |
| 957 | int iMark; |
| 958 | Blob sql; |
| 959 | |
| 960 | pMan = manifest_get(rid, CFTYPE_MANIFEST, 0); |
| 961 | if( pMan==0 ){ |
| 962 | /* Must be a phantom. Return without doing anything, and in particular |
| 963 | ** without creating a mark for this check-in. */ |
| 964 | return; |
| 965 | } |
| 966 | |
| 967 | /* Check to see if any parent logins have not yet been processed, and |
| 968 | ** if so, create them */ |
| 969 | for(i=0; i<pMan->nParent; i++){ |
| @@ -998,10 +997,12 @@ | |
| 997 | TAG_BRANCH, rid |
| 998 | ); |
| 999 | if( fossil_strcmp(zBranch,"trunk")==0 ){ |
| 1000 | fossil_free(zBranch); |
| 1001 | zBranch = mprintf("master"); |
| 1002 | }else if( zBranch==0 ){ |
| 1003 | zBranch = mprintf("unknown"); |
| 1004 | }else{ |
| 1005 | mirror_sanitize_git_name(zBranch); |
| 1006 | } |
| 1007 | |
| 1008 | /* Export the check-in */ |
| @@ -1013,23 +1014,26 @@ | |
| 1014 | pMan->zUser, pMan->zUser, |
| 1015 | (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0) |
| 1016 | ); |
| 1017 | fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment)); |
| 1018 | fprintf(xCmd, "%s\n", pMan->zComment); |
| 1019 | iParent = -1; /* Which ancestor is the primary parent */ |
| 1020 | for(i=0; i<pMan->nParent; i++){ |
| 1021 | int iOther = mirror_find_mark(pMan->azParent[i], 0); |
| 1022 | if( iOther==0 ) continue; |
| 1023 | if( iParent<0 ){ |
| 1024 | iParent = i; |
| 1025 | fprintf(xCmd, "from :%d\n", iOther); |
| 1026 | }else{ |
| 1027 | fprintf(xCmd, "merge :%d\n", iOther); |
| 1028 | } |
| 1029 | } |
| 1030 | if( iParent>=0 ){ |
| 1031 | db_prepare(&q, |
| 1032 | "SELECT filename FROM files_of_checkin(%Q)" |
| 1033 | " EXCEPT SELECT filename FROM files_of_checkin(%Q)", |
| 1034 | pMan->azParent[iParent], zUuid |
| 1035 | ); |
| 1036 | while( db_step(&q)==SQLITE_ROW ){ |
| 1037 | fprintf(xCmd, "D %s\n", db_column_text(&q,0)); |
| 1038 | } |
| 1039 | db_finalize(&q); |
| @@ -1123,11 +1127,11 @@ | |
| 1127 | Stmt q; |
| 1128 | char zLine[200]; |
| 1129 | |
| 1130 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| 1131 | zDebug = find_option("debug",0,1); |
| 1132 | db_find_and_open_repository(0, 0); |
| 1133 | zLimit = find_option("limit", 0, 1); |
| 1134 | if( zLimit ){ |
| 1135 | nLimit = (unsigned int)atoi(zLimit); |
| 1136 | if( nLimit<=0 ) fossil_fatal("--limit must be positive"); |
| 1137 | } |
| 1138 |