bookmarks: resolve target revision out of the bookmarks loop
authorYuya Nishihara <yuya@tcha.org>
Sat, 09 Nov 2019 12:32:20 +0900
changeset 43599 1c91576b88bb
parent 43598 2a8cd7edf409
child 43600 fe2e0d100187
bookmarks: resolve target revision out of the bookmarks loop The target revision doesn't depend on the bookmark to be added.
mercurial/bookmarks.py
--- 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))