[PATCH 3 of 8 evolve-ext, V2] metaedit: extend the functionality to support editing multiple commits

Mateusz Kwapich mitrandir at fb.com
Tue Dec 6 11:41:12 EST 2016


# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1481029159 28800
#      Tue Dec 06 04:59:19 2016 -0800
# Branch stable
# Node ID 2495e78f6db6bb8d885121c45c16b9ba9266d1a1
# Parent  b8cbdf6356d770b70df92b13095c11438b8ad1a1
metaedit: extend the functionality to support editing multiple commits

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -3282,17 +3282,29 @@ def metaedit(ui, repo, *revs, **opts):
                 else:
                     ui.status(_("nothing changed\n"))
             else:
-                if commitopts['edit']:
-                    commitopts['message'] = head.description()
-                newid, created = rewrite(repo, root, allctx, head,
-                                         [root.p1().node(), root.p2().node()],
-                                         commitopts=commitopts)
-                if created:
-                    if p1.rev() in revs:
-                        newp1 = newid
-                    phases.retractboundary(repo, tr, targetphase, [newid])
-                    obsolete.createmarkers(repo, [(ctx, (repo[newid],))
-                                                  for ctx in allctx])
+                replacemap = {}
+                # we need topological order
+                allctx = sorted(allctx, key=lambda c: c.rev())
+                for c in allctx:
+                    if commitopts['edit']:
+                        commitopts['message'] = \
+                            "HG: Commit message of changeset %s\n%s" %\
+                            (str(c), c.description())
+                    bases = [
+                        replacemap.get(c.p1().node(), c.p1().node()),
+                        replacemap.get(c.p2().node(), c.p2().node()),
+                    ]
+                    newid, created = metarewrite(repo, c, bases,
+                                                 commitopts=commitopts)
+                    if created:
+                        replacemap[c.node()] = newid
+
+                if p1.node() in replacemap:
+                    newp1 = replacemap[p1.node()]
+                if len(replacemap) > 0:
+                    obsolete.createmarkers(repo, [(repo[old], (repo[new],))
+                        for old, new in replacemap.iteritems()])
+                    # TODO: set poroper phase boundaries
                 else:
                     ui.status(_("nothing changed\n"))
             tr.close()


More information about the Mercurial-devel mailing list