histedit: inline cleanupnode
authorJun Wu <quark@fb.com>
Mon, 13 Mar 2017 22:30:07 -0700
changeset 31528 2b599f5468a4
parent 31527 6f0b7475cf9a
child 31529 61ff3852f6ed
histedit: inline cleanupnode Move "cleanupnode" (unsafe strip) into "safecleanupnode" so it's impossible to call the unsafe function directly. This helps reduce future programming errors.
hgext/histedit.py
--- a/hgext/histedit.py	Mon Mar 13 22:22:18 2017 -0700
+++ b/hgext/histedit.py	Mon Mar 13 22:30:07 2017 -0700
@@ -1580,28 +1580,6 @@
         finally:
             release(tr, lock)
 
-def cleanupnode(ui, repo, name, nodes):
-    """strip a group of nodes from the repository
-
-    The set of node to strip may contains unknown nodes."""
-    ui.debug('should strip %s nodes %s\n' %
-             (name, ', '.join([node.short(n) for n in nodes])))
-    with repo.lock():
-        # do not let filtering get in the way of the cleanse
-        # we should probably get rid of obsolescence marker created during the
-        # histedit, but we currently do not have such information.
-        repo = repo.unfiltered()
-        # Find all nodes that need to be stripped
-        # (we use %lr instead of %ln to silently ignore unknown items)
-        nm = repo.changelog.nodemap
-        nodes = sorted(n for n in nodes if n in nm)
-        roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
-        for c in roots:
-            # We should process node in reverse order to strip tip most first.
-            # but this trigger a bug in changegroup hook.
-            # This would reduce bundle overhead
-            repair.strip(ui, repo, c)
-
 def safecleanupnode(ui, repo, name, nodes):
     """strip or obsolete nodes
 
@@ -1628,7 +1606,23 @@
         if markers:
             obsolete.createmarkers(repo, markers)
     else:
-        return cleanupnode(ui, repo, name, nodes)
+        ui.debug('should strip %s nodes %s\n' %
+                 (name, ', '.join([node.short(n) for n in nodes])))
+        with repo.lock():
+            # Do not let filtering get in the way of the cleanse we should
+            # probably get rid of obsolescence marker created during the
+            # histedit, but we currently do not have such information.
+            repo = repo.unfiltered()
+            # Find all nodes that need to be stripped
+            # (we use %lr instead of %ln to silently ignore unknown items)
+            nm = repo.changelog.nodemap
+            nodes = sorted(n for n in nodes if n in nm)
+            roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
+            for c in roots:
+                # We should process node in reverse order to strip tip most
+                # first, but this trigger a bug in changegroup hook. This
+                # would reduce bundle overhead
+                repair.strip(ui, repo, c)
 
 def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs):
     if isinstance(nodelist, str):