Fossil SCM

Cleanup of the safemerge flag on update. Override available using the --force option.

drh 2007-09-26 16:20 trunk
Commit 7eecb079ed3c029eb31e6038e14bdd13f6592ece
1 file changed +14 -7
+14 -7
--- src/update.c
+++ src/update.c
@@ -36,28 +36,34 @@
3636
}
3737
3838
/*
3939
** COMMAND: update
4040
**
41
-** Usage: %fossil update ?VERSION?
41
+** Usage: %fossil update ?VERSION? ?--force? ?--latest?
4242
**
4343
** The optional argument is a version that should become the current
4444
** version. If the argument is omitted, then use the leaf of the
4545
** 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.
4748
**
4849
** This command is different from the "checkout" in that edits are
4950
** not overwritten. Edits are merged into the new version.
5051
**
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.
5155
*/
5256
void update_cmd(void){
5357
int vid; /* Current version */
5458
int tid=0; /* Target version - version we are changing to */
5559
Stmt q;
5660
int latestFlag; /* Pick the latest version if true */
61
+ int forceFlag; /* True force the update */
5762
5863
latestFlag = find_option("latest",0, 0)!=0;
64
+ forceFlag = find_option("force","f",0)!=0;
5965
if( g.argc!=3 && g.argc!=2 ){
6066
usage("?VERSION?");
6167
}
6268
db_must_be_within_tree();
6369
vid = db_lget_int("checkout", 0);
@@ -65,14 +71,14 @@
6571
fossil_fatal("cannot find current version");
6672
}
6773
if( db_exists("SELECT 1 FROM vmerge") ){
6874
fossil_fatal("cannot update an uncommitted merge");
6975
}
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");
7278
}
73
-
79
+
7480
if( g.argc==3 ){
7581
tid = name_to_rid(g.argv[2]);
7682
if( tid==0 ){
7783
fossil_fatal("not a version: %s", g.argv[2]);
7884
}
@@ -231,11 +237,11 @@
231237
}
232238
233239
/*
234240
** COMMAND: revert
235241
**
236
-** Usage: %fossil revert ?-yes ?-r REVISION FILE
242
+** Usage: %fossil revert ?--yes? ?-r REVISION? FILE
237243
**
238244
** Revert to the current repository version of FILE. This
239245
** command will confirm your operation, unless you do so
240246
** at the command line via the -yes option.
241247
**/
@@ -261,11 +267,12 @@
261267
if( !file_tree_name(zFile, &fname) ){
262268
fossil_panic("unknown file: %s", zFile);
263269
}
264270
265271
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]? ",
267274
&fname);
268275
blob_zero(&ans);
269276
prompt_user(prompt, &ans);
270277
if( blob_str(&ans)[0]=='y' ){
271278
yesRevert = 1;
272279
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button