Patchwork [4,of,4] histedit: inline cleanupnode

login
register
mail settings
Submitter Jun Wu
Date March 14, 2017, 5:36 a.m.
Message ID <c8fd15f1632259900b87.1489469779@localhost.localdomain>
Download mbox | patch
Permalink /patch/19327/
State Superseded
Headers show

Comments

Jun Wu - March 14, 2017, 5:36 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1489469407 25200
#      Mon Mar 13 22:30:07 2017 -0700
# Node ID c8fd15f1632259900b87f6df61211e94b2eb3637
# Parent  0993e7596542d0e29532f949bc4a59a3075c123b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r c8fd15f16322
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.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1544,26 +1544,4 @@  def movebookmarks(ui, repo, mapping, old
             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
@@ -1589,5 +1567,21 @@  def safecleanupnode(ui, repo, name, node
             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):