Patchwork [4,of,4] tags: unblock log-like template keywords and functions

login
register
mail settings
Submitter Yuya Nishihara
Date June 18, 2018, 1:37 p.m.
Message ID <a7593c4a8c90d1182f21.1529329028@mimosa>
Download mbox | patch
Permalink /patch/32281/
State Accepted
Headers show

Comments

Yuya Nishihara - June 18, 2018, 1:37 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1528463783 -32400
#      Fri Jun 08 22:16:23 2018 +0900
# Node ID a7593c4a8c90d1182f21fa1b802ef1bea63a5c14
# Parent  e669b5c1e8a6d4d36d38b0f9c525cfd05846cec8
tags: unblock log-like template keywords and functions

It checks if ctx will be used in template since loading ctx per revision
could take extra 10-100msec in total depending on the number of tags.
via Mercurial-devel - June 21, 2018, 5:15 p.m.
On Mon, Jun 18, 2018 at 6:37 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1528463783 -32400
> #      Fri Jun 08 22:16:23 2018 +0900
> # Node ID a7593c4a8c90d1182f21fa1b802ef1bea63a5c14
> # Parent  e669b5c1e8a6d4d36d38b0f9c525cfd05846cec8
> tags: unblock log-like template keywords and functions


Queued, thanks.

I was wondering if some patch in this series should be marked (API) because
it started requiring template keywords/functions in extensions to be
annotated with the "requires=" thing, but it doesn't seem to be required
(right?).
Yuya Nishihara - June 22, 2018, 11:16 a.m.
On Thu, 21 Jun 2018 10:15:23 -0700, Martin von Zweigbergk wrote:
> On Mon, Jun 18, 2018 at 6:37 AM Yuya Nishihara <yuya@tcha.org> wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1528463783 -32400
> > #      Fri Jun 08 22:16:23 2018 +0900
> > # Node ID a7593c4a8c90d1182f21fa1b802ef1bea63a5c14
> > # Parent  e669b5c1e8a6d4d36d38b0f9c525cfd05846cec8
> > tags: unblock log-like template keywords and functions
> 
> Queued, thanks.
> 
> I was wondering if some patch in this series should be marked (API) because
> it started requiring template keywords/functions in extensions to be
> annotated with the "requires=" thing, but it doesn't seem to be required
> (right?).

Correct. The requires= isn't required. It just serves as a hint to denote
that the function would abort if its requirements weren't satisfied.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5435,6 +5435,7 @@  def tags(ui, repo, **opts):
     opts = pycompat.byteskwargs(opts)
     ui.pager('tags')
     fm = ui.formatter('tags', opts)
+    contexthint = fm.contexthint('tag rev node type')
     hexfunc = fm.hexfunc
     tagtype = ""
 
@@ -5447,6 +5448,8 @@  def tags(ui, repo, **opts):
             tagtype = 'local'
 
         fm.startitem()
+        if 'ctx' in contexthint:
+            fm.context(ctx=repo[n])
         fm.write('tag', '%s', t, label=label)
         fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
         fm.condwrite(not ui.quiet, 'rev node', fmt,
diff --git a/tests/test-tags.t b/tests/test-tags.t
--- a/tests/test-tags.t
+++ b/tests/test-tags.t
@@ -610,6 +610,27 @@  to remove a tag of type X which actually
   localtag                           0:bbd179dfa0a7 local
   globaltag                          0:bbd179dfa0a7
 
+Templated output:
+
+ (immediate values)
+
+  $ hg tags -T '{pad(tag, 9)} {rev}:{node} ({type})\n'
+  tip       1:a0b6fe111088c8c29567d3876cc466aa02927cae ()
+  localtag  0:bbd179dfa0a71671c253b3ae0aa1513b60d199fa (local)
+  globaltag 0:bbd179dfa0a71671c253b3ae0aa1513b60d199fa ()
+
+ (ctx/revcache dependent)
+
+  $ hg tags -T '{pad(tag, 9)} {rev} {file_adds}\n'
+  tip       1 .hgtags
+  localtag  0 foo
+  globaltag 0 foo
+
+  $ hg tags -T '{pad(tag, 9)} {rev}:{node|shortest}\n'
+  tip       1:a0b6
+  localtag  0:bbd1
+  globaltag 0:bbd1
+
 Test for issue3911
 
   $ hg tag -r 0 -l localtag2