Fossil

Check-in [eafe5ce6]
Login

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

Overview
Comment:Export "manifest", "manifest.uuid", and "manifest.tags" files if that is what the repository needs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mirror-cmd
Files: files | file ages | folders
SHA3-256: eafe5ce624349d9643541069f5696eec0547c585a889497891fbbb42a650c9b8
User & Date: drh 2019-03-15 16:11:05
Context
2019-03-15
16:38
Rename "fossil mirror" to "fossil git export". Deprecate the "fossil export" command. check-in: 2faec6b7 user: drh tags: mirror-cmd
16:11
Export "manifest", "manifest.uuid", and "manifest.tags" files if that is what the repository needs. check-in: eafe5ce6 user: drh tags: mirror-cmd
13:12
The branch names should start with "refs/heads" (with an "s" at the end), not just "refs/head". check-in: d7437168 user: drh tags: mirror-cmd
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/export.c.

993
994
995
996
997
998
999
1000

1001
1002
1003
1004
1005
1006
1007
....
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
....
1117
1118
1119
1120
1121
1122
1123





















1124
1125
1126
1127
1128
1129
1130
....
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180

1181
1182

1183
1184
1185
1186
1187
1188
1189
1190
....
1239
1240
1241
1242
1243
1244
1245



1246
1247
1248
1249
1250
1251
1252
....
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
** have not been.  Update the MIRROR.MMARK table so that it holds the
** marks for the exported files. 
*/
static void mirror_send_checkin(
  FILE *xCmd,           /* Write fast-import text on this pipe */
  int rid,              /* BLOB.RID for the check-in to export */
  const char *zUuid,    /* BLOB.UUID for the check-in to export */
  int *pnLimit          /* Stop when the counter reaches zero */

){
  Manifest *pMan;       /* The check-in to be output */
  int i;                /* Loop counter */
  int iParent;          /* Which immediate ancestor is primary.  -1 for none */
  Stmt q;               /* An SQL query */
  char *zBranch;        /* The branch of the check-in */
  int iMark;            /* The mark for the check-in */
................................................................................
  /* Check to see if any parent logins have not yet been processed, and
  ** if so, create them */
  for(i=0; i<pMan->nParent; i++){
    int iMark = mirror_find_mark(pMan->azParent[i], 0);
    if( iMark<=0 ){
      int prid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q",
                        pMan->azParent[i]);
      mirror_send_checkin(xCmd, prid, pMan->azParent[i], pnLimit);
      if( *pnLimit<=0 ){
        manifest_destroy(pMan);
        return;
      }
    }
  }

................................................................................
      if( strchr(zMode,'l') ) zGitMode = "120000";
    }
    zFNQuoted = mirror_quote_filename_if_needed(zFilename);
    fprintf(xCmd,"M %s :%d %s\n", zGitMode, iMark, zFNQuoted);
    fossil_free(zFNQuoted);
  }
  db_finalize(&q);






















  /* The check-in is finished, so decrement the counter */
  (*pnLimit)--;
}

/*
** COMMAND: mirror
................................................................................
**    --debug FILE             Write fast-export text to FILE rather than
**                             piping it into "git fast-import".
**
**    --limit N                Add no more than N new check-ins to MIRROR.
**                             Useful for debugging
*/
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;

  char zLine[200];

  find_option("git", 0, 0);   /* Ignore the --git option for now */
  zDebug = find_option("debug",0,1);
  db_find_and_open_repository(0, 0);
  zLimit = find_option("limit", 0, 1);
  if( zLimit ){
    nLimit = (unsigned int)atoi(zLimit);
................................................................................
  if( !db_exists("SELECT 1 FROM event WHERE type IN ('t','ci')"
                 " AND mtime>coalesce((SELECT value FROM mconfig"
                                        " WHERE key='start'),0.0)")
  ){
    fossil_print("no changes\n");
    return;
  }




  /* Change to the MIRROR directory so that the Git commands will work */
  rc = file_chdir(zMirror, 0);
  if( rc ) fossil_fatal("cannot change the working directory to \"%s\"",
                        zMirror);

  /* Start up the git fast-import command */
................................................................................
    const char *zType = db_column_text(&q, 1);
    int rid = db_column_int(&q, 0);
    const char *zUuid = db_column_text(&q, 3);
    if( rMTime>rEnd ) rEnd = rMTime;
    if( zType[0]=='t' ){
      mirror_send_tag(xCmd, rid);
    }else{
      mirror_send_checkin(xCmd, rid, zUuid, &nLimit);
      printf("\r%d/%d  ", nTotal-nLimit, nTotal);
      fflush(stdout);
    }
  }
  db_finalize(&q);
  db_prepare(&q, "REPLACE INTO mirror.mconfig(key,value) VALUES('start',:x)");
  db_bind_double(&q, ":x", rEnd);







|
>







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
|
|
|
|
|
|
|
|
|
>
|
<
>
|







 







>
>
>







 







|







993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
....
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
....
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
....
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204

