absorb: be more specific when erroring out on merge commit
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 08 May 2019 21:25:23 -0700
changeset 42266 b3fc78c028ef
parent 42265 65f3a77223e0
child 42267 838f3a094b4f
absorb: be more specific when erroring out on merge commit When you have a merge commit checked out and run `hg absorb`, it would tell you abort: no mutable changeset to change That makes it sound like the problem is public commits when isn't really. Let's be more specific in this case. There was already a test case that test this, so that now prints the new message. I added a new test case that shows the old message (when a public commit is checked out). Differential Revision: https://phab.mercurial-scm.org/D6354
hgext/absorb.py
tests/test-absorb.t
--- a/hgext/absorb.py	Wed May 08 18:11:33 2019 -0400
+++ b/hgext/absorb.py	Wed May 08 21:25:23 2019 -0700
@@ -914,7 +914,10 @@
     """
     if stack is None:
         limit = ui.configint('absorb', 'max-stack-size')
-        stack = getdraftstack(repo['.'], limit)
+        headctx = repo['.']
+        if len(headctx.parents()) > 1:
+            raise error.Abort(_('cannot absorb into a merge'))
+        stack = getdraftstack(headctx, limit)
         if limit and len(stack) >= limit:
             ui.warn(_('absorb: only the recent %d changesets will '
                       'be analysed\n')
--- a/tests/test-absorb.t	Wed May 08 18:11:33 2019 -0400
+++ b/tests/test-absorb.t	Wed May 08 21:25:23 2019 -0700
@@ -176,7 +176,7 @@
      b2                        2:c9b20c925790
    * ba                        2:c9b20c925790
 
-Non-mofified files are ignored:
+Non-modified files are ignored:
 
   $ touch b
   $ hg commit -A b -m b
@@ -225,10 +225,15 @@
   2: 4d
   2: insert aftert 4d
 
+  $ hg co -qC 1
+  $ sedi 's/Insert/insert/' a
+  $ hg absorb --apply-changes
+  abort: no mutable changeset to change
+  [255]
+
 Make working copy clean:
 
-  $ hg revert -q -C a b
-  $ hg forget c
+  $ hg co -qC ba
   $ rm c
   $ hg status
 
@@ -261,7 +266,7 @@
   $ echo 2 >> m1
   $ echo 2 >> m2
   $ hg absorb --apply-changes
-  abort: no mutable changeset to change
+  abort: cannot absorb into a merge
   [255]
   $ hg revert -q -C m1 m2