Check-in [7eecb079ed]
Not logged in
Overview

SHA1 Hash:7eecb079ed3c029eb31e6038e14bdd13f6592ece
Date: 2007-09-26 16:20:41
User: drh
Comment:Cleanup of the safemerge flag on update. Override available using the --force option.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/update.c from [ca0677b5f7] to [abfa21b27a].

@@ -36,28 +36,34 @@
 }
 
 /*
 ** COMMAND: update
 **
-** Usage: %fossil update ?VERSION?
+** Usage: %fossil update ?VERSION? ?--force? ?--latest?
 **
 ** The optional argument is a version that should become the current
 ** version.  If the argument is omitted, then use the leaf of the
 ** tree that begins with the current version, if there is only a
-** single leaf.
+** single leaf.  If there are a multiple leaves, the latest is used
+** if the --latest flag is present.
 **
 ** This command is different from the "checkout" in that edits are
 ** not overwritten.  Edits are merged into the new version.
 **
+** If there are uncommitted edits and the safemerge option is
+** enabled then no update will occur unless you provide the
+** --force flag.
 */
 void update_cmd(void){
   int vid;              /* Current version */
   int tid=0;            /* Target version - version we are changing to */
   Stmt q;
   int latestFlag;       /* Pick the latest version if true */
+  int forceFlag;        /* True force the update */
 
   latestFlag = find_option("latest",0, 0)!=0;
+  forceFlag = find_option("force","f",0)!=0;
   if( g.argc!=3 && g.argc!=2 ){
     usage("?VERSION?");
   }
   db_must_be_within_tree();
   vid = db_lget_int("checkout", 0);
@@ -65,12 +71,12 @@
     fossil_fatal("cannot find current version");
   }
   if( db_exists("SELECT 1 FROM vmerge") ){
     fossil_fatal("cannot update an uncommitted merge");
   }
-  if( unsaved_changes() && db_get_int("safemerge", 0) ){
-    fossil_fatal("you have uncommitted changes and safemerge is enabled");
+  if( !forceFlag && db_get_int("safemerge", 0) && unsaved_changes() ){
+    fossil_fatal("there are uncommitted changes and safemerge is enabled");
   }
 
   if( g.argc==3 ){
     tid = name_to_rid(g.argv[2]);
     if( tid==0 ){
@@ -231,11 +237,11 @@
 }
 
 /*
 ** COMMAND: revert
 **
-** Usage: %fossil revert ?-yes ?-r REVISION FILE
+** Usage: %fossil revert ?--yes? ?-r REVISION? FILE
 **
 ** Revert to the current repository version of FILE. This
 ** command will confirm your operation, unless you do so
 ** at the command line via the -yes option.
 **/
@@ -261,11 +267,12 @@
   if( !file_tree_name(zFile, &fname) ){
     fossil_panic("unknown file: %s", zFile);
   }
 
   if( yesRevert==0 ){
-    char *prompt = mprintf("revert file %B? this will destroy local changes [y/N]? ",
+    char *prompt = mprintf("revert file %B? this will"
+                           " destroy local changes [y/N]? ",
                            &fname);
     blob_zero(&ans);
     prompt_user(prompt, &ans);
     if( blob_str(&ans)[0]=='y' ){
       yesRevert = 1;