rewriteutil: allow rewriting merge commits (issue4561)
authorAnton Shestakov <av6@dwimlabs.net>
Tue, 09 Jul 2019 17:08:34 +0800
changeset 4710 0e0731406efd
parent 4709 cc3569da7150
child 4711 88c8ef4d703c
rewriteutil: allow rewriting merge commits (issue4561) This patch simply allows rewriteutil.rewrite() to work with commits with multiple parents (i.e. merges). That function is used in such commands as fold, metaedit, touch, rewind. The issue 4561 is marked as easy, the limitation is called unnecessary, no tests fail after this change. What can go wrong.
CHANGELOG
hgext3rd/evolve/rewriteutil.py
tests/test-touch.t
--- a/CHANGELOG	Tue Jul 09 17:02:44 2019 +0800
+++ b/CHANGELOG	Tue Jul 09 17:08:34 2019 +0800
@@ -8,6 +8,7 @@
   * evolve: minor output message improvements
   * evolve: improve `hg evolve --all` behavior when "." is obsolete
   * topic: fix confusion in branch heads checking logic
+  * touch: now works on merge commit too
 
 9.0.1 - in progress
 -------------------
--- a/hgext3rd/evolve/rewriteutil.py	Tue Jul 09 17:02:44 2019 +0800
+++ b/hgext3rd/evolve/rewriteutil.py	Tue Jul 09 17:08:34 2019 +0800
@@ -171,8 +171,6 @@
         wlock = repo.wlock()
         lock = repo.lock()
         tr = repo.transaction('rewrite')
-        if len(old.parents()) > 1: # XXX remove this unnecessary limitation.
-            raise error.Abort(_('cannot amend merge changesets'))
         base = old.p1()
         updatebookmarks = bookmarksupdater(repo, old.node(), tr)
 
--- a/tests/test-touch.t	Tue Jul 09 17:02:44 2019 +0800
+++ b/tests/test-touch.t	Tue Jul 09 17:08:34 2019 +0800
@@ -186,5 +186,11 @@
   working directory is now at * (glob)
   1 changesets pruned
   $ hg touch 16 --hidden
-  abort: cannot amend merge changesets
-  [255]
+  $ hg glog -r '12+15+17'
+  o    17: merge
+  |\
+  | o  15: ab
+  |
+  @  12: move
+  |
+  ~