Patchwork [2,of,4] bookmarks: resolve target revision out of the bookmarks loop

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 9, 2019, 4:51 a.m.
Message ID <2562eaf1bb72faf1b238.1573275098@mimosa>
Download mbox | patch
Permalink /patch/43016/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 9, 2019, 4:51 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1573270340 -32400
#      Sat Nov 09 12:32:20 2019 +0900
# Node ID 2562eaf1bb72faf1b2383ef651f63be39b875e4f
# Parent  a5d3b2b0f3ddcb858e5d6416d571fa0e8870a6dd
bookmarks: resolve target revision out of the bookmarks loop

The target revision doesn't depend on the bookmark to be added.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -955,9 +955,14 @@  def addbookmarks(repo, tr, names, rev=No
     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 @@  def addbookmarks(repo, tr, names, rev=No
         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))