Fossil SCM
Cleanup of the safemerge flag on update. Override available using the --force option.
Commit
7eecb079ed3c029eb31e6038e14bdd13f6592ece
Parent
a15122ff2d64cb7…
1 file changed
+14
-7
+14
-7
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -36,28 +36,34 @@ | ||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /* |
| 39 | 39 | ** COMMAND: update |
| 40 | 40 | ** |
| 41 | -** Usage: %fossil update ?VERSION? | |
| 41 | +** Usage: %fossil update ?VERSION? ?--force? ?--latest? | |
| 42 | 42 | ** |
| 43 | 43 | ** The optional argument is a version that should become the current |
| 44 | 44 | ** version. If the argument is omitted, then use the leaf of the |
| 45 | 45 | ** tree that begins with the current version, if there is only a |
| 46 | -** single leaf. | |
| 46 | +** single leaf. If there are a multiple leaves, the latest is used | |
| 47 | +** if the --latest flag is present. | |
| 47 | 48 | ** |
| 48 | 49 | ** This command is different from the "checkout" in that edits are |
| 49 | 50 | ** not overwritten. Edits are merged into the new version. |
| 50 | 51 | ** |
| 52 | +** If there are uncommitted edits and the safemerge option is | |
| 53 | +** enabled then no update will occur unless you provide the | |
| 54 | +** --force flag. | |
| 51 | 55 | */ |
| 52 | 56 | void update_cmd(void){ |
| 53 | 57 | int vid; /* Current version */ |
| 54 | 58 | int tid=0; /* Target version - version we are changing to */ |
| 55 | 59 | Stmt q; |
| 56 | 60 | int latestFlag; /* Pick the latest version if true */ |
| 61 | + int forceFlag; /* True force the update */ | |
| 57 | 62 | |
| 58 | 63 | latestFlag = find_option("latest",0, 0)!=0; |
| 64 | + forceFlag = find_option("force","f",0)!=0; | |
| 59 | 65 | if( g.argc!=3 && g.argc!=2 ){ |
| 60 | 66 | usage("?VERSION?"); |
| 61 | 67 | } |
| 62 | 68 | db_must_be_within_tree(); |
| 63 | 69 | vid = db_lget_int("checkout", 0); |
| @@ -65,14 +71,14 @@ | ||
| 65 | 71 | fossil_fatal("cannot find current version"); |
| 66 | 72 | } |
| 67 | 73 | if( db_exists("SELECT 1 FROM vmerge") ){ |
| 68 | 74 | fossil_fatal("cannot update an uncommitted merge"); |
| 69 | 75 | } |
| 70 | - if( unsaved_changes() && db_get_int("safemerge", 0) ){ | |
| 71 | - fossil_fatal("you have uncommitted changes and safemerge is enabled"); | |
| 76 | + if( !forceFlag && db_get_int("safemerge", 0) && unsaved_changes() ){ | |
| 77 | + fossil_fatal("there are uncommitted changes and safemerge is enabled"); | |
| 72 | 78 | } |
| 73 | - | |
| 79 | + | |
| 74 | 80 | if( g.argc==3 ){ |
| 75 | 81 | tid = name_to_rid(g.argv[2]); |
| 76 | 82 | if( tid==0 ){ |
| 77 | 83 | fossil_fatal("not a version: %s", g.argv[2]); |
| 78 | 84 | } |
| @@ -231,11 +237,11 @@ | ||
| 231 | 237 | } |
| 232 | 238 | |
| 233 | 239 | /* |
| 234 | 240 | ** COMMAND: revert |
| 235 | 241 | ** |
| 236 | -** Usage: %fossil revert ?-yes ?-r REVISION FILE | |
| 242 | +** Usage: %fossil revert ?--yes? ?-r REVISION? FILE | |
| 237 | 243 | ** |
| 238 | 244 | ** Revert to the current repository version of FILE. This |
| 239 | 245 | ** command will confirm your operation, unless you do so |
| 240 | 246 | ** at the command line via the -yes option. |
| 241 | 247 | **/ |
| @@ -261,11 +267,12 @@ | ||
| 261 | 267 | if( !file_tree_name(zFile, &fname) ){ |
| 262 | 268 | fossil_panic("unknown file: %s", zFile); |
| 263 | 269 | } |
| 264 | 270 | |
| 265 | 271 | if( yesRevert==0 ){ |
| 266 | - char *prompt = mprintf("revert file %B? this will destroy local changes [y/N]? ", | |
| 272 | + char *prompt = mprintf("revert file %B? this will" | |
| 273 | + " destroy local changes [y/N]? ", | |
| 267 | 274 | &fname); |
| 268 | 275 | blob_zero(&ans); |
| 269 | 276 | prompt_user(prompt, &ans); |
| 270 | 277 | if( blob_str(&ans)[0]=='y' ){ |
| 271 | 278 | yesRevert = 1; |
| 272 | 279 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -36,28 +36,34 @@ | |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | ** COMMAND: update |
| 40 | ** |
| 41 | ** Usage: %fossil update ?VERSION? |
| 42 | ** |
| 43 | ** The optional argument is a version that should become the current |
| 44 | ** version. If the argument is omitted, then use the leaf of the |
| 45 | ** tree that begins with the current version, if there is only a |
| 46 | ** single leaf. |
| 47 | ** |
| 48 | ** This command is different from the "checkout" in that edits are |
| 49 | ** not overwritten. Edits are merged into the new version. |
| 50 | ** |
| 51 | */ |
| 52 | void update_cmd(void){ |
| 53 | int vid; /* Current version */ |
| 54 | int tid=0; /* Target version - version we are changing to */ |
| 55 | Stmt q; |
| 56 | int latestFlag; /* Pick the latest version if true */ |
| 57 | |
| 58 | latestFlag = find_option("latest",0, 0)!=0; |
| 59 | if( g.argc!=3 && g.argc!=2 ){ |
| 60 | usage("?VERSION?"); |
| 61 | } |
| 62 | db_must_be_within_tree(); |
| 63 | vid = db_lget_int("checkout", 0); |
| @@ -65,14 +71,14 @@ | |
| 65 | fossil_fatal("cannot find current version"); |
| 66 | } |
| 67 | if( db_exists("SELECT 1 FROM vmerge") ){ |
| 68 | fossil_fatal("cannot update an uncommitted merge"); |
| 69 | } |
| 70 | if( unsaved_changes() && db_get_int("safemerge", 0) ){ |
| 71 | fossil_fatal("you have uncommitted changes and safemerge is enabled"); |
| 72 | } |
| 73 | |
| 74 | if( g.argc==3 ){ |
| 75 | tid = name_to_rid(g.argv[2]); |
| 76 | if( tid==0 ){ |
| 77 | fossil_fatal("not a version: %s", g.argv[2]); |
| 78 | } |
| @@ -231,11 +237,11 @@ | |
| 231 | } |
| 232 | |
| 233 | /* |
| 234 | ** COMMAND: revert |
| 235 | ** |
| 236 | ** Usage: %fossil revert ?-yes ?-r REVISION FILE |
| 237 | ** |
| 238 | ** Revert to the current repository version of FILE. This |
| 239 | ** command will confirm your operation, unless you do so |
| 240 | ** at the command line via the -yes option. |
| 241 | **/ |
| @@ -261,11 +267,12 @@ | |
| 261 | if( !file_tree_name(zFile, &fname) ){ |
| 262 | fossil_panic("unknown file: %s", zFile); |
| 263 | } |
| 264 | |
| 265 | if( yesRevert==0 ){ |
| 266 | char *prompt = mprintf("revert file %B? this will destroy local changes [y/N]? ", |
| 267 | &fname); |
| 268 | blob_zero(&ans); |
| 269 | prompt_user(prompt, &ans); |
| 270 | if( blob_str(&ans)[0]=='y' ){ |
| 271 | yesRevert = 1; |
| 272 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -36,28 +36,34 @@ | |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | ** COMMAND: update |
| 40 | ** |
| 41 | ** Usage: %fossil update ?VERSION? ?--force? ?--latest? |
| 42 | ** |
| 43 | ** The optional argument is a version that should become the current |
| 44 | ** version. If the argument is omitted, then use the leaf of the |
| 45 | ** tree that begins with the current version, if there is only a |
| 46 | ** single leaf. If there are a multiple leaves, the latest is used |
| 47 | ** if the --latest flag is present. |
| 48 | ** |
| 49 | ** This command is different from the "checkout" in that edits are |
| 50 | ** not overwritten. Edits are merged into the new version. |
| 51 | ** |
| 52 | ** If there are uncommitted edits and the safemerge option is |
| 53 | ** enabled then no update will occur unless you provide the |
| 54 | ** --force flag. |
| 55 | */ |
| 56 | void update_cmd(void){ |
| 57 | int vid; /* Current version */ |
| 58 | int tid=0; /* Target version - version we are changing to */ |
| 59 | Stmt q; |
| 60 | int latestFlag; /* Pick the latest version if true */ |
| 61 | int forceFlag; /* True force the update */ |
| 62 | |
| 63 | latestFlag = find_option("latest",0, 0)!=0; |
| 64 | forceFlag = find_option("force","f",0)!=0; |
| 65 | if( g.argc!=3 && g.argc!=2 ){ |
| 66 | usage("?VERSION?"); |
| 67 | } |
| 68 | db_must_be_within_tree(); |
| 69 | vid = db_lget_int("checkout", 0); |
| @@ -65,14 +71,14 @@ | |
| 71 | fossil_fatal("cannot find current version"); |
| 72 | } |
| 73 | if( db_exists("SELECT 1 FROM vmerge") ){ |
| 74 | fossil_fatal("cannot update an uncommitted merge"); |
| 75 | } |
| 76 | if( !forceFlag && db_get_int("safemerge", 0) && unsaved_changes() ){ |
| 77 | fossil_fatal("there are uncommitted changes and safemerge is enabled"); |
| 78 | } |
| 79 | |
| 80 | if( g.argc==3 ){ |
| 81 | tid = name_to_rid(g.argv[2]); |
| 82 | if( tid==0 ){ |
| 83 | fossil_fatal("not a version: %s", g.argv[2]); |
| 84 | } |
| @@ -231,11 +237,11 @@ | |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | ** COMMAND: revert |
| 241 | ** |
| 242 | ** Usage: %fossil revert ?--yes? ?-r REVISION? FILE |
| 243 | ** |
| 244 | ** Revert to the current repository version of FILE. This |
| 245 | ** command will confirm your operation, unless you do so |
| 246 | ** at the command line via the -yes option. |
| 247 | **/ |
| @@ -261,11 +267,12 @@ | |
| 267 | if( !file_tree_name(zFile, &fname) ){ |
| 268 | fossil_panic("unknown file: %s", zFile); |
| 269 | } |
| 270 | |
| 271 | if( yesRevert==0 ){ |
| 272 | char *prompt = mprintf("revert file %B? this will" |
| 273 | " destroy local changes [y/N]? ", |
| 274 | &fname); |
| 275 | blob_zero(&ans); |
| 276 | prompt_user(prompt, &ans); |
| 277 | if( blob_str(&ans)[0]=='y' ){ |
| 278 | yesRevert = 1; |
| 279 |