Allow import --no-commit over an applied MQ patch.
authorBrendan Cully <brendan@kublai.com>
Mon, 16 Nov 2009 11:31:08 -0800
changeset 9867 81f1462ef2c7
parent 9861 0262bb59016f
child 9868 c02445cd1b50
Allow import --no-commit over an applied MQ patch. Since it only changes the working directory, it does not matter whether a patch is applied. This change makes it easier to use hg import --no-commit instead of patch.
hgext/mq.py
tests/test-mq
tests/test-mq.out
--- a/hgext/mq.py	Mon Nov 16 13:35:36 2009 +0100
+++ b/hgext/mq.py	Mon Nov 16 11:31:08 2009 -0800
@@ -2550,7 +2550,7 @@
         repo.__class__ = mqrepo
 
 def mqimport(orig, ui, repo, *args, **kwargs):
-    if hasattr(repo, 'abort_if_wdir_patched'):
+    if hasattr(repo, 'abort_if_wdir_patched') and not kwargs.get('no_commit', False):
         repo.abort_if_wdir_patched(_('cannot import over an applied patch'),
                                    kwargs.get('force'))
     return orig(ui, repo, *args, **kwargs)
--- a/tests/test-mq	Mon Nov 16 13:35:36 2009 +0100
+++ b/tests/test-mq	Mon Nov 16 11:31:08 2009 -0800
@@ -175,6 +175,10 @@
 hg revert --no-backup ../a
 hg import ../../import.diff
 hg st
+echo % import --no-commit should succeed
+hg import --no-commit ../../import.diff
+hg st
+hg revert --no-backup ../a
 
 echo % qunapplied
 hg qunapplied
--- a/tests/test-mq.out	Mon Nov 16 13:35:36 2009 +0100
+++ b/tests/test-mq.out	Mon Nov 16 11:31:08 2009 -0800
@@ -154,6 +154,9 @@
 abort: source has mq patches applied
 % import should fail
 abort: cannot import over an applied patch
+% import --no-commit should succeed
+applying ../../import.diff
+M a
 % qunapplied
 test2.patch
 % qpush/qpop with index