1205
1206
1207
1208
1209
1210
1211
1212
1213
....
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
....
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
** have not been.  Update the MIRROR.MMARK table so that it holds the
** marks for the exported files. 
*/
static void mirror_send_checkin(
  FILE *xCmd,           /* Write fast-import text on this pipe */
  int rid,              /* BLOB.RID for the check-in to export */
  const char *zUuid,    /* BLOB.UUID for the check-in to export */
  int *pnLimit,         /* Stop when the counter reaches zero */
  int fManifest         /* MFESTFLG_* values */
){
  Manifest *pMan;       /* The check-in to be output */
  int i;                /* Loop counter */
  int iParent;          /* Which immediate ancestor is primary.  -1 for none */
  Stmt q;               /* An SQL query */
  char *zBranch;        /* The branch of the check-in */
  int iMark;            /* The mark for the check-in */
................................................................................
  /* Check to see if any parent logins have not yet been processed, and
  ** if so, create them */
  for(i=0; i<pMan->nParent; i++){
    int iMark = mirror_find_mark(pMan->azParent[i], 0);
    if( iMark<=0 ){
      int prid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q",
                        pMan->azParent[i]);
      mirror_send_checkin(xCmd, prid, pMan->azParent[i], pnLimit, fManifest);
      if( *pnLimit<=0 ){
        manifest_destroy(pMan);
        return;
      }
    }
  }

................................................................................
      if( strchr(zMode,'l') ) zGitMode = "120000";
    }
    zFNQuoted = mirror_quote_filename_if_needed(zFilename);
    fprintf(xCmd,"M %s :%d %s\n", zGitMode, iMark, zFNQuoted);
    fossil_free(zFNQuoted);
  }
  db_finalize(&q);

  /* Include Fossil-generated auxiliary files in the check-in */
  if( fManifest & MFESTFLG_RAW ){
    Blob manifest;
    content_get(rid, &manifest);
    fprintf(xCmd,"M 100644 inline manifest\ndata %d\n%s\n",
      blob_size(&manifest), blob_str(&manifest));
    blob_reset(&manifest);
  }
  if( fManifest & MFESTFLG_UUID ){
    int n = (int)strlen(zUuid);
    fprintf(xCmd,"M 100644 inline manifest.uuid\ndata %d\n%s\n", n, zUuid);
  }
  if( fManifest & MFESTFLG_TAGS ){
    Blob tagslist;
    blob_init(&tagslist, 0, 0);
    get_checkin_taglist(rid, &tagslist);
    fprintf(xCmd,"M 100644 inline manifest.tags\ndata %d\n%s\n",
      blob_size(&tagslist), blob_str(&tagslist));
    blob_reset(&tagslist);
  }

  /* The check-in is finished, so decrement the counter */
  (*pnLimit)--;
}

/*
** COMMAND: mirror
................................................................................
**    --debug FILE             Write fast-export text to FILE rather than
**                             piping it into "git fast-import".
**
**    --limit N                Add no more than N new check-ins to MIRROR.
**                             Useful for debugging
*/
void mirror_command(void){
  const char *zLimit;             /* Text of the --limit flag */
  int nLimit = 0x7fffffff;        /* Numeric value of the --limit flag */
  int nTotal = 0;                 /* Total number of check-ins to export */
  char *zMirror;                  /* Name of the mirror */
  char *z;                        /* Generic string */
  char *zCmd;                     /* git command to run as a subprocess */
  const char *zDebug = 0;         /* Value of the --debug flag */
  double rEnd;                    /* time of most recent export */
  int rc;                         /* Result code */
  int fManifest;                  /* Current "manifest" setting */
  FILE *xCmd;                     /* Pipe to the "git fast-import" command */
  FILE *pIn, *pOut;               /* Git mark files */

  Stmt q;                         /* Queries */
  char zLine[200];                /* One line of a mark file */

  find_option("git", 0, 0);   /* Ignore the --git option for now */
  zDebug = find_option("debug",0,1);
  db_find_and_open_repository(0, 0);
  zLimit = find_option("limit", 0, 1);
  if( zLimit ){
    nLimit = (unsigned int)atoi(zLimit);
................................................................................
  if( !db_exists("SELECT 1 FROM event WHERE type IN ('t','ci')"
                 " AND mtime>coalesce((SELECT value FROM mconfig"
                                        " WHERE key='start'),0.0)")
  ){
    fossil_print("no changes\n");
    return;
  }

  /* Do we need to include manifest files in the clone? */
  fManifest = db_get_manifest_setting();

  /* Change to the MIRROR directory so that the Git commands will work */
  rc = file_chdir(zMirror, 0);
  if( rc ) fossil_fatal("cannot change the working directory to \"%s\"",
                        zMirror);

  /* Start up the git fast-import command */
................................................................................
    const char *zType = db_column_text(&q, 1);
    int rid = db_column_int(&q, 0);
    const char *zUuid = db_column_text(&q, 3);
    if( rMTime>rEnd ) rEnd = rMTime;
    if( zType[0]=='t' ){
      mirror_send_tag(xCmd, rid);
    }else{
      mirror_send_checkin(xCmd, rid, zUuid, &nLimit, fManifest);
      printf("\r%d/%d  ", nTotal-nLimit, nTotal);
      fflush(stdout);
    }
  }
  db_finalize(&q);
  db_prepare(&q, "REPLACE INTO mirror.mconfig(key,value) VALUES('start',:x)");
  db_bind_double(&q, ":x", rEnd);