[PATCH 1 of 8] bookmarks: add support for log-like template keywords and functions

Gregory Szorc gregory.szorc at gmail.com
Wed Jul 4 14:05:25 EDT 2018


On Tue, Jul 3, 2018 at 6:26 AM, Yuya Nishihara <yuya at tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1530451327 -32400
> #      Sun Jul 01 22:22:07 2018 +0900
> # Node ID 65ebef5548276d61a95e949d8ef2fd1b82947bc6
> # Parent  c1a7bbf9984d2614bfac478d42c86377a84641ba
> bookmarks: add support for log-like template keywords and functions
>

Queued this series.

It's great to see templates being more usable and consistent across
commands!


>
> This is basically the same as 5d9b765dbe15 "tags: unblock log-like template
> keywords and functions."
>
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -923,11 +923,14 @@ def _printbookmarks(ui, repo, bmarks, **
>      """
>      opts = pycompat.byteskwargs(opts)
>      fm = ui.formatter('bookmarks', opts)
> +    contexthint = fm.contexthint('bookmark rev node active')
>      hexfn = fm.hexfunc
>      if len(bmarks) == 0 and fm.isplain():
>          ui.status(_("no bookmarks set\n"))
>      for bmark, (n, prefix, label) in sorted(bmarks.iteritems()):
>          fm.startitem()
> +        if 'ctx' in contexthint:
> +            fm.context(ctx=repo[n])
>          if not ui.quiet:
>              fm.plain(' %s ' % prefix, label=label)
>          fm.write('bookmark', '%s', bmark, label=label)
> diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
> --- a/tests/test-bookmarks.t
> +++ b/tests/test-bookmarks.t
> @@ -77,6 +77,11 @@ list bookmarks
>    $ hg commit -m 1 --config "$TESTHOOK"
>    test-hook-bookmark: X2:  f7b1eb17ad24730a1651fccd46c43826d1bbc2ac ->
> 925d80f479bb026b0fb3deb27503780b13f74123
>
> +  $ hg bookmarks -T '{rev}:{node|shortest} {bookmark} {desc|firstline}\n'
> +  0:f7b1 X 0
> +  1:925d X2 1
> +  -1:0000 Y
> +
>    $ hg bookmarks -Tjson
>    [
>     {
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180704/ff3b1556/attachment.html>


More information about the Mercurial-devel mailing list