annotate mercurial/templatekw.py @ 21897:764adc332f6e

templatekw: add 'subrepos' keyword to show updated subrepositories 'subrepos' template keyword newly added by this patch shows updated subrepositories. For the compatibility with the list of subrepositories shown in the editor at commit: - 'subrepos' is empty, at revisions removing '.hgsub' itself - 'subrepos' is calculated between the revision and the first parent of it, at merge revisions To avoid silent regression, this patch also confirms "hg diff" of ".hgsubstate" and parents for each target revisions in the test.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 15 Jul 2014 23:34:13 +0900
parents 2b41ee1b5ea1
children 293930a1fa0a
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
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
8 from node import hex
14318
1f46be4689ed help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents: 14064
diff changeset
9 import patch, util, error
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
10 import hbisect
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
11
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
12 # 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
13 # "{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
14 # "{files % '{file}\n'}" (hgweb-style with inlining and function support)
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
15
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
16 class _hybrid(object):
18970
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
17 def __init__(self, gen, values, joinfmt=None):
17631
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
18 self.gen = gen
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
19 self.values = values
18970
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
20 if joinfmt:
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
21 self.joinfmt = joinfmt
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
22 else:
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
23 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
24 def __iter__(self):
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
25 return self.gen
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
26 def __call__(self):
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
27 for x in self.values:
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
28 yield x
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
29
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
30 def showlist(name, values, plural=None, element=None, **args):
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
31 if not element:
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
32 element = name
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
33 f = _showlist(name, values, plural, **args)
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
34 return _hybrid(f, [{element: x} for x in values])
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
35
0b241d7a8c62 templating: make new-style templating features work with command line lists
Matt Mackall <mpm@selenic.com>
parents: 17358
diff changeset
36 def _showlist(name, values, plural=None, **args):
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
37 '''expand set of values.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
38 name is name of key in template map.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
39 values is list of strings or dicts.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
40 plural is plural of name, if not simply name + 's'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
41
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
42 expansion works like this, given name 'foo'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
43
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
44 if values is empty, expand 'no_foos'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
45
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
46 if 'foo' not in template map, return values as a string,
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
47 joined by space.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
48
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
49 expand 'start_foos'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
50
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
51 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
52 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
53
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
54 expand 'end_foos'.
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
55 '''
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
56 templ = args['templ']
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
57 if plural:
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
58 names = plural
10053
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
59 else: names = name + 's'
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
60 if not values:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
61 noname = 'no_' + names
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
62 if noname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
63 yield templ(noname, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
64 return
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
65 if name not in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
66 if isinstance(values[0], str):
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
67 yield ' '.join(values)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
68 else:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
69 for v in values:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
70 yield dict(v, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
71 return
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
72 startname = 'start_' + names
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
73 if startname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
74 yield templ(startname, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
75 vargs = args.copy()
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
76 def one(v, tag=name):
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
77 try:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
78 vargs.update(v)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
79 except (AttributeError, ValueError):
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
80 try:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
81 for a, b in v:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
82 vargs[a] = b
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
83 except ValueError:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
84 vargs[name] = v
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
85 return templ(tag, **vargs)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
86 lastname = 'last_' + name
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
87 if lastname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
88 last = values.pop()
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 last = None
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
91 for v in values:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
92 yield one(v)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
93 if last is not None:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
94 yield one(last, tag=lastname)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
95 endname = 'end_' + names
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
96 if endname in templ:
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
97 yield templ(endname, **args)
5c5c6295533d cmdutil: replace showlist() closure with a function
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
98
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
99 def getfiles(repo, ctx, revcache):
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
100 if 'files' not in revcache:
13878
a8d13ee0ce68 misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents: 13593
diff changeset
101 revcache['files'] = repo.status(ctx.p1().node(), ctx.node())[:3]
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
102 return revcache['files']
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
103
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
104 def getlatesttags(repo, ctx, cache):
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
105 '''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
106
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
107 if 'latesttags' not in cache:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
108 # 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
109 # distance and tag name
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
110 cache['latesttags'] = {-1: (0, 0, 'null')}
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
111 latesttags = cache['latesttags']
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
112
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
113 rev = ctx.rev()
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
114 todo = [rev]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
115 while todo:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
116 rev = todo.pop()
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
117 if rev in latesttags:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
118 continue
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
119 ctx = repo[rev]
20218
0c22257388d6 templatekw: allow tagtypes other than global in getlatesttags
Andrew Shadura <andrew@shadura.me>
parents: 20183
diff changeset
120 tags = [t for t in ctx.tags()
0c22257388d6 templatekw: allow tagtypes other than global in getlatesttags
Andrew Shadura <andrew@shadura.me>
parents: 20183
diff changeset
121 if (repo.tagtype(t) and repo.tagtype(t) != 'local')]
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
122 if tags:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
123 latesttags[rev] = ctx.date()[0], 0, ':'.join(sorted(tags))
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
124 continue
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
125 try:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
126 # 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
127 # comparison.
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
128 pdate, pdist, ptag = max(
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
129 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
130 except KeyError:
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
131 # Cache miss - recurse
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
132 todo.append(rev)
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
133 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
134 continue
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
135 latesttags[rev] = pdate, pdist + 1, ptag
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
136 return latesttags[rev]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
137
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
138 def getrenamedfn(repo, endrev=None):
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
139 rcache = {}
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
140 if endrev is None:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
141 endrev = len(repo)
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
142
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
143 def getrenamed(fn, rev):
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
144 '''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
145 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
146 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
147 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
148 if fn not in rcache:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
149 rcache[fn] = {}
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
150 fl = repo.file(fn)
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
151 for i in fl:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
152 lr = fl.linkrev(i)
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
153 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
154 rcache[fn][lr] = renamed
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
155 if lr >= endrev:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
156 break
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
157 if rev in rcache[fn]:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
158 return rcache[fn][rev]
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
159
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
160 # 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
161 # filectx logic.
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
162 try:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
163 return repo[rev][fn].renamed()
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
164 except error.LookupError:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
165 return None
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
166
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
167 return getrenamed
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
168
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
169
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
170 def showauthor(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
171 """: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
172 return ctx.user()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
173
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
174 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
175 """: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
176 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
177
13156
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
178 def showbranch(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
179 """: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
180 committed.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
181 """
13156
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
182 return args['ctx'].branch()
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
183
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
184 def showbranches(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
185 """: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
186 changeset was committed. Will be empty if the branch name was
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
187 default.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
188 """
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
189 branch = args['ctx'].branch()
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
190 if branch != 'default':
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
191 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
192 return showlist('branch', [], plural='branches', **args)
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
193
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
194 def showbookmarks(**args):
13592
ad2ee188f4a5 templates: document missing keywords or filters
Patrick Mezard <pmezard@gmail.com>
parents: 13585
diff changeset
195 """:bookmarks: List of strings. Any bookmarks associated with the
ad2ee188f4a5 templates: document missing keywords or filters
Patrick Mezard <pmezard@gmail.com>
parents: 13585
diff changeset
196 changeset.
ad2ee188f4a5 templates: document missing keywords or filters
Patrick Mezard <pmezard@gmail.com>
parents: 13585
diff changeset
197 """
20520
5c65ee4193e1 template: add 'current' to scope during {bookmarks % ...}
Durham Goode <durham@fb.com>
parents: 20218
diff changeset
198 repo = args['ctx']._repo
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
199 bookmarks = args['ctx'].bookmarks()
20520
5c65ee4193e1 template: add 'current' to scope during {bookmarks % ...}
Durham Goode <durham@fb.com>
parents: 20218
diff changeset
200 hybrid = showlist('bookmark', bookmarks, **args)
5c65ee4193e1 template: add 'current' to scope during {bookmarks % ...}
Durham Goode <durham@fb.com>
parents: 20218
diff changeset
201 for value in hybrid.values:
5c65ee4193e1 template: add 'current' to scope during {bookmarks % ...}
Durham Goode <durham@fb.com>
parents: 20218
diff changeset
202 value['current'] = repo._bookmarkcurrent
5c65ee4193e1 template: add 'current' to scope during {bookmarks % ...}
Durham Goode <durham@fb.com>
parents: 20218
diff changeset
203 return hybrid
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
204
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
205 def showchildren(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
206 """:children: List of strings. The children of the changeset."""
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
207 ctx = args['ctx']
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
208 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
209 return showlist('children', childrevs, element='child', **args)
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
210
21896
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
211 def showcurrentbookmark(**args):
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
212 """:currentbookmark: String. The active bookmark, if it is
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
213 associated with the changeset"""
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
214 import bookmarks as bookmarks # to avoid circular import issues
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
215 repo = args['repo']
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
216 if bookmarks.iscurrent(repo):
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
217 current = repo._bookmarkcurrent
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
218 if current in args['ctx'].bookmarks():
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
219 return current
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
220 return ''
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
221
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
222 def showdate(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
223 """: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
224 return ctx.date()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
225
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
226 def showdescription(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
227 """: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
228 return ctx.description().strip()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
229
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
230 def showdiffstat(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
231 """:diffstat: String. Statistics of changes with the following format:
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
232 "modified files: +added/-removed lines"
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
233 """
14403
2c9f5897d4b7 templatekw: use diffstatsum in diffstat keyword
Matt Mackall <mpm@selenic.com>
parents: 14318
diff changeset
234 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
235 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
236 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
237
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
238 def showextras(**args):
20015
ad27cdacc743 help: document about {extras} template keyword
Matthew Turk <matthewturk@gmail.com>
parents: 18970
diff changeset
239 """: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
240 field of this changeset."""
20183
de7e6c489412 template: modify showextras to return a hybrid
Matthew Turk <matthewturk@gmail.com>
parents: 20079
diff changeset
241 extras = args['ctx'].extra()
de7e6c489412 template: modify showextras to return a hybrid
Matthew Turk <matthewturk@gmail.com>
parents: 20079
diff changeset
242 c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
de7e6c489412 template: modify showextras to return a hybrid
Matthew Turk <matthewturk@gmail.com>
parents: 20079
diff changeset
243 f = _showlist('extra', c, plural='extras', **args)
de7e6c489412 template: modify showextras to return a hybrid
Matthew Turk <matthewturk@gmail.com>
parents: 20079
diff changeset
244 return _hybrid(f, c, 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
245
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
246 def showfileadds(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
247 """: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
248 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
249 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
250 element='file', **args)
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
251
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
252 def showfilecopies(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
253 """: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
254 their sources.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
255 """
10394
4612cded5176 fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10282
diff changeset
256 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
257 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
258 if copies is None:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
259 if 'getrenamed' not in cache:
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
260 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
261 copies = []
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
262 getrenamed = cache['getrenamed']
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
263 for fn in ctx.files():
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
264 rename = getrenamed(fn, ctx.rev())
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
265 if rename:
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
266 copies.append((fn, rename[0]))
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10264
diff changeset
267
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
268 c = [{'name': x[0], 'source': x[1]} for x in copies]
18715
c4ff927b6f68 templater: properly handle file_copies with %
Matt Mackall <mpm@selenic.com>
parents: 17631
diff changeset
269 f = _showlist('file_copy', c, plural='file_copies', **args)
18970
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
270 return _hybrid(f, c, 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
271
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
272 # 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
273 # 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
274 # command line switch.
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
275 def showfilecopiesswitch(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
276 """: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
277 only if the --copied switch is set.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
278 """
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
279 copies = args['revcache'].get('copies') or []
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
280 c = [{'name': x[0], 'source': x[1]} for x in copies]
18715
c4ff927b6f68 templater: properly handle file_copies with %
Matt Mackall <mpm@selenic.com>
parents: 17631
diff changeset
281 f = _showlist('file_copy', c, plural='file_copies', **args)
18970
3cdb6f2f6789 templatekw: add default styles for hybrid types (issue3887)
Matt Mackall <mpm@selenic.com>
parents: 18715
diff changeset
282 return _hybrid(f, c, 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
283
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
284 def showfiledels(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
285 """: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
286 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
287 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
288 element='file', **args)
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
289
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
290 def showfilemods(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
291 """: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
292 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
293 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
294 element='file', **args)
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
295
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
296 def showfiles(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
297 """: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
298 changeset.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
299 """
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
300 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
301
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
302 def showlatesttag(repo, ctx, templ, cache, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
303 """:latesttag: String. Most recent global tag in the ancestors of this
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
304 changeset.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
305 """
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
306 return getlatesttags(repo, ctx, cache)[2]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
307
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
308 def showlatesttagdistance(repo, ctx, templ, cache, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
309 """: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
310 return getlatesttags(repo, ctx, cache)[1]
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
311
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
312 def showmanifest(**args):
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
313 repo, ctx, templ = args['repo'], args['ctx'], args['templ']
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
314 args = args.copy()
20683
6cb419dd3703 templatekw: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents: 20520
diff changeset
315 args.update({'rev': repo.manifest.rev(ctx.changeset()[0]),
6cb419dd3703 templatekw: move from dict() construction to {} literals
Augie Fackler <raf@durin42.com>
parents: 20520
diff changeset
316 'node': hex(ctx.changeset()[0])})
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
317 return templ('manifest', **args)
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
318
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
319 def shownode(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
320 """: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
321 digit string.
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
322 """
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
323 return ctx.hex()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
324
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
325 def showp1rev(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
326 """: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
327 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
328 return ctx.p1().rev()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
329
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
330 def showp2rev(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
331 """: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
332 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
333 return ctx.p2().rev()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
334
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
335 def showp1node(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
336 """: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
337 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
338 digits are 0."""
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
339 return ctx.p1().hex()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
340
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
341 def showp2node(repo, ctx, templ, **args):
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
342 """: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
343 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
344 parent, all digits are 0."""
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
345 return ctx.p2().hex()
17355
c25531ed58b0 templatekw: add parent1, parent1node, parent2, parent2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
346
15422
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
347 def showphase(repo, ctx, templ, **args):
15947
bdd1ed80e26e templatekw: fix phase keywords
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 15823
diff changeset
348 """: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
349 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
350
a1f818a2b50d phases: ``{phase}`` template keyword display the phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15422
diff changeset
351 def showphaseidx(repo, ctx, templ, **args):
15947
bdd1ed80e26e templatekw: fix phase keywords
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 15823
diff changeset
352 """: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
353 return ctx.phase()
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
354
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
355 def showrev(repo, ctx, templ, **args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
356 """:rev: Integer. The repository-local changeset revision number."""
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
357 return ctx.rev()
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
358
21897
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
359 def showsubrepos(**args):
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
360 """: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
361 ctx = args['ctx']
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
362 substate = ctx.substate
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
363 if not substate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
364 return showlist('subrepo', [], **args)
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
365 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
366 subrepos = []
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
367 for sub in substate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
368 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
369 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
370 for sub in psubstate:
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
371 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
372 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
373 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
374
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
375 def showtags(**args):
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
376 """:tags: List of strings. Any tags associated with the changeset."""
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
377 return showlist('tag', args['ctx'].tags(), **args)
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
378
10260
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
379 # keywords are callables like:
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
380 # 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
381 # with:
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
382 # repo - current repository instance
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
383 # ctx - the changectx being displayed
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
384 # templ - the templater instance
fe699ca08a45 templatekw: fix extras, manifest and showlist args (issue1989)
Patrick Mezard <pmezard@gmail.com>
parents: 10060
diff changeset
385 # 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
386 # 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
387 keywords = {
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
388 '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
389 'bisect': showbisect,
13156
d79fdff55627 template: add showbranch template for {branch}
Eric Eisner <ede@mit.edu>
parents: 13114
diff changeset
390 'branch': showbranch,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
391 'branches': showbranches,
13386
f78bc5ddbe4f templater: add bookmarks to templates and default output
David Soria Parra <dsp@php.net>
parents: 13156
diff changeset
392 'bookmarks': showbookmarks,
11655
6faf015e0ba0 templates: 'children' keyword
Jason Harris <jason@jasonfharris.com>
parents: 10394
diff changeset
393 'children': showchildren,
21896
2b41ee1b5ea1 templatekw: add 'currentbookmark' keyword to show current bookmark easily
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20683
diff changeset
394 'currentbookmark': showcurrentbookmark,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
395 'date': showdate,
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
396 'desc': showdescription,
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
397 'diffstat': showdiffstat,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
398 'extras': showextras,
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
399 'file_adds': showfileadds,
10058
c829563b3118 cmdutil: extract file copies closure into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10057
diff changeset
400 'file_copies': showfilecopies,
10060
f780b1098efc templatekw: change {file_copies} behaviour, add {file_copies_switch}
Patrick Mezard <pmezard@gmail.com>
parents: 10058
diff changeset
401 'file_copies_switch': showfilecopiesswitch,
10056
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
402 'file_dels': showfiledels,
1a114aca93fa cmdutil: extract file changes closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10055
diff changeset
403 'file_mods': showfilemods,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
404 'files': showfiles,
10057
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
405 'latesttag': showlatesttag,
babc00a82c5e cmdutil: extract latest tags closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10056
diff changeset
406 'latesttagdistance': showlatesttagdistance,
10055
e400a511e63a cmdutil: extract repo dependent closures in templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10054
diff changeset
407 'manifest': showmanifest,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
408 'node': shownode,
17357
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
409 'p1rev': showp1rev,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
410 'p1node': showp1node,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
411 'p2rev': showp2rev,
bd605568c5a0 templatekw: add p1rev, p1node, p2rev, p2node keywords
epriestley <hg@yghe.net>
parents: 17187
diff changeset
412 'p2node': showp2node,
15422
042e11c4e416 phases: add a phase template keyword
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15155
diff changeset
413 '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
414 'phaseidx': showphaseidx,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
415 'rev': showrev,
21897
764adc332f6e templatekw: add 'subrepos' keyword to show updated subrepositories
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21896
diff changeset
416 'subrepos': showsubrepos,
10054
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
417 'tags': showtags,
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
418 }
1a85861f59af cmdutil: extract ctx dependent closures into templatekw
Patrick Mezard <pmezard@gmail.com>
parents: 10053
diff changeset
419
17187
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
420 def _showparents(**args):
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
421 """:parents: List of strings. The parents of the changeset in "rev:node"
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
422 format. If the changeset has only one "natural" parent (the predecessor
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
423 revision) nothing is shown."""
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
424 pass
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
425
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
426 dockeywords = {
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
427 'parents': _showparents,
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
428 }
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
429 dockeywords.update(keywords)
20078
43e872a35f8a help: drop help for branches template keyword
Matt Mackall <mpm@selenic.com>
parents: 20017
diff changeset
430 del dockeywords['branches']
17187
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
431
13585
2e80d495592a templates: generate keyword help dynamically
Patrick Mezard <pmezard@gmail.com>
parents: 13386
diff changeset
432 # tell hggettext to extract docstrings from these functions:
17187
293dd81e4601 templatekw/help: document the {parents} keyword
epriestley <hg@yghe.net>
parents: 15947
diff changeset
433 i18nfunctions = dockeywords.values()