changeset 43600:fe2e0d100187

bookmarks: use changectx instead of remembering hex of hidden revision It should be better to not depend on the ctx variable which was assigned conditionally.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Nov 2019 12:44:00 +0900
parents 1c91576b88bb
children a80d5ddecc2d
files mercurial/bookmarks.py
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Sat Nov 09 12:32:20 2019 +0900
+++ b/mercurial/bookmarks.py	Sat Nov 09 12:44:00 2019 +0900
@@ -953,16 +953,13 @@
     cur = repo[b'.'].node()
     newact = None
     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()
+
+    ctx = scmutil.revsingle(repo, rev)
+    tgt = ctx.node()
 
     for mark in names:
         mark = checkformat(repo, mark)
@@ -979,11 +976,11 @@
     if not changes:
         return
 
-    if hiddenrev:
-        repo.ui.warn(_(b"bookmarking hidden changeset %s\n") % hiddenrev)
+    if ctx.hidden():
+        repo.ui.warn(_(b"bookmarking hidden changeset %s\n") % ctx.hex()[:12])
 
         if ctx.obsolete():
-            msg = obsutil._getfilteredreason(repo, b"%s" % hiddenrev, ctx)
+            msg = obsutil._getfilteredreason(repo, ctx.hex()[:12], ctx)
             repo.ui.warn(b"(%s)\n" % msg)
 
     marks.applychanges(repo, tr, changes)