prune: use scmutil.cleanupnodes()
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 22 Jan 2019 10:17:58 -0800
changeset 4374 86bf0b106949
parent 4373 11bbf4dc694f
child 4375 07ccf1686024
prune: use scmutil.cleanupnodes()
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Jan 22 10:45:16 2019 -0800
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Jan 22 10:17:58 2019 -0800
@@ -1037,9 +1037,9 @@
             msg = "please add --fold if you want to do a fold"
             raise error.Abort(msg)
         elif biject:
-            relations = [(p, (s,)) for p, s in zip(precs, sucs)]
+            replacements = {p.node(): [s.node()] for p, s in zip(precs, sucs)}
         else:
-            relations = [(p, sucs) for p in precs]
+            replacements = {p.node(): [s.node() for s in sucs] for p in precs}
 
         wdp = repo['.']
 
@@ -1099,14 +1099,8 @@
         if opts.get('note'):
             metadata['note'] = opts['note']
 
-        # create markers
-        obsolete.createmarkers(repo, relations, metadata=metadata,
-                               operation="prune")
-
-        # informs that changeset have been pruned
-        ui.status(_('%i changesets pruned\n') % len(precs))
-
         precrevs = (precursor.rev() for precursor in precs)
+        moves = {}
         for ctx in repo.unfiltered().set('bookmark() and %ld', precrevs):
             # used to be:
             #
@@ -1117,11 +1111,14 @@
             # but then revset took a lazy arrow in the knee and became much
             # slower. The new forms makes as much sense and a much faster.
             for dest in ctx.ancestors():
-                if not dest.obsolete():
-                    bookmarksupdater = rewriteutil.bookmarksupdater
-                    updatebookmarks = bookmarksupdater(repo, ctx.node(), tr)
-                    updatebookmarks(dest.node())
+                if not dest.obsolete() and dest.node() not in replacements:
+                    moves[ctx.node()] = dest.node()
                     break
+        scmutil.cleanupnodes(repo, replacements, operation="prune", moves=moves,
+                             metadata=metadata)
+
+        # informs that changeset have been pruned
+        ui.status(_('%i changesets pruned\n') % len(precs))
 
         tr.close()
     finally: