Patchwork [4,of,7] strip: compute bookmark target only if we have bookmark to move

login
register
mail settings
Submitter Boris Feld
Date Jan. 2, 2019, 10:35 p.m.
Message ID <b2a59d144ba0849db830.1546468552@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37427/
State Accepted
Headers show

Comments

Boris Feld - Jan. 2, 2019, 10:35 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1546402023 -3600
#      Wed Jan 02 05:07:03 2019 +0100
# Node ID b2a59d144ba0849db8302ce92123b70cb2ba2dc6
# Parent  76e9f1990f18a4fe686c3689fa34f827d9318a53
# EXP-Topic archived-phase-UX
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b2a59d144ba0
strip: compute bookmark target only if we have bookmark to move

This is a small change that seems to make sense.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -153,20 +153,22 @@  def strip(ui, repo, nodelist, backup=Tru
         stripobsidx = [i for i, m in enumerate(repo.obsstore)
                        if m in obsmarkers]
 
-    # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but
-    # is much faster
-    newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
-    if newbmtarget:
-        newbmtarget = repo[newbmtarget.first()].node()
-    else:
-        newbmtarget = '.'
-
+    # compute necessary bookmark movement
     bm = repo._bookmarks
     updatebm = []
     for m in bm:
         rev = repo[bm[m]].rev()
         if rev in tostrip:
             updatebm.append(m)
+    newbmtarget = None
+    if updatebm: # don't compute anything is there is no bookmark to move anyway
+        # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)),
+        # but is much faster
+        newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
+        if newbmtarget:
+            newbmtarget = repo[newbmtarget.first()].node()
+        else:
+            newbmtarget = '.'
 
     backupfile = None
     node = nodelist[-1]