Diff
Not logged in

Differences From:

File src/checkin.c part of check-in [a36177bcce] - Add the "undo" and "redo" commands. Untested at this point so don't try to use them yet. by drh on 2007-09-11 02:25:19. Also file src/checkin.c part of check-in [f76192b245] - Pulled the latest CLI, website, and sqlite changes into the importer branch. by aku on 2007-09-17 01:00:32. [view]

To:

File src/checkin.c part of check-in [371dd6574c] - Fix the revert command so that it works from subdirectories. Other minor comment and help-text changes. by drh on 2007-12-04 01:26:21. Also file src/checkin.c part of check-in [d0305b305a] - Merged mainline into my branch to get the newest application. by aku on 2007-12-05 08:07:46. [view]

@@ -45,10 +45,13 @@
     const char *zPathname = db_column_text(&q,0);
     int isDeleted = db_column_int(&q, 1);
     int isChnged = db_column_int(&q,2);
     int isNew = db_column_int(&q,3)==0;
+    char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname);
     blob_append(report, zPrefix, nPrefix);
-    if( isNew ){
+    if( access(zFullName, 0) ){
+      blob_appendf(report, "MISSING  %s\n", zPathname);
+    }else if( isNew ){
       blob_appendf(report, "ADDED    %s\n", zPathname);
     }else if( isDeleted ){
       blob_appendf(report, "DELETED  %s\n", zPathname);
     }else if( isChnged==2 ){
@@ -57,8 +60,9 @@
       blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname);
     }else{
       blob_appendf(report, "EDITED   %s\n", zPathname);
     }
+    free(zFullName);
   }
   db_finalize(&q);
   db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid"
                  " WHERE id=0");
@@ -163,16 +167,22 @@
 }
 
 /*
 ** COMMAND: clean
-** Usage: %fossil clean
+** Usage: %fossil clean ?-all
 ** Delete all "extra" files in the source tree.  "Extra" files are
 ** files that are not officially part of the checkout.  See also
-** the "extra" command.
+** the "extra" command. This operation cannot be undone.
+**
+** You will be prompted before removing each file. If you are
+** sure you wish to remove all "extra" files you can specify the
+** optional -all flag.
 */
 void clean_cmd(void){
+  int allFlag;
   Blob path;
   Stmt q;
+  allFlag = find_option("all","a",0)!=0;
   db_must_be_within_tree();
   db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
   chdir(g.zLocalRoot);
   blob_zero(&path);
@@ -181,9 +191,20 @@
       "SELECT %Q || x FROM sfile"
       " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
       " ORDER BY 1", g.zLocalRoot);
   while( db_step(&q)==SQLITE_ROW ){
-    unlink(db_column_text(&q, 0));
+    if( allFlag ){
+      unlink(db_column_text(&q, 0));
+    }else{
+      Blob ans;
+      char *prompt = mprintf("remove unmanaged file \"%s\" [y/N]? ",
+                              db_column_text(&q, 0));
+      blob_zero(&ans);
+      prompt_user(prompt, &ans);
+      if( blob_str(&ans)[0]=='y' ){
+        unlink(db_column_text(&q, 0));
+      }
+    }
   }
   db_finalize(&q);
 }
 
@@ -206,9 +227,9 @@
     "\n# Enter comments on this commit.  Lines beginning with # are ignored\n"
     "#\n"
   );
   status_report(&text, "# ");
-  zEditor = db_global_get("editor", 0);
+  zEditor = db_get("editor", 0);
   if( zEditor==0 ){
     zEditor = getenv("VISUAL");
   }
   if( zEditor==0 ){
@@ -219,9 +240,9 @@
   }
   zFile = db_text(0, "SELECT '%qci-comment-' || hex(randomblob(6)) || '.txt'",
                    g.zLocalRoot);
   blob_write_to_file(&text, zFile);
-  zCmd = mprintf("%s %s", zEditor, zFile);
+  zCmd = mprintf("%s \"%s\"", zEditor, zFile);
   printf("%s\n", zCmd);
   if( system(zCmd) ){
     fossil_panic("editor aborted");
   }
@@ -299,16 +320,17 @@
 ** on the command line.
 */
 void commit_cmd(void){
   int rc;
-  int vid, nrid, nvid;
+  int vid, nrid, nvid, wouldFork=0;
   Blob comment;
   const char *zComment;
   Stmt q;
   Stmt q2;
   char *zUuid, *zDate;
   int noSign = 0;        /* True to omit signing the manifest using GPG */
   int isAMerge = 0;      /* True if checking in a merge */
+  int forceFlag = 0;     /* Force a fork */
   char *zManifestFile;   /* Name of the manifest file */
   Blob manifest;
   Blob muuid;            /* Manifest uuid */
   Blob mcksum;           /* Self-checksum on the manifest */
@@ -316,11 +338,17 @@
   Blob cksum1b;          /* Checksum recorded in the manifest */
 
   noSign = find_option("nosign","",0)!=0;
   zComment = find_option("comment","m",1);
+  forceFlag = find_option("force", "r", 0)!=0;
   db_must_be_within_tree();
-  noSign = db_get_int("omit-ci-sig", 0)|noSign;
+  noSign = db_get_int("omitsign", 0)|noSign;
   verify_all_options();
+
+  /*
+  ** Autosync if requested.
+  */
+  autosync(1);
 
   /* There are two ways this command may be executed. If there are
   ** no arguments following the word "commit", then all modified files
   ** in the checked out directory are committed. If one or more arguments
@@ -339,9 +367,9 @@
 
   user_select();
   db_begin_transaction();
   rc = unsaved_changes();
-  if( rc==0 && !isAMerge ){
+  if( rc==0 && !isAMerge && !forceFlag ){
     fossil_panic("nothing has changed");
   }
 
   /* If one or more files that were named on the command line have not
@@ -359,8 +387,14 @@
     }
   }
 
   vid = db_lget_int("checkout", 0);
+  if( db_exists("SELECT 1 FROM plink WHERE pid=%d", vid) ){
+    wouldFork=1;
+    if( forceFlag==0 && db_get_int("safemerge", 0)==0 ){
+      fossil_fatal("would fork.  use -f or --force");
+    }
+  }
   vfile_aggregate_checksum_disk(vid, &cksum1);
   if( zComment ){
     blob_zero(&comment);
     blob_append(&comment, zComment, -1);
@@ -507,5 +541,17 @@
   undo_reset();
 
   /* Commit */
   db_end_transaction(0);
+
+  if( wouldFork==0 ){
+    /* Do an autosync push if requested. If wouldFork == 1, then they either
+    ** forced this commit or safe merge is on, and this commit did indeed
+    ** create a fork. In this case, we want the user to merge before sending
+    ** their new commit back to the rest of the world, so do not auto-push.
+    */
+    autosync(0);
+  }else{
+    printf("Warning: commit caused a fork to occur. Please merge and push\n");
+    printf("         your changes as soon as possible.\n");
+  }
 }