Patchwork [2,of,3] templatekw: introduce activebookmark keyword

login
register
mail settings
Submitter Ryan McElroy
Date May 9, 2015, 12:56 a.m.
Message ID <d65c8127035c9adc66a9.1431132976@devbig105.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8991/
State Accepted
Commit 277aba2c151a367e2dfc96ec88e753a8bb033fd6
Delegated to: Augie Fackler
Headers show

Comments

Ryan McElroy - May 9, 2015, 12:56 a.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1429110724 25200
#      Wed Apr 15 08:12:04 2015 -0700
# Node ID d65c8127035c9adc66a9e550c0d9127c0494d397
# Parent  2462f6c6190123d76d653cc3bbc460cd319fe6d6
templatekw: introduce activebookmark keyword

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.
Yuya Nishihara - May 9, 2015, 1:10 a.m.
On Fri, 8 May 2015 17:56:16 -0700, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy@fb.com>
> # Date 1429110724 25200
> #      Wed Apr 15 08:12:04 2015 -0700
> # Node ID d65c8127035c9adc66a9e550c0d9127c0494d397
> # Parent  2462f6c6190123d76d653cc3bbc460cd319fe6d6
> templatekw: introduce activebookmark keyword
> 
> 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/templatekw.py b/mercurial/templatekw.py
> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -221,8 +221,8 @@ def showchildren(**args):
>      childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
>      return showlist('children', childrevs, element='child', **args)
>  
> -def showcurrentbookmark(**args):
> -    """:currentbookmark: String. The active bookmark, if it is
> +def showactivebookmark(**args):
> +    """:activetbookmark: String. The active bookmark, if it is
>      associated with the changeset"""
>      import bookmarks as bookmarks # to avoid circular import issues
>      repo = args['repo']
> @@ -418,13 +418,15 @@ def showtags(**args):
>  # cache - a cache dictionary for the whole templater run
>  # revcache - a cache dictionary for the current revision
>  keywords = {
> +    'activebookmark': showactivebookmark,
>      'author': showauthor,
>      'bisect': showbisect,
>      'branch': showbranch,
>      'branches': showbranches,
>      'bookmarks': showbookmarks,
>      'children': showchildren,
> -    'currentbookmark': showcurrentbookmark,
> +    # currentbookmark is deprecated
> +    'currentbookmark': showactivebookmark,

"activebookmark" will show up twice in "hg help template". Perhaps we'll need
two functions to host docstrings, like revset.author and user.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -221,8 +221,8 @@  def showchildren(**args):
     childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
     return showlist('children', childrevs, element='child', **args)
 
-def showcurrentbookmark(**args):
-    """:currentbookmark: String. The active bookmark, if it is
+def showactivebookmark(**args):
+    """:activetbookmark: String. The active bookmark, if it is
     associated with the changeset"""
     import bookmarks as bookmarks # to avoid circular import issues
     repo = args['repo']
@@ -418,13 +418,15 @@  def showtags(**args):
 # cache - a cache dictionary for the whole templater run
 # revcache - a cache dictionary for the current revision
 keywords = {
+    'activebookmark': showactivebookmark,
     'author': showauthor,
     'bisect': showbisect,
     'branch': showbranch,
     'branches': showbranches,
     'bookmarks': showbookmarks,
     'children': showchildren,
-    'currentbookmark': showcurrentbookmark,
+    # currentbookmark is deprecated
+    'currentbookmark': showactivebookmark,
     'date': showdate,
     'desc': showdescription,
     'diffstat': showdiffstat,