# HG changeset patch # User Boris Feld # Date 1546401675 -3600 # Node ID 399010051cf4e83ea3c0ebeab95af2ddbe291c7b # Parent e80329a3952c9c6db63838d2fa50b534f941fcb2 strip: extract code to create strip backup We will reuse this for soft stripping. diff -r e80329a3952c -r 399010051cf4 mercurial/repair.py --- a/mercurial/repair.py Wed Jan 02 04:57:47 2019 +0100 +++ b/mercurial/repair.py Wed Jan 02 05:01:15 2019 +0100 @@ -168,15 +168,10 @@ if rev in tostrip: updatebm.append(m) - # backup the changeset we are about to strip backupfile = None node = nodelist[-1] if backup: - backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic) - repo.ui.status(_("saved backup bundle to %s\n") % - vfs.join(backupfile)) - repo.ui.log("backupbundle", "saved backup bundle to %s\n", - vfs.join(backupfile)) + backupfile = _createstripbackup(repo, stripbases, node, topic) # create a changegroup for all the branches we need to keep tmpbundlefile = None if saveheads: @@ -270,6 +265,17 @@ # extensions can use it return backupfile +def _createstripbackup(repo, stripbases, node, topic): + # backup the changeset we are about to strip + vfs = repo.vfs + cl = repo.changelog + backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic) + repo.ui.status(_("saved backup bundle to %s\n") % + vfs.join(backupfile)) + repo.ui.log("backupbundle", "saved backup bundle to %s\n", + vfs.join(backupfile)) + return backupfile + def safestriproots(ui, repo, nodes): """return list of roots of nodes where descendants are covered by nodes""" torev = repo.unfiltered().changelog.rev