[PATCH] Allow import --no-commit over an applied MQ patch

Brendan Cully brendan at kublai.com
Fri Nov 13 18:07:38 CST 2009


# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1258156906 28800
# Node ID 9bc9a3133947bd7c656d8668f7c1ef2562d1d855
# Parent  ed362d41d1f636a2029e53dfb0fb28ff8a154d86
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.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -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)
diff --git a/tests/test-mq b/tests/test-mq
--- a/tests/test-mq
+++ b/tests/test-mq
@@ -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
diff --git a/tests/test-mq.out b/tests/test-mq.out
--- a/tests/test-mq.out
+++ b/tests/test-mq.out
@@ -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


More information about the Mercurial-devel mailing list