[PATCH 3 of 3] bookmarks: rename current to active in variables and comments

Martin von Zweigbergk martinvonz at google.com
Thu May 14 18:16:34 CDT 2015


I've finally rebased and pushed this to the clowncopter. Thanks, and sorry
about the delay.

On Thu, May 7, 2015 at 1:58 PM Ryan McElroy <rmcelroy at fb.com> wrote:

> # HG changeset patch
> # User Ryan McElroy <rmcelroy at fb.com>
> # Date 1429041228 25200
> #      Tue Apr 14 12:53:48 2015 -0700
> # Node ID 5e9699f4cf6063b077223a0baf5ab7cba7dc42b2
> # Parent  258d4654240ae6e6978acaeab753ed65c6843789
> bookmarks: rename current to active in variables and comments
>
> 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/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -22,7 +22,7 @@ class bmstore(dict):
>      {hash}\s{name}\n (the same format as localtags) in
>      .hg/bookmarks. The mapping is stored as {name: nodeid}.
>
> -    This class does NOT handle the "current" bookmark state at this
> +    This class does NOT handle the "active" bookmark state at this
>      time.
>      """
>
> @@ -137,8 +137,8 @@ def activate(repo, mark):
>      if mark not in repo._bookmarks:
>          raise AssertionError('bookmark %s does not exist!' % mark)
>
> -    current = repo._activebookmark
> -    if current == mark:
> +    active = repo._activebookmark
> +    if active == mark:
>          return
>
>      wlock = repo.wlock()
> @@ -197,33 +197,33 @@ 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._activebookmark
> +        activemark = repo._activebookmark
>          if isactivecurrent(repo):
>              movemarkfrom = repo['.'].node()
> -        elif curmark:
> -            ui.status(_("updating to active bookmark %s\n") % curmark)
> -            checkout = curmark
> +        elif activemark:
> +            ui.status(_("updating to active bookmark %s\n") % activemark)
> +            checkout = activemark
>      return (checkout, movemarkfrom)
>
>  def update(repo, parents, node):
>      deletefrom = parents
>      marks = repo._bookmarks
>      update = False
> -    cur = repo._activebookmark
> -    if not cur:
> +    active = repo._activebookmark
> +    if not active:
>          return False
>
> -    if marks[cur] in parents:
> +    if marks[active] in parents:
>          new = repo[node]
>          divs = [repo[b] for b in marks
> -                if b.split('@', 1)[0] == cur.split('@', 1)[0]]
> +                if b.split('@', 1)[0] == active.split('@', 1)[0]]
>          anc = repo.changelog.ancestors([new.rev()])
>          deletefrom = [b.node() for b in divs if b.rev() in anc or b ==
> new]
> -        if validdest(repo, repo[marks[cur]], new):
> -            marks[cur] = new.node()
> +        if validdest(repo, repo[marks[active]], new):
> +            marks[active] = new.node()
>              update = True
>
> -    if deletedivergent(repo, deletefrom, cur):
> +    if deletedivergent(repo, deletefrom, active):
>          update = True
>
>      if update:
> 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._activebookmark
> +            activebookmark = repo._activebookmark
>              try:
>                  repo._activebookmark = None
>                  opts['message'] = 'temporary amend commit for %s' % old
>                  node = commit(ui, repo, commitfunc, pats, opts)
>              finally:
> -                repo._activebookmark = currentbookmark
> +                repo._activebookmark = activebookmark
>                  ui.callhooks = True
>              ctx = repo[node]
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150514/06d0034b/attachment.html>


More information about the Mercurial-devel mailing list