# HG changeset patch # User Jun Wu <qu...@fb.com> # Date 1489469407 25200 # Mon Mar 13 22:30:07 2017 -0700 # Node ID 20c997a9d3dc9bc82fc2146316baac14c23d4ae6 # Parent 68d4ace59316593d06c4bd2ec088178df6304a28 # Available At https://bitbucket.org/quark-zju/hg-draft # hg pull https://bitbucket.org/quark-zju/hg-draft -r 20c997a9d3dc 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. diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -1581,26 +1581,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 @@ -1629,5 +1607,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): _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel