Fossil SCM

Fix the export so that it is able to handle phantom check-ins.

drh 2019-03-14 19:43 UTC mirror-cmd
Commit 4a480954e7335eeab0e8dfa7c3b481d92cba718f987dfdcf555d1f0f5fc9dec4
1 file changed +14 -10
+14 -10
--- src/export.c
+++ src/export.c
@@ -949,22 +949,21 @@
949949
int rid, /* BLOB.RID for the check-in to export */
950950
const char *zUuid, /* BLOB.UUID for the check-in to export */
951951
int *pnLimit /* Stop when the counter reaches zero */
952952
){
953953
Manifest *pMan;
954
- int i;
955
- Blob err;
954
+ int i, iParent;
956955
Stmt q;
957956
char *zBranch;
958957
int iMark;
959958
Blob sql;
960959
961
- blob_init(&err, 0, 0);
962
- pMan = manifest_get(rid, CFTYPE_MANIFEST, &err);
960
+ pMan = manifest_get(rid, CFTYPE_MANIFEST, 0);
963961
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;
966965
}
967966
968967
/* Check to see if any parent logins have not yet been processed, and
969968
** if so, create them */
970969
for(i=0; i<pMan->nParent; i++){
@@ -998,10 +997,12 @@
998997
TAG_BRANCH, rid
999998
);
1000999
if( fossil_strcmp(zBranch,"trunk")==0 ){
10011000
fossil_free(zBranch);
10021001
zBranch = mprintf("master");
1002
+ }else if( zBranch==0 ){
1003
+ zBranch = mprintf("unknown");
10031004
}else{
10041005
mirror_sanitize_git_name(zBranch);
10051006
}
10061007
10071008
/* Export the check-in */
@@ -1013,23 +1014,26 @@
10131014
pMan->zUser, pMan->zUser,
10141015
(sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
10151016
);
10161017
fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment));
10171018
fprintf(xCmd, "%s\n", pMan->zComment);
1019
+ iParent = -1; /* Which ancestor is the primary parent */
10181020
for(i=0; i<pMan->nParent; i++){
10191021
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;
10211025
fprintf(xCmd, "from :%d\n", iOther);
10221026
}else{
10231027
fprintf(xCmd, "merge :%d\n", iOther);
10241028
}
10251029
}
1026
- if( pMan->nParent ){
1030
+ if( iParent>=0 ){
10271031
db_prepare(&q,
10281032
"SELECT filename FROM files_of_checkin(%Q)"
10291033
" EXCEPT SELECT filename FROM files_of_checkin(%Q)",
1030
- pMan->azParent[0], zUuid
1034
+ pMan->azParent[iParent], zUuid
10311035
);
10321036
while( db_step(&q)==SQLITE_ROW ){
10331037
fprintf(xCmd, "D %s\n", db_column_text(&q,0));
10341038
}
10351039
db_finalize(&q);
@@ -1123,11 +1127,11 @@
11231127
Stmt q;
11241128
char zLine[200];
11251129
11261130
find_option("git", 0, 0); /* Ignore the --git option for now */
11271131
zDebug = find_option("debug",0,1);
1128
- db_find_and_open_repository(0, 2);
1132
+ db_find_and_open_repository(0, 0);
11291133
zLimit = find_option("limit", 0, 1);
11301134
if( zLimit ){
11311135
nLimit = (unsigned int)atoi(zLimit);
11321136
if( nLimit<=0 ) fossil_fatal("--limit must be positive");
11331137
}
11341138
--- 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

Keyboard Shortcuts

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