annotate mercurial/templatekw.py @ 27367:8833daddfc3f

test: rename 'check-code' own test to 'test-contrib-check-code.t' This test (making sure the 'check-code' script run as intended) have been confused with the test making that the mercurial code base comply with our coding still by multiple generations of contributors. We are moving it out of the way so that all tests starting with 'test-check' are now doing compliance testing.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 05 Dec 2015 22:47:26 -0800
parents 5b8da5643a8a
children ac8c0ee5c3b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
1 # templatekw.py - common changeset template keywords
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
2 #
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com>
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
4 #
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
10264
d6512b3e9ac0 Merge with stable
Matt Mackall <mpm@selenic.com>
parents: 10260
diff changeset
6 # GNU General Public License version 2 or any later version.
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
7
25984
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
8 from __future__ import absolute_import
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
9
27215
5b8da5643a8a templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents: 27214
diff changeset
10 from .node import hex, nullid
25984
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
11 from . import (
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
12 error,
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
13 hbisect,
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
14 patch,
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
15 scmutil,
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
16 util,
c57509e88922 templatekw: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25740
diff changeset
17 )
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
18
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
19 # This helper class allows us to handle both:
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
20 # "{files}" (legacy command-line-specific list hack) and
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
21 # "{files % '{file}\n'}" (hgweb-style with inlining and function support)
24240
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24239
diff changeset
22 # and to access raw values:
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24239
diff changeset
23 # "{ifcontains(file, files, ...)}", "{ifcontains(key, extras, ...)}"
24241
e7baf88c29c3 templatekw: forward _hybrid.get to raw values so that get(extras, key) works
Yuya Nishihara <yuya@tcha.org>
parents: 24240
diff changeset
24 # "{get(extras, key)}"
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
25
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
26 class _hybrid(object):
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
27 def __init__(self, gen, values, makemap, joinfmt=None):
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
28 self.gen = gen
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
29 self.values = values
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
30 self._makemap = makemap
18970
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
31 if joinfmt:
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
32 self.joinfmt = joinfmt
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
33 else:
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
34 self.joinfmt = lambda x: x.values()[0]
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
35 def __iter__(self):
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
36 return self.gen
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
37 def __call__(self):
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
38 makemap = self._makemap
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
39 for x in self.values:
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
40 yield makemap(x)
24240
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24239
diff changeset
41 def __contains__(self, x):
bd504d90588d templater: implement _hybrid.__contains__ so that ifcontains can accept dict
Yuya Nishihara <yuya@tcha.org>
parents: 24239
diff changeset
42 return x in self.values
22393
293930a1fa0a templater: implement __len__ for _hybrid
Anton Shestakov <engored@ya.ru>
parents: 21897
diff changeset
43 def __len__(self):
293930a1fa0a templater: implement __len__ for _hybrid
Anton Shestakov <engored@ya.ru>
parents: 21897
diff changeset
44 return len(self.values)
24241
e7baf88c29c3 templatekw: forward _hybrid.get to raw values so that get(extras, key) works
Yuya Nishihara <yuya@tcha.org>
parents: 24240
diff changeset
45 def __getattr__(self, name):
e7baf88c29c3 templatekw: forward _hybrid.get to raw values so that get(extras, key) works
Yuya Nishihara <yuya@tcha.org>
parents: 24240
diff changeset
46 if name != 'get':
e7baf88c29c3 templatekw: forward _hybrid.get to raw values so that get(extras, key) works
Yuya Nishihara <yuya@tcha.org>
parents: 24240
diff changeset
47 raise AttributeError(name)
e7baf88c29c3 templatekw: forward _hybrid.get to raw values so that get(extras, key) works
Yuya Nishihara <yuya@tcha.org>
parents: 24240
diff changeset
48 return getattr(self.values, name)
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
49
25726
b44e483726d3 templatekw: allow the caller of showlist() to specify the join() separator
Matt Harbison <matt_harbison@yahoo.com>
parents: 25724
diff changeset
50 def showlist(name, values, plural=None, element=None, separator=' ', **args):
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
51 if not element:
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
52 element = name
25726
b44e483726d3 templatekw: allow the caller of showlist() to specify the join() separator
Matt Harbison <matt_harbison@yahoo.com>
parents: 25724
diff changeset
53 f = _showlist(name, values, plural, separator, **args)
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
54 return _hybrid(f, values, lambda x: {element: x})
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
55
25726
b44e483726d3 templatekw: allow the caller of showlist() to specify the join() separator
Matt Harbison <matt_harbison@yahoo.com>
parents: 25724
diff changeset
56 def _showlist(name, values, plural=None, separator=' ', **args):
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
57 '''expand set of values.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
58 name is name of key in template map.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
59 values is list of strings or dicts.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
60 plural is plural of name, if not simply name + 's'.
25726
b44e483726d3 templatekw: allow the caller of showlist() to specify the join() separator
Matt Harbison <matt_harbison@yahoo.com>
parents: 25724
diff changeset
61 separator is used to join values as a string
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
62
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
63 expansion works like this, given name 'foo'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
64
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
65 if values is empty, expand 'no_foos'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
66
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
67 if 'foo' not in template map, return values as a string,
25726
b44e483726d3 templatekw: allow the caller of showlist() to specify the join() separator
Matt Harbison <matt_harbison@yahoo.com>
parents: 25724
diff changeset
68 joined by 'separator'.
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
69
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
70 expand 'start_foos'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
71
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
72 for each value, expand 'foo'. if 'last_foo' in template
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
73 map, expand it instead of 'foo' for last key.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
74
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
75 expand 'end_foos'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
76 '''
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
77 templ = args['templ']
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
78 if plural:
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
79 names = plural
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
80 else: names = name + 's'
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
81 if not values:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
82 noname = 'no_' + names
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
83 if noname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
84 yield templ(noname, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
85 return
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
86 if name not in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
87 if isinstance(values[0], str):
25726
b44e483726d3 templatekw: allow the caller of showlist() to specify the join() separator
Matt Harbison <matt_harbison@yahoo.com>
parents: 25724
diff changeset
88 yield separator.join(values)
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
89 else:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
90 for v in values:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
91 yield dict(v, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
92 return
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
93 startname = 'start_' + names
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
94 if startname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
95 yield templ(startname, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
96 vargs = args.copy()
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
97 def one(v, tag=name):
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
98 try:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
99 vargs.update(v)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
100 except (AttributeError, ValueError):
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
101 try:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
102 for a, b in v:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
103 vargs[a] = b
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
104 except ValueError:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
105 vargs[name] = v
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
106 return templ(tag, **vargs)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
107 lastname = 'last_' + name
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
108 if lastname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
109 last = values.pop()
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
110 else:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
111 last = None
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
112 for v in values:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
113 yield one(v)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
114 if last is not None:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
115 yield one(last, tag=lastname)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
116 endname = 'end_' + names
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
117 if endname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
118 yield templ(endname, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
119
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
120 def getfiles(repo, ctx, revcache):
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
121 if 'files' not in revcache:
25392
ed18f4acf435 templatekw: compare target context and its parent exactly (issue4690)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 24676
diff changeset
122 revcache['files'] = repo.status(ctx.p1(), ctx)[:3]
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
123 return revcache['files']
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
124
26482
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
125 def getlatesttags(repo, ctx, cache, pattern=None):
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
126 '''return date, distance and name for the latest tag of rev'''
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
127
26482
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
128 cachename = 'latesttags'
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
129 if pattern is not None:
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
130 cachename += '-' + pattern
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
131 match = util.stringmatcher(pattern)[2]
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
132 else:
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
133 match = util.always
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
134
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
135 if cachename not in cache:
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
136 # Cache mapping from rev to a tuple with tag date, tag
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
137 # distance and tag name
26482
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
138 cache[cachename] = {-1: (0, 0, ['null'])}
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
139 latesttags = cache[cachename]
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
140
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
141 rev = ctx.rev()
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
142 todo = [rev]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
143 while todo:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
144 rev = todo.pop()
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
145 if rev in latesttags:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
146 continue
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
147 ctx = repo[rev]
20218
0c22257388d6 templatekw: allow tagtypes other than global in getlatesttags
Andrew Shadura <andrew@shadura.me>
parents: 20183
diff changeset
148 tags = [t for t in ctx.tags()
26482
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
149 if (repo.tagtype(t) and repo.tagtype(t) != 'local'
d2e69584e330 templatekw: allow getlatesttags() to match a specific tag pattern
Matt Harbison <matt_harbison@yahoo.com>
parents: 26437
diff changeset
150 and match(t))]
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
151 if tags:
25700
0fca47b206f6 templatekw: use a list of tags in getlatesttags() instead of joining them
Matt Harbison <matt_harbison@yahoo.com>
parents: 25663
diff changeset
152 latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
153 continue
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
154 try:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
155 # The tuples are laid out so the right one can be found by
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
156 # comparison.
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
157 pdate, pdist, ptag = max(
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
158 latesttags[p.rev()] for p in ctx.parents())
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
159 except KeyError:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
160 # Cache miss - recurse
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
161 todo.append(rev)
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
162 todo.extend(p.rev() for p in ctx.parents())
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
163 continue
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
164 latesttags[rev] = pdate, pdist + 1, ptag
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
165 return latesttags[rev]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
166
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
167 def getrenamedfn(repo, endrev=None):
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
168 rcache = {}
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
169 if endrev is None:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
170 endrev = len(repo)
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
171
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
172 def getrenamed(fn, rev):
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
173 '''looks up all renames for a file (up to endrev) the first
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
174 time the file is given. It indexes on the changerev and only
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
175 parses the manifest if linkrev != changerev.
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
176 Returns rename info for fn at changerev rev.'''
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
177 if fn not in rcache:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
178 rcache[fn] = {}
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
179 fl = repo.file(fn)
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
180 for i in fl:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
181 lr = fl.linkrev(i)
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
182 renamed = fl.renamed(fl.node(i))
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
183 rcache[fn][lr] = renamed
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
184 if lr >= endrev:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
185 break
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
186 if rev in rcache[fn]:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
187 return rcache[fn][rev]
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
188
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
189 # If linkrev != rev (i.e. rev not found in rcache) fallback to
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
190 # filectx logic.
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
191 try:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
192 return repo[rev][fn].renamed()
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
193 except error.LookupError:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
194 return None
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
195
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
196 return getrenamed
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
197
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
198
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
199 def showauthor(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
200 """:author: String. The unmodified author of the changeset."""
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
201 return ctx.user()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
202
15155
f4a8d754cd0a templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 14437
diff changeset
203 def showbisect(repo, ctx, templ, **args):
f4a8d754cd0a templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 14437
diff changeset
204 """:bisect: String. The changeset bisection status."""
f4a8d754cd0a templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 14437
diff changeset
205 return hbisect.label(repo, ctx.node())
f4a8d754cd0a templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 14437
diff changeset
206
13156
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
207 def showbranch(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
208 """:branch: String. The name of the branch on which the changeset was
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
209 committed.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
210 """
13156
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
211 return args['ctx'].branch()
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
212
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
213 def showbranches(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
214 """:branches: List of strings. The name of the branch on which the
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
215 changeset was committed. Will be empty if the branch name was
26437
4628b26f040e templatekw: hide help of "branches" by DEPRECATED marker
Yuya Nishihara <yuya@tcha.org>
parents: 26436
diff changeset
216 default. (DEPRECATED)
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
217 """
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
218 branch = args['ctx'].branch()
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
219 if branch != 'default':
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
220 return showlist('branch', [branch], plural='branches', **args)
20076
faa4b3fc4197 templater: makes branches work correctly with stringify (issue4108)
Matt Mackall <mpm@selenic.com>
parents: 18970
diff changeset
221 return showlist('branch', [], plural='branches', **args)
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
222
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
223 def showbookmarks(**args):
13592
ad2ee188f4a5 templates: document missing keywords or filters
Patrick Mezard <pmezard@gmail.com>
parents: 13585
diff changeset
224 """:bookmarks: List of strings. Any bookmarks associated with the
25348
f26efa4f0eff templatekw: introduce active subkeyword from bookmarks keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25013
diff changeset
225 changeset. Also sets 'active', the name of the active bookmark.
13592
ad2ee188f4a5 templates: document missing keywords or filters
Patrick Mezard <pmezard@gmail.com>
parents: 13585
diff changeset
226 """
20520
5c65ee4193e1 template: add 'current' to scope during {bookmarks % ...}
Durham Goode <durham@fb.com>
parents: 20218
diff changeset
227 repo = args['ctx']._repo
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
228 bookmarks = args['ctx'].bookmarks()
25348
f26efa4f0eff templatekw: introduce active subkeyword from bookmarks keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25013
diff changeset
229 active = repo._activebookmark
f26efa4f0eff templatekw: introduce active subkeyword from bookmarks keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25013
diff changeset
230 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
24156
75a2df2bbde8 templatekw: inline showlist() into showbookmarks()
Yuya Nishihara <yuya@tcha.org>
parents: 23977
diff changeset
231 f = _showlist('bookmark', bookmarks, **args)
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
232 return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark'])
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
233
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
234 def showchildren(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
235 """:children: List of strings. The children of the changeset."""
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
236 ctx = args['ctx']
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
237 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
238 return showlist('children', childrevs, element='child', **args)
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
239
25013
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
240 # Deprecated, but kept alive for help generation a purpose.
21896
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
241 def showcurrentbookmark(**args):
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
242 """:currentbookmark: String. The active bookmark, if it is
25013
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
243 associated with the changeset (DEPRECATED)"""
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
244 return showactivebookmark(**args)
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
245
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
246 def showactivebookmark(**args):
25663
edd2d20ac687 templatekw: correct typo in activebookmark documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 25393
diff changeset
247 """:activebookmark: String. The active bookmark, if it is
21896
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
248 associated with the changeset"""
25387
390a10b7843b templatekw: display active bookmark more consistently (issue4552) (BC)
Ryan McElroy <rmcelroy@fb.com>
parents: 25348
diff changeset
249 active = args['repo']._activebookmark
390a10b7843b templatekw: display active bookmark more consistently (issue4552) (BC)
Ryan McElroy <rmcelroy@fb.com>
parents: 25348
diff changeset
250 if active and active in args['ctx'].bookmarks():
390a10b7843b templatekw: display active bookmark more consistently (issue4552) (BC)
Ryan McElroy <rmcelroy@fb.com>
parents: 25348
diff changeset
251 return active
21896
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
252 return ''
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
253
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
254 def showdate(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
255 """:date: Date information. The date when the changeset was committed."""
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
256 return ctx.date()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
257
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
258 def showdescription(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
259 """:desc: String. The text of the changeset description."""
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
260 return ctx.description().strip()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
261
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
262 def showdiffstat(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
263 """:diffstat: String. Statistics of changes with the following format:
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
264 "modified files: +added/-removed lines"
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
265 """
14403
2c9f5897d4b7 templatekw: use diffstatsum in diffstat keyword
Matt Mackall <mpm@selenic.com>
parents: 14318
diff changeset
266 stats = patch.diffstatdata(util.iterlines(ctx.diff()))
14437
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 14403
diff changeset
267 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
14403
2c9f5897d4b7 templatekw: use diffstatsum in diffstat keyword
Matt Mackall <mpm@selenic.com>
parents: 14318
diff changeset
268 return '%s: +%s/-%s' % (len(stats), adds, removes)
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
269
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
270 def showextras(**args):
20015
ad27cdacc743 help: document about {extras} template keyword
Matthew Turk <matthewturk@gmail.com>
parents: 18970
diff changeset
271 """:extras: List of dicts with key, value entries of the 'extras'
ad27cdacc743 help: document about {extras} template keyword
Matthew Turk <matthewturk@gmail.com>
parents: 18970
diff changeset
272 field of this changeset."""
20183
de7e6c489412 template: modify showextras to return a hybrid
Matthew Turk <matthewturk@gmail.com>
parents: 20079
diff changeset
273 extras = args['ctx'].extra()
24237
9ad02823dc5b templatekw: convert list of key/value pairs to sortdict
Yuya Nishihara <yuya@tcha.org>
parents: 24157
diff changeset
274 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
24238
49cee6d8573d templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents: 24237
diff changeset
275 makemap = lambda k: {'key': k, 'value': extras[k]}
49cee6d8573d templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents: 24237
diff changeset
276 c = [makemap(k) for k in extras]
20183
de7e6c489412 template: modify showextras to return a hybrid
Matthew Turk <matthewturk@gmail.com>
parents: 20079
diff changeset
277 f = _showlist('extra', c, plural='extras', **args)
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
278 return _hybrid(f, extras, makemap,
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
279 lambda x: '%s=%s' % (x['key'], x['value']))
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
280
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
281 def showfileadds(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
282 """:file_adds: List of strings. Files added by this changeset."""
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
283 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
284 return showlist('file_add', getfiles(repo, ctx, revcache)[1],
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
285 element='file', **args)
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
286
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
287 def showfilecopies(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
288 """:file_copies: List of strings. Files copied in this changeset with
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
289 their sources.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
290 """
10394
4612cded5176 fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10282
diff changeset
291 cache, ctx = args['cache'], args['ctx']
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
292 copies = args['revcache'].get('copies')
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
293 if copies is None:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
294 if 'getrenamed' not in cache:
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
295 cache['getrenamed'] = getrenamedfn(args['repo'])
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
296 copies = []
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
297 getrenamed = cache['getrenamed']
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
298 for fn in ctx.files():
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
299 rename = getrenamed(fn, ctx.rev())
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
300 if rename:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
301 copies.append((fn, rename[0]))
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
302
24237
9ad02823dc5b templatekw: convert list of key/value pairs to sortdict
Yuya Nishihara <yuya@tcha.org>
parents: 24157
diff changeset
303 copies = util.sortdict(copies)
24238
49cee6d8573d templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents: 24237
diff changeset
304 makemap = lambda k: {'name': k, 'source': copies[k]}
49cee6d8573d templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents: 24237
diff changeset
305 c = [makemap(k) for k in copies]
18715
c4ff927b6f68 templater: properly handle file_copies with %
Matt Mackall <mpm@selenic.com>
parents: 17631
diff changeset
306 f = _showlist('file_copy', c, plural='file_copies', **args)
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
307 return _hybrid(f, copies, makemap,
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
308 lambda x: '%s (%s)' % (x['name'], x['source']))
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
309
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
310 # showfilecopiesswitch() displays file copies only if copy records are
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
311 # provided before calling the templater, usually with a --copies
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
312 # command line switch.
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
313 def showfilecopiesswitch(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
314 """:file_copies_switch: List of strings. Like "file_copies" but displayed
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
315 only if the --copied switch is set.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
316 """
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
317 copies = args['revcache'].get('copies') or []
24237
9ad02823dc5b templatekw: convert list of key/value pairs to sortdict
Yuya Nishihara <yuya@tcha.org>
parents: 24157
diff changeset
318 copies = util.sortdict(copies)
24238
49cee6d8573d templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents: 24237
diff changeset
319 makemap = lambda k: {'name': k, 'source': copies[k]}
49cee6d8573d templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara <yuya@tcha.org>
parents: 24237
diff changeset
320 c = [makemap(k) for k in copies]
18715
c4ff927b6f68 templater: properly handle file_copies with %
Matt Mackall <mpm@selenic.com>
parents: 17631
diff changeset
321 f = _showlist('file_copy', c, plural='file_copies', **args)
24239
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
322 return _hybrid(f, copies, makemap,
31f9b1b16d1e templatekw: keep raw list or dict in _hybrid object
Yuya Nishihara <yuya@tcha.org>
parents: 24238
diff changeset
323 lambda x: '%s (%s)' % (x['name'], x['source']))
10058
c829563b3118 cmdutil: extract file copies closure into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10057
diff changeset
324
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
325 def showfiledels(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
326 """:file_dels: List of strings. Files removed by this changeset."""
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
327 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
328 return showlist('file_del', getfiles(repo, ctx, revcache)[2],
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
329 element='file', **args)
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
330
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
331 def showfilemods(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
332 """:file_mods: List of strings. Files modified by this changeset."""
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
333 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
334 return showlist('file_mod', getfiles(repo, ctx, revcache)[0],
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
335 element='file', **args)
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
336
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
337 def showfiles(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
338 """:files: List of strings. All files modified, added, or removed by this
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
339 changeset.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
340 """
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
341 return showlist('file', args['ctx'].files(), **args)
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
342
27214
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
343 def showgraphnode(repo, ctx, **args):
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
344 """:graphnode: String. The character representing the changeset node in
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
345 an ASCII revision graph"""
27215
5b8da5643a8a templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents: 27214
diff changeset
346 wpnodes = repo.dirstate.parents()
5b8da5643a8a templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents: 27214
diff changeset
347 if wpnodes[1] == nullid:
5b8da5643a8a templatekw: avoid slow creation of changectx objects in showgraphnode()
Yuya Nishihara <yuya@tcha.org>
parents: 27214
diff changeset
348 wpnodes = wpnodes[:1]
27214
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
349 if ctx.node() in wpnodes:
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
350 return '@'
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
351 elif ctx.obsolete():
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
352 return 'x'
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
353 elif ctx.closesbranch():
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
354 return '_'
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
355 else:
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
356 return 'o'
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
357
25727
b8245386ab40 templatekw: make {latesttag} a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 25726
diff changeset
358 def showlatesttag(**args):
b8245386ab40 templatekw: make {latesttag} a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 25726
diff changeset
359 """:latesttag: List of strings. The global tags on the most recent globally
b8245386ab40 templatekw: make {latesttag} a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 25726
diff changeset
360 tagged ancestor of this changeset.
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
361 """
26486
8a732c322ca7 templatekw: add {changes}, {distance} and {tag} to the {latesttag} keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 26484
diff changeset
362 return showlatesttags(None, **args)
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
363
26484
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
364 def showlatesttags(pattern, **args):
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
365 """helper method for the latesttag keyword and function"""
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
366 repo, ctx = args['repo'], args['ctx']
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
367 cache = args['cache']
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
368 latesttags = getlatesttags(repo, ctx, cache, pattern)
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
369
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
370 # latesttag[0] is an implementation detail for sorting csets on different
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
371 # branches in a stable manner- it is the date the tagged cset was created,
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
372 # not the date the tag was created. Therefore it isn't made visible here.
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
373 makemap = lambda v: {
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
374 'changes': _showchangessincetag,
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
375 'distance': latesttags[1],
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
376 'latesttag': v, # BC with {latesttag % '{latesttag}'}
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
377 'tag': v
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
378 }
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
379
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
380 tags = latesttags[2]
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
381 f = _showlist('latesttag', tags, separator=':', **args)
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
382 return _hybrid(f, tags, makemap, lambda x: x['latesttag'])
93c80e7ed8c8 templatekw: introduce showlatesttags() to handle {latesttag} keywords
Matt Harbison <matt_harbison@yahoo.com>
parents: 26483
diff changeset
383
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
384 def showlatesttagdistance(repo, ctx, templ, cache, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
385 """:latesttagdistance: Integer. Longest path to the latest tag."""
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
386 return getlatesttags(repo, ctx, cache)[1]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
387
25724
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
388 def showchangessincelatesttag(repo, ctx, templ, cache, **args):
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
389 """:changessincelatesttag: Integer. All ancestors not in the latest tag."""
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
390 latesttag = getlatesttags(repo, ctx, cache)[2][0]
26483
e94f93043a4e templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents: 26482
diff changeset
391
e94f93043a4e templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents: 26482
diff changeset
392 return _showchangessincetag(repo, ctx, tag=latesttag, **args)
e94f93043a4e templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents: 26482
diff changeset
393
e94f93043a4e templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents: 26482
diff changeset
394 def _showchangessincetag(repo, ctx, **args):
25724
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
395 offset = 0
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
396 revs = [ctx.rev()]
26483
e94f93043a4e templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents: 26482
diff changeset
397 tag = args['tag']
25724
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
398
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
399 # The only() revset doesn't currently support wdir()
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
400 if ctx.rev() is None:
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
401 offset = 1
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
402 revs = [p.rev() for p in ctx.parents()]
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
403
26483
e94f93043a4e templatekw: factor out the changessincetag calculation to a private method
Matt Harbison <matt_harbison@yahoo.com>
parents: 26482
diff changeset
404 return len(repo.revs('only(%ld, %s)', revs, tag)) + offset
25724
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
405
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
406 def showmanifest(**args):
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
407 repo, ctx, templ = args['repo'], args['ctx'], args['templ']
24676
13c42a883e8b templatekw: have {manifest} use ctx.manifestnode() for consistency
Yuya Nishihara <yuya@tcha.org>
parents: 24337
diff changeset
408 mnode = ctx.manifestnode()
25736
8854ca3fa675 templatekw: apply manifest template only if ctx.manifestnode() exists
Yuya Nishihara <yuya@tcha.org>
parents: 25727
diff changeset
409 if mnode is None:
8854ca3fa675 templatekw: apply manifest template only if ctx.manifestnode() exists
Yuya Nishihara <yuya@tcha.org>
parents: 25727
diff changeset
410 # just avoid crash, we might want to use the 'ff...' hash in future
8854ca3fa675 templatekw: apply manifest template only if ctx.manifestnode() exists
Yuya Nishihara <yuya@tcha.org>
parents: 25727
diff changeset
411 return
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
412 args = args.copy()
24676
13c42a883e8b templatekw: have {manifest} use ctx.manifestnode() for consistency
Yuya Nishihara <yuya@tcha.org>
parents: 24337
diff changeset
413 args.update({'rev': repo.manifest.rev(mnode), 'node': hex(mnode)})
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
414 return templ('manifest', **args)
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
415
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
416 def shownode(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
417 """:node: String. The changeset identification hash, as a 40 hexadecimal
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
418 digit string.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
419 """
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
420 return ctx.hex()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
421
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
422 def showp1rev(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
423 """:p1rev: Integer. The repository-local revision number of the changeset's
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
424 first parent, or -1 if the changeset has no parents."""
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
425 return ctx.p1().rev()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
426
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
427 def showp2rev(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
428 """:p2rev: Integer. The repository-local revision number of the changeset's
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
429 second parent, or -1 if the changeset has no second parent."""
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
430 return ctx.p2().rev()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
431
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
432 def showp1node(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
433 """:p1node: String. The identification hash of the changeset's first parent,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
434 as a 40 digit hexadecimal string. If the changeset has no parents, all
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
435 digits are 0."""
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
436 return ctx.p1().hex()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
437
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
438 def showp2node(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
439 """:p2node: String. The identification hash of the changeset's second
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
440 parent, as a 40 digit hexadecimal string. If the changeset has no second
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
441 parent, all digits are 0."""
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
442 return ctx.p2().hex()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
443
26435
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
444 def showparents(**args):
26434
0a823de8d7b7 templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents: 26234
diff changeset
445 """:parents: List of strings. The parents of the changeset in "rev:node"
0a823de8d7b7 templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents: 26234
diff changeset
446 format. If the changeset has only one "natural" parent (the predecessor
0a823de8d7b7 templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents: 26234
diff changeset
447 revision) nothing is shown."""
26435
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
448 repo = args['repo']
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
449 ctx = args['ctx']
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
450 parents = [[('rev', p.rev()),
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
451 ('node', p.hex()),
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
452 ('phase', p.phasestr())]
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
453 for p in scmutil.meaningfulparents(repo, ctx)]
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
454 return showlist('parent', parents, **args)
26434
0a823de8d7b7 templatekw: reorder stub of showparents() function
Yuya Nishihara <yuya@tcha.org>
parents: 26234
diff changeset
455
15422
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
456 def showphase(repo, ctx, templ, **args):
15947
bdd1ed80e26e templatekw: fix phase keywords
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 15823
diff changeset
457 """:phase: String. The changeset phase name."""
15823
a1f818a2b50d phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15422
diff changeset
458 return ctx.phasestr()
a1f818a2b50d phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15422
diff changeset
459
a1f818a2b50d phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15422
diff changeset
460 def showphaseidx(repo, ctx, templ, **args):
15947
bdd1ed80e26e templatekw: fix phase keywords
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 15823
diff changeset
461 """:phaseidx: Integer. The changeset phase index."""
15422
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
462 return ctx.phase()
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
463
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
464 def showrev(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
465 """:rev: Integer. The repository-local changeset revision number."""
25740
47469fa8fb01 templatekw: make {rev} return wdirrev instead of None
Yuya Nishihara <yuya@tcha.org>
parents: 25736
diff changeset
466 return scmutil.intrev(ctx.rev())
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
467
26234
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
468 def showrevslist(name, revs, **args):
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
469 """helper to generate a list of revisions in which a mapped template will
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
470 be evaluated"""
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
471 repo = args['ctx'].repo()
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
472 f = _showlist(name, revs, **args)
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
473 return _hybrid(f, revs,
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
474 lambda x: {name: x, 'ctx': repo[x], 'revcache': {}})
e4609ec959f8 templater: switch ctx of list expression to rev of revset() (BC)
Yuya Nishihara <yuya@tcha.org>
parents: 25984
diff changeset
475
21897
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
476 def showsubrepos(**args):
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
477 """:subrepos: List of strings. Updated subrepositories in the changeset."""
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
478 ctx = args['ctx']
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
479 substate = ctx.substate
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
480 if not substate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
481 return showlist('subrepo', [], **args)
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
482 psubstate = ctx.parents()[0].substate or {}
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
483 subrepos = []
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
484 for sub in substate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
485 if sub not in psubstate or substate[sub] != psubstate[sub]:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
486 subrepos.append(sub) # modified or newly added in ctx
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
487 for sub in psubstate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
488 if sub not in substate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
489 subrepos.append(sub) # removed in ctx
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
490 return showlist('subrepo', sorted(subrepos), **args)
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
491
23609
40fcf6c05217 templatekw: add helper method to generate a template keyword for a namespace
Sean Farley <sean.michael.farley@gmail.com>
parents: 22393
diff changeset
492 def shownames(namespace, **args):
40fcf6c05217 templatekw: add helper method to generate a template keyword for a namespace
Sean Farley <sean.michael.farley@gmail.com>
parents: 22393
diff changeset
493 """helper method to generate a template keyword for a namespace"""
40fcf6c05217 templatekw: add helper method to generate a template keyword for a namespace
Sean Farley <sean.michael.farley@gmail.com>
parents: 22393
diff changeset
494 ctx = args['ctx']
24337
696ab1a24ae0 templater: replace 'ctx._repo' with 'ctx.repo()'
Matt Harbison <matt_harbison@yahoo.com>
parents: 24241
diff changeset
495 repo = ctx.repo()
23737
b56400eeefaf templatekw: update namespace calls
Sean Farley <sean.michael.farley@gmail.com>
parents: 23611
diff changeset
496 ns = repo.names[namespace]
b56400eeefaf templatekw: update namespace calls
Sean Farley <sean.michael.farley@gmail.com>
parents: 23611
diff changeset
497 names = ns.names(repo, ctx.node())
b56400eeefaf templatekw: update namespace calls
Sean Farley <sean.michael.farley@gmail.com>
parents: 23611
diff changeset
498 return showlist(ns.templatename, names, plural=namespace, **args)
23609
40fcf6c05217 templatekw: add helper method to generate a template keyword for a namespace
Sean Farley <sean.michael.farley@gmail.com>
parents: 22393
diff changeset
499
23977
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
500 # don't remove "showtags" definition, even though namespaces will put
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
501 # a helper function for "tags" keyword into "keywords" map automatically,
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
502 # because online help text is built without namespaces initialization
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
503 def showtags(**args):
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
504 """:tags: List of strings. Any tags associated with the changeset."""
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
505 return shownames('tags', **args)
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
506
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
507 # keywords are callables like:
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
508 # fn(repo, ctx, templ, cache, revcache, **args)
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
509 # with:
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
510 # repo - current repository instance
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
511 # ctx - the changectx being displayed
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
512 # templ - the templater instance
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
513 # cache - a cache dictionary for the whole templater run
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
514 # revcache - a cache dictionary for the current revision
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
515 keywords = {
25013
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
516 'activebookmark': showactivebookmark,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
517 'author': showauthor,
15155
f4a8d754cd0a templates: add 'bisect' keyword to return a cset's bisect status
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 14437
diff changeset
518 'bisect': showbisect,
13156
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
519 'branch': showbranch,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
520 'branches': showbranches,
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
521 'bookmarks': showbookmarks,
25724
4474a750413f templatekw: introduce the changessincelatesttag keyword
Matt Harbison <matt_harbison@yahoo.com>
parents: 25700
diff changeset
522 'changessincelatesttag': showchangessincelatesttag,
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
523 'children': showchildren,
25013
277aba2c151a templatekw: introduce activebookmark keyword
Ryan McElroy <rmcelroy@fb.com>
parents: 25012
diff changeset
524 # currentbookmark is deprecated
21896
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
525 'currentbookmark': showcurrentbookmark,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
526 'date': showdate,
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
527 'desc': showdescription,
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
528 'diffstat': showdiffstat,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
529 'extras': showextras,
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
530 'file_adds': showfileadds,
10058
c829563b3118 cmdutil: extract file copies closure into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10057
diff changeset
531 'file_copies': showfilecopies,
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
532 'file_copies_switch': showfilecopiesswitch,
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
533 'file_dels': showfiledels,
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
534 'file_mods': showfilemods,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
535 'files': showfiles,
27214
60af96494a76 graphlog: extract "graphnode" template keyword that represents node symbol
Yuya Nishihara <yuya@tcha.org>
parents: 26486
diff changeset
536 'graphnode': showgraphnode,
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
537 'latesttag': showlatesttag,
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
538 'latesttagdistance': showlatesttagdistance,
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
539 'manifest': showmanifest,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
540 'node': shownode,
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
541 'p1rev': showp1rev,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
542 'p1node': showp1node,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
543 'p2rev': showp2rev,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
544 'p2node': showp2node,
26435
882b170ae616 templatekw: port implementation of showparents() from changeset_templater
Yuya Nishihara <yuya@tcha.org>
parents: 26434
diff changeset
545 'parents': showparents,
15422
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
546 'phase': showphase,
15823
a1f818a2b50d phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15422
diff changeset
547 'phaseidx': showphaseidx,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
548 'rev': showrev,
21897
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
549 'subrepos': showsubrepos,
23977
0870bb93573c templatekw: re-add showtags() to list tags keyword up in online help
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23737
diff changeset
550 'tags': showtags,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
551 }
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
552
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
553 # tell hggettext to extract docstrings from these functions:
26436
a2291c9c85a1 templatekw: remove dockeywords hack
Yuya Nishihara <yuya@tcha.org>
parents: 26435
diff changeset
554 i18nfunctions = keywords.values()