[PATCH 4 of 4 V2] bookmarks: rename bookmarkcurrent to activebookmark
Ryan McElroy
rmcelroy at fb.com
Tue May 5 12:36:26 CDT 2015
# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1429042653 25200
# Tue Apr 14 13:17:33 2015 -0700
# Node ID 3ca94ee0645edfdc89c8a8e64cf7b0f96e5aa839
# Parent 3fae1a985ae9ef452aedb0e6c93ad02297248b4c
bookmarks: rename bookmarkcurrent to activebookmark
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -358,7 +358,7 @@ def rebase(ui, repo, **opts):
# Keep track of the current bookmarks in order to reset them later
currentbookmarks = repo._bookmarks.copy()
- activebookmark = activebookmark or repo._bookmarkcurrent
+ activebookmark = activebookmark or repo._activebookmark
if activebookmark:
bookmarks.deactivate(repo)
@@ -1052,7 +1052,7 @@ def pullrebase(orig, ui, repo, *args, **
hg.update(repo, dest)
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
ui.status(_("updating bookmark %s\n")
- % repo._bookmarkcurrent)
+ % repo._activebookmark)
else:
if opts.get('tool'):
raise util.Abort(_('--tool can only be used with --rebase'))
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -163,7 +163,7 @@ def createcmd(ui, repo, pats, opts):
# we never need the user, so we use a generic user for all shelve operations
user = 'shelve at localhost'
- label = repo._bookmarkcurrent or parent.branch() or 'default'
+ label = repo._activebookmark or parent.branch() or 'default'
# slashes aren't allowed in filenames, therefore we rename it
label = label.replace('/', '_')
diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -60,7 +60,7 @@ def strip(ui, repo, revs, update=True, b
marks = repo._bookmarks
if bookmark:
- if bookmark == repo._bookmarkcurrent:
+ if bookmark == repo._activebookmark:
bookmarks.deactivate(repo)
del marks[bookmark]
marks.write()
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -83,7 +83,7 @@ class bmstore(dict):
def _writerepo(self, repo):
"""Factored out for extensibility"""
- if repo._bookmarkcurrent not in self:
+ if repo._activebookmark not in self:
deactivate(repo)
wlock = repo.wlock()
@@ -143,7 +143,7 @@ def activate(repo, mark):
if mark not in repo._bookmarks:
raise AssertionError('bookmark %s does not exist!' % mark)
- current = repo._bookmarkcurrent
+ current = repo._activebookmark
if current == mark:
return
@@ -154,7 +154,7 @@ def activate(repo, mark):
file.close()
finally:
wlock.release()
- repo._bookmarkcurrent = mark
+ repo._activebookmark = mark
def deactivate(repo):
"""
@@ -164,7 +164,7 @@ def deactivate(repo):
try:
try:
repo.vfs.unlink('bookmarks.current')
- repo._bookmarkcurrent = None
+ repo._activebookmark = None
except OSError, inst:
if inst.errno != errno.ENOENT:
raise
@@ -178,7 +178,7 @@ def iscurrent(repo, mark=None, parents=N
parent of the working directory.
'''
if not mark:
- mark = repo._bookmarkcurrent
+ mark = repo._activebookmark
if not parents:
parents = [p.node() for p in repo[None].parents()]
marks = repo._bookmarks
@@ -215,7 +215,7 @@ def calculateupdate(ui, repo, checkout):
check out and where to move the active bookmark from, if needed.'''
movemarkfrom = None
if checkout is None:
- curmark = repo._bookmarkcurrent
+ curmark = repo._activebookmark
if iscurrent(repo):
movemarkfrom = repo['.'].node()
elif curmark:
@@ -227,7 +227,7 @@ def update(repo, parents, node):
deletefrom = parents
marks = repo._bookmarks
update = False
- cur = repo._bookmarkcurrent
+ cur = repo._activebookmark
if not cur:
return False
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2480,13 +2480,13 @@ def amend(ui, repo, commitfunc, old, ext
# First, do a regular commit to record all changes in the working
# directory (if there are any)
ui.callhooks = False
- currentbookmark = repo._bookmarkcurrent
+ currentbookmark = repo._activebookmark
try:
- repo._bookmarkcurrent = None
+ repo._activebookmark = None
opts['message'] = 'temporary amend commit for %s' % old
node = commit(ui, repo, commitfunc, pats, opts)
finally:
- repo._bookmarkcurrent = currentbookmark
+ repo._activebookmark = currentbookmark
ui.callhooks = True
ctx = repo[node]
@@ -2722,7 +2722,7 @@ def buildcommittext(repo, ctx, subs, ext
if ctx.branch():
edittext.append(_("HG: branch '%s'") % ctx.branch())
if bookmarks.iscurrent(repo):
- edittext.append(_("HG: bookmark '%s'") % repo._bookmarkcurrent)
+ edittext.append(_("HG: bookmark '%s'") % repo._activebookmark)
edittext.extend([_("HG: subrepo %s") % s for s in subs])
edittext.extend([_("HG: added %s") % f for f in added])
edittext.extend([_("HG: changed %s") % f for f in modified])
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -979,7 +979,7 @@ def bookmark(ui, repo, *names, **opts):
if mark not in marks:
raise util.Abort(_("bookmark '%s' does not exist") %
mark)
- if mark == repo._bookmarkcurrent:
+ if mark == repo._activebookmark:
bookmarks.deactivate(repo)
del marks[mark]
marks.write()
@@ -994,7 +994,7 @@ def bookmark(ui, repo, *names, **opts):
raise util.Abort(_("bookmark '%s' does not exist") % rename)
checkconflict(repo, mark, cur, force)
marks[mark] = marks[rename]
- if repo._bookmarkcurrent == rename and not inactive:
+ if repo._activebookmark == rename and not inactive:
bookmarks.activate(repo, mark)
del marks[rename]
marks.write()
@@ -1005,7 +1005,7 @@ def bookmark(ui, repo, *names, **opts):
mark = checkformat(mark)
if newact is None:
newact = mark
- if inactive and mark == repo._bookmarkcurrent:
+ if inactive and mark == repo._activebookmark:
bookmarks.deactivate(repo)
return
tgt = cur
@@ -1015,14 +1015,14 @@ def bookmark(ui, repo, *names, **opts):
marks[mark] = tgt
if not inactive and cur == marks[newact] and not rev:
bookmarks.activate(repo, newact)
- elif cur != tgt and newact == repo._bookmarkcurrent:
+ elif cur != tgt and newact == repo._activebookmark:
bookmarks.deactivate(repo)
marks.write()
elif inactive:
if len(marks) == 0:
ui.status(_("no bookmarks set\n"))
- elif not repo._bookmarkcurrent:
+ elif not repo._activebookmark:
ui.status(_("no active bookmark\n"))
else:
bookmarks.deactivate(repo)
@@ -1035,7 +1035,7 @@ def bookmark(ui, repo, *names, **opts):
if len(marks) == 0 and not fm:
ui.status(_("no bookmarks set\n"))
for bmark, n in sorted(marks.iteritems()):
- current = repo._bookmarkcurrent
+ current = repo._activebookmark
if bmark == current:
prefix, label = '*', 'bookmarks.current'
else:
@@ -1506,7 +1506,7 @@ def commit(ui, repo, *pats, **opts):
match,
extra=extra)
- current = repo._bookmarkcurrent
+ current = repo._activebookmark
marks = old.bookmarks()
node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
if node == old.node():
@@ -4702,9 +4702,9 @@ def merge(ui, repo, node=None, **opts):
if node:
node = scmutil.revsingle(repo, node).node()
- if not node and repo._bookmarkcurrent:
- bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
- curhead = repo[repo._bookmarkcurrent].node()
+ if not node and repo._activebookmark:
+ bmheads = repo.bookmarkheads(repo._activebookmark)
+ curhead = repo[repo._activebookmark].node()
if len(bmheads) == 2:
if curhead == bmheads[0]:
node = bmheads[1]
@@ -4719,7 +4719,7 @@ def merge(ui, repo, node=None, **opts):
"please merge with an explicit rev or bookmark"),
hint=_("run 'hg heads' to see all heads"))
- if not node and not repo._bookmarkcurrent:
+ if not node and not repo._activebookmark:
branch = repo[None].branch()
bheads = repo.branchheads(branch)
nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
@@ -5049,7 +5049,7 @@ def postincoming(ui, repo, modheads, opt
return 0
if not ret and not checkout:
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
- ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
+ ui.status(_("updating bookmark %s\n") % repo._activebookmark)
return ret
if modheads > 1:
currentbranchheads = len(repo.branchheads())
@@ -5914,7 +5914,7 @@ def summary(ui, repo, **opts):
ui.status(m, label='log.branch')
if marks:
- current = repo._bookmarkcurrent
+ current = repo._activebookmark
# i18n: column positioning for "hg summary"
ui.write(_('bookmarks:'), label='log.bookmark')
if current is not None:
@@ -6405,14 +6405,14 @@ def update(ui, repo, node=None, rev=None
if not ret and movemarkfrom:
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
- ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
+ ui.status(_("updating bookmark %s\n") % repo._activebookmark)
elif brev in repo._bookmarks:
bookmarks.activate(repo, brev)
ui.status(_("(activating bookmark %s)\n") % brev)
elif brev:
- if repo._bookmarkcurrent:
+ if repo._activebookmark:
ui.status(_("(leaving bookmark %s)\n") %
- repo._bookmarkcurrent)
+ repo._activebookmark)
bookmarks.deactivate(repo)
return ret
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -418,7 +418,7 @@ class localrepository(object):
return bookmarks.bmstore(self)
@repofilecache('bookmarks.current')
- def _bookmarkcurrent(self):
+ def _activebookmark(self):
return bookmarks.readactive(self)
def bookmarkheads(self, bookmark):
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -210,7 +210,7 @@ def showbookmarks(**args):
"""
repo = args['ctx']._repo
bookmarks = args['ctx'].bookmarks()
- current = repo._bookmarkcurrent
+ current = repo._activebookmark
makemap = lambda v: {'bookmark': v, 'current': current}
f = _showlist('bookmark', bookmarks, **args)
return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark'])
@@ -227,7 +227,7 @@ def showcurrentbookmark(**args):
import bookmarks as bookmarks # to avoid circular import issues
repo = args['repo']
if bookmarks.iscurrent(repo):
- current = repo._bookmarkcurrent
+ current = repo._activebookmark
if current in args['ctx'].bookmarks():
return current
return ''
More information about the Mercurial-devel
mailing list