Fossil SCM

Progress on the "fossil mirror" command.

drh 2019-03-14 18:20 UTC mirror-cmd
Commit 5063eb521ed10926d736cd54fbff2fb9707c97ba27104c9eead71d545e0d7a1b
1 file changed +9 -13
+9 -13
--- src/export.c
+++ src/export.c
@@ -971,11 +971,11 @@
971971
fossil_free(zBranch);
972972
iMark = mirror_find_mark(zUuid, 1);
973973
fprintf(xCmd, "mark :%d\n", iMark);
974974
fprintf(xCmd, "committer %s <%[email protected]> %lld +0000\n",
975975
pMan->zUser, pMan->zUser,
976
- (sqlite3_int64)(pMan->rDate-2440587.5)*86400
976
+ (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
977977
);
978978
fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment));
979979
fprintf(xCmd, "%s\n", pMan->zComment);
980980
for(i=0; i<pMan->nParent; i++){
981981
int iOther = mirror_find_mark(pMan->azParent[i], 0);
@@ -1074,12 +1074,10 @@
10741074
const char *zLimit;
10751075
int nLimit = 0x7fffffff;
10761076
int nTotal = 0;
10771077
char *zMirror;
10781078
char *z;
1079
- char *zInFile;
1080
- char *zOutFile;
10811079
char *zCmd;
10821080
const char *zDebug = 0;
10831081
double rEnd;
10841082
int rc;
10851083
FILE *xCmd;
@@ -1219,25 +1217,23 @@
12191217
fossil_print("%d check-ins added to the mirror\n", nTotal-nLimit);
12201218
12211219
/* Read the export-marks file. Transfer the new marks over into
12221220
** the import-marks file.
12231221
*/
1224
- zInFile = mprintf("%s/.mirror_state/in", zMirror);
1225
- zOutFile = mprintf("%s/.mirror_state/out", zMirror);
1226
- pOut = fopen(zOutFile, "rb");
1222
+ pOut = fopen(".mirror_state/out", "rb");
12271223
if( pOut ){
1228
- pIn = fopen(zInFile, "ab");
1224
+ pIn = fopen(".mirror_state/in", "ab");
12291225
if( pIn==0 ){
1230
- fossil_fatal("cannot open %s for appending", zInFile);
1226
+ fossil_fatal("cannot open %s/.mirror_state/in for appending", zMirror);
12311227
}
1232
- while( fgets(zLine, sizeof(zLine), pIn) ){
1233
- fputs(zLine, pOut);
1228
+ while( fgets(zLine, sizeof(zLine), pOut) ){
1229
+ fputs(zLine, pIn);
12341230
}
12351231
fclose(pOut);
12361232
fclose(pIn);
1237
- file_delete(zOutFile);
1233
+ file_delete(".mirror_state/out");
1234
+ }else{
1235
+ fossil_fatal("git fast-import didn't generate a marks file!");
12381236
}
1239
- fossil_free(zInFile);
1240
- fossil_free(zOutFile);
12411237
12421238
/* Optionally do a "git push" */
12431239
}
12441240
--- src/export.c
+++ src/export.c
@@ -971,11 +971,11 @@
971 fossil_free(zBranch);
972 iMark = mirror_find_mark(zUuid, 1);
973 fprintf(xCmd, "mark :%d\n", iMark);
974 fprintf(xCmd, "committer %s <%[email protected]> %lld +0000\n",
975 pMan->zUser, pMan->zUser,
976 (sqlite3_int64)(pMan->rDate-2440587.5)*86400
977 );
978 fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment));
979 fprintf(xCmd, "%s\n", pMan->zComment);
980 for(i=0; i<pMan->nParent; i++){
981 int iOther = mirror_find_mark(pMan->azParent[i], 0);
@@ -1074,12 +1074,10 @@
1074 const char *zLimit;
1075 int nLimit = 0x7fffffff;
1076 int nTotal = 0;
1077 char *zMirror;
1078 char *z;
1079 char *zInFile;
1080 char *zOutFile;
1081 char *zCmd;
1082 const char *zDebug = 0;
1083 double rEnd;
1084 int rc;
1085 FILE *xCmd;
@@ -1219,25 +1217,23 @@
1219 fossil_print("%d check-ins added to the mirror\n", nTotal-nLimit);
1220
1221 /* Read the export-marks file. Transfer the new marks over into
1222 ** the import-marks file.
1223 */
1224 zInFile = mprintf("%s/.mirror_state/in", zMirror);
1225 zOutFile = mprintf("%s/.mirror_state/out", zMirror);
1226 pOut = fopen(zOutFile, "rb");
1227 if( pOut ){
1228 pIn = fopen(zInFile, "ab");
1229 if( pIn==0 ){
1230 fossil_fatal("cannot open %s for appending", zInFile);
1231 }
1232 while( fgets(zLine, sizeof(zLine), pIn) ){
1233 fputs(zLine, pOut);
1234 }
1235 fclose(pOut);
1236 fclose(pIn);
1237 file_delete(zOutFile);
 
 
1238 }
1239 fossil_free(zInFile);
1240 fossil_free(zOutFile);
1241
1242 /* Optionally do a "git push" */
1243 }
1244
--- src/export.c
+++ src/export.c
@@ -971,11 +971,11 @@
971 fossil_free(zBranch);
972 iMark = mirror_find_mark(zUuid, 1);
973 fprintf(xCmd, "mark :%d\n", iMark);
974 fprintf(xCmd, "committer %s <%[email protected]> %lld +0000\n",
975 pMan->zUser, pMan->zUser,
976 (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
977 );
978 fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment));
979 fprintf(xCmd, "%s\n", pMan->zComment);
980 for(i=0; i<pMan->nParent; i++){
981 int iOther = mirror_find_mark(pMan->azParent[i], 0);
@@ -1074,12 +1074,10 @@
1074 const char *zLimit;
1075 int nLimit = 0x7fffffff;
1076 int nTotal = 0;
1077 char *zMirror;
1078 char *z;
 
 
1079 char *zCmd;
1080 const char *zDebug = 0;
1081 double rEnd;
1082 int rc;
1083 FILE *xCmd;
@@ -1219,25 +1217,23 @@
1217 fossil_print("%d check-ins added to the mirror\n", nTotal-nLimit);
1218
1219 /* Read the export-marks file. Transfer the new marks over into
1220 ** the import-marks file.
1221 */
1222 pOut = fopen(".mirror_state/out", "rb");
 
 
1223 if( pOut ){
1224 pIn = fopen(".mirror_state/in", "ab");
1225 if( pIn==0 ){
1226 fossil_fatal("cannot open %s/.mirror_state/in for appending", zMirror);
1227 }
1228 while( fgets(zLine, sizeof(zLine), pOut) ){
1229 fputs(zLine, pIn);
1230 }
1231 fclose(pOut);
1232 fclose(pIn);
1233 file_delete(".mirror_state/out");
1234 }else{
1235 fossil_fatal("git fast-import didn't generate a marks file!");
1236 }
 
 
1237
1238 /* Optionally do a "git push" */
1239 }
1240

Keyboard Shortcuts

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