[PATCH 2 of 4] bookmarks: rename setcurrent to activate

Ryan McElroy rmcelroy at fb.com
Mon May 4 19:44:49 CDT 2015


# HG changeset patch
# User Ryan McElroy <rmcelroy at fb.com>
# Date 1428989221 25200
#      Mon Apr 13 22:27:01 2015 -0700
# Node ID ccbbed6c718894b21aa79e397111b1e8540b0cf3
# Parent  33363e62aac24396fdfd8cc5dac99a8e7e07106b
bookmarks: rename setcurrent to activate

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
@@ -498,7 +498,7 @@ def rebase(ui, repo, **opts):
 
         if (activebookmark and
             repo['.'].node() == repo._bookmarks[activebookmark]):
-                bookmarks.setcurrent(repo, activebookmark)
+                bookmarks.activate(repo, activebookmark)
 
     finally:
         release(lock, wlock)
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -130,11 +130,17 @@ def readcurrent(repo):
     return mark
 
 def setcurrent(repo, mark):
-    '''Set the name of the bookmark that we are currently on
+    warnings.warn('deprecated function bookmarks.setcurrent() called. ' +
+                  'update extension to call bookmarks.activate() instead.',
+                  category=DeprecationWarning, stacklevel=2)
+    activate(repo, mark)
 
-    Set the name of the bookmark that we are on (hg update <bookmark>).
+def activate(repo, mark):
+    """
+    Set the given bookmark to be 'active', meaning that this bookmark will
+    follow new commits that are made.
     The name is recorded in .hg/bookmarks.current
-    '''
+    """
     if mark not in repo._bookmarks:
         raise AssertionError('bookmark %s does not exist!' % mark)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -995,7 +995,7 @@ def bookmark(ui, repo, *names, **opts):
                 checkconflict(repo, mark, cur, force)
                 marks[mark] = marks[rename]
                 if repo._bookmarkcurrent == rename and not inactive:
-                    bookmarks.setcurrent(repo, mark)
+                    bookmarks.activate(repo, mark)
                 del marks[rename]
                 marks.write()
 
@@ -1014,7 +1014,7 @@ def bookmark(ui, repo, *names, **opts):
                     checkconflict(repo, mark, cur, force, tgt)
                     marks[mark] = tgt
                 if not inactive and cur == marks[newact] and not rev:
-                    bookmarks.setcurrent(repo, newact)
+                    bookmarks.activate(repo, newact)
                 elif cur != tgt and newact == repo._bookmarkcurrent:
                     bookmarks.deactivate(repo)
                 marks.write()
@@ -1519,7 +1519,7 @@ def commit(ui, repo, *pats, **opts):
             for bm in marks:
                 newmarks[bm] = node
                 if bm == current:
-                    bookmarks.setcurrent(repo, bm)
+                    bookmarks.activate(repo, bm)
             newmarks.write()
     else:
         def commitfunc(ui, repo, message, match, opts):
@@ -6407,7 +6407,7 @@ def update(ui, repo, node=None, rev=None
         if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
             ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
     elif brev in repo._bookmarks:
-        bookmarks.setcurrent(repo, brev)
+        bookmarks.activate(repo, brev)
         ui.status(_("(activating bookmark %s)\n") % brev)
     elif brev:
         if repo._bookmarkcurrent:
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -497,7 +497,7 @@ def clone(ui, peeropts, source, dest=Non
                 destrepo.ui.status(status)
                 _update(destrepo, uprev)
                 if update in destrepo._bookmarks:
-                    bookmarks.setcurrent(destrepo, update)
+                    bookmarks.activate(destrepo, update)
     finally:
         release(srclock, destlock)
         if cleandir is not None:


More information about the Mercurial-devel mailing list