hg import: abort with uncommitted changes, override with --force
authormpm@selenic.com
Fri, 19 Aug 2005 23:07:31 -0800
changeset 966 022bcc738389
parent 965 a425123e6afe
child 967 1f3710636b45
hg import: abort with uncommitted changes, override with --force
doc/hg.1.txt
mercurial/commands.py
--- a/doc/hg.1.txt	Fri Aug 19 22:48:43 2005 -0800
+++ b/doc/hg.1.txt	Fri Aug 19 23:07:31 2005 -0800
@@ -188,13 +188,14 @@
 
     aliases: id
 
-import [-p <n> -b <base> -q] <patches>::
+import [-p <n> -b <base> -f] <patches>::
     Import a list of patches and commit them individually.
 
     options:
     -p, --strip <n>   directory strip option for patch. This has the same
                       meaning as the correnponding patch option
     -b <path>         base directory to read patches from
+    -f, --force	      skip check for outstanding uncommitted changes
 
     aliases: patch
 
--- a/mercurial/commands.py	Fri Aug 19 22:48:43 2005 -0800
+++ b/mercurial/commands.py	Fri Aug 19 23:07:31 2005 -0800
@@ -737,6 +737,12 @@
     """import an ordered set of patches"""
     patches = (patch1,) + patches
 
+    if not opts['force']:
+        (c, a, d, u) = repo.changes()
+        if c or a or d:
+            ui.warn("abort: outstanding uncommitted changes!\n")
+            return 1
+
     d = opts["base"]
     strip = opts["strip"]
 
@@ -1329,6 +1335,7 @@
     "import|patch":
         (import_,
          [('p', 'strip', 1, 'path strip'),
+          ('f', 'force', None, 'skip check for outstanding changes'),
           ('b', 'base', "", 'base path')],
          "hg import [-p NUM] [-b BASE] PATCH..."),
     "incoming|in": (incoming, [], 'hg incoming [SOURCE]'),