Fossil SCM
Add the "fossil all git export" and "fossil all git status" commands.
Commit
9d53f2f6a22037e4d27049875f179829c320ac738cf2038a2b20ceacaaf27c27
Parent
bcff80c1d4cb969…
2 files changed
+17
-1
+4
+17
-1
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -91,10 +91,13 @@ | ||
| 91 | 91 | ** line options supported by the extra command itself, if any |
| 92 | 92 | ** are present, are passed along verbatim. |
| 93 | 93 | ** |
| 94 | 94 | ** fts-config Run the "fts-config" command on all repositories. |
| 95 | 95 | ** |
| 96 | +** git export Do the "git export" command on all repositories for which | |
| 97 | +** a Git mirror has been previously established. | |
| 98 | +** | |
| 96 | 99 | ** info Run the "info" command on all repositories. |
| 97 | 100 | ** |
| 98 | 101 | ** pull Run a "pull" operation on all repositories. Only the |
| 99 | 102 | ** --verbose option is supported. |
| 100 | 103 | ** |
| @@ -236,10 +239,23 @@ | ||
| 236 | 239 | collect_argument_value(&extra, "ignore"); |
| 237 | 240 | collect_argument(&extra, "rel-paths",0); |
| 238 | 241 | useCheckouts = 1; |
| 239 | 242 | stopOnError = 0; |
| 240 | 243 | quiet = 1; |
| 244 | + }else if( strncmp(zCmd, "git", n)==0 ){ | |
| 245 | + if( g.argc<4 ){ | |
| 246 | + usage("git (export|status)"); | |
| 247 | + }else{ | |
| 248 | + int n3 = (int)strlen(g.argv[3]); | |
| 249 | + if( strncmp(g.argv[3], "export", n3)==0 ){ | |
| 250 | + zCmd = "git export --if-mirrored -R"; | |
| 251 | + }else if( strncmp(g.argv[3], "status", n3)==0 ){ | |
| 252 | + zCmd = "git status -R"; | |
| 253 | + }else{ | |
| 254 | + usage("git (export|status)"); | |
| 255 | + } | |
| 256 | + } | |
| 241 | 257 | }else if( strncmp(zCmd, "push", n)==0 ){ |
| 242 | 258 | zCmd = "push -autourl -R"; |
| 243 | 259 | collect_argument(&extra, "verbose","v"); |
| 244 | 260 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 245 | 261 | zCmd = "pull -autourl -R"; |
| @@ -358,11 +374,11 @@ | ||
| 358 | 374 | zCmd = "cache -R"; |
| 359 | 375 | showLabel = 1; |
| 360 | 376 | collect_argv(&extra, 3); |
| 361 | 377 | }else{ |
| 362 | 378 | fossil_fatal("\"all\" subcommand should be one of: " |
| 363 | - "add cache changes clean dbstat extras fts-config ignore " | |
| 379 | + "add cache changes clean dbstat extras fts-config git ignore " | |
| 364 | 380 | "info list ls pull push rebuild server setting sync ui unset"); |
| 365 | 381 | } |
| 366 | 382 | verify_all_options(); |
| 367 | 383 | db_multi_exec("CREATE TEMP TABLE repolist(name,tag);"); |
| 368 | 384 | if( useCheckouts ){ |
| 369 | 385 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -91,10 +91,13 @@ | |
| 91 | ** line options supported by the extra command itself, if any |
| 92 | ** are present, are passed along verbatim. |
| 93 | ** |
| 94 | ** fts-config Run the "fts-config" command on all repositories. |
| 95 | ** |
| 96 | ** info Run the "info" command on all repositories. |
| 97 | ** |
| 98 | ** pull Run a "pull" operation on all repositories. Only the |
| 99 | ** --verbose option is supported. |
| 100 | ** |
| @@ -236,10 +239,23 @@ | |
| 236 | collect_argument_value(&extra, "ignore"); |
| 237 | collect_argument(&extra, "rel-paths",0); |
| 238 | useCheckouts = 1; |
| 239 | stopOnError = 0; |
| 240 | quiet = 1; |
| 241 | }else if( strncmp(zCmd, "push", n)==0 ){ |
| 242 | zCmd = "push -autourl -R"; |
| 243 | collect_argument(&extra, "verbose","v"); |
| 244 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 245 | zCmd = "pull -autourl -R"; |
| @@ -358,11 +374,11 @@ | |
| 358 | zCmd = "cache -R"; |
| 359 | showLabel = 1; |
| 360 | collect_argv(&extra, 3); |
| 361 | }else{ |
| 362 | fossil_fatal("\"all\" subcommand should be one of: " |
| 363 | "add cache changes clean dbstat extras fts-config ignore " |
| 364 | "info list ls pull push rebuild server setting sync ui unset"); |
| 365 | } |
| 366 | verify_all_options(); |
| 367 | db_multi_exec("CREATE TEMP TABLE repolist(name,tag);"); |
| 368 | if( useCheckouts ){ |
| 369 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -91,10 +91,13 @@ | |
| 91 | ** line options supported by the extra command itself, if any |
| 92 | ** are present, are passed along verbatim. |
| 93 | ** |
| 94 | ** fts-config Run the "fts-config" command on all repositories. |
| 95 | ** |
| 96 | ** git export Do the "git export" command on all repositories for which |
| 97 | ** a Git mirror has been previously established. |
| 98 | ** |
| 99 | ** info Run the "info" command on all repositories. |
| 100 | ** |
| 101 | ** pull Run a "pull" operation on all repositories. Only the |
| 102 | ** --verbose option is supported. |
| 103 | ** |
| @@ -236,10 +239,23 @@ | |
| 239 | collect_argument_value(&extra, "ignore"); |
| 240 | collect_argument(&extra, "rel-paths",0); |
| 241 | useCheckouts = 1; |
| 242 | stopOnError = 0; |
| 243 | quiet = 1; |
| 244 | }else if( strncmp(zCmd, "git", n)==0 ){ |
| 245 | if( g.argc<4 ){ |
| 246 | usage("git (export|status)"); |
| 247 | }else{ |
| 248 | int n3 = (int)strlen(g.argv[3]); |
| 249 | if( strncmp(g.argv[3], "export", n3)==0 ){ |
| 250 | zCmd = "git export --if-mirrored -R"; |
| 251 | }else if( strncmp(g.argv[3], "status", n3)==0 ){ |
| 252 | zCmd = "git status -R"; |
| 253 | }else{ |
| 254 | usage("git (export|status)"); |
| 255 | } |
| 256 | } |
| 257 | }else if( strncmp(zCmd, "push", n)==0 ){ |
| 258 | zCmd = "push -autourl -R"; |
| 259 | collect_argument(&extra, "verbose","v"); |
| 260 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 261 | zCmd = "pull -autourl -R"; |
| @@ -358,11 +374,11 @@ | |
| 374 | zCmd = "cache -R"; |
| 375 | showLabel = 1; |
| 376 | collect_argv(&extra, 3); |
| 377 | }else{ |
| 378 | fossil_fatal("\"all\" subcommand should be one of: " |
| 379 | "add cache changes clean dbstat extras fts-config git ignore " |
| 380 | "info list ls pull push rebuild server setting sync ui unset"); |
| 381 | } |
| 382 | verify_all_options(); |
| 383 | db_multi_exec("CREATE TEMP TABLE repolist(name,tag);"); |
| 384 | if( useCheckouts ){ |
| 385 |
+4
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -1300,10 +1300,11 @@ | ||
| 1300 | 1300 | double rEnd; /* time of most recent export */ |
| 1301 | 1301 | int rc; /* Result code */ |
| 1302 | 1302 | int bForce; /* Do the export and sync even if no changes*/ |
| 1303 | 1303 | int bNeedRepack = 0; /* True if we should run repack at the end */ |
| 1304 | 1304 | int fManifest; /* Current "manifest" setting */ |
| 1305 | + int bIfExists; /* The --if-mirrored flag */ | |
| 1305 | 1306 | FILE *xCmd; /* Pipe to the "git fast-import" command */ |
| 1306 | 1307 | FILE *pMarks; /* Git mark files */ |
| 1307 | 1308 | Stmt q; /* Queries */ |
| 1308 | 1309 | char zLine[200]; /* One line of a mark file */ |
| 1309 | 1310 | |
| @@ -1314,10 +1315,11 @@ | ||
| 1314 | 1315 | nLimit = (unsigned int)atoi(zLimit); |
| 1315 | 1316 | if( nLimit<=0 ) fossil_fatal("--limit must be positive"); |
| 1316 | 1317 | } |
| 1317 | 1318 | zAutoPush = find_option("autopush",0,1); |
| 1318 | 1319 | bForce = find_option("force","f",0)!=0; |
| 1320 | + bIfExists = find_option("if-mirrored",0,0)!=0; | |
| 1319 | 1321 | gitmirror_verbosity = VERB_NORMAL; |
| 1320 | 1322 | while( find_option("quiet","q",0)!=0 ){ gitmirror_verbosity--; } |
| 1321 | 1323 | while( find_option("verbose","v",0)!=0 ){ gitmirror_verbosity++; } |
| 1322 | 1324 | verify_all_options(); |
| 1323 | 1325 | if( g.argc!=4 && g.argc!=3 ){ usage("export ?MIRROR?"); } |
| @@ -1327,10 +1329,11 @@ | ||
| 1327 | 1329 | db_set("last-git-export-repo", blob_str(&mirror), 0); |
| 1328 | 1330 | blob_reset(&mirror); |
| 1329 | 1331 | } |
| 1330 | 1332 | zMirror = db_get("last-git-export-repo", 0); |
| 1331 | 1333 | if( zMirror==0 ){ |
| 1334 | + if( bIfExists ) return; | |
| 1332 | 1335 | fossil_fatal("no Git repository specified"); |
| 1333 | 1336 | } |
| 1334 | 1337 | |
| 1335 | 1338 | /* Make sure the GIT repository directory exists */ |
| 1336 | 1339 | rc = file_mkdir(zMirror, ExtFILE, 0); |
| @@ -1700,10 +1703,11 @@ | ||
| 1700 | 1703 | ** to the same repository. Or if URL is "off" the |
| 1701 | 1704 | ** auto-push mechanism is disabled |
| 1702 | 1705 | ** --debug FILE Write fast-export text to FILE rather than |
| 1703 | 1706 | ** piping it into "git fast-import". |
| 1704 | 1707 | ** --force|-f Do the export even if nothing has changed |
| 1708 | +** --if-mirrored No-op if the mirror does not already exist. | |
| 1705 | 1709 | ** --limit N Add no more than N new check-ins to MIRROR. |
| 1706 | 1710 | ** Useful for debugging |
| 1707 | 1711 | ** --quiet|-q Reduce output. Repeat for even less output. |
| 1708 | 1712 | ** --verbose|-v More output. |
| 1709 | 1713 | ** |
| 1710 | 1714 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1300,10 +1300,11 @@ | |
| 1300 | double rEnd; /* time of most recent export */ |
| 1301 | int rc; /* Result code */ |
| 1302 | int bForce; /* Do the export and sync even if no changes*/ |
| 1303 | int bNeedRepack = 0; /* True if we should run repack at the end */ |
| 1304 | int fManifest; /* Current "manifest" setting */ |
| 1305 | FILE *xCmd; /* Pipe to the "git fast-import" command */ |
| 1306 | FILE *pMarks; /* Git mark files */ |
| 1307 | Stmt q; /* Queries */ |
| 1308 | char zLine[200]; /* One line of a mark file */ |
| 1309 | |
| @@ -1314,10 +1315,11 @@ | |
| 1314 | nLimit = (unsigned int)atoi(zLimit); |
| 1315 | if( nLimit<=0 ) fossil_fatal("--limit must be positive"); |
| 1316 | } |
| 1317 | zAutoPush = find_option("autopush",0,1); |
| 1318 | bForce = find_option("force","f",0)!=0; |
| 1319 | gitmirror_verbosity = VERB_NORMAL; |
| 1320 | while( find_option("quiet","q",0)!=0 ){ gitmirror_verbosity--; } |
| 1321 | while( find_option("verbose","v",0)!=0 ){ gitmirror_verbosity++; } |
| 1322 | verify_all_options(); |
| 1323 | if( g.argc!=4 && g.argc!=3 ){ usage("export ?MIRROR?"); } |
| @@ -1327,10 +1329,11 @@ | |
| 1327 | db_set("last-git-export-repo", blob_str(&mirror), 0); |
| 1328 | blob_reset(&mirror); |
| 1329 | } |
| 1330 | zMirror = db_get("last-git-export-repo", 0); |
| 1331 | if( zMirror==0 ){ |
| 1332 | fossil_fatal("no Git repository specified"); |
| 1333 | } |
| 1334 | |
| 1335 | /* Make sure the GIT repository directory exists */ |
| 1336 | rc = file_mkdir(zMirror, ExtFILE, 0); |
| @@ -1700,10 +1703,11 @@ | |
| 1700 | ** to the same repository. Or if URL is "off" the |
| 1701 | ** auto-push mechanism is disabled |
| 1702 | ** --debug FILE Write fast-export text to FILE rather than |
| 1703 | ** piping it into "git fast-import". |
| 1704 | ** --force|-f Do the export even if nothing has changed |
| 1705 | ** --limit N Add no more than N new check-ins to MIRROR. |
| 1706 | ** Useful for debugging |
| 1707 | ** --quiet|-q Reduce output. Repeat for even less output. |
| 1708 | ** --verbose|-v More output. |
| 1709 | ** |
| 1710 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1300,10 +1300,11 @@ | |
| 1300 | double rEnd; /* time of most recent export */ |
| 1301 | int rc; /* Result code */ |
| 1302 | int bForce; /* Do the export and sync even if no changes*/ |
| 1303 | int bNeedRepack = 0; /* True if we should run repack at the end */ |
| 1304 | int fManifest; /* Current "manifest" setting */ |
| 1305 | int bIfExists; /* The --if-mirrored flag */ |
| 1306 | FILE *xCmd; /* Pipe to the "git fast-import" command */ |
| 1307 | FILE *pMarks; /* Git mark files */ |
| 1308 | Stmt q; /* Queries */ |
| 1309 | char zLine[200]; /* One line of a mark file */ |
| 1310 | |
| @@ -1314,10 +1315,11 @@ | |
| 1315 | nLimit = (unsigned int)atoi(zLimit); |
| 1316 | if( nLimit<=0 ) fossil_fatal("--limit must be positive"); |
| 1317 | } |
| 1318 | zAutoPush = find_option("autopush",0,1); |
| 1319 | bForce = find_option("force","f",0)!=0; |
| 1320 | bIfExists = find_option("if-mirrored",0,0)!=0; |
| 1321 | gitmirror_verbosity = VERB_NORMAL; |
| 1322 | while( find_option("quiet","q",0)!=0 ){ gitmirror_verbosity--; } |
| 1323 | while( find_option("verbose","v",0)!=0 ){ gitmirror_verbosity++; } |
| 1324 | verify_all_options(); |
| 1325 | if( g.argc!=4 && g.argc!=3 ){ usage("export ?MIRROR?"); } |
| @@ -1327,10 +1329,11 @@ | |
| 1329 | db_set("last-git-export-repo", blob_str(&mirror), 0); |
| 1330 | blob_reset(&mirror); |
| 1331 | } |
| 1332 | zMirror = db_get("last-git-export-repo", 0); |
| 1333 | if( zMirror==0 ){ |
| 1334 | if( bIfExists ) return; |
| 1335 | fossil_fatal("no Git repository specified"); |
| 1336 | } |
| 1337 | |
| 1338 | /* Make sure the GIT repository directory exists */ |
| 1339 | rc = file_mkdir(zMirror, ExtFILE, 0); |
| @@ -1700,10 +1703,11 @@ | |
| 1703 | ** to the same repository. Or if URL is "off" the |
| 1704 | ** auto-push mechanism is disabled |
| 1705 | ** --debug FILE Write fast-export text to FILE rather than |
| 1706 | ** piping it into "git fast-import". |
| 1707 | ** --force|-f Do the export even if nothing has changed |
| 1708 | ** --if-mirrored No-op if the mirror does not already exist. |
| 1709 | ** --limit N Add no more than N new check-ins to MIRROR. |
| 1710 | ** Useful for debugging |
| 1711 | ** --quiet|-q Reduce output. Repeat for even less output. |
| 1712 | ** --verbose|-v More output. |
| 1713 | ** |
| 1714 |