changeset 13520:9510ddf87c43 stable

mq: forbid commit of merge involving mq patches
author Martin Geisler <mg@aragost.com>
date Wed, 02 Mar 2011 14:09:06 +0100
parents da192c62f89e
children 644166163116 8ac1260941c0
files hgext/mq.py tests/test-mq-merge.t
diffstat 2 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Tue Mar 01 16:01:38 2011 -0600
+++ b/hgext/mq.py	Wed Mar 02 14:09:06 2011 +0100
@@ -2921,8 +2921,9 @@
 
         def abort_if_wdir_patched(self, errmsg, force=False):
             if self.mq.applied and not force:
-                parent = self.dirstate.parents()[0]
-                if parent in [s.node for s in self.mq.applied]:
+                parents = self.dirstate.parents()
+                patches = [s.node for s in self.mq.applied]
+                if parents[0] in patches or parents[1] in patches:
                     raise util.Abort(errmsg)
 
         def commit(self, text="", user=None, date=None, match=None,
--- a/tests/test-mq-merge.t	Tue Mar 01 16:01:38 2011 -0600
+++ b/tests/test-mq-merge.t	Wed Mar 02 14:09:06 2011 +0100
@@ -1,3 +1,32 @@
+Setup extension:
+
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "mq =" >> $HGRCPATH
+  $ echo "[mq]" >> $HGRCPATH
+  $ echo "git = keep" >> $HGRCPATH
+
+Test merge with mq changeset as the second parent:
+
+  $ hg init m
+  $ cd m
+  $ touch a b c
+  $ hg add a
+  $ hg commit -m a
+  $ hg add b
+  $ hg qnew -d "0 0" b
+  $ hg update 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg add c
+  $ hg commit -m c
+  created new head
+  $ hg merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg commit -m merge
+  abort: cannot commit over an applied mq patch
+  [255]
+  $ cd ..
+
 Issue529: mq aborts when merging patch deleting files
 
   $ checkundo()
@@ -7,11 +36,6 @@
   >     fi
   > }
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "mq =" >> $HGRCPATH
-  $ echo "[mq]" >> $HGRCPATH
-  $ echo "git = keep" >> $HGRCPATH
-
 Commit two dummy files in "init" changeset:
 
   $ hg init t