Fossil SCM
Add -n|--dry-run options to commands which already have --test or --nochange.
Commit
0b866397a8e994c73ee0cc4b4439f692da5c2fdb
Parent
91aa222d7f2a874…
5 files changed
+9
-6
+9
-10
+16
-8
+16
-14
+19
-16
+9
-6
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -453,29 +453,32 @@ | ||
| 453 | 453 | ** |
| 454 | 454 | ** This command can be used to track third party software. |
| 455 | 455 | ** |
| 456 | 456 | ** Options: |
| 457 | 457 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 458 | -** --dotfiles include files beginning with a dot (".") | |
| 459 | -** --ignore <CSG> ignore files matching patterns from the | |
| 458 | +** --dotfiles include files beginning with a dot (".") | |
| 459 | +** --ignore <CSG> ignore files matching patterns from the | |
| 460 | 460 | ** comma separated list of glob patterns. |
| 461 | -** --test If given, display instead of run actions | |
| 461 | +** -n|--dry-run If given, display instead of run actions | |
| 462 | 462 | ** |
| 463 | 463 | ** See also: add, rm |
| 464 | 464 | */ |
| 465 | 465 | void addremove_cmd(void){ |
| 466 | 466 | Blob path; |
| 467 | 467 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 468 | 468 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 469 | - int isTest = find_option("test",0,0)!=0; | |
| 469 | + int dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 470 | 470 | int n; |
| 471 | 471 | Stmt q; |
| 472 | 472 | int vid; |
| 473 | 473 | int nAdd = 0; |
| 474 | 474 | int nDelete = 0; |
| 475 | 475 | Glob *pIgnore; |
| 476 | 476 | |
| 477 | + if( !dryRunFlag ){ | |
| 478 | + dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ | |
| 479 | + } | |
| 477 | 480 | capture_case_sensitive_option(); |
| 478 | 481 | db_must_be_within_tree(); |
| 479 | 482 | if( zIgnoreFlag==0 ){ |
| 480 | 483 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 481 | 484 | } |
| @@ -512,11 +515,11 @@ | ||
| 512 | 515 | const char * zPath; |
| 513 | 516 | |
| 514 | 517 | zFile = db_column_text(&q, 0); |
| 515 | 518 | zPath = db_column_text(&q, 1); |
| 516 | 519 | if( !file_wd_isfile_or_link(zPath) ){ |
| 517 | - if( !isTest ){ | |
| 520 | + if( !dryRunFlag ){ | |
| 518 | 521 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 519 | 522 | } |
| 520 | 523 | fossil_print("DELETED %s\n", zFile); |
| 521 | 524 | nDelete++; |
| 522 | 525 | } |
| @@ -523,11 +526,11 @@ | ||
| 523 | 526 | } |
| 524 | 527 | db_finalize(&q); |
| 525 | 528 | /* show command summary */ |
| 526 | 529 | fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); |
| 527 | 530 | |
| 528 | - db_end_transaction(isTest); | |
| 531 | + db_end_transaction(dryRunFlag); | |
| 529 | 532 | } |
| 530 | 533 | |
| 531 | 534 | |
| 532 | 535 | /* |
| 533 | 536 | ** Rename a single file. |
| 534 | 537 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -453,29 +453,32 @@ | |
| 453 | ** |
| 454 | ** This command can be used to track third party software. |
| 455 | ** |
| 456 | ** Options: |
| 457 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 458 | ** --dotfiles include files beginning with a dot (".") |
| 459 | ** --ignore <CSG> ignore files matching patterns from the |
| 460 | ** comma separated list of glob patterns. |
| 461 | ** --test If given, display instead of run actions |
| 462 | ** |
| 463 | ** See also: add, rm |
| 464 | */ |
| 465 | void addremove_cmd(void){ |
| 466 | Blob path; |
| 467 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 468 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 469 | int isTest = find_option("test",0,0)!=0; |
| 470 | int n; |
| 471 | Stmt q; |
| 472 | int vid; |
| 473 | int nAdd = 0; |
| 474 | int nDelete = 0; |
| 475 | Glob *pIgnore; |
| 476 | |
| 477 | capture_case_sensitive_option(); |
| 478 | db_must_be_within_tree(); |
| 479 | if( zIgnoreFlag==0 ){ |
| 480 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 481 | } |
| @@ -512,11 +515,11 @@ | |
| 512 | const char * zPath; |
| 513 | |
| 514 | zFile = db_column_text(&q, 0); |
| 515 | zPath = db_column_text(&q, 1); |
| 516 | if( !file_wd_isfile_or_link(zPath) ){ |
| 517 | if( !isTest ){ |
| 518 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 519 | } |
| 520 | fossil_print("DELETED %s\n", zFile); |
| 521 | nDelete++; |
| 522 | } |
| @@ -523,11 +526,11 @@ | |
| 523 | } |
| 524 | db_finalize(&q); |
| 525 | /* show command summary */ |
| 526 | fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); |
| 527 | |
| 528 | db_end_transaction(isTest); |
| 529 | } |
| 530 | |
| 531 | |
| 532 | /* |
| 533 | ** Rename a single file. |
| 534 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -453,29 +453,32 @@ | |
| 453 | ** |
| 454 | ** This command can be used to track third party software. |
| 455 | ** |
| 456 | ** Options: |
| 457 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 458 | ** --dotfiles include files beginning with a dot (".") |
| 459 | ** --ignore <CSG> ignore files matching patterns from the |
| 460 | ** comma separated list of glob patterns. |
| 461 | ** -n|--dry-run If given, display instead of run actions |
| 462 | ** |
| 463 | ** See also: add, rm |
| 464 | */ |
| 465 | void addremove_cmd(void){ |
| 466 | Blob path; |
| 467 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 468 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 469 | int dryRunFlag = find_option("dry-run","n",0)!=0; |
| 470 | int n; |
| 471 | Stmt q; |
| 472 | int vid; |
| 473 | int nAdd = 0; |
| 474 | int nDelete = 0; |
| 475 | Glob *pIgnore; |
| 476 | |
| 477 | if( !dryRunFlag ){ |
| 478 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 479 | } |
| 480 | capture_case_sensitive_option(); |
| 481 | db_must_be_within_tree(); |
| 482 | if( zIgnoreFlag==0 ){ |
| 483 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 484 | } |
| @@ -512,11 +515,11 @@ | |
| 515 | const char * zPath; |
| 516 | |
| 517 | zFile = db_column_text(&q, 0); |
| 518 | zPath = db_column_text(&q, 1); |
| 519 | if( !file_wd_isfile_or_link(zPath) ){ |
| 520 | if( !dryRunFlag ){ |
| 521 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 522 | } |
| 523 | fossil_print("DELETED %s\n", zFile); |
| 524 | nDelete++; |
| 525 | } |
| @@ -523,11 +526,11 @@ | |
| 526 | } |
| 527 | db_finalize(&q); |
| 528 | /* show command summary */ |
| 529 | fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); |
| 530 | |
| 531 | db_end_transaction(dryRunFlag); |
| 532 | } |
| 533 | |
| 534 | |
| 535 | /* |
| 536 | ** Rename a single file. |
| 537 |
+9
-10
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -109,20 +109,19 @@ | ||
| 109 | 109 | char *zFossil; |
| 110 | 110 | char *zQFilename; |
| 111 | 111 | Blob extra; |
| 112 | 112 | int useCheckouts = 0; |
| 113 | 113 | int quiet = 0; |
| 114 | - int testRun = 0; | |
| 114 | + int dryRunFlag = 0; | |
| 115 | 115 | int stopOnError = find_option("dontstop",0,0)==0; |
| 116 | 116 | int rc; |
| 117 | 117 | Bag outOfDate; |
| 118 | 118 | |
| 119 | - /* The undocumented --test option causes no changes to occur to any | |
| 120 | - ** repository, but instead show what would have happened. Intended for | |
| 121 | - ** test and debugging use. | |
| 122 | - */ | |
| 123 | - testRun = find_option("test",0,0)!=0; | |
| 119 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 120 | + if( !dryRunFlag ){ | |
| 121 | + dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ | |
| 122 | + } | |
| 124 | 123 | |
| 125 | 124 | if( g.argc<3 ){ |
| 126 | 125 | usage("changes|list|ls|pull|push|rebuild|sync"); |
| 127 | 126 | } |
| 128 | 127 | n = strlen(g.argv[2]); |
| @@ -169,11 +168,11 @@ | ||
| 169 | 168 | verify_all_options(); |
| 170 | 169 | db_begin_transaction(); |
| 171 | 170 | for(j=3; j<g.argc; j++){ |
| 172 | 171 | char *zSql = mprintf("DELETE FROM global_config" |
| 173 | 172 | " WHERE name GLOB 'repo:%q'", g.argv[j]); |
| 174 | - if( testRun ){ | |
| 173 | + if( dryRunFlag ){ | |
| 175 | 174 | fossil_print("%s\n", zSql); |
| 176 | 175 | }else{ |
| 177 | 176 | db_multi_exec("%s", zSql); |
| 178 | 177 | } |
| 179 | 178 | fossil_free(zSql); |
| @@ -218,15 +217,15 @@ | ||
| 218 | 217 | continue; |
| 219 | 218 | } |
| 220 | 219 | zQFilename = quoteFilename(zFilename); |
| 221 | 220 | zSyscmd = mprintf("%s %s %s%s", |
| 222 | 221 | zFossil, zCmd, zQFilename, blob_str(&extra)); |
| 223 | - if( !quiet || testRun ){ | |
| 222 | + if( !quiet || dryRunFlag ){ | |
| 224 | 223 | fossil_print("%s\n", zSyscmd); |
| 225 | 224 | fflush(stdout); |
| 226 | 225 | } |
| 227 | - rc = testRun ? 0 : fossil_system(zSyscmd); | |
| 226 | + rc = dryRunFlag ? 0 : fossil_system(zSyscmd); | |
| 228 | 227 | free(zSyscmd); |
| 229 | 228 | free(zQFilename); |
| 230 | 229 | if( stopOnError && rc ){ |
| 231 | 230 | break; |
| 232 | 231 | } |
| @@ -245,13 +244,13 @@ | ||
| 245 | 244 | for(rowid=bag_first(&outOfDate); rowid>0; rowid=bag_next(&outOfDate,rowid)){ |
| 246 | 245 | blob_appendf(&sql, "%s%d", zSep, rowid); |
| 247 | 246 | zSep = ","; |
| 248 | 247 | } |
| 249 | 248 | blob_appendf(&sql, ")"); |
| 250 | - if( testRun ){ | |
| 249 | + if( dryRunFlag ){ | |
| 251 | 250 | fossil_print("%s\n", blob_str(&sql)); |
| 252 | 251 | }else{ |
| 253 | 252 | db_multi_exec(blob_str(&sql)); |
| 254 | 253 | } |
| 255 | 254 | blob_reset(&sql); |
| 256 | 255 | } |
| 257 | 256 | } |
| 258 | 257 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -109,20 +109,19 @@ | |
| 109 | char *zFossil; |
| 110 | char *zQFilename; |
| 111 | Blob extra; |
| 112 | int useCheckouts = 0; |
| 113 | int quiet = 0; |
| 114 | int testRun = 0; |
| 115 | int stopOnError = find_option("dontstop",0,0)==0; |
| 116 | int rc; |
| 117 | Bag outOfDate; |
| 118 | |
| 119 | /* The undocumented --test option causes no changes to occur to any |
| 120 | ** repository, but instead show what would have happened. Intended for |
| 121 | ** test and debugging use. |
| 122 | */ |
| 123 | testRun = find_option("test",0,0)!=0; |
| 124 | |
| 125 | if( g.argc<3 ){ |
| 126 | usage("changes|list|ls|pull|push|rebuild|sync"); |
| 127 | } |
| 128 | n = strlen(g.argv[2]); |
| @@ -169,11 +168,11 @@ | |
| 169 | verify_all_options(); |
| 170 | db_begin_transaction(); |
| 171 | for(j=3; j<g.argc; j++){ |
| 172 | char *zSql = mprintf("DELETE FROM global_config" |
| 173 | " WHERE name GLOB 'repo:%q'", g.argv[j]); |
| 174 | if( testRun ){ |
| 175 | fossil_print("%s\n", zSql); |
| 176 | }else{ |
| 177 | db_multi_exec("%s", zSql); |
| 178 | } |
| 179 | fossil_free(zSql); |
| @@ -218,15 +217,15 @@ | |
| 218 | continue; |
| 219 | } |
| 220 | zQFilename = quoteFilename(zFilename); |
| 221 | zSyscmd = mprintf("%s %s %s%s", |
| 222 | zFossil, zCmd, zQFilename, blob_str(&extra)); |
| 223 | if( !quiet || testRun ){ |
| 224 | fossil_print("%s\n", zSyscmd); |
| 225 | fflush(stdout); |
| 226 | } |
| 227 | rc = testRun ? 0 : fossil_system(zSyscmd); |
| 228 | free(zSyscmd); |
| 229 | free(zQFilename); |
| 230 | if( stopOnError && rc ){ |
| 231 | break; |
| 232 | } |
| @@ -245,13 +244,13 @@ | |
| 245 | for(rowid=bag_first(&outOfDate); rowid>0; rowid=bag_next(&outOfDate,rowid)){ |
| 246 | blob_appendf(&sql, "%s%d", zSep, rowid); |
| 247 | zSep = ","; |
| 248 | } |
| 249 | blob_appendf(&sql, ")"); |
| 250 | if( testRun ){ |
| 251 | fossil_print("%s\n", blob_str(&sql)); |
| 252 | }else{ |
| 253 | db_multi_exec(blob_str(&sql)); |
| 254 | } |
| 255 | blob_reset(&sql); |
| 256 | } |
| 257 | } |
| 258 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -109,20 +109,19 @@ | |
| 109 | char *zFossil; |
| 110 | char *zQFilename; |
| 111 | Blob extra; |
| 112 | int useCheckouts = 0; |
| 113 | int quiet = 0; |
| 114 | int dryRunFlag = 0; |
| 115 | int stopOnError = find_option("dontstop",0,0)==0; |
| 116 | int rc; |
| 117 | Bag outOfDate; |
| 118 | |
| 119 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 120 | if( !dryRunFlag ){ |
| 121 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 122 | } |
| 123 | |
| 124 | if( g.argc<3 ){ |
| 125 | usage("changes|list|ls|pull|push|rebuild|sync"); |
| 126 | } |
| 127 | n = strlen(g.argv[2]); |
| @@ -169,11 +168,11 @@ | |
| 168 | verify_all_options(); |
| 169 | db_begin_transaction(); |
| 170 | for(j=3; j<g.argc; j++){ |
| 171 | char *zSql = mprintf("DELETE FROM global_config" |
| 172 | " WHERE name GLOB 'repo:%q'", g.argv[j]); |
| 173 | if( dryRunFlag ){ |
| 174 | fossil_print("%s\n", zSql); |
| 175 | }else{ |
| 176 | db_multi_exec("%s", zSql); |
| 177 | } |
| 178 | fossil_free(zSql); |
| @@ -218,15 +217,15 @@ | |
| 217 | continue; |
| 218 | } |
| 219 | zQFilename = quoteFilename(zFilename); |
| 220 | zSyscmd = mprintf("%s %s %s%s", |
| 221 | zFossil, zCmd, zQFilename, blob_str(&extra)); |
| 222 | if( !quiet || dryRunFlag ){ |
| 223 | fossil_print("%s\n", zSyscmd); |
| 224 | fflush(stdout); |
| 225 | } |
| 226 | rc = dryRunFlag ? 0 : fossil_system(zSyscmd); |
| 227 | free(zSyscmd); |
| 228 | free(zQFilename); |
| 229 | if( stopOnError && rc ){ |
| 230 | break; |
| 231 | } |
| @@ -245,13 +244,13 @@ | |
| 244 | for(rowid=bag_first(&outOfDate); rowid>0; rowid=bag_next(&outOfDate,rowid)){ |
| 245 | blob_appendf(&sql, "%s%d", zSep, rowid); |
| 246 | zSep = ","; |
| 247 | } |
| 248 | blob_appendf(&sql, ")"); |
| 249 | if( dryRunFlag ){ |
| 250 | fossil_print("%s\n", blob_str(&sql)); |
| 251 | }else{ |
| 252 | db_multi_exec(blob_str(&sql)); |
| 253 | } |
| 254 | blob_reset(&sql); |
| 255 | } |
| 256 | } |
| 257 |
+16
-8
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -395,13 +395,14 @@ | ||
| 395 | 395 | ** is used if the --ignore option is omitted. |
| 396 | 396 | ** |
| 397 | 397 | ** Options: |
| 398 | 398 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 399 | 399 | ** --dotfiles include files beginning with a dot (".") |
| 400 | -** --force Remove files without prompting | |
| 400 | +** -f|--force Remove files without prompting | |
| 401 | 401 | ** --ignore <CSG> ignore files matching patterns from the |
| 402 | 402 | ** comma separated list of glob patterns. |
| 403 | +** -n|--dry-run If given, display instead of run actions | |
| 403 | 404 | ** --temp Remove only Fossil-generated temporary files |
| 404 | 405 | ** |
| 405 | 406 | ** See also: addremove, extra, status |
| 406 | 407 | */ |
| 407 | 408 | void clean_cmd(void){ |
| @@ -410,17 +411,20 @@ | ||
| 410 | 411 | const char *zIgnoreFlag; |
| 411 | 412 | Blob path, repo; |
| 412 | 413 | Stmt q; |
| 413 | 414 | int n; |
| 414 | 415 | Glob *pIgnore; |
| 415 | - int testFlag = 0; | |
| 416 | + int dryRunFlag = 0; | |
| 416 | 417 | |
| 417 | 418 | allFlag = find_option("force","f",0)!=0; |
| 418 | 419 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 419 | 420 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 420 | 421 | zIgnoreFlag = find_option("ignore",0,1); |
| 421 | - testFlag = find_option("test",0,0)!=0; | |
| 422 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 423 | + if( !dryRunFlag ){ | |
| 424 | + dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ | |
| 425 | + } | |
| 422 | 426 | capture_case_sensitive_option(); |
| 423 | 427 | db_must_be_within_tree(); |
| 424 | 428 | if( zIgnoreFlag==0 ){ |
| 425 | 429 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 426 | 430 | } |
| @@ -440,11 +444,11 @@ | ||
| 440 | 444 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 441 | 445 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 442 | 446 | } |
| 443 | 447 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 444 | 448 | while( db_step(&q)==SQLITE_ROW ){ |
| 445 | - if( testFlag ){ | |
| 449 | + if( dryRunFlag ){ | |
| 446 | 450 | fossil_print("%s\n", db_column_text(&q,0)); |
| 447 | 451 | continue; |
| 448 | 452 | }else if( !allFlag ){ |
| 449 | 453 | Blob ans; |
| 450 | 454 | char cReply; |
| @@ -1125,10 +1129,11 @@ | ||
| 1125 | 1129 | ** --branchcolor COLOR apply given COLOR to the branch |
| 1126 | 1130 | ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 1127 | 1131 | ** --delta use a delta manifest in the commit process |
| 1128 | 1132 | ** --message-file|-M FILE read the commit comment from given file |
| 1129 | 1133 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 1134 | +** -n|--dry-run If given, display instead of run actions | |
| 1130 | 1135 | ** --no-warnings omit all warnings about file contents |
| 1131 | 1136 | ** --nosign do not attempt to sign this commit with gpg |
| 1132 | 1137 | ** --private do not sync changes and their descendants |
| 1133 | 1138 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1134 | 1139 | ** |
| @@ -1154,11 +1159,11 @@ | ||
| 1154 | 1159 | int allowFork = 0; /* Allow the commit to fork */ |
| 1155 | 1160 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 1156 | 1161 | char *zManifestFile; /* Name of the manifest file */ |
| 1157 | 1162 | int useCksum; /* True if checksums should be computed and verified */ |
| 1158 | 1163 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| 1159 | - int testRun; /* True for a test run. Debugging only */ | |
| 1164 | + int dryRunFlag; /* True for a test run. Debugging only */ | |
| 1160 | 1165 | CheckinInfo sCiInfo; /* Information about this check-in */ |
| 1161 | 1166 | const char *zComFile; /* Read commit message from this file */ |
| 1162 | 1167 | int nTag = 0; /* Number of --tag arguments */ |
| 1163 | 1168 | const char *zTag; /* A single --tag argument */ |
| 1164 | 1169 | Blob manifest; /* Manifest in baseline form */ |
| @@ -1178,11 +1183,14 @@ | ||
| 1178 | 1183 | forceDelta = find_option("delta",0,0)!=0; |
| 1179 | 1184 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1180 | 1185 | if( forceDelta && forceBaseline ){ |
| 1181 | 1186 | fossil_fatal("cannot use --delta and --baseline together"); |
| 1182 | 1187 | } |
| 1183 | - testRun = find_option("test",0,0)!=0; | |
| 1188 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 1189 | + if( !dryRunFlag ){ | |
| 1190 | + dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ | |
| 1191 | + } | |
| 1184 | 1192 | zComment = find_option("comment","m",1); |
| 1185 | 1193 | forceFlag = find_option("force", "f", 0)!=0; |
| 1186 | 1194 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 1187 | 1195 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 1188 | 1196 | allowFork = find_option("allow-fork",0,0)!=0; |
| @@ -1522,11 +1530,11 @@ | ||
| 1522 | 1530 | } |
| 1523 | 1531 | |
| 1524 | 1532 | /* If the --test option is specified, output the manifest file |
| 1525 | 1533 | ** and rollback the transaction. |
| 1526 | 1534 | */ |
| 1527 | - if( testRun ){ | |
| 1535 | + if( dryRunFlag ){ | |
| 1528 | 1536 | blob_write_to_file(&manifest, ""); |
| 1529 | 1537 | } |
| 1530 | 1538 | |
| 1531 | 1539 | if( outputManifest ){ |
| 1532 | 1540 | zManifestFile = mprintf("%smanifest", g.zLocalRoot); |
| @@ -1601,11 +1609,11 @@ | ||
| 1601 | 1609 | /* Clear the undo/redo stack */ |
| 1602 | 1610 | undo_reset(); |
| 1603 | 1611 | |
| 1604 | 1612 | /* Commit */ |
| 1605 | 1613 | db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'"); |
| 1606 | - if( testRun ){ | |
| 1614 | + if( dryRunFlag ){ | |
| 1607 | 1615 | db_end_transaction(1); |
| 1608 | 1616 | exit(1); |
| 1609 | 1617 | } |
| 1610 | 1618 | db_end_transaction(0); |
| 1611 | 1619 | |
| 1612 | 1620 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -395,13 +395,14 @@ | |
| 395 | ** is used if the --ignore option is omitted. |
| 396 | ** |
| 397 | ** Options: |
| 398 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 399 | ** --dotfiles include files beginning with a dot (".") |
| 400 | ** --force Remove files without prompting |
| 401 | ** --ignore <CSG> ignore files matching patterns from the |
| 402 | ** comma separated list of glob patterns. |
| 403 | ** --temp Remove only Fossil-generated temporary files |
| 404 | ** |
| 405 | ** See also: addremove, extra, status |
| 406 | */ |
| 407 | void clean_cmd(void){ |
| @@ -410,17 +411,20 @@ | |
| 410 | const char *zIgnoreFlag; |
| 411 | Blob path, repo; |
| 412 | Stmt q; |
| 413 | int n; |
| 414 | Glob *pIgnore; |
| 415 | int testFlag = 0; |
| 416 | |
| 417 | allFlag = find_option("force","f",0)!=0; |
| 418 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 419 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 420 | zIgnoreFlag = find_option("ignore",0,1); |
| 421 | testFlag = find_option("test",0,0)!=0; |
| 422 | capture_case_sensitive_option(); |
| 423 | db_must_be_within_tree(); |
| 424 | if( zIgnoreFlag==0 ){ |
| 425 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 426 | } |
| @@ -440,11 +444,11 @@ | |
| 440 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 441 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 442 | } |
| 443 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 444 | while( db_step(&q)==SQLITE_ROW ){ |
| 445 | if( testFlag ){ |
| 446 | fossil_print("%s\n", db_column_text(&q,0)); |
| 447 | continue; |
| 448 | }else if( !allFlag ){ |
| 449 | Blob ans; |
| 450 | char cReply; |
| @@ -1125,10 +1129,11 @@ | |
| 1125 | ** --branchcolor COLOR apply given COLOR to the branch |
| 1126 | ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 1127 | ** --delta use a delta manifest in the commit process |
| 1128 | ** --message-file|-M FILE read the commit comment from given file |
| 1129 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 1130 | ** --no-warnings omit all warnings about file contents |
| 1131 | ** --nosign do not attempt to sign this commit with gpg |
| 1132 | ** --private do not sync changes and their descendants |
| 1133 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1134 | ** |
| @@ -1154,11 +1159,11 @@ | |
| 1154 | int allowFork = 0; /* Allow the commit to fork */ |
| 1155 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 1156 | char *zManifestFile; /* Name of the manifest file */ |
| 1157 | int useCksum; /* True if checksums should be computed and verified */ |
| 1158 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| 1159 | int testRun; /* True for a test run. Debugging only */ |
| 1160 | CheckinInfo sCiInfo; /* Information about this check-in */ |
| 1161 | const char *zComFile; /* Read commit message from this file */ |
| 1162 | int nTag = 0; /* Number of --tag arguments */ |
| 1163 | const char *zTag; /* A single --tag argument */ |
| 1164 | Blob manifest; /* Manifest in baseline form */ |
| @@ -1178,11 +1183,14 @@ | |
| 1178 | forceDelta = find_option("delta",0,0)!=0; |
| 1179 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1180 | if( forceDelta && forceBaseline ){ |
| 1181 | fossil_fatal("cannot use --delta and --baseline together"); |
| 1182 | } |
| 1183 | testRun = find_option("test",0,0)!=0; |
| 1184 | zComment = find_option("comment","m",1); |
| 1185 | forceFlag = find_option("force", "f", 0)!=0; |
| 1186 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 1187 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 1188 | allowFork = find_option("allow-fork",0,0)!=0; |
| @@ -1522,11 +1530,11 @@ | |
| 1522 | } |
| 1523 | |
| 1524 | /* If the --test option is specified, output the manifest file |
| 1525 | ** and rollback the transaction. |
| 1526 | */ |
| 1527 | if( testRun ){ |
| 1528 | blob_write_to_file(&manifest, ""); |
| 1529 | } |
| 1530 | |
| 1531 | if( outputManifest ){ |
| 1532 | zManifestFile = mprintf("%smanifest", g.zLocalRoot); |
| @@ -1601,11 +1609,11 @@ | |
| 1601 | /* Clear the undo/redo stack */ |
| 1602 | undo_reset(); |
| 1603 | |
| 1604 | /* Commit */ |
| 1605 | db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'"); |
| 1606 | if( testRun ){ |
| 1607 | db_end_transaction(1); |
| 1608 | exit(1); |
| 1609 | } |
| 1610 | db_end_transaction(0); |
| 1611 | |
| 1612 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -395,13 +395,14 @@ | |
| 395 | ** is used if the --ignore option is omitted. |
| 396 | ** |
| 397 | ** Options: |
| 398 | ** --case-sensitive <BOOL> override case-sensitive setting |
| 399 | ** --dotfiles include files beginning with a dot (".") |
| 400 | ** -f|--force Remove files without prompting |
| 401 | ** --ignore <CSG> ignore files matching patterns from the |
| 402 | ** comma separated list of glob patterns. |
| 403 | ** -n|--dry-run If given, display instead of run actions |
| 404 | ** --temp Remove only Fossil-generated temporary files |
| 405 | ** |
| 406 | ** See also: addremove, extra, status |
| 407 | */ |
| 408 | void clean_cmd(void){ |
| @@ -410,17 +411,20 @@ | |
| 411 | const char *zIgnoreFlag; |
| 412 | Blob path, repo; |
| 413 | Stmt q; |
| 414 | int n; |
| 415 | Glob *pIgnore; |
| 416 | int dryRunFlag = 0; |
| 417 | |
| 418 | allFlag = find_option("force","f",0)!=0; |
| 419 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 420 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 421 | zIgnoreFlag = find_option("ignore",0,1); |
| 422 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 423 | if( !dryRunFlag ){ |
| 424 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 425 | } |
| 426 | capture_case_sensitive_option(); |
| 427 | db_must_be_within_tree(); |
| 428 | if( zIgnoreFlag==0 ){ |
| 429 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 430 | } |
| @@ -440,11 +444,11 @@ | |
| 444 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 445 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 446 | } |
| 447 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 448 | while( db_step(&q)==SQLITE_ROW ){ |
| 449 | if( dryRunFlag ){ |
| 450 | fossil_print("%s\n", db_column_text(&q,0)); |
| 451 | continue; |
| 452 | }else if( !allFlag ){ |
| 453 | Blob ans; |
| 454 | char cReply; |
| @@ -1125,10 +1129,11 @@ | |
| 1129 | ** --branchcolor COLOR apply given COLOR to the branch |
| 1130 | ** --comment|-m COMMENT-TEXT use COMMENT-TEXT as commit comment |
| 1131 | ** --delta use a delta manifest in the commit process |
| 1132 | ** --message-file|-M FILE read the commit comment from given file |
| 1133 | ** --mimetype MIMETYPE mimetype of check-in comment |
| 1134 | ** -n|--dry-run If given, display instead of run actions |
| 1135 | ** --no-warnings omit all warnings about file contents |
| 1136 | ** --nosign do not attempt to sign this commit with gpg |
| 1137 | ** --private do not sync changes and their descendants |
| 1138 | ** --tag TAG-NAME assign given tag TAG-NAME to the checkin |
| 1139 | ** |
| @@ -1154,11 +1159,11 @@ | |
| 1159 | int allowFork = 0; /* Allow the commit to fork */ |
| 1160 | int allowOlder = 0; /* Allow a commit older than its ancestor */ |
| 1161 | char *zManifestFile; /* Name of the manifest file */ |
| 1162 | int useCksum; /* True if checksums should be computed and verified */ |
| 1163 | int outputManifest; /* True to output "manifest" and "manifest.uuid" */ |
| 1164 | int dryRunFlag; /* True for a test run. Debugging only */ |
| 1165 | CheckinInfo sCiInfo; /* Information about this check-in */ |
| 1166 | const char *zComFile; /* Read commit message from this file */ |
| 1167 | int nTag = 0; /* Number of --tag arguments */ |
| 1168 | const char *zTag; /* A single --tag argument */ |
| 1169 | Blob manifest; /* Manifest in baseline form */ |
| @@ -1178,11 +1183,14 @@ | |
| 1183 | forceDelta = find_option("delta",0,0)!=0; |
| 1184 | forceBaseline = find_option("baseline",0,0)!=0; |
| 1185 | if( forceDelta && forceBaseline ){ |
| 1186 | fossil_fatal("cannot use --delta and --baseline together"); |
| 1187 | } |
| 1188 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 1189 | if( !dryRunFlag ){ |
| 1190 | dryRunFlag = find_option("test",0,0)!=0; /* deprecated */ |
| 1191 | } |
| 1192 | zComment = find_option("comment","m",1); |
| 1193 | forceFlag = find_option("force", "f", 0)!=0; |
| 1194 | allowConflict = find_option("allow-conflict",0,0)!=0; |
| 1195 | allowEmpty = find_option("allow-empty",0,0)!=0; |
| 1196 | allowFork = find_option("allow-fork",0,0)!=0; |
| @@ -1522,11 +1530,11 @@ | |
| 1530 | } |
| 1531 | |
| 1532 | /* If the --test option is specified, output the manifest file |
| 1533 | ** and rollback the transaction. |
| 1534 | */ |
| 1535 | if( dryRunFlag ){ |
| 1536 | blob_write_to_file(&manifest, ""); |
| 1537 | } |
| 1538 | |
| 1539 | if( outputManifest ){ |
| 1540 | zManifestFile = mprintf("%smanifest", g.zLocalRoot); |
| @@ -1601,11 +1609,11 @@ | |
| 1609 | /* Clear the undo/redo stack */ |
| 1610 | undo_reset(); |
| 1611 | |
| 1612 | /* Commit */ |
| 1613 | db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'"); |
| 1614 | if( dryRunFlag ){ |
| 1615 | db_end_transaction(1); |
| 1616 | exit(1); |
| 1617 | } |
| 1618 | db_end_transaction(0); |
| 1619 | |
| 1620 |
+16
-14
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -91,23 +91,22 @@ | ||
| 91 | 91 | ** files whose names differ only in case are taken |
| 92 | 92 | ** to be the same file. |
| 93 | 93 | ** |
| 94 | 94 | ** --detail Show additional details of the merge |
| 95 | 95 | ** |
| 96 | -** --force | -f Force the merge even if it would be a no-op. | |
| 96 | +** -f|--force Force the merge even if it would be a no-op. | |
| 97 | 97 | ** |
| 98 | -** --nochange | -n Dryrun: do not actually make any changes; just | |
| 99 | -** show what would have happened. | |
| 98 | +** -n|--dry-run If given, display instead of run actions | |
| 100 | 99 | */ |
| 101 | 100 | void merge_cmd(void){ |
| 102 | 101 | int vid; /* Current version "V" */ |
| 103 | 102 | int mid; /* Version we are merging from "M" */ |
| 104 | 103 | int pid; /* The pivot version - most recent common ancestor P */ |
| 105 | 104 | int detailFlag; /* True if the --detail option is present */ |
| 106 | 105 | int pickFlag; /* True if the --cherrypick option is present */ |
| 107 | 106 | int backoutFlag; /* True if the --backout option is present */ |
| 108 | - int nochangeFlag; /* True if the --nochange or -n option is present */ | |
| 107 | + int dryRunFlag; /* True if the --dry-run or -n option is present */ | |
| 109 | 108 | int forceFlag; /* True if the --force or -f option is present */ |
| 110 | 109 | const char *zBinGlob; /* The value of --binary */ |
| 111 | 110 | const char *zPivot; /* The value of --baseline */ |
| 112 | 111 | int debugFlag; /* True if --debug is present */ |
| 113 | 112 | int nChng; /* Number of file name changes */ |
| @@ -129,11 +128,14 @@ | ||
| 129 | 128 | detailFlag = find_option("detail",0,0)!=0; |
| 130 | 129 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 131 | 130 | backoutFlag = find_option("backout",0,0)!=0; |
| 132 | 131 | debugFlag = find_option("debug",0,0)!=0; |
| 133 | 132 | zBinGlob = find_option("binary",0,1); |
| 134 | - nochangeFlag = find_option("nochange","n",0)!=0; | |
| 133 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 134 | + if( !dryRunFlag ){ | |
| 135 | + dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */ | |
| 136 | + } | |
| 135 | 137 | forceFlag = find_option("force","f",0)!=0; |
| 136 | 138 | zPivot = find_option("baseline",0,1); |
| 137 | 139 | capture_case_sensitive_option(); |
| 138 | 140 | verify_all_options(); |
| 139 | 141 | db_must_be_within_tree(); |
| @@ -252,11 +254,11 @@ | ||
| 252 | 254 | print_checkin_description(mid, 12, "merge-from:"); |
| 253 | 255 | print_checkin_description(pid, 12, "baseline:"); |
| 254 | 256 | } |
| 255 | 257 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 256 | 258 | db_begin_transaction(); |
| 257 | - if( !nochangeFlag ) undo_begin(); | |
| 259 | + if( !dryRunFlag ) undo_begin(); | |
| 258 | 260 | load_vfile_from_rid(mid); |
| 259 | 261 | load_vfile_from_rid(pid); |
| 260 | 262 | if( debugFlag ){ |
| 261 | 263 | char *z; |
| 262 | 264 | z = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pid); |
| @@ -443,11 +445,11 @@ | ||
| 443 | 445 | nOverwrite++; |
| 444 | 446 | }else{ |
| 445 | 447 | fossil_print("ADDED %s\n", zName); |
| 446 | 448 | } |
| 447 | 449 | fossil_free(zFullName); |
| 448 | - if( !nochangeFlag ){ | |
| 450 | + if( !dryRunFlag ){ | |
| 449 | 451 | undo_save(zName); |
| 450 | 452 | vfile_to_disk(0, idm, 0, 0); |
| 451 | 453 | } |
| 452 | 454 | } |
| 453 | 455 | db_finalize(&q); |
| @@ -466,11 +468,11 @@ | ||
| 466 | 468 | int ridm = db_column_int(&q, 1); |
| 467 | 469 | const char *zName = db_column_text(&q, 2); |
| 468 | 470 | int islinkm = db_column_int(&q, 3); |
| 469 | 471 | /* Copy content from idm over into idv. Overwrite idv. */ |
| 470 | 472 | fossil_print("UPDATE %s\n", zName); |
| 471 | - if( !nochangeFlag ){ | |
| 473 | + if( !dryRunFlag ){ | |
| 472 | 474 | undo_save(zName); |
| 473 | 475 | db_multi_exec( |
| 474 | 476 | "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d " |
| 475 | 477 | " WHERE id=%d", ridm, islinkm, idv |
| 476 | 478 | ); |
| @@ -518,15 +520,15 @@ | ||
| 518 | 520 | content_get(ridm, &m); |
| 519 | 521 | if( isBinary ){ |
| 520 | 522 | rc = -1; |
| 521 | 523 | blob_zero(&r); |
| 522 | 524 | }else{ |
| 523 | - unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0; | |
| 525 | + unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; | |
| 524 | 526 | rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags); |
| 525 | 527 | } |
| 526 | 528 | if( rc>=0 ){ |
| 527 | - if( !nochangeFlag ){ | |
| 529 | + if( !dryRunFlag ){ | |
| 528 | 530 | blob_write_to_file(&r, zFullPath); |
| 529 | 531 | file_wd_setexe(zFullPath, isExe); |
| 530 | 532 | } |
| 531 | 533 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); |
| 532 | 534 | if( rc>0 ){ |
| @@ -565,11 +567,11 @@ | ||
| 565 | 567 | } |
| 566 | 568 | undo_save(zName); |
| 567 | 569 | db_multi_exec( |
| 568 | 570 | "UPDATE vfile SET deleted=1 WHERE id=%d", idv |
| 569 | 571 | ); |
| 570 | - if( !nochangeFlag ){ | |
| 572 | + if( !dryRunFlag ){ | |
| 571 | 573 | char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName); |
| 572 | 574 | file_delete(zFullPath); |
| 573 | 575 | free(zFullPath); |
| 574 | 576 | } |
| 575 | 577 | } |
| @@ -593,11 +595,11 @@ | ||
| 593 | 595 | undo_save(zNewName); |
| 594 | 596 | db_multi_exec( |
| 595 | 597 | "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)" |
| 596 | 598 | " WHERE id=%d AND vid=%d", zNewName, idv, vid |
| 597 | 599 | ); |
| 598 | - if( !nochangeFlag ){ | |
| 600 | + if( !dryRunFlag ){ | |
| 599 | 601 | char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); |
| 600 | 602 | char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); |
| 601 | 603 | if( file_wd_islink(zFullOldPath) ){ |
| 602 | 604 | symlink_copy(zFullOldPath, zFullNewPath); |
| 603 | 605 | }else{ |
| @@ -618,11 +620,11 @@ | ||
| 618 | 620 | } |
| 619 | 621 | if( nOverwrite ){ |
| 620 | 622 | fossil_warning("WARNING: %d unmanaged files were overwritten", |
| 621 | 623 | nOverwrite); |
| 622 | 624 | } |
| 623 | - if( nochangeFlag ){ | |
| 625 | + if( dryRunFlag ){ | |
| 624 | 626 | fossil_warning("REMINDER: this was a dry run -" |
| 625 | 627 | " no file were actually changed."); |
| 626 | 628 | } |
| 627 | 629 | |
| 628 | 630 | /* |
| @@ -643,7 +645,7 @@ | ||
| 643 | 645 | db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid); |
| 644 | 646 | }else{ |
| 645 | 647 | db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid); |
| 646 | 648 | } |
| 647 | 649 | undo_finish(); |
| 648 | - db_end_transaction(nochangeFlag); | |
| 650 | + db_end_transaction(dryRunFlag); | |
| 649 | 651 | } |
| 650 | 652 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -91,23 +91,22 @@ | |
| 91 | ** files whose names differ only in case are taken |
| 92 | ** to be the same file. |
| 93 | ** |
| 94 | ** --detail Show additional details of the merge |
| 95 | ** |
| 96 | ** --force | -f Force the merge even if it would be a no-op. |
| 97 | ** |
| 98 | ** --nochange | -n Dryrun: do not actually make any changes; just |
| 99 | ** show what would have happened. |
| 100 | */ |
| 101 | void merge_cmd(void){ |
| 102 | int vid; /* Current version "V" */ |
| 103 | int mid; /* Version we are merging from "M" */ |
| 104 | int pid; /* The pivot version - most recent common ancestor P */ |
| 105 | int detailFlag; /* True if the --detail option is present */ |
| 106 | int pickFlag; /* True if the --cherrypick option is present */ |
| 107 | int backoutFlag; /* True if the --backout option is present */ |
| 108 | int nochangeFlag; /* True if the --nochange or -n option is present */ |
| 109 | int forceFlag; /* True if the --force or -f option is present */ |
| 110 | const char *zBinGlob; /* The value of --binary */ |
| 111 | const char *zPivot; /* The value of --baseline */ |
| 112 | int debugFlag; /* True if --debug is present */ |
| 113 | int nChng; /* Number of file name changes */ |
| @@ -129,11 +128,14 @@ | |
| 129 | detailFlag = find_option("detail",0,0)!=0; |
| 130 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 131 | backoutFlag = find_option("backout",0,0)!=0; |
| 132 | debugFlag = find_option("debug",0,0)!=0; |
| 133 | zBinGlob = find_option("binary",0,1); |
| 134 | nochangeFlag = find_option("nochange","n",0)!=0; |
| 135 | forceFlag = find_option("force","f",0)!=0; |
| 136 | zPivot = find_option("baseline",0,1); |
| 137 | capture_case_sensitive_option(); |
| 138 | verify_all_options(); |
| 139 | db_must_be_within_tree(); |
| @@ -252,11 +254,11 @@ | |
| 252 | print_checkin_description(mid, 12, "merge-from:"); |
| 253 | print_checkin_description(pid, 12, "baseline:"); |
| 254 | } |
| 255 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 256 | db_begin_transaction(); |
| 257 | if( !nochangeFlag ) undo_begin(); |
| 258 | load_vfile_from_rid(mid); |
| 259 | load_vfile_from_rid(pid); |
| 260 | if( debugFlag ){ |
| 261 | char *z; |
| 262 | z = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pid); |
| @@ -443,11 +445,11 @@ | |
| 443 | nOverwrite++; |
| 444 | }else{ |
| 445 | fossil_print("ADDED %s\n", zName); |
| 446 | } |
| 447 | fossil_free(zFullName); |
| 448 | if( !nochangeFlag ){ |
| 449 | undo_save(zName); |
| 450 | vfile_to_disk(0, idm, 0, 0); |
| 451 | } |
| 452 | } |
| 453 | db_finalize(&q); |
| @@ -466,11 +468,11 @@ | |
| 466 | int ridm = db_column_int(&q, 1); |
| 467 | const char *zName = db_column_text(&q, 2); |
| 468 | int islinkm = db_column_int(&q, 3); |
| 469 | /* Copy content from idm over into idv. Overwrite idv. */ |
| 470 | fossil_print("UPDATE %s\n", zName); |
| 471 | if( !nochangeFlag ){ |
| 472 | undo_save(zName); |
| 473 | db_multi_exec( |
| 474 | "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d " |
| 475 | " WHERE id=%d", ridm, islinkm, idv |
| 476 | ); |
| @@ -518,15 +520,15 @@ | |
| 518 | content_get(ridm, &m); |
| 519 | if( isBinary ){ |
| 520 | rc = -1; |
| 521 | blob_zero(&r); |
| 522 | }else{ |
| 523 | unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0; |
| 524 | rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags); |
| 525 | } |
| 526 | if( rc>=0 ){ |
| 527 | if( !nochangeFlag ){ |
| 528 | blob_write_to_file(&r, zFullPath); |
| 529 | file_wd_setexe(zFullPath, isExe); |
| 530 | } |
| 531 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); |
| 532 | if( rc>0 ){ |
| @@ -565,11 +567,11 @@ | |
| 565 | } |
| 566 | undo_save(zName); |
| 567 | db_multi_exec( |
| 568 | "UPDATE vfile SET deleted=1 WHERE id=%d", idv |
| 569 | ); |
| 570 | if( !nochangeFlag ){ |
| 571 | char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName); |
| 572 | file_delete(zFullPath); |
| 573 | free(zFullPath); |
| 574 | } |
| 575 | } |
| @@ -593,11 +595,11 @@ | |
| 593 | undo_save(zNewName); |
| 594 | db_multi_exec( |
| 595 | "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)" |
| 596 | " WHERE id=%d AND vid=%d", zNewName, idv, vid |
| 597 | ); |
| 598 | if( !nochangeFlag ){ |
| 599 | char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); |
| 600 | char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); |
| 601 | if( file_wd_islink(zFullOldPath) ){ |
| 602 | symlink_copy(zFullOldPath, zFullNewPath); |
| 603 | }else{ |
| @@ -618,11 +620,11 @@ | |
| 618 | } |
| 619 | if( nOverwrite ){ |
| 620 | fossil_warning("WARNING: %d unmanaged files were overwritten", |
| 621 | nOverwrite); |
| 622 | } |
| 623 | if( nochangeFlag ){ |
| 624 | fossil_warning("REMINDER: this was a dry run -" |
| 625 | " no file were actually changed."); |
| 626 | } |
| 627 | |
| 628 | /* |
| @@ -643,7 +645,7 @@ | |
| 643 | db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid); |
| 644 | }else{ |
| 645 | db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid); |
| 646 | } |
| 647 | undo_finish(); |
| 648 | db_end_transaction(nochangeFlag); |
| 649 | } |
| 650 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -91,23 +91,22 @@ | |
| 91 | ** files whose names differ only in case are taken |
| 92 | ** to be the same file. |
| 93 | ** |
| 94 | ** --detail Show additional details of the merge |
| 95 | ** |
| 96 | ** -f|--force Force the merge even if it would be a no-op. |
| 97 | ** |
| 98 | ** -n|--dry-run If given, display instead of run actions |
| 99 | */ |
| 100 | void merge_cmd(void){ |
| 101 | int vid; /* Current version "V" */ |
| 102 | int mid; /* Version we are merging from "M" */ |
| 103 | int pid; /* The pivot version - most recent common ancestor P */ |
| 104 | int detailFlag; /* True if the --detail option is present */ |
| 105 | int pickFlag; /* True if the --cherrypick option is present */ |
| 106 | int backoutFlag; /* True if the --backout option is present */ |
| 107 | int dryRunFlag; /* True if the --dry-run or -n option is present */ |
| 108 | int forceFlag; /* True if the --force or -f option is present */ |
| 109 | const char *zBinGlob; /* The value of --binary */ |
| 110 | const char *zPivot; /* The value of --baseline */ |
| 111 | int debugFlag; /* True if --debug is present */ |
| 112 | int nChng; /* Number of file name changes */ |
| @@ -129,11 +128,14 @@ | |
| 128 | detailFlag = find_option("detail",0,0)!=0; |
| 129 | pickFlag = find_option("cherrypick",0,0)!=0; |
| 130 | backoutFlag = find_option("backout",0,0)!=0; |
| 131 | debugFlag = find_option("debug",0,0)!=0; |
| 132 | zBinGlob = find_option("binary",0,1); |
| 133 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 134 | if( !dryRunFlag ){ |
| 135 | dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */ |
| 136 | } |
| 137 | forceFlag = find_option("force","f",0)!=0; |
| 138 | zPivot = find_option("baseline",0,1); |
| 139 | capture_case_sensitive_option(); |
| 140 | verify_all_options(); |
| 141 | db_must_be_within_tree(); |
| @@ -252,11 +254,11 @@ | |
| 254 | print_checkin_description(mid, 12, "merge-from:"); |
| 255 | print_checkin_description(pid, 12, "baseline:"); |
| 256 | } |
| 257 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 258 | db_begin_transaction(); |
| 259 | if( !dryRunFlag ) undo_begin(); |
| 260 | load_vfile_from_rid(mid); |
| 261 | load_vfile_from_rid(pid); |
| 262 | if( debugFlag ){ |
| 263 | char *z; |
| 264 | z = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pid); |
| @@ -443,11 +445,11 @@ | |
| 445 | nOverwrite++; |
| 446 | }else{ |
| 447 | fossil_print("ADDED %s\n", zName); |
| 448 | } |
| 449 | fossil_free(zFullName); |
| 450 | if( !dryRunFlag ){ |
| 451 | undo_save(zName); |
| 452 | vfile_to_disk(0, idm, 0, 0); |
| 453 | } |
| 454 | } |
| 455 | db_finalize(&q); |
| @@ -466,11 +468,11 @@ | |
| 468 | int ridm = db_column_int(&q, 1); |
| 469 | const char *zName = db_column_text(&q, 2); |
| 470 | int islinkm = db_column_int(&q, 3); |
| 471 | /* Copy content from idm over into idv. Overwrite idv. */ |
| 472 | fossil_print("UPDATE %s\n", zName); |
| 473 | if( !dryRunFlag ){ |
| 474 | undo_save(zName); |
| 475 | db_multi_exec( |
| 476 | "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d " |
| 477 | " WHERE id=%d", ridm, islinkm, idv |
| 478 | ); |
| @@ -518,15 +520,15 @@ | |
| 520 | content_get(ridm, &m); |
| 521 | if( isBinary ){ |
| 522 | rc = -1; |
| 523 | blob_zero(&r); |
| 524 | }else{ |
| 525 | unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; |
| 526 | rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags); |
| 527 | } |
| 528 | if( rc>=0 ){ |
| 529 | if( !dryRunFlag ){ |
| 530 | blob_write_to_file(&r, zFullPath); |
| 531 | file_wd_setexe(zFullPath, isExe); |
| 532 | } |
| 533 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); |
| 534 | if( rc>0 ){ |
| @@ -565,11 +567,11 @@ | |
| 567 | } |
| 568 | undo_save(zName); |
| 569 | db_multi_exec( |
| 570 | "UPDATE vfile SET deleted=1 WHERE id=%d", idv |
| 571 | ); |
| 572 | if( !dryRunFlag ){ |
| 573 | char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName); |
| 574 | file_delete(zFullPath); |
| 575 | free(zFullPath); |
| 576 | } |
| 577 | } |
| @@ -593,11 +595,11 @@ | |
| 595 | undo_save(zNewName); |
| 596 | db_multi_exec( |
| 597 | "UPDATE vfile SET pathname=%Q, origname=coalesce(origname,pathname)" |
| 598 | " WHERE id=%d AND vid=%d", zNewName, idv, vid |
| 599 | ); |
| 600 | if( !dryRunFlag ){ |
| 601 | char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); |
| 602 | char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); |
| 603 | if( file_wd_islink(zFullOldPath) ){ |
| 604 | symlink_copy(zFullOldPath, zFullNewPath); |
| 605 | }else{ |
| @@ -618,11 +620,11 @@ | |
| 620 | } |
| 621 | if( nOverwrite ){ |
| 622 | fossil_warning("WARNING: %d unmanaged files were overwritten", |
| 623 | nOverwrite); |
| 624 | } |
| 625 | if( dryRunFlag ){ |
| 626 | fossil_warning("REMINDER: this was a dry run -" |
| 627 | " no file were actually changed."); |
| 628 | } |
| 629 | |
| 630 | /* |
| @@ -643,7 +645,7 @@ | |
| 645 | db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid); |
| 646 | }else{ |
| 647 | db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid); |
| 648 | } |
| 649 | undo_finish(); |
| 650 | db_end_transaction(dryRunFlag); |
| 651 | } |
| 652 |
+19
-16
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -87,21 +87,21 @@ | ||
| 87 | 87 | ** files in addition to those file that actually do change. |
| 88 | 88 | ** |
| 89 | 89 | ** Options: |
| 90 | 90 | ** --debug print debug information on stdout |
| 91 | 91 | ** --latest acceptable in place of VERSION, update to latest version |
| 92 | -** -n|--nochange do not perform changes but show what would be done | |
| 92 | +** -n|--dry-run If given, display instead of run actions | |
| 93 | 93 | ** -v|--verbose print status information about all files |
| 94 | 94 | ** |
| 95 | 95 | ** See also: revert |
| 96 | 96 | */ |
| 97 | 97 | void update_cmd(void){ |
| 98 | 98 | int vid; /* Current version */ |
| 99 | 99 | int tid=0; /* Target version - version we are changing to */ |
| 100 | 100 | Stmt q; |
| 101 | 101 | int latestFlag; /* --latest. Pick the latest version if true */ |
| 102 | - int nochangeFlag; /* -n or --nochange. Do a dry run */ | |
| 102 | + int dryRunFlag; /* -n or --dry-run. Do a dry run */ | |
| 103 | 103 | int verboseFlag; /* -v or --verbose. Output extra information */ |
| 104 | 104 | int debugFlag; /* --debug option */ |
| 105 | 105 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 106 | 106 | int nChng; /* Number of file renames */ |
| 107 | 107 | int *aChng; /* Array of file renames */ |
| @@ -114,26 +114,29 @@ | ||
| 114 | 114 | if( !internalUpdate ){ |
| 115 | 115 | undo_capture_command_line(); |
| 116 | 116 | url_proxy_options(); |
| 117 | 117 | } |
| 118 | 118 | latestFlag = find_option("latest",0, 0)!=0; |
| 119 | - nochangeFlag = find_option("nochange","n",0)!=0; | |
| 119 | + dryRunFlag = find_option("dry-run","n",0)!=0; | |
| 120 | + if( !dryRunFlag ){ | |
| 121 | + dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */ | |
| 122 | + } | |
| 120 | 123 | verboseFlag = find_option("verbose","v",0)!=0; |
| 121 | 124 | debugFlag = find_option("debug",0,0)!=0; |
| 122 | 125 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 123 | 126 | db_must_be_within_tree(); |
| 124 | 127 | vid = db_lget_int("checkout", 0); |
| 125 | 128 | if( vid==0 ){ |
| 126 | 129 | fossil_fatal("cannot find current version"); |
| 127 | 130 | } |
| 128 | - if( !nochangeFlag && !internalUpdate ){ | |
| 131 | + if( !dryRunFlag && !internalUpdate ){ | |
| 129 | 132 | autosync(SYNC_PULL + SYNC_VERBOSE*verboseFlag); |
| 130 | 133 | } |
| 131 | 134 | |
| 132 | 135 | /* Create any empty directories now, as well as after the update, |
| 133 | 136 | ** so changes in settings are reflected now */ |
| 134 | - if( !nochangeFlag ) ensure_empty_dirs_created(); | |
| 137 | + if( !dryRunFlag ) ensure_empty_dirs_created(); | |
| 135 | 138 | |
| 136 | 139 | if( internalUpdate ){ |
| 137 | 140 | tid = internalUpdate; |
| 138 | 141 | }else if( g.argc>=3 ){ |
| 139 | 142 | if( fossil_strcmp(g.argv[2], "current")==0 ){ |
| @@ -199,11 +202,11 @@ | ||
| 199 | 202 | fossil_panic("Internal Error: unable to find a version to update to."); |
| 200 | 203 | } |
| 201 | 204 | |
| 202 | 205 | db_begin_transaction(); |
| 203 | 206 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 204 | - if( !nochangeFlag && !internalUpdate ) undo_begin(); | |
| 207 | + if( !dryRunFlag && !internalUpdate ) undo_begin(); | |
| 205 | 208 | load_vfile_from_rid(tid); |
| 206 | 209 | |
| 207 | 210 | /* |
| 208 | 211 | ** The record.fn field is used to match files against each other. The |
| 209 | 212 | ** FV table contains one row for each each unique filename in |
| @@ -389,27 +392,27 @@ | ||
| 389 | 392 | nOverwrite++; |
| 390 | 393 | }else{ |
| 391 | 394 | fossil_print("ADD %s\n", zName); |
| 392 | 395 | } |
| 393 | 396 | undo_save(zName); |
| 394 | - if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); | |
| 397 | + if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); | |
| 395 | 398 | }else if( idt>0 && idv>0 && ridt!=ridv && (chnged==0 || deleted) ){ |
| 396 | 399 | /* The file is unedited. Change it to the target version */ |
| 397 | 400 | undo_save(zName); |
| 398 | 401 | if( deleted ){ |
| 399 | 402 | fossil_print("UPDATE %s - change to unmanged file\n", zName); |
| 400 | 403 | }else{ |
| 401 | 404 | fossil_print("UPDATE %s\n", zName); |
| 402 | 405 | } |
| 403 | - if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); | |
| 406 | + if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); | |
| 404 | 407 | }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){ |
| 405 | 408 | /* The file missing from the local check-out. Restore it to the |
| 406 | 409 | ** version that appears in the target. */ |
| 407 | 410 | fossil_print("UPDATE %s%s\n", zName, |
| 408 | 411 | deleted?" - change to unmanaged file":""); |
| 409 | 412 | undo_save(zName); |
| 410 | - if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); | |
| 413 | + if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); | |
| 411 | 414 | }else if( idt==0 && idv>0 ){ |
| 412 | 415 | if( ridv==0 ){ |
| 413 | 416 | /* Added in current checkout. Continue to hold the file as |
| 414 | 417 | ** as an addition */ |
| 415 | 418 | db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv); |
| @@ -420,11 +423,11 @@ | ||
| 420 | 423 | zName); |
| 421 | 424 | nConflict++; |
| 422 | 425 | }else{ |
| 423 | 426 | fossil_print("REMOVE %s\n", zName); |
| 424 | 427 | undo_save(zName); |
| 425 | - if( !nochangeFlag ) file_delete(zFullPath); | |
| 428 | + if( !dryRunFlag ) file_delete(zFullPath); | |
| 426 | 429 | } |
| 427 | 430 | }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){ |
| 428 | 431 | /* Merge the changes in the current tree into the target version */ |
| 429 | 432 | Blob r, t, v; |
| 430 | 433 | int rc; |
| @@ -435,34 +438,34 @@ | ||
| 435 | 438 | } |
| 436 | 439 | if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){ |
| 437 | 440 | fossil_print("***** Cannot merge symlink %s\n", zNewName); |
| 438 | 441 | nConflict++; |
| 439 | 442 | }else{ |
| 440 | - unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0; | |
| 443 | + unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; | |
| 441 | 444 | undo_save(zName); |
| 442 | 445 | content_get(ridt, &t); |
| 443 | 446 | content_get(ridv, &v); |
| 444 | 447 | rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags); |
| 445 | 448 | if( rc>=0 ){ |
| 446 | - if( !nochangeFlag ){ | |
| 449 | + if( !dryRunFlag ){ | |
| 447 | 450 | blob_write_to_file(&r, zFullNewPath); |
| 448 | 451 | file_wd_setexe(zFullNewPath, isexe); |
| 449 | 452 | } |
| 450 | 453 | if( rc>0 ){ |
| 451 | 454 | fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); |
| 452 | 455 | nConflict++; |
| 453 | 456 | } |
| 454 | 457 | }else{ |
| 455 | - if( !nochangeFlag ){ | |
| 458 | + if( !dryRunFlag ){ | |
| 456 | 459 | blob_write_to_file(&t, zFullNewPath); |
| 457 | 460 | file_wd_setexe(zFullNewPath, isexe); |
| 458 | 461 | } |
| 459 | 462 | fossil_print("***** Cannot merge binary file %s\n", zNewName); |
| 460 | 463 | nConflict++; |
| 461 | 464 | } |
| 462 | 465 | } |
| 463 | - if( nameChng && !nochangeFlag ) file_delete(zFullPath); | |
| 466 | + if( nameChng && !dryRunFlag ) file_delete(zFullPath); | |
| 464 | 467 | blob_reset(&v); |
| 465 | 468 | blob_reset(&t); |
| 466 | 469 | blob_reset(&r); |
| 467 | 470 | }else{ |
| 468 | 471 | nUpdate--; |
| @@ -491,11 +494,11 @@ | ||
| 491 | 494 | nUpdate, nUpdate>1 ? "s" : ""); |
| 492 | 495 | } |
| 493 | 496 | |
| 494 | 497 | /* Report on conflicts |
| 495 | 498 | */ |
| 496 | - if( !nochangeFlag ){ | |
| 499 | + if( !dryRunFlag ){ | |
| 497 | 500 | Stmt q; |
| 498 | 501 | int nMerge = 0; |
| 499 | 502 | db_prepare(&q, "SELECT uuid, id FROM vmerge JOIN blob ON merge=rid" |
| 500 | 503 | " WHERE id<=0"); |
| 501 | 504 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -528,11 +531,11 @@ | ||
| 528 | 531 | } |
| 529 | 532 | |
| 530 | 533 | /* |
| 531 | 534 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 532 | 535 | */ |
| 533 | - if( nochangeFlag ){ | |
| 536 | + if( dryRunFlag ){ | |
| 534 | 537 | db_end_transaction(1); /* With --nochange, rollback changes */ |
| 535 | 538 | }else{ |
| 536 | 539 | ensure_empty_dirs_created(); |
| 537 | 540 | if( g.argc<=3 ){ |
| 538 | 541 | /* All files updated. Shift the current checkout to the target. */ |
| 539 | 542 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -87,21 +87,21 @@ | |
| 87 | ** files in addition to those file that actually do change. |
| 88 | ** |
| 89 | ** Options: |
| 90 | ** --debug print debug information on stdout |
| 91 | ** --latest acceptable in place of VERSION, update to latest version |
| 92 | ** -n|--nochange do not perform changes but show what would be done |
| 93 | ** -v|--verbose print status information about all files |
| 94 | ** |
| 95 | ** See also: revert |
| 96 | */ |
| 97 | void update_cmd(void){ |
| 98 | int vid; /* Current version */ |
| 99 | int tid=0; /* Target version - version we are changing to */ |
| 100 | Stmt q; |
| 101 | int latestFlag; /* --latest. Pick the latest version if true */ |
| 102 | int nochangeFlag; /* -n or --nochange. Do a dry run */ |
| 103 | int verboseFlag; /* -v or --verbose. Output extra information */ |
| 104 | int debugFlag; /* --debug option */ |
| 105 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 106 | int nChng; /* Number of file renames */ |
| 107 | int *aChng; /* Array of file renames */ |
| @@ -114,26 +114,29 @@ | |
| 114 | if( !internalUpdate ){ |
| 115 | undo_capture_command_line(); |
| 116 | url_proxy_options(); |
| 117 | } |
| 118 | latestFlag = find_option("latest",0, 0)!=0; |
| 119 | nochangeFlag = find_option("nochange","n",0)!=0; |
| 120 | verboseFlag = find_option("verbose","v",0)!=0; |
| 121 | debugFlag = find_option("debug",0,0)!=0; |
| 122 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 123 | db_must_be_within_tree(); |
| 124 | vid = db_lget_int("checkout", 0); |
| 125 | if( vid==0 ){ |
| 126 | fossil_fatal("cannot find current version"); |
| 127 | } |
| 128 | if( !nochangeFlag && !internalUpdate ){ |
| 129 | autosync(SYNC_PULL + SYNC_VERBOSE*verboseFlag); |
| 130 | } |
| 131 | |
| 132 | /* Create any empty directories now, as well as after the update, |
| 133 | ** so changes in settings are reflected now */ |
| 134 | if( !nochangeFlag ) ensure_empty_dirs_created(); |
| 135 | |
| 136 | if( internalUpdate ){ |
| 137 | tid = internalUpdate; |
| 138 | }else if( g.argc>=3 ){ |
| 139 | if( fossil_strcmp(g.argv[2], "current")==0 ){ |
| @@ -199,11 +202,11 @@ | |
| 199 | fossil_panic("Internal Error: unable to find a version to update to."); |
| 200 | } |
| 201 | |
| 202 | db_begin_transaction(); |
| 203 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 204 | if( !nochangeFlag && !internalUpdate ) undo_begin(); |
| 205 | load_vfile_from_rid(tid); |
| 206 | |
| 207 | /* |
| 208 | ** The record.fn field is used to match files against each other. The |
| 209 | ** FV table contains one row for each each unique filename in |
| @@ -389,27 +392,27 @@ | |
| 389 | nOverwrite++; |
| 390 | }else{ |
| 391 | fossil_print("ADD %s\n", zName); |
| 392 | } |
| 393 | undo_save(zName); |
| 394 | if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); |
| 395 | }else if( idt>0 && idv>0 && ridt!=ridv && (chnged==0 || deleted) ){ |
| 396 | /* The file is unedited. Change it to the target version */ |
| 397 | undo_save(zName); |
| 398 | if( deleted ){ |
| 399 | fossil_print("UPDATE %s - change to unmanged file\n", zName); |
| 400 | }else{ |
| 401 | fossil_print("UPDATE %s\n", zName); |
| 402 | } |
| 403 | if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); |
| 404 | }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){ |
| 405 | /* The file missing from the local check-out. Restore it to the |
| 406 | ** version that appears in the target. */ |
| 407 | fossil_print("UPDATE %s%s\n", zName, |
| 408 | deleted?" - change to unmanaged file":""); |
| 409 | undo_save(zName); |
| 410 | if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0); |
| 411 | }else if( idt==0 && idv>0 ){ |
| 412 | if( ridv==0 ){ |
| 413 | /* Added in current checkout. Continue to hold the file as |
| 414 | ** as an addition */ |
| 415 | db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv); |
| @@ -420,11 +423,11 @@ | |
| 420 | zName); |
| 421 | nConflict++; |
| 422 | }else{ |
| 423 | fossil_print("REMOVE %s\n", zName); |
| 424 | undo_save(zName); |
| 425 | if( !nochangeFlag ) file_delete(zFullPath); |
| 426 | } |
| 427 | }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){ |
| 428 | /* Merge the changes in the current tree into the target version */ |
| 429 | Blob r, t, v; |
| 430 | int rc; |
| @@ -435,34 +438,34 @@ | |
| 435 | } |
| 436 | if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){ |
| 437 | fossil_print("***** Cannot merge symlink %s\n", zNewName); |
| 438 | nConflict++; |
| 439 | }else{ |
| 440 | unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0; |
| 441 | undo_save(zName); |
| 442 | content_get(ridt, &t); |
| 443 | content_get(ridv, &v); |
| 444 | rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags); |
| 445 | if( rc>=0 ){ |
| 446 | if( !nochangeFlag ){ |
| 447 | blob_write_to_file(&r, zFullNewPath); |
| 448 | file_wd_setexe(zFullNewPath, isexe); |
| 449 | } |
| 450 | if( rc>0 ){ |
| 451 | fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); |
| 452 | nConflict++; |
| 453 | } |
| 454 | }else{ |
| 455 | if( !nochangeFlag ){ |
| 456 | blob_write_to_file(&t, zFullNewPath); |
| 457 | file_wd_setexe(zFullNewPath, isexe); |
| 458 | } |
| 459 | fossil_print("***** Cannot merge binary file %s\n", zNewName); |
| 460 | nConflict++; |
| 461 | } |
| 462 | } |
| 463 | if( nameChng && !nochangeFlag ) file_delete(zFullPath); |
| 464 | blob_reset(&v); |
| 465 | blob_reset(&t); |
| 466 | blob_reset(&r); |
| 467 | }else{ |
| 468 | nUpdate--; |
| @@ -491,11 +494,11 @@ | |
| 491 | nUpdate, nUpdate>1 ? "s" : ""); |
| 492 | } |
| 493 | |
| 494 | /* Report on conflicts |
| 495 | */ |
| 496 | if( !nochangeFlag ){ |
| 497 | Stmt q; |
| 498 | int nMerge = 0; |
| 499 | db_prepare(&q, "SELECT uuid, id FROM vmerge JOIN blob ON merge=rid" |
| 500 | " WHERE id<=0"); |
| 501 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -528,11 +531,11 @@ | |
| 528 | } |
| 529 | |
| 530 | /* |
| 531 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 532 | */ |
| 533 | if( nochangeFlag ){ |
| 534 | db_end_transaction(1); /* With --nochange, rollback changes */ |
| 535 | }else{ |
| 536 | ensure_empty_dirs_created(); |
| 537 | if( g.argc<=3 ){ |
| 538 | /* All files updated. Shift the current checkout to the target. */ |
| 539 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -87,21 +87,21 @@ | |
| 87 | ** files in addition to those file that actually do change. |
| 88 | ** |
| 89 | ** Options: |
| 90 | ** --debug print debug information on stdout |
| 91 | ** --latest acceptable in place of VERSION, update to latest version |
| 92 | ** -n|--dry-run If given, display instead of run actions |
| 93 | ** -v|--verbose print status information about all files |
| 94 | ** |
| 95 | ** See also: revert |
| 96 | */ |
| 97 | void update_cmd(void){ |
| 98 | int vid; /* Current version */ |
| 99 | int tid=0; /* Target version - version we are changing to */ |
| 100 | Stmt q; |
| 101 | int latestFlag; /* --latest. Pick the latest version if true */ |
| 102 | int dryRunFlag; /* -n or --dry-run. Do a dry run */ |
| 103 | int verboseFlag; /* -v or --verbose. Output extra information */ |
| 104 | int debugFlag; /* --debug option */ |
| 105 | int setmtimeFlag; /* --setmtime. Set mtimes on files */ |
| 106 | int nChng; /* Number of file renames */ |
| 107 | int *aChng; /* Array of file renames */ |
| @@ -114,26 +114,29 @@ | |
| 114 | if( !internalUpdate ){ |
| 115 | undo_capture_command_line(); |
| 116 | url_proxy_options(); |
| 117 | } |
| 118 | latestFlag = find_option("latest",0, 0)!=0; |
| 119 | dryRunFlag = find_option("dry-run","n",0)!=0; |
| 120 | if( !dryRunFlag ){ |
| 121 | dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */ |
| 122 | } |
| 123 | verboseFlag = find_option("verbose","v",0)!=0; |
| 124 | debugFlag = find_option("debug",0,0)!=0; |
| 125 | setmtimeFlag = find_option("setmtime",0,0)!=0; |
| 126 | db_must_be_within_tree(); |
| 127 | vid = db_lget_int("checkout", 0); |
| 128 | if( vid==0 ){ |
| 129 | fossil_fatal("cannot find current version"); |
| 130 | } |
| 131 | if( !dryRunFlag && !internalUpdate ){ |
| 132 | autosync(SYNC_PULL + SYNC_VERBOSE*verboseFlag); |
| 133 | } |
| 134 | |
| 135 | /* Create any empty directories now, as well as after the update, |
| 136 | ** so changes in settings are reflected now */ |
| 137 | if( !dryRunFlag ) ensure_empty_dirs_created(); |
| 138 | |
| 139 | if( internalUpdate ){ |
| 140 | tid = internalUpdate; |
| 141 | }else if( g.argc>=3 ){ |
| 142 | if( fossil_strcmp(g.argv[2], "current")==0 ){ |
| @@ -199,11 +202,11 @@ | |
| 202 | fossil_panic("Internal Error: unable to find a version to update to."); |
| 203 | } |
| 204 | |
| 205 | db_begin_transaction(); |
| 206 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 207 | if( !dryRunFlag && !internalUpdate ) undo_begin(); |
| 208 | load_vfile_from_rid(tid); |
| 209 | |
| 210 | /* |
| 211 | ** The record.fn field is used to match files against each other. The |
| 212 | ** FV table contains one row for each each unique filename in |
| @@ -389,27 +392,27 @@ | |
| 392 | nOverwrite++; |
| 393 | }else{ |
| 394 | fossil_print("ADD %s\n", zName); |
| 395 | } |
| 396 | undo_save(zName); |
| 397 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| 398 | }else if( idt>0 && idv>0 && ridt!=ridv && (chnged==0 || deleted) ){ |
| 399 | /* The file is unedited. Change it to the target version */ |
| 400 | undo_save(zName); |
| 401 | if( deleted ){ |
| 402 | fossil_print("UPDATE %s - change to unmanged file\n", zName); |
| 403 | }else{ |
| 404 | fossil_print("UPDATE %s\n", zName); |
| 405 | } |
| 406 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| 407 | }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){ |
| 408 | /* The file missing from the local check-out. Restore it to the |
| 409 | ** version that appears in the target. */ |
| 410 | fossil_print("UPDATE %s%s\n", zName, |
| 411 | deleted?" - change to unmanaged file":""); |
| 412 | undo_save(zName); |
| 413 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| 414 | }else if( idt==0 && idv>0 ){ |
| 415 | if( ridv==0 ){ |
| 416 | /* Added in current checkout. Continue to hold the file as |
| 417 | ** as an addition */ |
| 418 | db_multi_exec("UPDATE vfile SET vid=%d WHERE id=%d", tid, idv); |
| @@ -420,11 +423,11 @@ | |
| 423 | zName); |
| 424 | nConflict++; |
| 425 | }else{ |
| 426 | fossil_print("REMOVE %s\n", zName); |
| 427 | undo_save(zName); |
| 428 | if( !dryRunFlag ) file_delete(zFullPath); |
| 429 | } |
| 430 | }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){ |
| 431 | /* Merge the changes in the current tree into the target version */ |
| 432 | Blob r, t, v; |
| 433 | int rc; |
| @@ -435,34 +438,34 @@ | |
| 438 | } |
| 439 | if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){ |
| 440 | fossil_print("***** Cannot merge symlink %s\n", zNewName); |
| 441 | nConflict++; |
| 442 | }else{ |
| 443 | unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; |
| 444 | undo_save(zName); |
| 445 | content_get(ridt, &t); |
| 446 | content_get(ridv, &v); |
| 447 | rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags); |
| 448 | if( rc>=0 ){ |
| 449 | if( !dryRunFlag ){ |
| 450 | blob_write_to_file(&r, zFullNewPath); |
| 451 | file_wd_setexe(zFullNewPath, isexe); |
| 452 | } |
| 453 | if( rc>0 ){ |
| 454 | fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); |
| 455 | nConflict++; |
| 456 | } |
| 457 | }else{ |
| 458 | if( !dryRunFlag ){ |
| 459 | blob_write_to_file(&t, zFullNewPath); |
| 460 | file_wd_setexe(zFullNewPath, isexe); |
| 461 | } |
| 462 | fossil_print("***** Cannot merge binary file %s\n", zNewName); |
| 463 | nConflict++; |
| 464 | } |
| 465 | } |
| 466 | if( nameChng && !dryRunFlag ) file_delete(zFullPath); |
| 467 | blob_reset(&v); |
| 468 | blob_reset(&t); |
| 469 | blob_reset(&r); |
| 470 | }else{ |
| 471 | nUpdate--; |
| @@ -491,11 +494,11 @@ | |
| 494 | nUpdate, nUpdate>1 ? "s" : ""); |
| 495 | } |
| 496 | |
| 497 | /* Report on conflicts |
| 498 | */ |
| 499 | if( !dryRunFlag ){ |
| 500 | Stmt q; |
| 501 | int nMerge = 0; |
| 502 | db_prepare(&q, "SELECT uuid, id FROM vmerge JOIN blob ON merge=rid" |
| 503 | " WHERE id<=0"); |
| 504 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -528,11 +531,11 @@ | |
| 531 | } |
| 532 | |
| 533 | /* |
| 534 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 535 | */ |
| 536 | if( dryRunFlag ){ |
| 537 | db_end_transaction(1); /* With --nochange, rollback changes */ |
| 538 | }else{ |
| 539 | ensure_empty_dirs_created(); |
| 540 | if( g.argc<=3 ){ |
| 541 | /* All files updated. Shift the current checkout to the target. */ |
| 542 |