##// END OF EJS Templates
templatekw: move from dict() construction to {} literals...
Augie Fackler -
r20683:6cb419dd default
parent child Browse files
Show More
@@ -1,404 +1,404 b''
1 # templatekw.py - common changeset template keywords
1 # templatekw.py - common changeset template keywords
2 #
2 #
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from node import hex
8 from node import hex
9 import patch, util, error
9 import patch, util, error
10 import hbisect
10 import hbisect
11
11
12 # This helper class allows us to handle both:
12 # This helper class allows us to handle both:
13 # "{files}" (legacy command-line-specific list hack) and
13 # "{files}" (legacy command-line-specific list hack) and
14 # "{files % '{file}\n'}" (hgweb-style with inlining and function support)
14 # "{files % '{file}\n'}" (hgweb-style with inlining and function support)
15
15
16 class _hybrid(object):
16 class _hybrid(object):
17 def __init__(self, gen, values, joinfmt=None):
17 def __init__(self, gen, values, joinfmt=None):
18 self.gen = gen
18 self.gen = gen
19 self.values = values
19 self.values = values
20 if joinfmt:
20 if joinfmt:
21 self.joinfmt = joinfmt
21 self.joinfmt = joinfmt
22 else:
22 else:
23 self.joinfmt = lambda x: x.values()[0]
23 self.joinfmt = lambda x: x.values()[0]
24 def __iter__(self):
24 def __iter__(self):
25 return self.gen
25 return self.gen
26 def __call__(self):
26 def __call__(self):
27 for x in self.values:
27 for x in self.values:
28 yield x
28 yield x
29
29
30 def showlist(name, values, plural=None, element=None, **args):
30 def showlist(name, values, plural=None, element=None, **args):
31 if not element:
31 if not element:
32 element = name
32 element = name
33 f = _showlist(name, values, plural, **args)
33 f = _showlist(name, values, plural, **args)
34 return _hybrid(f, [{element: x} for x in values])
34 return _hybrid(f, [{element: x} for x in values])
35
35
36 def _showlist(name, values, plural=None, **args):
36 def _showlist(name, values, plural=None, **args):
37 '''expand set of values.
37 '''expand set of values.
38 name is name of key in template map.
38 name is name of key in template map.
39 values is list of strings or dicts.
39 values is list of strings or dicts.
40 plural is plural of name, if not simply name + 's'.
40 plural is plural of name, if not simply name + 's'.
41
41
42 expansion works like this, given name 'foo'.
42 expansion works like this, given name 'foo'.
43
43
44 if values is empty, expand 'no_foos'.
44 if values is empty, expand 'no_foos'.
45
45
46 if 'foo' not in template map, return values as a string,
46 if 'foo' not in template map, return values as a string,
47 joined by space.
47 joined by space.
48
48
49 expand 'start_foos'.
49 expand 'start_foos'.
50
50
51 for each value, expand 'foo'. if 'last_foo' in template
51 for each value, expand 'foo'. if 'last_foo' in template
52 map, expand it instead of 'foo' for last key.
52 map, expand it instead of 'foo' for last key.
53
53
54 expand 'end_foos'.
54 expand 'end_foos'.
55 '''
55 '''
56 templ = args['templ']
56 templ = args['templ']
57 if plural:
57 if plural:
58 names = plural
58 names = plural
59 else: names = name + 's'
59 else: names = name + 's'
60 if not values:
60 if not values:
61 noname = 'no_' + names
61 noname = 'no_' + names
62 if noname in templ:
62 if noname in templ:
63 yield templ(noname, **args)
63 yield templ(noname, **args)
64 return
64 return
65 if name not in templ:
65 if name not in templ:
66 if isinstance(values[0], str):
66 if isinstance(values[0], str):
67 yield ' '.join(values)
67 yield ' '.join(values)
68 else:
68 else:
69 for v in values:
69 for v in values:
70 yield dict(v, **args)
70 yield dict(v, **args)
71 return
71 return
72 startname = 'start_' + names
72 startname = 'start_' + names
73 if startname in templ:
73 if startname in templ:
74 yield templ(startname, **args)
74 yield templ(startname, **args)
75 vargs = args.copy()
75 vargs = args.copy()
76 def one(v, tag=name):
76 def one(v, tag=name):
77 try:
77 try:
78 vargs.update(v)
78 vargs.update(v)
79 except (AttributeError, ValueError):
79 except (AttributeError, ValueError):
80 try:
80 try:
81 for a, b in v:
81 for a, b in v:
82 vargs[a] = b
82 vargs[a] = b
83 except ValueError:
83 except ValueError:
84 vargs[name] = v
84 vargs[name] = v
85 return templ(tag, **vargs)
85 return templ(tag, **vargs)
86 lastname = 'last_' + name
86 lastname = 'last_' + name
87 if lastname in templ:
87 if lastname in templ:
88 last = values.pop()
88 last = values.pop()
89 else:
89 else:
90 last = None
90 last = None
91 for v in values:
91 for v in values:
92 yield one(v)
92 yield one(v)
93 if last is not None:
93 if last is not None:
94 yield one(last, tag=lastname)
94 yield one(last, tag=lastname)
95 endname = 'end_' + names
95 endname = 'end_' + names
96 if endname in templ:
96 if endname in templ:
97 yield templ(endname, **args)
97 yield templ(endname, **args)
98
98
99 def getfiles(repo, ctx, revcache):
99 def getfiles(repo, ctx, revcache):
100 if 'files' not in revcache:
100 if 'files' not in revcache:
101 revcache['files'] = repo.status(ctx.p1().node(), ctx.node())[:3]
101 revcache['files'] = repo.status(ctx.p1().node(), ctx.node())[:3]
102 return revcache['files']
102 return revcache['files']
103
103
104 def getlatesttags(repo, ctx, cache):
104 def getlatesttags(repo, ctx, cache):
105 '''return date, distance and name for the latest tag of rev'''
105 '''return date, distance and name for the latest tag of rev'''
106
106
107 if 'latesttags' not in cache:
107 if 'latesttags' not in cache:
108 # Cache mapping from rev to a tuple with tag date, tag
108 # Cache mapping from rev to a tuple with tag date, tag
109 # distance and tag name
109 # distance and tag name
110 cache['latesttags'] = {-1: (0, 0, 'null')}
110 cache['latesttags'] = {-1: (0, 0, 'null')}
111 latesttags = cache['latesttags']
111 latesttags = cache['latesttags']
112
112
113 rev = ctx.rev()
113 rev = ctx.rev()
114 todo = [rev]
114 todo = [rev]
115 while todo:
115 while todo:
116 rev = todo.pop()
116 rev = todo.pop()
117 if rev in latesttags:
117 if rev in latesttags:
118 continue
118 continue
119 ctx = repo[rev]
119 ctx = repo[rev]
120 tags = [t for t in ctx.tags()
120 tags = [t for t in ctx.tags()
121 if (repo.tagtype(t) and repo.tagtype(t) != 'local')]
121 if (repo.tagtype(t) and repo.tagtype(t) != 'local')]
122 if tags:
122 if tags:
123 latesttags[rev] = ctx.date()[0], 0, ':'.join(sorted(tags))
123 latesttags[rev] = ctx.date()[0], 0, ':'.join(sorted(tags))
124 continue
124 continue
125 try:
125 try:
126 # The tuples are laid out so the right one can be found by
126 # The tuples are laid out so the right one can be found by
127 # comparison.
127 # comparison.
128 pdate, pdist, ptag = max(
128 pdate, pdist, ptag = max(
129 latesttags[p.rev()] for p in ctx.parents())
129 latesttags[p.rev()] for p in ctx.parents())
130 except KeyError:
130 except KeyError:
131 # Cache miss - recurse
131 # Cache miss - recurse
132 todo.append(rev)
132 todo.append(rev)
133 todo.extend(p.rev() for p in ctx.parents())
133 todo.extend(p.rev() for p in ctx.parents())
134 continue
134 continue
135 latesttags[rev] = pdate, pdist + 1, ptag
135 latesttags[rev] = pdate, pdist + 1, ptag
136 return latesttags[rev]
136 return latesttags[rev]
137
137
138 def getrenamedfn(repo, endrev=None):
138 def getrenamedfn(repo, endrev=None):
139 rcache = {}
139 rcache = {}
140 if endrev is None:
140 if endrev is None:
141 endrev = len(repo)
141 endrev = len(repo)
142
142
143 def getrenamed(fn, rev):
143 def getrenamed(fn, rev):
144 '''looks up all renames for a file (up to endrev) the first
144 '''looks up all renames for a file (up to endrev) the first
145 time the file is given. It indexes on the changerev and only
145 time the file is given. It indexes on the changerev and only
146 parses the manifest if linkrev != changerev.
146 parses the manifest if linkrev != changerev.
147 Returns rename info for fn at changerev rev.'''
147 Returns rename info for fn at changerev rev.'''
148 if fn not in rcache:
148 if fn not in rcache:
149 rcache[fn] = {}
149 rcache[fn] = {}
150 fl = repo.file(fn)
150 fl = repo.file(fn)
151 for i in fl:
151 for i in fl:
152 lr = fl.linkrev(i)
152 lr = fl.linkrev(i)
153 renamed = fl.renamed(fl.node(i))
153 renamed = fl.renamed(fl.node(i))
154 rcache[fn][lr] = renamed
154 rcache[fn][lr] = renamed
155 if lr >= endrev:
155 if lr >= endrev:
156 break
156 break
157 if rev in rcache[fn]:
157 if rev in rcache[fn]:
158 return rcache[fn][rev]
158 return rcache[fn][rev]
159
159
160 # If linkrev != rev (i.e. rev not found in rcache) fallback to
160 # If linkrev != rev (i.e. rev not found in rcache) fallback to
161 # filectx logic.
161 # filectx logic.
162 try:
162 try:
163 return repo[rev][fn].renamed()
163 return repo[rev][fn].renamed()
164 except error.LookupError:
164 except error.LookupError:
165 return None
165 return None
166
166
167 return getrenamed
167 return getrenamed
168
168
169
169
170 def showauthor(repo, ctx, templ, **args):
170 def showauthor(repo, ctx, templ, **args):
171 """:author: String. The unmodified author of the changeset."""
171 """:author: String. The unmodified author of the changeset."""
172 return ctx.user()
172 return ctx.user()
173
173
174 def showbisect(repo, ctx, templ, **args):
174 def showbisect(repo, ctx, templ, **args):
175 """:bisect: String. The changeset bisection status."""
175 """:bisect: String. The changeset bisection status."""
176 return hbisect.label(repo, ctx.node())
176 return hbisect.label(repo, ctx.node())
177
177
178 def showbranch(**args):
178 def showbranch(**args):
179 """:branch: String. The name of the branch on which the changeset was
179 """:branch: String. The name of the branch on which the changeset was
180 committed.
180 committed.
181 """
181 """
182 return args['ctx'].branch()
182 return args['ctx'].branch()
183
183
184 def showbranches(**args):
184 def showbranches(**args):
185 """:branches: List of strings. The name of the branch on which the
185 """:branches: List of strings. The name of the branch on which the
186 changeset was committed. Will be empty if the branch name was
186 changeset was committed. Will be empty if the branch name was
187 default.
187 default.
188 """
188 """
189 branch = args['ctx'].branch()
189 branch = args['ctx'].branch()
190 if branch != 'default':
190 if branch != 'default':
191 return showlist('branch', [branch], plural='branches', **args)
191 return showlist('branch', [branch], plural='branches', **args)
192 return showlist('branch', [], plural='branches', **args)
192 return showlist('branch', [], plural='branches', **args)
193
193
194 def showbookmarks(**args):
194 def showbookmarks(**args):
195 """:bookmarks: List of strings. Any bookmarks associated with the
195 """:bookmarks: List of strings. Any bookmarks associated with the
196 changeset.
196 changeset.
197 """
197 """
198 repo = args['ctx']._repo
198 repo = args['ctx']._repo
199 bookmarks = args['ctx'].bookmarks()
199 bookmarks = args['ctx'].bookmarks()
200 hybrid = showlist('bookmark', bookmarks, **args)
200 hybrid = showlist('bookmark', bookmarks, **args)
201 for value in hybrid.values:
201 for value in hybrid.values:
202 value['current'] = repo._bookmarkcurrent
202 value['current'] = repo._bookmarkcurrent
203 return hybrid
203 return hybrid
204
204
205 def showchildren(**args):
205 def showchildren(**args):
206 """:children: List of strings. The children of the changeset."""
206 """:children: List of strings. The children of the changeset."""
207 ctx = args['ctx']
207 ctx = args['ctx']
208 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
208 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
209 return showlist('children', childrevs, element='child', **args)
209 return showlist('children', childrevs, element='child', **args)
210
210
211 def showdate(repo, ctx, templ, **args):
211 def showdate(repo, ctx, templ, **args):
212 """:date: Date information. The date when the changeset was committed."""
212 """:date: Date information. The date when the changeset was committed."""
213 return ctx.date()
213 return ctx.date()
214
214
215 def showdescription(repo, ctx, templ, **args):
215 def showdescription(repo, ctx, templ, **args):
216 """:desc: String. The text of the changeset description."""
216 """:desc: String. The text of the changeset description."""
217 return ctx.description().strip()
217 return ctx.description().strip()
218
218
219 def showdiffstat(repo, ctx, templ, **args):
219 def showdiffstat(repo, ctx, templ, **args):
220 """:diffstat: String. Statistics of changes with the following format:
220 """:diffstat: String. Statistics of changes with the following format:
221 "modified files: +added/-removed lines"
221 "modified files: +added/-removed lines"
222 """
222 """
223 stats = patch.diffstatdata(util.iterlines(ctx.diff()))
223 stats = patch.diffstatdata(util.iterlines(ctx.diff()))
224 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
224 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
225 return '%s: +%s/-%s' % (len(stats), adds, removes)
225 return '%s: +%s/-%s' % (len(stats), adds, removes)
226
226
227 def showextras(**args):
227 def showextras(**args):
228 """:extras: List of dicts with key, value entries of the 'extras'
228 """:extras: List of dicts with key, value entries of the 'extras'
229 field of this changeset."""
229 field of this changeset."""
230 extras = args['ctx'].extra()
230 extras = args['ctx'].extra()
231 c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
231 c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
232 f = _showlist('extra', c, plural='extras', **args)
232 f = _showlist('extra', c, plural='extras', **args)
233 return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
233 return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
234
234
235 def showfileadds(**args):
235 def showfileadds(**args):
236 """:file_adds: List of strings. Files added by this changeset."""
236 """:file_adds: List of strings. Files added by this changeset."""
237 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
237 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
238 return showlist('file_add', getfiles(repo, ctx, revcache)[1],
238 return showlist('file_add', getfiles(repo, ctx, revcache)[1],
239 element='file', **args)
239 element='file', **args)
240
240
241 def showfilecopies(**args):
241 def showfilecopies(**args):
242 """:file_copies: List of strings. Files copied in this changeset with
242 """:file_copies: List of strings. Files copied in this changeset with
243 their sources.
243 their sources.
244 """
244 """
245 cache, ctx = args['cache'], args['ctx']
245 cache, ctx = args['cache'], args['ctx']
246 copies = args['revcache'].get('copies')
246 copies = args['revcache'].get('copies')
247 if copies is None:
247 if copies is None:
248 if 'getrenamed' not in cache:
248 if 'getrenamed' not in cache:
249 cache['getrenamed'] = getrenamedfn(args['repo'])
249 cache['getrenamed'] = getrenamedfn(args['repo'])
250 copies = []
250 copies = []
251 getrenamed = cache['getrenamed']
251 getrenamed = cache['getrenamed']
252 for fn in ctx.files():
252 for fn in ctx.files():
253 rename = getrenamed(fn, ctx.rev())
253 rename = getrenamed(fn, ctx.rev())
254 if rename:
254 if rename:
255 copies.append((fn, rename[0]))
255 copies.append((fn, rename[0]))
256
256
257 c = [{'name': x[0], 'source': x[1]} for x in copies]
257 c = [{'name': x[0], 'source': x[1]} for x in copies]
258 f = _showlist('file_copy', c, plural='file_copies', **args)
258 f = _showlist('file_copy', c, plural='file_copies', **args)
259 return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
259 return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
260
260
261 # showfilecopiesswitch() displays file copies only if copy records are
261 # showfilecopiesswitch() displays file copies only if copy records are
262 # provided before calling the templater, usually with a --copies
262 # provided before calling the templater, usually with a --copies
263 # command line switch.
263 # command line switch.
264 def showfilecopiesswitch(**args):
264 def showfilecopiesswitch(**args):
265 """:file_copies_switch: List of strings. Like "file_copies" but displayed
265 """:file_copies_switch: List of strings. Like "file_copies" but displayed
266 only if the --copied switch is set.
266 only if the --copied switch is set.
267 """
267 """
268 copies = args['revcache'].get('copies') or []
268 copies = args['revcache'].get('copies') or []
269 c = [{'name': x[0], 'source': x[1]} for x in copies]
269 c = [{'name': x[0], 'source': x[1]} for x in copies]
270 f = _showlist('file_copy', c, plural='file_copies', **args)
270 f = _showlist('file_copy', c, plural='file_copies', **args)
271 return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
271 return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
272
272
273 def showfiledels(**args):
273 def showfiledels(**args):
274 """:file_dels: List of strings. Files removed by this changeset."""
274 """:file_dels: List of strings. Files removed by this changeset."""
275 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
275 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
276 return showlist('file_del', getfiles(repo, ctx, revcache)[2],
276 return showlist('file_del', getfiles(repo, ctx, revcache)[2],
277 element='file', **args)
277 element='file', **args)
278
278
279 def showfilemods(**args):
279 def showfilemods(**args):
280 """:file_mods: List of strings. Files modified by this changeset."""
280 """:file_mods: List of strings. Files modified by this changeset."""
281 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
281 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
282 return showlist('file_mod', getfiles(repo, ctx, revcache)[0],
282 return showlist('file_mod', getfiles(repo, ctx, revcache)[0],
283 element='file', **args)
283 element='file', **args)
284
284
285 def showfiles(**args):
285 def showfiles(**args):
286 """:files: List of strings. All files modified, added, or removed by this
286 """:files: List of strings. All files modified, added, or removed by this
287 changeset.
287 changeset.
288 """
288 """
289 return showlist('file', args['ctx'].files(), **args)
289 return showlist('file', args['ctx'].files(), **args)
290
290
291 def showlatesttag(repo, ctx, templ, cache, **args):
291 def showlatesttag(repo, ctx, templ, cache, **args):
292 """:latesttag: String. Most recent global tag in the ancestors of this
292 """:latesttag: String. Most recent global tag in the ancestors of this
293 changeset.
293 changeset.
294 """
294 """
295 return getlatesttags(repo, ctx, cache)[2]
295 return getlatesttags(repo, ctx, cache)[2]
296
296
297 def showlatesttagdistance(repo, ctx, templ, cache, **args):
297 def showlatesttagdistance(repo, ctx, templ, cache, **args):
298 """:latesttagdistance: Integer. Longest path to the latest tag."""
298 """:latesttagdistance: Integer. Longest path to the latest tag."""
299 return getlatesttags(repo, ctx, cache)[1]
299 return getlatesttags(repo, ctx, cache)[1]
300
300
301 def showmanifest(**args):
301 def showmanifest(**args):
302 repo, ctx, templ = args['repo'], args['ctx'], args['templ']
302 repo, ctx, templ = args['repo'], args['ctx'], args['templ']
303 args = args.copy()
303 args = args.copy()
304 args.update(dict(rev=repo.manifest.rev(ctx.changeset()[0]),
304 args.update({'rev': repo.manifest.rev(ctx.changeset()[0]),
305 node=hex(ctx.changeset()[0])))
305 'node': hex(ctx.changeset()[0])})
306 return templ('manifest', **args)
306 return templ('manifest', **args)
307
307
308 def shownode(repo, ctx, templ, **args):
308 def shownode(repo, ctx, templ, **args):
309 """:node: String. The changeset identification hash, as a 40 hexadecimal
309 """:node: String. The changeset identification hash, as a 40 hexadecimal
310 digit string.
310 digit string.
311 """
311 """
312 return ctx.hex()
312 return ctx.hex()
313
313
314 def showp1rev(repo, ctx, templ, **args):
314 def showp1rev(repo, ctx, templ, **args):
315 """:p1rev: Integer. The repository-local revision number of the changeset's
315 """:p1rev: Integer. The repository-local revision number of the changeset's
316 first parent, or -1 if the changeset has no parents."""
316 first parent, or -1 if the changeset has no parents."""
317 return ctx.p1().rev()
317 return ctx.p1().rev()
318
318
319 def showp2rev(repo, ctx, templ, **args):
319 def showp2rev(repo, ctx, templ, **args):
320 """:p2rev: Integer. The repository-local revision number of the changeset's
320 """:p2rev: Integer. The repository-local revision number of the changeset's
321 second parent, or -1 if the changeset has no second parent."""
321 second parent, or -1 if the changeset has no second parent."""
322 return ctx.p2().rev()
322 return ctx.p2().rev()
323
323
324 def showp1node(repo, ctx, templ, **args):
324 def showp1node(repo, ctx, templ, **args):
325 """:p1node: String. The identification hash of the changeset's first parent,
325 """:p1node: String. The identification hash of the changeset's first parent,
326 as a 40 digit hexadecimal string. If the changeset has no parents, all
326 as a 40 digit hexadecimal string. If the changeset has no parents, all
327 digits are 0."""
327 digits are 0."""
328 return ctx.p1().hex()
328 return ctx.p1().hex()
329
329
330 def showp2node(repo, ctx, templ, **args):
330 def showp2node(repo, ctx, templ, **args):
331 """:p2node: String. The identification hash of the changeset's second
331 """:p2node: String. The identification hash of the changeset's second
332 parent, as a 40 digit hexadecimal string. If the changeset has no second
332 parent, as a 40 digit hexadecimal string. If the changeset has no second
333 parent, all digits are 0."""
333 parent, all digits are 0."""
334 return ctx.p2().hex()
334 return ctx.p2().hex()
335
335
336 def showphase(repo, ctx, templ, **args):
336 def showphase(repo, ctx, templ, **args):
337 """:phase: String. The changeset phase name."""
337 """:phase: String. The changeset phase name."""
338 return ctx.phasestr()
338 return ctx.phasestr()
339
339
340 def showphaseidx(repo, ctx, templ, **args):
340 def showphaseidx(repo, ctx, templ, **args):
341 """:phaseidx: Integer. The changeset phase index."""
341 """:phaseidx: Integer. The changeset phase index."""
342 return ctx.phase()
342 return ctx.phase()
343
343
344 def showrev(repo, ctx, templ, **args):
344 def showrev(repo, ctx, templ, **args):
345 """:rev: Integer. The repository-local changeset revision number."""
345 """:rev: Integer. The repository-local changeset revision number."""
346 return ctx.rev()
346 return ctx.rev()
347
347
348 def showtags(**args):
348 def showtags(**args):
349 """:tags: List of strings. Any tags associated with the changeset."""
349 """:tags: List of strings. Any tags associated with the changeset."""
350 return showlist('tag', args['ctx'].tags(), **args)
350 return showlist('tag', args['ctx'].tags(), **args)
351
351
352 # keywords are callables like:
352 # keywords are callables like:
353 # fn(repo, ctx, templ, cache, revcache, **args)
353 # fn(repo, ctx, templ, cache, revcache, **args)
354 # with:
354 # with:
355 # repo - current repository instance
355 # repo - current repository instance
356 # ctx - the changectx being displayed
356 # ctx - the changectx being displayed
357 # templ - the templater instance
357 # templ - the templater instance
358 # cache - a cache dictionary for the whole templater run
358 # cache - a cache dictionary for the whole templater run
359 # revcache - a cache dictionary for the current revision
359 # revcache - a cache dictionary for the current revision
360 keywords = {
360 keywords = {
361 'author': showauthor,
361 'author': showauthor,
362 'bisect': showbisect,
362 'bisect': showbisect,
363 'branch': showbranch,
363 'branch': showbranch,
364 'branches': showbranches,
364 'branches': showbranches,
365 'bookmarks': showbookmarks,
365 'bookmarks': showbookmarks,
366 'children': showchildren,
366 'children': showchildren,
367 'date': showdate,
367 'date': showdate,
368 'desc': showdescription,
368 'desc': showdescription,
369 'diffstat': showdiffstat,
369 'diffstat': showdiffstat,
370 'extras': showextras,
370 'extras': showextras,
371 'file_adds': showfileadds,
371 'file_adds': showfileadds,
372 'file_copies': showfilecopies,
372 'file_copies': showfilecopies,
373 'file_copies_switch': showfilecopiesswitch,
373 'file_copies_switch': showfilecopiesswitch,
374 'file_dels': showfiledels,
374 'file_dels': showfiledels,
375 'file_mods': showfilemods,
375 'file_mods': showfilemods,
376 'files': showfiles,
376 'files': showfiles,
377 'latesttag': showlatesttag,
377 'latesttag': showlatesttag,
378 'latesttagdistance': showlatesttagdistance,
378 'latesttagdistance': showlatesttagdistance,
379 'manifest': showmanifest,
379 'manifest': showmanifest,
380 'node': shownode,
380 'node': shownode,
381 'p1rev': showp1rev,
381 'p1rev': showp1rev,
382 'p1node': showp1node,
382 'p1node': showp1node,
383 'p2rev': showp2rev,
383 'p2rev': showp2rev,
384 'p2node': showp2node,
384 'p2node': showp2node,
385 'phase': showphase,
385 'phase': showphase,
386 'phaseidx': showphaseidx,
386 'phaseidx': showphaseidx,
387 'rev': showrev,
387 'rev': showrev,
388 'tags': showtags,
388 'tags': showtags,
389 }
389 }
390
390
391 def _showparents(**args):
391 def _showparents(**args):
392 """:parents: List of strings. The parents of the changeset in "rev:node"
392 """:parents: List of strings. The parents of the changeset in "rev:node"
393 format. If the changeset has only one "natural" parent (the predecessor
393 format. If the changeset has only one "natural" parent (the predecessor
394 revision) nothing is shown."""
394 revision) nothing is shown."""
395 pass
395 pass
396
396
397 dockeywords = {
397 dockeywords = {
398 'parents': _showparents,
398 'parents': _showparents,
399 }
399 }
400 dockeywords.update(keywords)
400 dockeywords.update(keywords)
401 del dockeywords['branches']
401 del dockeywords['branches']
402
402
403 # tell hggettext to extract docstrings from these functions:
403 # tell hggettext to extract docstrings from these functions:
404 i18nfunctions = dockeywords.values()
404 i18nfunctions = dockeywords.values()
General Comments 0
You need to be logged in to leave comments. Login now