Fossil

Check-in [5063eb52]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Progress on the "fossil mirror" command.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mirror-cmd
Files: files | file ages | folders
SHA3-256: 5063eb521ed10926d736cd54fbff2fb9707c97ba27104c9eead71d545e0d7a1b
User & Date: drh 2019-03-14 18:20:47
Context
2019-03-14
18:55
Sanitize branch names to conform to Git restrictions. check-in: 11bcc4eb user: drh tags: mirror-cmd
18:20
Progress on the "fossil mirror" command. check-in: 5063eb52 user: drh tags: mirror-cmd
17:16
Begin work on the "fossil mirror" command. check-in: dbc1c62a user: drh tags: mirror-cmd
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/export.c.

969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
....
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
....
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
  /* Export the check-in */
  fprintf(xCmd, "commit refs/head/%s\n", zBranch);
  fossil_free(zBranch);
  iMark = mirror_find_mark(zUuid, 1);
  fprintf(xCmd, "mark :%d\n", iMark);
  fprintf(xCmd, "committer %s <%s@noemail.net> %lld +0000\n",
     pMan->zUser, pMan->zUser, 
     (sqlite3_int64)(pMan->rDate-2440587.5)*86400
  );
  fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment));
  fprintf(xCmd, "%s\n", pMan->zComment);
  for(i=0; i<pMan->nParent; i++){
    int iOther = mirror_find_mark(pMan->azParent[i], 0);
    if( i==0 ){
      fprintf(xCmd, "from :%d\n", iOther);
................................................................................
*/
void mirror_command(void){
  const char *zLimit;
  int nLimit = 0x7fffffff;
  int nTotal = 0;
  char *zMirror;
  char *z;
  char *zInFile;
  char *zOutFile;
  char *zCmd;
  const char *zDebug = 0;
  double rEnd;
  int rc;
  FILE *xCmd;
  FILE *pIn, *pOut;
  Stmt q;
................................................................................
    pclose(xCmd);
  }
  fossil_print("%d check-ins added to the mirror\n", nTotal-nLimit);

  /* Read the export-marks file.  Transfer the new marks over into
  ** the import-marks file.
  */
  zInFile = mprintf("%s/.mirror_state/in", zMirror);
  zOutFile = mprintf("%s/.mirror_state/out", zMirror);
  pOut = fopen(zOutFile, "rb");
  if( pOut ){
    pIn = fopen(zInFile, "ab");
    if( pIn==0 ){
      fossil_fatal("cannot open %s for appending", zInFile);
    }
    while( fgets(zLine, sizeof(zLine), pIn) ){
      fputs(zLine, pOut);
    }
    fclose(pOut);
    fclose(pIn);
    file_delete(zOutFile);
  }
  fossil_free(zInFile);
  fossil_free(zOutFile);

  /* Optionally do a "git push" */
}







|







 







<
<







 







<
|
<

|

|

|
|



|
|
|
|



969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
....
1072
1073
1074
1075
1076
1077
1078


1079
1080
1081
1082
1083
1084
1085
....
1215
1216
1217
1218
1219
1220
1221

1222

1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
  /* Export the check-in */
  fprintf(xCmd, "commit refs/head/%s\n", zBranch);
  fossil_free(zBranch);
  iMark = mirror_find_mark(zUuid, 1);
  fprintf(xCmd, "mark :%d\n", iMark);
  fprintf(xCmd, "committer %s <%s@noemail.net> %lld +0000\n",
     pMan->zUser, pMan->zUser, 
     (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
  );
  fprintf(xCmd, "data %d\n", (int)strlen(pMan->zComment));
  fprintf(xCmd, "%s\n", pMan->zComment);
  for(i=0; i<pMan->nParent; i++){
    int iOther = mirror_find_mark(pMan->azParent[i], 0);
    if( i==0 ){
      fprintf(xCmd, "from :%d\n", iOther);
................................................................................
*/
void mirror_command(void){
  const char *zLimit;
  int nLimit = 0x7fffffff;
  int nTotal = 0;
  char *zMirror;
  char *z;


  char *zCmd;
  const char *zDebug = 0;
  double rEnd;
  int rc;
  FILE *xCmd;
  FILE *pIn, *pOut;
  Stmt q;
................................................................................
    pclose(xCmd);
  }
  fossil_print("%d check-ins added to the mirror\n", nTotal-nLimit);

  /* Read the export-marks file.  Transfer the new marks over into
  ** the import-marks file.
  */

  pOut = fopen(".mirror_state/out", "rb");

  if( pOut ){
    pIn = fopen(".mirror_state/in", "ab");
    if( pIn==0 ){
      fossil_fatal("cannot open %s/.mirror_state/in for appending", zMirror);
    }
    while( fgets(zLine, sizeof(zLine), pOut) ){
      fputs(zLine, pIn);
    }
    fclose(pOut);
    fclose(pIn);
    file_delete(".mirror_state/out");
  }else{
    fossil_fatal("git fast-import didn't generate a marks file!");
  }

  /* Optionally do a "git push" */
}