import: let --exact 'work' with --no-commit (issue4376)
authorMatt Mackall <mpm@selenic.com>
Fri, 19 Sep 2014 14:51:58 -0500
changeset 22485 efedda4aed49
parent 22484 2b5940f64750
child 22486 f166e08ece3b
import: let --exact 'work' with --no-commit (issue4376)
mercurial/cmdutil.py
tests/test-impexp-branch.t
--- a/mercurial/cmdutil.py	Tue Sep 16 16:03:21 2014 -0700
+++ b/mercurial/cmdutil.py	Fri Sep 19 14:51:58 2014 -0500
@@ -727,7 +727,11 @@
                 n = memctx.commit()
             finally:
                 store.close()
-        if opts.get('exact') and hex(n) != nodeid:
+        if opts.get('exact') and opts.get('no_commit'):
+            # --exact with --no-commit is still useful in that it does merge
+            # and branch bits
+            ui.warn(_("warning: can't check exact import with --no-commit\n"))
+        elif opts.get('exact') and hex(n) != nodeid:
             raise util.Abort(_('patch is damaged or loses information'))
         if n:
             # i18n: refers to a short changeset id
--- a/tests/test-impexp-branch.t	Tue Sep 16 16:03:21 2014 -0700
+++ b/tests/test-impexp-branch.t	Fri Sep 19 14:51:58 2014 -0500
@@ -54,6 +54,14 @@
 
   $ hg init c
   $ cd c
+  $ hg import --exact --no-commit ../r0.patch
+  applying ../r0.patch
+  warning: can't check exact import with --no-commit
+  $ hg st
+  A rev
+  $ hg revert -a
+  forgetting rev
+  $ rm rev
   $ hg import --exact ../r0.patch
   applying ../r0.patch
   $ hg import --exact ../r1.patch