bookmarks: rename bookmarkcurrent to activebookmark (API)
authorRyan McElroy <rmcelroy@fb.com>
Tue, 14 Apr 2015 13:17:33 -0700
changeset 24947 a02d293a1079
parent 24946 c44534209a0a
child 24951 eeca859cc045
bookmarks: rename bookmarkcurrent to activebookmark (API) 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.
hgext/rebase.py
hgext/shelve.py
hgext/strip.py
mercurial/bookmarks.py
mercurial/cmdutil.py
mercurial/commands.py
mercurial/localrepo.py
mercurial/templatekw.py
--- a/hgext/rebase.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/hgext/rebase.py	Tue Apr 14 13:17:33 2015 -0700
@@ -358,7 +358,7 @@
 
         # 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 @@
                 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'))
--- a/hgext/shelve.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/hgext/shelve.py	Tue Apr 14 13:17:33 2015 -0700
@@ -163,7 +163,7 @@
 
     # we never need the user, so we use a generic user for all shelve operations
     user = 'shelve@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('/', '_')
--- a/hgext/strip.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/hgext/strip.py	Tue Apr 14 13:17:33 2015 -0700
@@ -60,7 +60,7 @@
 
         marks = repo._bookmarks
         if bookmark:
-            if bookmark == repo._bookmarkcurrent:
+            if bookmark == repo._activebookmark:
                 bookmarks.deactivate(repo)
             del marks[bookmark]
             marks.write()
--- a/mercurial/bookmarks.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/mercurial/bookmarks.py	Tue Apr 14 13:17:33 2015 -0700
@@ -83,7 +83,7 @@
 
     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()
@@ -137,7 +137,7 @@
     if mark not in repo._bookmarks:
         raise AssertionError('bookmark %s does not exist!' % mark)
 
-    current = repo._bookmarkcurrent
+    current = repo._activebookmark
     if current == mark:
         return
 
@@ -148,7 +148,7 @@
         file.close()
     finally:
         wlock.release()
-    repo._bookmarkcurrent = mark
+    repo._activebookmark = mark
 
 def deactivate(repo):
     """
@@ -158,7 +158,7 @@
     try:
         try:
             repo.vfs.unlink('bookmarks.current')
-            repo._bookmarkcurrent = None
+            repo._activebookmark = None
         except OSError, inst:
             if inst.errno != errno.ENOENT:
                 raise
@@ -172,7 +172,7 @@
     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
@@ -209,7 +209,7 @@
     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:
@@ -221,7 +221,7 @@
     deletefrom = parents
     marks = repo._bookmarks
     update = False
-    cur = repo._bookmarkcurrent
+    cur = repo._activebookmark
     if not cur:
         return False
 
--- a/mercurial/cmdutil.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/mercurial/cmdutil.py	Tue Apr 14 13:17:33 2015 -0700
@@ -2480,13 +2480,13 @@
             # 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 @@
     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])
--- a/mercurial/commands.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/mercurial/commands.py	Tue Apr 14 13:17:33 2015 -0700
@@ -979,7 +979,7 @@
                     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 @@
                     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 @@
                     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 @@
                     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 @@
         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 @@
                                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 @@
     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 @@
                 "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 @@
             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 @@
         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 @@
 
     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
--- a/mercurial/localrepo.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/mercurial/localrepo.py	Tue Apr 14 13:17:33 2015 -0700
@@ -415,7 +415,7 @@
         return bookmarks.bmstore(self)
 
     @repofilecache('bookmarks.current')
-    def _bookmarkcurrent(self):
+    def _activebookmark(self):
         return bookmarks.readactive(self)
 
     def bookmarkheads(self, bookmark):
--- a/mercurial/templatekw.py	Mon Apr 13 23:03:13 2015 -0700
+++ b/mercurial/templatekw.py	Tue Apr 14 13:17:33 2015 -0700
@@ -210,7 +210,7 @@
     """
     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 @@
     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 ''