strip: extract code to create strip backup
authorBoris Feld <boris.feld@octobus.net>
Wed, 02 Jan 2019 05:01:15 +0100
changeset 41100 399010051cf4
parent 41099 e80329a3952c
child 41101 f04e0ca04099
strip: extract code to create strip backup We will reuse this for soft stripping.
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