changeset 43599:1c91576b88bb

bookmarks: resolve target revision out of the bookmarks loop The target revision doesn't depend on the bookmark to be added.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Nov 2019 12:32:20 +0900
parents 2a8cd7edf409
children fe2e0d100187
files mercurial/bookmarks.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Sat Nov 09 12:09:50 2019 +0900
+++ b/mercurial/bookmarks.py	Sat Nov 09 12:32:20 2019 +0900
@@ -955,9 +955,14 @@
     changes = []
     hiddenrev = None
 
+    tgt = cur
     # unhide revs if any
     if rev:
         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
+        ctx = scmutil.revsingle(repo, rev)
+        if ctx.hidden():
+            hiddenrev = ctx.hex()[:12]
+        tgt = ctx.node()
 
     for mark in names:
         mark = checkformat(repo, mark)
@@ -966,12 +971,6 @@
         if inactive and mark == repo._activebookmark:
             deactivate(repo)
             continue
-        tgt = cur
-        if rev:
-            ctx = scmutil.revsingle(repo, rev)
-            if ctx.hidden():
-                hiddenrev = ctx.hex()[:12]
-            tgt = ctx.node()
         for bm in marks.checkconflict(mark, force, tgt):
             changes.append((bm, None))
         changes.append((mark, tgt))