changeset 41100:399010051cf4

strip: extract code to create strip backup We will reuse this for soft stripping.
author Boris Feld <boris.feld@octobus.net>
date Wed, 02 Jan 2019 05:01:15 +0100
parents e80329a3952c
children f04e0ca04099
files mercurial/repair.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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