##// END OF EJS Templates
templater: store revisions as ints so min/max won't compare them as strings...
Yuya Nishihara -
r34582:ee0d7408 default
parent child Browse files
Show More
@@ -1,888 +1,886
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 __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from .i18n import _
10 from .i18n import _
11 from .node import (
11 from .node import (
12 hex,
12 hex,
13 nullid,
13 nullid,
14 )
14 )
15
15
16 from . import (
16 from . import (
17 encoding,
17 encoding,
18 error,
18 error,
19 hbisect,
19 hbisect,
20 obsutil,
20 obsutil,
21 patch,
21 patch,
22 pycompat,
22 pycompat,
23 registrar,
23 registrar,
24 scmutil,
24 scmutil,
25 util,
25 util,
26 )
26 )
27
27
28 class _hybrid(object):
28 class _hybrid(object):
29 """Wrapper for list or dict to support legacy template
29 """Wrapper for list or dict to support legacy template
30
30
31 This class allows us to handle both:
31 This class allows us to handle both:
32 - "{files}" (legacy command-line-specific list hack) and
32 - "{files}" (legacy command-line-specific list hack) and
33 - "{files % '{file}\n'}" (hgweb-style with inlining and function support)
33 - "{files % '{file}\n'}" (hgweb-style with inlining and function support)
34 and to access raw values:
34 and to access raw values:
35 - "{ifcontains(file, files, ...)}", "{ifcontains(key, extras, ...)}"
35 - "{ifcontains(file, files, ...)}", "{ifcontains(key, extras, ...)}"
36 - "{get(extras, key)}"
36 - "{get(extras, key)}"
37 - "{files|json}"
37 - "{files|json}"
38 """
38 """
39
39
40 def __init__(self, gen, values, makemap, joinfmt):
40 def __init__(self, gen, values, makemap, joinfmt, keytype=None):
41 if gen is not None:
41 if gen is not None:
42 self.gen = gen # generator or function returning generator
42 self.gen = gen # generator or function returning generator
43 self._values = values
43 self._values = values
44 self._makemap = makemap
44 self._makemap = makemap
45 self.joinfmt = joinfmt
45 self.joinfmt = joinfmt
46 self.keytype = keytype # hint for 'x in y' where type(x) is unresolved
46 def gen(self):
47 def gen(self):
47 """Default generator to stringify this as {join(self, ' ')}"""
48 """Default generator to stringify this as {join(self, ' ')}"""
48 for i, x in enumerate(self._values):
49 for i, x in enumerate(self._values):
49 if i > 0:
50 if i > 0:
50 yield ' '
51 yield ' '
51 yield self.joinfmt(x)
52 yield self.joinfmt(x)
52 def itermaps(self):
53 def itermaps(self):
53 makemap = self._makemap
54 makemap = self._makemap
54 for x in self._values:
55 for x in self._values:
55 yield makemap(x)
56 yield makemap(x)
56 def __contains__(self, x):
57 def __contains__(self, x):
57 return x in self._values
58 return x in self._values
58 def __getitem__(self, key):
59 def __getitem__(self, key):
59 return self._values[key]
60 return self._values[key]
60 def __len__(self):
61 def __len__(self):
61 return len(self._values)
62 return len(self._values)
62 def __iter__(self):
63 def __iter__(self):
63 return iter(self._values)
64 return iter(self._values)
64 def __getattr__(self, name):
65 def __getattr__(self, name):
65 if name not in ('get', 'items', 'iteritems', 'iterkeys', 'itervalues',
66 if name not in ('get', 'items', 'iteritems', 'iterkeys', 'itervalues',
66 'keys', 'values'):
67 'keys', 'values'):
67 raise AttributeError(name)
68 raise AttributeError(name)
68 return getattr(self._values, name)
69 return getattr(self._values, name)
69
70
70 class _mappable(object):
71 class _mappable(object):
71 """Wrapper for non-list/dict object to support map operation
72 """Wrapper for non-list/dict object to support map operation
72
73
73 This class allows us to handle both:
74 This class allows us to handle both:
74 - "{manifest}"
75 - "{manifest}"
75 - "{manifest % '{rev}:{node}'}"
76 - "{manifest % '{rev}:{node}'}"
76 - "{manifest.rev}"
77 - "{manifest.rev}"
77
78
78 Unlike a _hybrid, this does not simulate the behavior of the underling
79 Unlike a _hybrid, this does not simulate the behavior of the underling
79 value. Use unwrapvalue() or unwraphybrid() to obtain the inner object.
80 value. Use unwrapvalue() or unwraphybrid() to obtain the inner object.
80 """
81 """
81
82
82 def __init__(self, gen, key, value, makemap):
83 def __init__(self, gen, key, value, makemap):
83 if gen is not None:
84 if gen is not None:
84 self.gen = gen # generator or function returning generator
85 self.gen = gen # generator or function returning generator
85 self._key = key
86 self._key = key
86 self._value = value # may be generator of strings
87 self._value = value # may be generator of strings
87 self._makemap = makemap
88 self._makemap = makemap
88
89
89 def gen(self):
90 def gen(self):
90 yield pycompat.bytestr(self._value)
91 yield pycompat.bytestr(self._value)
91
92
92 def tomap(self):
93 def tomap(self):
93 return self._makemap(self._key)
94 return self._makemap(self._key)
94
95
95 def itermaps(self):
96 def itermaps(self):
96 yield self.tomap()
97 yield self.tomap()
97
98
98 def hybriddict(data, key='key', value='value', fmt='%s=%s', gen=None):
99 def hybriddict(data, key='key', value='value', fmt='%s=%s', gen=None):
99 """Wrap data to support both dict-like and string-like operations"""
100 """Wrap data to support both dict-like and string-like operations"""
100 return _hybrid(gen, data, lambda k: {key: k, value: data[k]},
101 return _hybrid(gen, data, lambda k: {key: k, value: data[k]},
101 lambda k: fmt % (k, data[k]))
102 lambda k: fmt % (k, data[k]))
102
103
103 def hybridlist(data, name, fmt='%s', gen=None):
104 def hybridlist(data, name, fmt='%s', gen=None):
104 """Wrap data to support both list-like and string-like operations"""
105 """Wrap data to support both list-like and string-like operations"""
105 return _hybrid(gen, data, lambda x: {name: x}, lambda x: fmt % x)
106 return _hybrid(gen, data, lambda x: {name: x}, lambda x: fmt % x)
106
107
107 def unwraphybrid(thing):
108 def unwraphybrid(thing):
108 """Return an object which can be stringified possibly by using a legacy
109 """Return an object which can be stringified possibly by using a legacy
109 template"""
110 template"""
110 gen = getattr(thing, 'gen', None)
111 gen = getattr(thing, 'gen', None)
111 if gen is None:
112 if gen is None:
112 return thing
113 return thing
113 if callable(gen):
114 if callable(gen):
114 return gen()
115 return gen()
115 return gen
116 return gen
116
117
117 def unwrapvalue(thing):
118 def unwrapvalue(thing):
118 """Move the inner value object out of the wrapper"""
119 """Move the inner value object out of the wrapper"""
119 if not util.safehasattr(thing, '_value'):
120 if not util.safehasattr(thing, '_value'):
120 return thing
121 return thing
121 return thing._value
122 return thing._value
122
123
123 def wraphybridvalue(container, key, value):
124 def wraphybridvalue(container, key, value):
124 """Wrap an element of hybrid container to be mappable
125 """Wrap an element of hybrid container to be mappable
125
126
126 The key is passed to the makemap function of the given container, which
127 The key is passed to the makemap function of the given container, which
127 should be an item generated by iter(container).
128 should be an item generated by iter(container).
128 """
129 """
129 makemap = getattr(container, '_makemap', None)
130 makemap = getattr(container, '_makemap', None)
130 if makemap is None:
131 if makemap is None:
131 return value
132 return value
132 if util.safehasattr(value, '_makemap'):
133 if util.safehasattr(value, '_makemap'):
133 # a nested hybrid list/dict, which has its own way of map operation
134 # a nested hybrid list/dict, which has its own way of map operation
134 return value
135 return value
135 return _mappable(None, key, value, makemap)
136 return _mappable(None, key, value, makemap)
136
137
137 def showdict(name, data, mapping, plural=None, key='key', value='value',
138 def showdict(name, data, mapping, plural=None, key='key', value='value',
138 fmt='%s=%s', separator=' '):
139 fmt='%s=%s', separator=' '):
139 c = [{key: k, value: v} for k, v in data.iteritems()]
140 c = [{key: k, value: v} for k, v in data.iteritems()]
140 f = _showlist(name, c, mapping, plural, separator)
141 f = _showlist(name, c, mapping, plural, separator)
141 return hybriddict(data, key=key, value=value, fmt=fmt, gen=f)
142 return hybriddict(data, key=key, value=value, fmt=fmt, gen=f)
142
143
143 def showlist(name, values, mapping, plural=None, element=None, separator=' '):
144 def showlist(name, values, mapping, plural=None, element=None, separator=' '):
144 if not element:
145 if not element:
145 element = name
146 element = name
146 f = _showlist(name, values, mapping, plural, separator)
147 f = _showlist(name, values, mapping, plural, separator)
147 return hybridlist(values, name=element, gen=f)
148 return hybridlist(values, name=element, gen=f)
148
149
149 def _showlist(name, values, mapping, plural=None, separator=' '):
150 def _showlist(name, values, mapping, plural=None, separator=' '):
150 '''expand set of values.
151 '''expand set of values.
151 name is name of key in template map.
152 name is name of key in template map.
152 values is list of strings or dicts.
153 values is list of strings or dicts.
153 plural is plural of name, if not simply name + 's'.
154 plural is plural of name, if not simply name + 's'.
154 separator is used to join values as a string
155 separator is used to join values as a string
155
156
156 expansion works like this, given name 'foo'.
157 expansion works like this, given name 'foo'.
157
158
158 if values is empty, expand 'no_foos'.
159 if values is empty, expand 'no_foos'.
159
160
160 if 'foo' not in template map, return values as a string,
161 if 'foo' not in template map, return values as a string,
161 joined by 'separator'.
162 joined by 'separator'.
162
163
163 expand 'start_foos'.
164 expand 'start_foos'.
164
165
165 for each value, expand 'foo'. if 'last_foo' in template
166 for each value, expand 'foo'. if 'last_foo' in template
166 map, expand it instead of 'foo' for last key.
167 map, expand it instead of 'foo' for last key.
167
168
168 expand 'end_foos'.
169 expand 'end_foos'.
169 '''
170 '''
170 templ = mapping['templ']
171 templ = mapping['templ']
171 strmapping = pycompat.strkwargs(mapping)
172 strmapping = pycompat.strkwargs(mapping)
172 if not plural:
173 if not plural:
173 plural = name + 's'
174 plural = name + 's'
174 if not values:
175 if not values:
175 noname = 'no_' + plural
176 noname = 'no_' + plural
176 if noname in templ:
177 if noname in templ:
177 yield templ(noname, **strmapping)
178 yield templ(noname, **strmapping)
178 return
179 return
179 if name not in templ:
180 if name not in templ:
180 if isinstance(values[0], bytes):
181 if isinstance(values[0], bytes):
181 yield separator.join(values)
182 yield separator.join(values)
182 else:
183 else:
183 for v in values:
184 for v in values:
184 yield dict(v, **strmapping)
185 yield dict(v, **strmapping)
185 return
186 return
186 startname = 'start_' + plural
187 startname = 'start_' + plural
187 if startname in templ:
188 if startname in templ:
188 yield templ(startname, **strmapping)
189 yield templ(startname, **strmapping)
189 vmapping = mapping.copy()
190 vmapping = mapping.copy()
190 def one(v, tag=name):
191 def one(v, tag=name):
191 try:
192 try:
192 vmapping.update(v)
193 vmapping.update(v)
193 except (AttributeError, ValueError):
194 except (AttributeError, ValueError):
194 try:
195 try:
195 for a, b in v:
196 for a, b in v:
196 vmapping[a] = b
197 vmapping[a] = b
197 except ValueError:
198 except ValueError:
198 vmapping[name] = v
199 vmapping[name] = v
199 return templ(tag, **pycompat.strkwargs(vmapping))
200 return templ(tag, **pycompat.strkwargs(vmapping))
200 lastname = 'last_' + name
201 lastname = 'last_' + name
201 if lastname in templ:
202 if lastname in templ:
202 last = values.pop()
203 last = values.pop()
203 else:
204 else:
204 last = None
205 last = None
205 for v in values:
206 for v in values:
206 yield one(v)
207 yield one(v)
207 if last is not None:
208 if last is not None:
208 yield one(last, tag=lastname)
209 yield one(last, tag=lastname)
209 endname = 'end_' + plural
210 endname = 'end_' + plural
210 if endname in templ:
211 if endname in templ:
211 yield templ(endname, **strmapping)
212 yield templ(endname, **strmapping)
212
213
213 def getfiles(repo, ctx, revcache):
214 def getfiles(repo, ctx, revcache):
214 if 'files' not in revcache:
215 if 'files' not in revcache:
215 revcache['files'] = repo.status(ctx.p1(), ctx)[:3]
216 revcache['files'] = repo.status(ctx.p1(), ctx)[:3]
216 return revcache['files']
217 return revcache['files']
217
218
218 def getlatesttags(repo, ctx, cache, pattern=None):
219 def getlatesttags(repo, ctx, cache, pattern=None):
219 '''return date, distance and name for the latest tag of rev'''
220 '''return date, distance and name for the latest tag of rev'''
220
221
221 cachename = 'latesttags'
222 cachename = 'latesttags'
222 if pattern is not None:
223 if pattern is not None:
223 cachename += '-' + pattern
224 cachename += '-' + pattern
224 match = util.stringmatcher(pattern)[2]
225 match = util.stringmatcher(pattern)[2]
225 else:
226 else:
226 match = util.always
227 match = util.always
227
228
228 if cachename not in cache:
229 if cachename not in cache:
229 # Cache mapping from rev to a tuple with tag date, tag
230 # Cache mapping from rev to a tuple with tag date, tag
230 # distance and tag name
231 # distance and tag name
231 cache[cachename] = {-1: (0, 0, ['null'])}
232 cache[cachename] = {-1: (0, 0, ['null'])}
232 latesttags = cache[cachename]
233 latesttags = cache[cachename]
233
234
234 rev = ctx.rev()
235 rev = ctx.rev()
235 todo = [rev]
236 todo = [rev]
236 while todo:
237 while todo:
237 rev = todo.pop()
238 rev = todo.pop()
238 if rev in latesttags:
239 if rev in latesttags:
239 continue
240 continue
240 ctx = repo[rev]
241 ctx = repo[rev]
241 tags = [t for t in ctx.tags()
242 tags = [t for t in ctx.tags()
242 if (repo.tagtype(t) and repo.tagtype(t) != 'local'
243 if (repo.tagtype(t) and repo.tagtype(t) != 'local'
243 and match(t))]
244 and match(t))]
244 if tags:
245 if tags:
245 latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
246 latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
246 continue
247 continue
247 try:
248 try:
248 ptags = [latesttags[p.rev()] for p in ctx.parents()]
249 ptags = [latesttags[p.rev()] for p in ctx.parents()]
249 if len(ptags) > 1:
250 if len(ptags) > 1:
250 if ptags[0][2] == ptags[1][2]:
251 if ptags[0][2] == ptags[1][2]:
251 # The tuples are laid out so the right one can be found by
252 # The tuples are laid out so the right one can be found by
252 # comparison in this case.
253 # comparison in this case.
253 pdate, pdist, ptag = max(ptags)
254 pdate, pdist, ptag = max(ptags)
254 else:
255 else:
255 def key(x):
256 def key(x):
256 changessincetag = len(repo.revs('only(%d, %s)',
257 changessincetag = len(repo.revs('only(%d, %s)',
257 ctx.rev(), x[2][0]))
258 ctx.rev(), x[2][0]))
258 # Smallest number of changes since tag wins. Date is
259 # Smallest number of changes since tag wins. Date is
259 # used as tiebreaker.
260 # used as tiebreaker.
260 return [-changessincetag, x[0]]
261 return [-changessincetag, x[0]]
261 pdate, pdist, ptag = max(ptags, key=key)
262 pdate, pdist, ptag = max(ptags, key=key)
262 else:
263 else:
263 pdate, pdist, ptag = ptags[0]
264 pdate, pdist, ptag = ptags[0]
264 except KeyError:
265 except KeyError:
265 # Cache miss - recurse
266 # Cache miss - recurse
266 todo.append(rev)
267 todo.append(rev)
267 todo.extend(p.rev() for p in ctx.parents())
268 todo.extend(p.rev() for p in ctx.parents())
268 continue
269 continue
269 latesttags[rev] = pdate, pdist + 1, ptag
270 latesttags[rev] = pdate, pdist + 1, ptag
270 return latesttags[rev]
271 return latesttags[rev]
271
272
272 def getrenamedfn(repo, endrev=None):
273 def getrenamedfn(repo, endrev=None):
273 rcache = {}
274 rcache = {}
274 if endrev is None:
275 if endrev is None:
275 endrev = len(repo)
276 endrev = len(repo)
276
277
277 def getrenamed(fn, rev):
278 def getrenamed(fn, rev):
278 '''looks up all renames for a file (up to endrev) the first
279 '''looks up all renames for a file (up to endrev) the first
279 time the file is given. It indexes on the changerev and only
280 time the file is given. It indexes on the changerev and only
280 parses the manifest if linkrev != changerev.
281 parses the manifest if linkrev != changerev.
281 Returns rename info for fn at changerev rev.'''
282 Returns rename info for fn at changerev rev.'''
282 if fn not in rcache:
283 if fn not in rcache:
283 rcache[fn] = {}
284 rcache[fn] = {}
284 fl = repo.file(fn)
285 fl = repo.file(fn)
285 for i in fl:
286 for i in fl:
286 lr = fl.linkrev(i)
287 lr = fl.linkrev(i)
287 renamed = fl.renamed(fl.node(i))
288 renamed = fl.renamed(fl.node(i))
288 rcache[fn][lr] = renamed
289 rcache[fn][lr] = renamed
289 if lr >= endrev:
290 if lr >= endrev:
290 break
291 break
291 if rev in rcache[fn]:
292 if rev in rcache[fn]:
292 return rcache[fn][rev]
293 return rcache[fn][rev]
293
294
294 # If linkrev != rev (i.e. rev not found in rcache) fallback to
295 # If linkrev != rev (i.e. rev not found in rcache) fallback to
295 # filectx logic.
296 # filectx logic.
296 try:
297 try:
297 return repo[rev][fn].renamed()
298 return repo[rev][fn].renamed()
298 except error.LookupError:
299 except error.LookupError:
299 return None
300 return None
300
301
301 return getrenamed
302 return getrenamed
302
303
303 # default templates internally used for rendering of lists
304 # default templates internally used for rendering of lists
304 defaulttempl = {
305 defaulttempl = {
305 'parent': '{rev}:{node|formatnode} ',
306 'parent': '{rev}:{node|formatnode} ',
306 'manifest': '{rev}:{node|formatnode}',
307 'manifest': '{rev}:{node|formatnode}',
307 'file_copy': '{name} ({source})',
308 'file_copy': '{name} ({source})',
308 'envvar': '{key}={value}',
309 'envvar': '{key}={value}',
309 'extra': '{key}={value|stringescape}'
310 'extra': '{key}={value|stringescape}'
310 }
311 }
311 # filecopy is preserved for compatibility reasons
312 # filecopy is preserved for compatibility reasons
312 defaulttempl['filecopy'] = defaulttempl['file_copy']
313 defaulttempl['filecopy'] = defaulttempl['file_copy']
313
314
314 # keywords are callables like:
315 # keywords are callables like:
315 # fn(repo, ctx, templ, cache, revcache, **args)
316 # fn(repo, ctx, templ, cache, revcache, **args)
316 # with:
317 # with:
317 # repo - current repository instance
318 # repo - current repository instance
318 # ctx - the changectx being displayed
319 # ctx - the changectx being displayed
319 # templ - the templater instance
320 # templ - the templater instance
320 # cache - a cache dictionary for the whole templater run
321 # cache - a cache dictionary for the whole templater run
321 # revcache - a cache dictionary for the current revision
322 # revcache - a cache dictionary for the current revision
322 keywords = {}
323 keywords = {}
323
324
324 templatekeyword = registrar.templatekeyword(keywords)
325 templatekeyword = registrar.templatekeyword(keywords)
325
326
326 @templatekeyword('author')
327 @templatekeyword('author')
327 def showauthor(repo, ctx, templ, **args):
328 def showauthor(repo, ctx, templ, **args):
328 """String. The unmodified author of the changeset."""
329 """String. The unmodified author of the changeset."""
329 return ctx.user()
330 return ctx.user()
330
331
331 @templatekeyword('bisect')
332 @templatekeyword('bisect')
332 def showbisect(repo, ctx, templ, **args):
333 def showbisect(repo, ctx, templ, **args):
333 """String. The changeset bisection status."""
334 """String. The changeset bisection status."""
334 return hbisect.label(repo, ctx.node())
335 return hbisect.label(repo, ctx.node())
335
336
336 @templatekeyword('branch')
337 @templatekeyword('branch')
337 def showbranch(**args):
338 def showbranch(**args):
338 """String. The name of the branch on which the changeset was
339 """String. The name of the branch on which the changeset was
339 committed.
340 committed.
340 """
341 """
341 return args[r'ctx'].branch()
342 return args[r'ctx'].branch()
342
343
343 @templatekeyword('branches')
344 @templatekeyword('branches')
344 def showbranches(**args):
345 def showbranches(**args):
345 """List of strings. The name of the branch on which the
346 """List of strings. The name of the branch on which the
346 changeset was committed. Will be empty if the branch name was
347 changeset was committed. Will be empty if the branch name was
347 default. (DEPRECATED)
348 default. (DEPRECATED)
348 """
349 """
349 args = pycompat.byteskwargs(args)
350 args = pycompat.byteskwargs(args)
350 branch = args['ctx'].branch()
351 branch = args['ctx'].branch()
351 if branch != 'default':
352 if branch != 'default':
352 return showlist('branch', [branch], args, plural='branches')
353 return showlist('branch', [branch], args, plural='branches')
353 return showlist('branch', [], args, plural='branches')
354 return showlist('branch', [], args, plural='branches')
354
355
355 @templatekeyword('bookmarks')
356 @templatekeyword('bookmarks')
356 def showbookmarks(**args):
357 def showbookmarks(**args):
357 """List of strings. Any bookmarks associated with the
358 """List of strings. Any bookmarks associated with the
358 changeset. Also sets 'active', the name of the active bookmark.
359 changeset. Also sets 'active', the name of the active bookmark.
359 """
360 """
360 args = pycompat.byteskwargs(args)
361 args = pycompat.byteskwargs(args)
361 repo = args['ctx']._repo
362 repo = args['ctx']._repo
362 bookmarks = args['ctx'].bookmarks()
363 bookmarks = args['ctx'].bookmarks()
363 active = repo._activebookmark
364 active = repo._activebookmark
364 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
365 makemap = lambda v: {'bookmark': v, 'active': active, 'current': active}
365 f = _showlist('bookmark', bookmarks, args)
366 f = _showlist('bookmark', bookmarks, args)
366 return _hybrid(f, bookmarks, makemap, pycompat.identity)
367 return _hybrid(f, bookmarks, makemap, pycompat.identity)
367
368
368 @templatekeyword('children')
369 @templatekeyword('children')
369 def showchildren(**args):
370 def showchildren(**args):
370 """List of strings. The children of the changeset."""
371 """List of strings. The children of the changeset."""
371 args = pycompat.byteskwargs(args)
372 args = pycompat.byteskwargs(args)
372 ctx = args['ctx']
373 ctx = args['ctx']
373 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
374 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
374 return showlist('children', childrevs, args, element='child')
375 return showlist('children', childrevs, args, element='child')
375
376
376 # Deprecated, but kept alive for help generation a purpose.
377 # Deprecated, but kept alive for help generation a purpose.
377 @templatekeyword('currentbookmark')
378 @templatekeyword('currentbookmark')
378 def showcurrentbookmark(**args):
379 def showcurrentbookmark(**args):
379 """String. The active bookmark, if it is
380 """String. The active bookmark, if it is
380 associated with the changeset (DEPRECATED)"""
381 associated with the changeset (DEPRECATED)"""
381 return showactivebookmark(**args)
382 return showactivebookmark(**args)
382
383
383 @templatekeyword('activebookmark')
384 @templatekeyword('activebookmark')
384 def showactivebookmark(**args):
385 def showactivebookmark(**args):
385 """String. The active bookmark, if it is
386 """String. The active bookmark, if it is
386 associated with the changeset"""
387 associated with the changeset"""
387 active = args[r'repo']._activebookmark
388 active = args[r'repo']._activebookmark
388 if active and active in args[r'ctx'].bookmarks():
389 if active and active in args[r'ctx'].bookmarks():
389 return active
390 return active
390 return ''
391 return ''
391
392
392 @templatekeyword('date')
393 @templatekeyword('date')
393 def showdate(repo, ctx, templ, **args):
394 def showdate(repo, ctx, templ, **args):
394 """Date information. The date when the changeset was committed."""
395 """Date information. The date when the changeset was committed."""
395 return ctx.date()
396 return ctx.date()
396
397
397 @templatekeyword('desc')
398 @templatekeyword('desc')
398 def showdescription(repo, ctx, templ, **args):
399 def showdescription(repo, ctx, templ, **args):
399 """String. The text of the changeset description."""
400 """String. The text of the changeset description."""
400 s = ctx.description()
401 s = ctx.description()
401 if isinstance(s, encoding.localstr):
402 if isinstance(s, encoding.localstr):
402 # try hard to preserve utf-8 bytes
403 # try hard to preserve utf-8 bytes
403 return encoding.tolocal(encoding.fromlocal(s).strip())
404 return encoding.tolocal(encoding.fromlocal(s).strip())
404 else:
405 else:
405 return s.strip()
406 return s.strip()
406
407
407 @templatekeyword('diffstat')
408 @templatekeyword('diffstat')
408 def showdiffstat(repo, ctx, templ, **args):
409 def showdiffstat(repo, ctx, templ, **args):
409 """String. Statistics of changes with the following format:
410 """String. Statistics of changes with the following format:
410 "modified files: +added/-removed lines"
411 "modified files: +added/-removed lines"
411 """
412 """
412 stats = patch.diffstatdata(util.iterlines(ctx.diff(noprefix=False)))
413 stats = patch.diffstatdata(util.iterlines(ctx.diff(noprefix=False)))
413 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
414 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
414 return '%s: +%s/-%s' % (len(stats), adds, removes)
415 return '%s: +%s/-%s' % (len(stats), adds, removes)
415
416
416 @templatekeyword('envvars')
417 @templatekeyword('envvars')
417 def showenvvars(repo, **args):
418 def showenvvars(repo, **args):
418 """A dictionary of environment variables. (EXPERIMENTAL)"""
419 """A dictionary of environment variables. (EXPERIMENTAL)"""
419 args = pycompat.byteskwargs(args)
420 args = pycompat.byteskwargs(args)
420 env = repo.ui.exportableenviron()
421 env = repo.ui.exportableenviron()
421 env = util.sortdict((k, env[k]) for k in sorted(env))
422 env = util.sortdict((k, env[k]) for k in sorted(env))
422 return showdict('envvar', env, args, plural='envvars')
423 return showdict('envvar', env, args, plural='envvars')
423
424
424 @templatekeyword('extras')
425 @templatekeyword('extras')
425 def showextras(**args):
426 def showextras(**args):
426 """List of dicts with key, value entries of the 'extras'
427 """List of dicts with key, value entries of the 'extras'
427 field of this changeset."""
428 field of this changeset."""
428 args = pycompat.byteskwargs(args)
429 args = pycompat.byteskwargs(args)
429 extras = args['ctx'].extra()
430 extras = args['ctx'].extra()
430 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
431 extras = util.sortdict((k, extras[k]) for k in sorted(extras))
431 makemap = lambda k: {'key': k, 'value': extras[k]}
432 makemap = lambda k: {'key': k, 'value': extras[k]}
432 c = [makemap(k) for k in extras]
433 c = [makemap(k) for k in extras]
433 f = _showlist('extra', c, args, plural='extras')
434 f = _showlist('extra', c, args, plural='extras')
434 return _hybrid(f, extras, makemap,
435 return _hybrid(f, extras, makemap,
435 lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
436 lambda k: '%s=%s' % (k, util.escapestr(extras[k])))
436
437
437 @templatekeyword('file_adds')
438 @templatekeyword('file_adds')
438 def showfileadds(**args):
439 def showfileadds(**args):
439 """List of strings. Files added by this changeset."""
440 """List of strings. Files added by this changeset."""
440 args = pycompat.byteskwargs(args)
441 args = pycompat.byteskwargs(args)
441 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
442 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
442 return showlist('file_add', getfiles(repo, ctx, revcache)[1], args,
443 return showlist('file_add', getfiles(repo, ctx, revcache)[1], args,
443 element='file')
444 element='file')
444
445
445 @templatekeyword('file_copies')
446 @templatekeyword('file_copies')
446 def showfilecopies(**args):
447 def showfilecopies(**args):
447 """List of strings. Files copied in this changeset with
448 """List of strings. Files copied in this changeset with
448 their sources.
449 their sources.
449 """
450 """
450 args = pycompat.byteskwargs(args)
451 args = pycompat.byteskwargs(args)
451 cache, ctx = args['cache'], args['ctx']
452 cache, ctx = args['cache'], args['ctx']
452 copies = args['revcache'].get('copies')
453 copies = args['revcache'].get('copies')
453 if copies is None:
454 if copies is None:
454 if 'getrenamed' not in cache:
455 if 'getrenamed' not in cache:
455 cache['getrenamed'] = getrenamedfn(args['repo'])
456 cache['getrenamed'] = getrenamedfn(args['repo'])
456 copies = []
457 copies = []
457 getrenamed = cache['getrenamed']
458 getrenamed = cache['getrenamed']
458 for fn in ctx.files():
459 for fn in ctx.files():
459 rename = getrenamed(fn, ctx.rev())
460 rename = getrenamed(fn, ctx.rev())
460 if rename:
461 if rename:
461 copies.append((fn, rename[0]))
462 copies.append((fn, rename[0]))
462
463
463 copies = util.sortdict(copies)
464 copies = util.sortdict(copies)
464 return showdict('file_copy', copies, args, plural='file_copies',
465 return showdict('file_copy', copies, args, plural='file_copies',
465 key='name', value='source', fmt='%s (%s)')
466 key='name', value='source', fmt='%s (%s)')
466
467
467 # showfilecopiesswitch() displays file copies only if copy records are
468 # showfilecopiesswitch() displays file copies only if copy records are
468 # provided before calling the templater, usually with a --copies
469 # provided before calling the templater, usually with a --copies
469 # command line switch.
470 # command line switch.
470 @templatekeyword('file_copies_switch')
471 @templatekeyword('file_copies_switch')
471 def showfilecopiesswitch(**args):
472 def showfilecopiesswitch(**args):
472 """List of strings. Like "file_copies" but displayed
473 """List of strings. Like "file_copies" but displayed
473 only if the --copied switch is set.
474 only if the --copied switch is set.
474 """
475 """
475 args = pycompat.byteskwargs(args)
476 args = pycompat.byteskwargs(args)
476 copies = args['revcache'].get('copies') or []
477 copies = args['revcache'].get('copies') or []
477 copies = util.sortdict(copies)
478 copies = util.sortdict(copies)
478 return showdict('file_copy', copies, args, plural='file_copies',
479 return showdict('file_copy', copies, args, plural='file_copies',
479 key='name', value='source', fmt='%s (%s)')
480 key='name', value='source', fmt='%s (%s)')
480
481
481 @templatekeyword('file_dels')
482 @templatekeyword('file_dels')
482 def showfiledels(**args):
483 def showfiledels(**args):
483 """List of strings. Files removed by this changeset."""
484 """List of strings. Files removed by this changeset."""
484 args = pycompat.byteskwargs(args)
485 args = pycompat.byteskwargs(args)
485 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
486 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
486 return showlist('file_del', getfiles(repo, ctx, revcache)[2], args,
487 return showlist('file_del', getfiles(repo, ctx, revcache)[2], args,
487 element='file')
488 element='file')
488
489
489 @templatekeyword('file_mods')
490 @templatekeyword('file_mods')
490 def showfilemods(**args):
491 def showfilemods(**args):
491 """List of strings. Files modified by this changeset."""
492 """List of strings. Files modified by this changeset."""
492 args = pycompat.byteskwargs(args)
493 args = pycompat.byteskwargs(args)
493 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
494 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
494 return showlist('file_mod', getfiles(repo, ctx, revcache)[0], args,
495 return showlist('file_mod', getfiles(repo, ctx, revcache)[0], args,
495 element='file')
496 element='file')
496
497
497 @templatekeyword('files')
498 @templatekeyword('files')
498 def showfiles(**args):
499 def showfiles(**args):
499 """List of strings. All files modified, added, or removed by this
500 """List of strings. All files modified, added, or removed by this
500 changeset.
501 changeset.
501 """
502 """
502 args = pycompat.byteskwargs(args)
503 args = pycompat.byteskwargs(args)
503 return showlist('file', args['ctx'].files(), args)
504 return showlist('file', args['ctx'].files(), args)
504
505
505 @templatekeyword('graphnode')
506 @templatekeyword('graphnode')
506 def showgraphnode(repo, ctx, **args):
507 def showgraphnode(repo, ctx, **args):
507 """String. The character representing the changeset node in
508 """String. The character representing the changeset node in
508 an ASCII revision graph"""
509 an ASCII revision graph"""
509 wpnodes = repo.dirstate.parents()
510 wpnodes = repo.dirstate.parents()
510 if wpnodes[1] == nullid:
511 if wpnodes[1] == nullid:
511 wpnodes = wpnodes[:1]
512 wpnodes = wpnodes[:1]
512 if ctx.node() in wpnodes:
513 if ctx.node() in wpnodes:
513 return '@'
514 return '@'
514 elif ctx.obsolete():
515 elif ctx.obsolete():
515 return 'x'
516 return 'x'
516 elif ctx.closesbranch():
517 elif ctx.closesbranch():
517 return '_'
518 return '_'
518 else:
519 else:
519 return 'o'
520 return 'o'
520
521
521 @templatekeyword('graphwidth')
522 @templatekeyword('graphwidth')
522 def showgraphwidth(repo, ctx, templ, **args):
523 def showgraphwidth(repo, ctx, templ, **args):
523 """Integer. The width of the graph drawn by 'log --graph' or zero."""
524 """Integer. The width of the graph drawn by 'log --graph' or zero."""
524 # The value args['graphwidth'] will be this function, so we use an internal
525 # The value args['graphwidth'] will be this function, so we use an internal
525 # name to pass the value through props into this function.
526 # name to pass the value through props into this function.
526 return args.get('_graphwidth', 0)
527 return args.get('_graphwidth', 0)
527
528
528 @templatekeyword('index')
529 @templatekeyword('index')
529 def showindex(**args):
530 def showindex(**args):
530 """Integer. The current iteration of the loop. (0 indexed)"""
531 """Integer. The current iteration of the loop. (0 indexed)"""
531 # just hosts documentation; should be overridden by template mapping
532 # just hosts documentation; should be overridden by template mapping
532 raise error.Abort(_("can't use index in this context"))
533 raise error.Abort(_("can't use index in this context"))
533
534
534 @templatekeyword('latesttag')
535 @templatekeyword('latesttag')
535 def showlatesttag(**args):
536 def showlatesttag(**args):
536 """List of strings. The global tags on the most recent globally
537 """List of strings. The global tags on the most recent globally
537 tagged ancestor of this changeset. If no such tags exist, the list
538 tagged ancestor of this changeset. If no such tags exist, the list
538 consists of the single string "null".
539 consists of the single string "null".
539 """
540 """
540 return showlatesttags(None, **args)
541 return showlatesttags(None, **args)
541
542
542 def showlatesttags(pattern, **args):
543 def showlatesttags(pattern, **args):
543 """helper method for the latesttag keyword and function"""
544 """helper method for the latesttag keyword and function"""
544 args = pycompat.byteskwargs(args)
545 args = pycompat.byteskwargs(args)
545 repo, ctx = args['repo'], args['ctx']
546 repo, ctx = args['repo'], args['ctx']
546 cache = args['cache']
547 cache = args['cache']
547 latesttags = getlatesttags(repo, ctx, cache, pattern)
548 latesttags = getlatesttags(repo, ctx, cache, pattern)
548
549
549 # latesttag[0] is an implementation detail for sorting csets on different
550 # latesttag[0] is an implementation detail for sorting csets on different
550 # branches in a stable manner- it is the date the tagged cset was created,
551 # branches in a stable manner- it is the date the tagged cset was created,
551 # not the date the tag was created. Therefore it isn't made visible here.
552 # not the date the tag was created. Therefore it isn't made visible here.
552 makemap = lambda v: {
553 makemap = lambda v: {
553 'changes': _showchangessincetag,
554 'changes': _showchangessincetag,
554 'distance': latesttags[1],
555 'distance': latesttags[1],
555 'latesttag': v, # BC with {latesttag % '{latesttag}'}
556 'latesttag': v, # BC with {latesttag % '{latesttag}'}
556 'tag': v
557 'tag': v
557 }
558 }
558
559
559 tags = latesttags[2]
560 tags = latesttags[2]
560 f = _showlist('latesttag', tags, args, separator=':')
561 f = _showlist('latesttag', tags, args, separator=':')
561 return _hybrid(f, tags, makemap, pycompat.identity)
562 return _hybrid(f, tags, makemap, pycompat.identity)
562
563
563 @templatekeyword('latesttagdistance')
564 @templatekeyword('latesttagdistance')
564 def showlatesttagdistance(repo, ctx, templ, cache, **args):
565 def showlatesttagdistance(repo, ctx, templ, cache, **args):
565 """Integer. Longest path to the latest tag."""
566 """Integer. Longest path to the latest tag."""
566 return getlatesttags(repo, ctx, cache)[1]
567 return getlatesttags(repo, ctx, cache)[1]
567
568
568 @templatekeyword('changessincelatesttag')
569 @templatekeyword('changessincelatesttag')
569 def showchangessincelatesttag(repo, ctx, templ, cache, **args):
570 def showchangessincelatesttag(repo, ctx, templ, cache, **args):
570 """Integer. All ancestors not in the latest tag."""
571 """Integer. All ancestors not in the latest tag."""
571 latesttag = getlatesttags(repo, ctx, cache)[2][0]
572 latesttag = getlatesttags(repo, ctx, cache)[2][0]
572
573
573 return _showchangessincetag(repo, ctx, tag=latesttag, **args)
574 return _showchangessincetag(repo, ctx, tag=latesttag, **args)
574
575
575 def _showchangessincetag(repo, ctx, **args):
576 def _showchangessincetag(repo, ctx, **args):
576 offset = 0
577 offset = 0
577 revs = [ctx.rev()]
578 revs = [ctx.rev()]
578 tag = args[r'tag']
579 tag = args[r'tag']
579
580
580 # The only() revset doesn't currently support wdir()
581 # The only() revset doesn't currently support wdir()
581 if ctx.rev() is None:
582 if ctx.rev() is None:
582 offset = 1
583 offset = 1
583 revs = [p.rev() for p in ctx.parents()]
584 revs = [p.rev() for p in ctx.parents()]
584
585
585 return len(repo.revs('only(%ld, %s)', revs, tag)) + offset
586 return len(repo.revs('only(%ld, %s)', revs, tag)) + offset
586
587
587 @templatekeyword('manifest')
588 @templatekeyword('manifest')
588 def showmanifest(**args):
589 def showmanifest(**args):
589 repo, ctx, templ = args[r'repo'], args[r'ctx'], args[r'templ']
590 repo, ctx, templ = args[r'repo'], args[r'ctx'], args[r'templ']
590 mnode = ctx.manifestnode()
591 mnode = ctx.manifestnode()
591 if mnode is None:
592 if mnode is None:
592 # just avoid crash, we might want to use the 'ff...' hash in future
593 # just avoid crash, we might want to use the 'ff...' hash in future
593 return
594 return
594 mrev = repo.manifestlog._revlog.rev(mnode)
595 mrev = repo.manifestlog._revlog.rev(mnode)
595 mhex = hex(mnode)
596 mhex = hex(mnode)
596 args = args.copy()
597 args = args.copy()
597 args.update({r'rev': mrev, r'node': mhex})
598 args.update({r'rev': mrev, r'node': mhex})
598 f = templ('manifest', **args)
599 f = templ('manifest', **args)
599 # TODO: perhaps 'ctx' should be dropped from mapping because manifest
600 # TODO: perhaps 'ctx' should be dropped from mapping because manifest
600 # rev and node are completely different from changeset's.
601 # rev and node are completely different from changeset's.
601 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
602 return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
602
603
603 def shownames(namespace, **args):
604 def shownames(namespace, **args):
604 """helper method to generate a template keyword for a namespace"""
605 """helper method to generate a template keyword for a namespace"""
605 args = pycompat.byteskwargs(args)
606 args = pycompat.byteskwargs(args)
606 ctx = args['ctx']
607 ctx = args['ctx']
607 repo = ctx.repo()
608 repo = ctx.repo()
608 ns = repo.names[namespace]
609 ns = repo.names[namespace]
609 names = ns.names(repo, ctx.node())
610 names = ns.names(repo, ctx.node())
610 return showlist(ns.templatename, names, args, plural=namespace)
611 return showlist(ns.templatename, names, args, plural=namespace)
611
612
612 @templatekeyword('namespaces')
613 @templatekeyword('namespaces')
613 def shownamespaces(**args):
614 def shownamespaces(**args):
614 """Dict of lists. Names attached to this changeset per
615 """Dict of lists. Names attached to this changeset per
615 namespace."""
616 namespace."""
616 args = pycompat.byteskwargs(args)
617 args = pycompat.byteskwargs(args)
617 ctx = args['ctx']
618 ctx = args['ctx']
618 repo = ctx.repo()
619 repo = ctx.repo()
619
620
620 namespaces = util.sortdict()
621 namespaces = util.sortdict()
621 def makensmapfn(ns):
622 def makensmapfn(ns):
622 # 'name' for iterating over namespaces, templatename for local reference
623 # 'name' for iterating over namespaces, templatename for local reference
623 return lambda v: {'name': v, ns.templatename: v}
624 return lambda v: {'name': v, ns.templatename: v}
624
625
625 for k, ns in repo.names.iteritems():
626 for k, ns in repo.names.iteritems():
626 names = ns.names(repo, ctx.node())
627 names = ns.names(repo, ctx.node())
627 f = _showlist('name', names, args)
628 f = _showlist('name', names, args)
628 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
629 namespaces[k] = _hybrid(f, names, makensmapfn(ns), pycompat.identity)
629
630
630 f = _showlist('namespace', list(namespaces), args)
631 f = _showlist('namespace', list(namespaces), args)
631
632
632 def makemap(ns):
633 def makemap(ns):
633 return {
634 return {
634 'namespace': ns,
635 'namespace': ns,
635 'names': namespaces[ns],
636 'names': namespaces[ns],
636 'builtin': repo.names[ns].builtin,
637 'builtin': repo.names[ns].builtin,
637 'colorname': repo.names[ns].colorname,
638 'colorname': repo.names[ns].colorname,
638 }
639 }
639
640
640 return _hybrid(f, namespaces, makemap, pycompat.identity)
641 return _hybrid(f, namespaces, makemap, pycompat.identity)
641
642
642 @templatekeyword('node')
643 @templatekeyword('node')
643 def shownode(repo, ctx, templ, **args):
644 def shownode(repo, ctx, templ, **args):
644 """String. The changeset identification hash, as a 40 hexadecimal
645 """String. The changeset identification hash, as a 40 hexadecimal
645 digit string.
646 digit string.
646 """
647 """
647 return ctx.hex()
648 return ctx.hex()
648
649
649 @templatekeyword('obsolete')
650 @templatekeyword('obsolete')
650 def showobsolete(repo, ctx, templ, **args):
651 def showobsolete(repo, ctx, templ, **args):
651 """String. Whether the changeset is obsolete.
652 """String. Whether the changeset is obsolete.
652 """
653 """
653 if ctx.obsolete():
654 if ctx.obsolete():
654 return 'obsolete'
655 return 'obsolete'
655 return ''
656 return ''
656
657
657 @templatekeyword('peerurls')
658 @templatekeyword('peerurls')
658 def showpeerurls(repo, **args):
659 def showpeerurls(repo, **args):
659 """A dictionary of repository locations defined in the [paths] section
660 """A dictionary of repository locations defined in the [paths] section
660 of your configuration file."""
661 of your configuration file."""
661 # see commands.paths() for naming of dictionary keys
662 # see commands.paths() for naming of dictionary keys
662 paths = repo.ui.paths
663 paths = repo.ui.paths
663 urls = util.sortdict((k, p.rawloc) for k, p in sorted(paths.iteritems()))
664 urls = util.sortdict((k, p.rawloc) for k, p in sorted(paths.iteritems()))
664 def makemap(k):
665 def makemap(k):
665 p = paths[k]
666 p = paths[k]
666 d = {'name': k, 'url': p.rawloc}
667 d = {'name': k, 'url': p.rawloc}
667 d.update((o, v) for o, v in sorted(p.suboptions.iteritems()))
668 d.update((o, v) for o, v in sorted(p.suboptions.iteritems()))
668 return d
669 return d
669 return _hybrid(None, urls, makemap, lambda k: '%s=%s' % (k, urls[k]))
670 return _hybrid(None, urls, makemap, lambda k: '%s=%s' % (k, urls[k]))
670
671
671 @templatekeyword("predecessors")
672 @templatekeyword("predecessors")
672 def showpredecessors(repo, ctx, **args):
673 def showpredecessors(repo, ctx, **args):
673 """Returns the list if the closest visible successors
674 """Returns the list if the closest visible successors
674 """
675 """
675 predecessors = sorted(obsutil.closestpredecessors(repo, ctx.node()))
676 predecessors = sorted(obsutil.closestpredecessors(repo, ctx.node()))
676 predecessors = map(hex, predecessors)
677 predecessors = map(hex, predecessors)
677
678
678 return _hybrid(None, predecessors,
679 return _hybrid(None, predecessors,
679 lambda x: {'ctx': repo[x], 'revcache': {}},
680 lambda x: {'ctx': repo[x], 'revcache': {}},
680 lambda x: scmutil.formatchangeid(repo[x]))
681 lambda x: scmutil.formatchangeid(repo[x]))
681
682
682 @templatekeyword("successorssets")
683 @templatekeyword("successorssets")
683 def showsuccessorssets(repo, ctx, **args):
684 def showsuccessorssets(repo, ctx, **args):
684 """Returns a string of sets of successors for a changectx
685 """Returns a string of sets of successors for a changectx
685
686
686 Format used is: [ctx1, ctx2], [ctx3] if ctx has been splitted into ctx1 and
687 Format used is: [ctx1, ctx2], [ctx3] if ctx has been splitted into ctx1 and
687 ctx2 while also diverged into ctx3"""
688 ctx2 while also diverged into ctx3"""
688 if not ctx.obsolete():
689 if not ctx.obsolete():
689 return ''
690 return ''
690 args = pycompat.byteskwargs(args)
691 args = pycompat.byteskwargs(args)
691
692
692 ssets = obsutil.successorssets(repo, ctx.node(), closest=True)
693 ssets = obsutil.successorssets(repo, ctx.node(), closest=True)
693 ssets = [[hex(n) for n in ss] for ss in ssets]
694 ssets = [[hex(n) for n in ss] for ss in ssets]
694
695
695 data = []
696 data = []
696 for ss in ssets:
697 for ss in ssets:
697 h = _hybrid(None, ss, lambda x: {'ctx': repo[x], 'revcache': {}},
698 h = _hybrid(None, ss, lambda x: {'ctx': repo[x], 'revcache': {}},
698 lambda x: scmutil.formatchangeid(repo[x]))
699 lambda x: scmutil.formatchangeid(repo[x]))
699 data.append(h)
700 data.append(h)
700
701
701 # Format the successorssets
702 # Format the successorssets
702 def render(d):
703 def render(d):
703 t = []
704 t = []
704 for i in d.gen():
705 for i in d.gen():
705 t.append(i)
706 t.append(i)
706 return "".join(t)
707 return "".join(t)
707
708
708 def gen(data):
709 def gen(data):
709 yield "; ".join(render(d) for d in data)
710 yield "; ".join(render(d) for d in data)
710
711
711 return _hybrid(gen(data), data, lambda x: {'successorset': x},
712 return _hybrid(gen(data), data, lambda x: {'successorset': x},
712 pycompat.identity)
713 pycompat.identity)
713
714
714 @templatekeyword("succsandmarkers")
715 @templatekeyword("succsandmarkers")
715 def showsuccsandmarkers(repo, ctx, **args):
716 def showsuccsandmarkers(repo, ctx, **args):
716 """Returns a list of dict for each final successor of ctx.
717 """Returns a list of dict for each final successor of ctx.
717
718
718 The dict contains successors node id in "successors" keys and the list of
719 The dict contains successors node id in "successors" keys and the list of
719 obs-markers from ctx to the set of successors in "markers"
720 obs-markers from ctx to the set of successors in "markers"
720
721
721 (EXPERIMENTAL)
722 (EXPERIMENTAL)
722 """
723 """
723
724
724 values = obsutil.successorsandmarkers(repo, ctx)
725 values = obsutil.successorsandmarkers(repo, ctx)
725
726
726 if values is None:
727 if values is None:
727 values = []
728 values = []
728
729
729 # Format successors and markers to avoid exposing binary to templates
730 # Format successors and markers to avoid exposing binary to templates
730 data = []
731 data = []
731 for i in values:
732 for i in values:
732 # Format successors
733 # Format successors
733 successors = i['successors']
734 successors = i['successors']
734
735
735 successors = [hex(n) for n in successors]
736 successors = [hex(n) for n in successors]
736 successors = _hybrid(None, successors,
737 successors = _hybrid(None, successors,
737 lambda x: {'ctx': repo[x], 'revcache': {}},
738 lambda x: {'ctx': repo[x], 'revcache': {}},
738 lambda x: scmutil.formatchangeid(repo[x]))
739 lambda x: scmutil.formatchangeid(repo[x]))
739
740
740 # Format markers
741 # Format markers
741 finalmarkers = []
742 finalmarkers = []
742 for m in i['markers']:
743 for m in i['markers']:
743 hexprec = hex(m[0])
744 hexprec = hex(m[0])
744 hexsucs = tuple(hex(n) for n in m[1])
745 hexsucs = tuple(hex(n) for n in m[1])
745 hexparents = None
746 hexparents = None
746 if m[5] is not None:
747 if m[5] is not None:
747 hexparents = tuple(hex(n) for n in m[5])
748 hexparents = tuple(hex(n) for n in m[5])
748 newmarker = (hexprec, hexsucs) + m[2:5] + (hexparents,) + m[6:]
749 newmarker = (hexprec, hexsucs) + m[2:5] + (hexparents,) + m[6:]
749 finalmarkers.append(newmarker)
750 finalmarkers.append(newmarker)
750
751
751 data.append({'successors': successors, 'markers': finalmarkers})
752 data.append({'successors': successors, 'markers': finalmarkers})
752
753
753 f = _showlist('succsandmarkers', data, args)
754 f = _showlist('succsandmarkers', data, args)
754 return _hybrid(f, data, lambda x: x, pycompat.identity)
755 return _hybrid(f, data, lambda x: x, pycompat.identity)
755
756
756 @templatekeyword('p1rev')
757 @templatekeyword('p1rev')
757 def showp1rev(repo, ctx, templ, **args):
758 def showp1rev(repo, ctx, templ, **args):
758 """Integer. The repository-local revision number of the changeset's
759 """Integer. The repository-local revision number of the changeset's
759 first parent, or -1 if the changeset has no parents."""
760 first parent, or -1 if the changeset has no parents."""
760 return ctx.p1().rev()
761 return ctx.p1().rev()
761
762
762 @templatekeyword('p2rev')
763 @templatekeyword('p2rev')
763 def showp2rev(repo, ctx, templ, **args):
764 def showp2rev(repo, ctx, templ, **args):
764 """Integer. The repository-local revision number of the changeset's
765 """Integer. The repository-local revision number of the changeset's
765 second parent, or -1 if the changeset has no second parent."""
766 second parent, or -1 if the changeset has no second parent."""
766 return ctx.p2().rev()
767 return ctx.p2().rev()
767
768
768 @templatekeyword('p1node')
769 @templatekeyword('p1node')
769 def showp1node(repo, ctx, templ, **args):
770 def showp1node(repo, ctx, templ, **args):
770 """String. The identification hash of the changeset's first parent,
771 """String. The identification hash of the changeset's first parent,
771 as a 40 digit hexadecimal string. If the changeset has no parents, all
772 as a 40 digit hexadecimal string. If the changeset has no parents, all
772 digits are 0."""
773 digits are 0."""
773 return ctx.p1().hex()
774 return ctx.p1().hex()
774
775
775 @templatekeyword('p2node')
776 @templatekeyword('p2node')
776 def showp2node(repo, ctx, templ, **args):
777 def showp2node(repo, ctx, templ, **args):
777 """String. The identification hash of the changeset's second
778 """String. The identification hash of the changeset's second
778 parent, as a 40 digit hexadecimal string. If the changeset has no second
779 parent, as a 40 digit hexadecimal string. If the changeset has no second
779 parent, all digits are 0."""
780 parent, all digits are 0."""
780 return ctx.p2().hex()
781 return ctx.p2().hex()
781
782
782 @templatekeyword('parents')
783 @templatekeyword('parents')
783 def showparents(**args):
784 def showparents(**args):
784 """List of strings. The parents of the changeset in "rev:node"
785 """List of strings. The parents of the changeset in "rev:node"
785 format. If the changeset has only one "natural" parent (the predecessor
786 format. If the changeset has only one "natural" parent (the predecessor
786 revision) nothing is shown."""
787 revision) nothing is shown."""
787 args = pycompat.byteskwargs(args)
788 args = pycompat.byteskwargs(args)
788 repo = args['repo']
789 repo = args['repo']
789 ctx = args['ctx']
790 ctx = args['ctx']
790 pctxs = scmutil.meaningfulparents(repo, ctx)
791 pctxs = scmutil.meaningfulparents(repo, ctx)
791 # ifcontains() needs a list of str
792 prevs = [p.rev() for p in pctxs]
792 prevs = ["%d" % p.rev() for p in pctxs]
793 parents = [[('rev', p.rev()),
793 parents = [[('rev', p.rev()),
794 ('node', p.hex()),
794 ('node', p.hex()),
795 ('phase', p.phasestr())]
795 ('phase', p.phasestr())]
796 for p in pctxs]
796 for p in pctxs]
797 f = _showlist('parent', parents, args)
797 f = _showlist('parent', parents, args)
798 return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}},
798 return _hybrid(f, prevs, lambda x: {'ctx': repo[x], 'revcache': {}},
799 lambda x: scmutil.formatchangeid(repo[int(x)]))
799 lambda x: scmutil.formatchangeid(repo[x]), keytype=int)
800
800
801 @templatekeyword('phase')
801 @templatekeyword('phase')
802 def showphase(repo, ctx, templ, **args):
802 def showphase(repo, ctx, templ, **args):
803 """String. The changeset phase name."""
803 """String. The changeset phase name."""
804 return ctx.phasestr()
804 return ctx.phasestr()
805
805
806 @templatekeyword('phaseidx')
806 @templatekeyword('phaseidx')
807 def showphaseidx(repo, ctx, templ, **args):
807 def showphaseidx(repo, ctx, templ, **args):
808 """Integer. The changeset phase index."""
808 """Integer. The changeset phase index."""
809 return ctx.phase()
809 return ctx.phase()
810
810
811 @templatekeyword('rev')
811 @templatekeyword('rev')
812 def showrev(repo, ctx, templ, **args):
812 def showrev(repo, ctx, templ, **args):
813 """Integer. The repository-local changeset revision number."""
813 """Integer. The repository-local changeset revision number."""
814 return scmutil.intrev(ctx)
814 return scmutil.intrev(ctx)
815
815
816 def showrevslist(name, revs, **args):
816 def showrevslist(name, revs, **args):
817 """helper to generate a list of revisions in which a mapped template will
817 """helper to generate a list of revisions in which a mapped template will
818 be evaluated"""
818 be evaluated"""
819 args = pycompat.byteskwargs(args)
819 args = pycompat.byteskwargs(args)
820 repo = args['ctx'].repo()
820 repo = args['ctx'].repo()
821 # ifcontains() needs a list of str
821 f = _showlist(name, ['%d' % r for r in revs], args)
822 revs = ["%d" % r for r in revs]
823 f = _showlist(name, revs, args)
824 return _hybrid(f, revs,
822 return _hybrid(f, revs,
825 lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}},
823 lambda x: {name: x, 'ctx': repo[x], 'revcache': {}},
826 pycompat.identity)
824 pycompat.identity, keytype=int)
827
825
828 @templatekeyword('subrepos')
826 @templatekeyword('subrepos')
829 def showsubrepos(**args):
827 def showsubrepos(**args):
830 """List of strings. Updated subrepositories in the changeset."""
828 """List of strings. Updated subrepositories in the changeset."""
831 args = pycompat.byteskwargs(args)
829 args = pycompat.byteskwargs(args)
832 ctx = args['ctx']
830 ctx = args['ctx']
833 substate = ctx.substate
831 substate = ctx.substate
834 if not substate:
832 if not substate:
835 return showlist('subrepo', [], args)
833 return showlist('subrepo', [], args)
836 psubstate = ctx.parents()[0].substate or {}
834 psubstate = ctx.parents()[0].substate or {}
837 subrepos = []
835 subrepos = []
838 for sub in substate:
836 for sub in substate:
839 if sub not in psubstate or substate[sub] != psubstate[sub]:
837 if sub not in psubstate or substate[sub] != psubstate[sub]:
840 subrepos.append(sub) # modified or newly added in ctx
838 subrepos.append(sub) # modified or newly added in ctx
841 for sub in psubstate:
839 for sub in psubstate:
842 if sub not in substate:
840 if sub not in substate:
843 subrepos.append(sub) # removed in ctx
841 subrepos.append(sub) # removed in ctx
844 return showlist('subrepo', sorted(subrepos), args)
842 return showlist('subrepo', sorted(subrepos), args)
845
843
846 # don't remove "showtags" definition, even though namespaces will put
844 # don't remove "showtags" definition, even though namespaces will put
847 # a helper function for "tags" keyword into "keywords" map automatically,
845 # a helper function for "tags" keyword into "keywords" map automatically,
848 # because online help text is built without namespaces initialization
846 # because online help text is built without namespaces initialization
849 @templatekeyword('tags')
847 @templatekeyword('tags')
850 def showtags(**args):
848 def showtags(**args):
851 """List of strings. Any tags associated with the changeset."""
849 """List of strings. Any tags associated with the changeset."""
852 return shownames('tags', **args)
850 return shownames('tags', **args)
853
851
854 def loadkeyword(ui, extname, registrarobj):
852 def loadkeyword(ui, extname, registrarobj):
855 """Load template keyword from specified registrarobj
853 """Load template keyword from specified registrarobj
856 """
854 """
857 for name, func in registrarobj._table.iteritems():
855 for name, func in registrarobj._table.iteritems():
858 keywords[name] = func
856 keywords[name] = func
859
857
860 @templatekeyword('termwidth')
858 @templatekeyword('termwidth')
861 def showtermwidth(repo, ctx, templ, **args):
859 def showtermwidth(repo, ctx, templ, **args):
862 """Integer. The width of the current terminal."""
860 """Integer. The width of the current terminal."""
863 return repo.ui.termwidth()
861 return repo.ui.termwidth()
864
862
865 @templatekeyword('troubles')
863 @templatekeyword('troubles')
866 def showtroubles(repo, **args):
864 def showtroubles(repo, **args):
867 """List of strings. Evolution troubles affecting the changeset.
865 """List of strings. Evolution troubles affecting the changeset.
868
866
869 (DEPRECATED)
867 (DEPRECATED)
870 """
868 """
871 msg = ("'troubles' is deprecated, "
869 msg = ("'troubles' is deprecated, "
872 "use 'instabilities'")
870 "use 'instabilities'")
873 repo.ui.deprecwarn(msg, '4.4')
871 repo.ui.deprecwarn(msg, '4.4')
874
872
875 return showinstabilities(repo=repo, **args)
873 return showinstabilities(repo=repo, **args)
876
874
877 @templatekeyword('instabilities')
875 @templatekeyword('instabilities')
878 def showinstabilities(**args):
876 def showinstabilities(**args):
879 """List of strings. Evolution instabilities affecting the changeset.
877 """List of strings. Evolution instabilities affecting the changeset.
880
878
881 (EXPERIMENTAL)
879 (EXPERIMENTAL)
882 """
880 """
883 args = pycompat.byteskwargs(args)
881 args = pycompat.byteskwargs(args)
884 return showlist('instability', args['ctx'].instabilities(), args,
882 return showlist('instability', args['ctx'].instabilities(), args,
885 plural='instabilities')
883 plural='instabilities')
886
884
887 # tell hggettext to extract docstrings from these functions:
885 # tell hggettext to extract docstrings from these functions:
888 i18nfunctions = keywords.values()
886 i18nfunctions = keywords.values()
@@ -1,1499 +1,1514
1 # templater.py - template expansion for output
1 # templater.py - template expansion for output
2 #
2 #
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005, 2006 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 __future__ import absolute_import, print_function
8 from __future__ import absolute_import, print_function
9
9
10 import os
10 import os
11 import re
11 import re
12 import types
12 import types
13
13
14 from .i18n import _
14 from .i18n import _
15 from . import (
15 from . import (
16 color,
16 color,
17 config,
17 config,
18 encoding,
18 encoding,
19 error,
19 error,
20 minirst,
20 minirst,
21 obsutil,
21 obsutil,
22 parser,
22 parser,
23 pycompat,
23 pycompat,
24 registrar,
24 registrar,
25 revset as revsetmod,
25 revset as revsetmod,
26 revsetlang,
26 revsetlang,
27 scmutil,
27 scmutil,
28 templatefilters,
28 templatefilters,
29 templatekw,
29 templatekw,
30 util,
30 util,
31 )
31 )
32
32
33 # template parsing
33 # template parsing
34
34
35 elements = {
35 elements = {
36 # token-type: binding-strength, primary, prefix, infix, suffix
36 # token-type: binding-strength, primary, prefix, infix, suffix
37 "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None),
37 "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None),
38 ".": (18, None, None, (".", 18), None),
38 ".": (18, None, None, (".", 18), None),
39 "%": (15, None, None, ("%", 15), None),
39 "%": (15, None, None, ("%", 15), None),
40 "|": (15, None, None, ("|", 15), None),
40 "|": (15, None, None, ("|", 15), None),
41 "*": (5, None, None, ("*", 5), None),
41 "*": (5, None, None, ("*", 5), None),
42 "/": (5, None, None, ("/", 5), None),
42 "/": (5, None, None, ("/", 5), None),
43 "+": (4, None, None, ("+", 4), None),
43 "+": (4, None, None, ("+", 4), None),
44 "-": (4, None, ("negate", 19), ("-", 4), None),
44 "-": (4, None, ("negate", 19), ("-", 4), None),
45 "=": (3, None, None, ("keyvalue", 3), None),
45 "=": (3, None, None, ("keyvalue", 3), None),
46 ",": (2, None, None, ("list", 2), None),
46 ",": (2, None, None, ("list", 2), None),
47 ")": (0, None, None, None, None),
47 ")": (0, None, None, None, None),
48 "integer": (0, "integer", None, None, None),
48 "integer": (0, "integer", None, None, None),
49 "symbol": (0, "symbol", None, None, None),
49 "symbol": (0, "symbol", None, None, None),
50 "string": (0, "string", None, None, None),
50 "string": (0, "string", None, None, None),
51 "template": (0, "template", None, None, None),
51 "template": (0, "template", None, None, None),
52 "end": (0, None, None, None, None),
52 "end": (0, None, None, None, None),
53 }
53 }
54
54
55 def tokenize(program, start, end, term=None):
55 def tokenize(program, start, end, term=None):
56 """Parse a template expression into a stream of tokens, which must end
56 """Parse a template expression into a stream of tokens, which must end
57 with term if specified"""
57 with term if specified"""
58 pos = start
58 pos = start
59 program = pycompat.bytestr(program)
59 program = pycompat.bytestr(program)
60 while pos < end:
60 while pos < end:
61 c = program[pos]
61 c = program[pos]
62 if c.isspace(): # skip inter-token whitespace
62 if c.isspace(): # skip inter-token whitespace
63 pass
63 pass
64 elif c in "(=,).%|+-*/": # handle simple operators
64 elif c in "(=,).%|+-*/": # handle simple operators
65 yield (c, None, pos)
65 yield (c, None, pos)
66 elif c in '"\'': # handle quoted templates
66 elif c in '"\'': # handle quoted templates
67 s = pos + 1
67 s = pos + 1
68 data, pos = _parsetemplate(program, s, end, c)
68 data, pos = _parsetemplate(program, s, end, c)
69 yield ('template', data, s)
69 yield ('template', data, s)
70 pos -= 1
70 pos -= 1
71 elif c == 'r' and program[pos:pos + 2] in ("r'", 'r"'):
71 elif c == 'r' and program[pos:pos + 2] in ("r'", 'r"'):
72 # handle quoted strings
72 # handle quoted strings
73 c = program[pos + 1]
73 c = program[pos + 1]
74 s = pos = pos + 2
74 s = pos = pos + 2
75 while pos < end: # find closing quote
75 while pos < end: # find closing quote
76 d = program[pos]
76 d = program[pos]
77 if d == '\\': # skip over escaped characters
77 if d == '\\': # skip over escaped characters
78 pos += 2
78 pos += 2
79 continue
79 continue
80 if d == c:
80 if d == c:
81 yield ('string', program[s:pos], s)
81 yield ('string', program[s:pos], s)
82 break
82 break
83 pos += 1
83 pos += 1
84 else:
84 else:
85 raise error.ParseError(_("unterminated string"), s)
85 raise error.ParseError(_("unterminated string"), s)
86 elif c.isdigit():
86 elif c.isdigit():
87 s = pos
87 s = pos
88 while pos < end:
88 while pos < end:
89 d = program[pos]
89 d = program[pos]
90 if not d.isdigit():
90 if not d.isdigit():
91 break
91 break
92 pos += 1
92 pos += 1
93 yield ('integer', program[s:pos], s)
93 yield ('integer', program[s:pos], s)
94 pos -= 1
94 pos -= 1
95 elif (c == '\\' and program[pos:pos + 2] in (r"\'", r'\"')
95 elif (c == '\\' and program[pos:pos + 2] in (r"\'", r'\"')
96 or c == 'r' and program[pos:pos + 3] in (r"r\'", r'r\"')):
96 or c == 'r' and program[pos:pos + 3] in (r"r\'", r'r\"')):
97 # handle escaped quoted strings for compatibility with 2.9.2-3.4,
97 # handle escaped quoted strings for compatibility with 2.9.2-3.4,
98 # where some of nested templates were preprocessed as strings and
98 # where some of nested templates were preprocessed as strings and
99 # then compiled. therefore, \"...\" was allowed. (issue4733)
99 # then compiled. therefore, \"...\" was allowed. (issue4733)
100 #
100 #
101 # processing flow of _evalifliteral() at 5ab28a2e9962:
101 # processing flow of _evalifliteral() at 5ab28a2e9962:
102 # outer template string -> stringify() -> compiletemplate()
102 # outer template string -> stringify() -> compiletemplate()
103 # ------------------------ ------------ ------------------
103 # ------------------------ ------------ ------------------
104 # {f("\\\\ {g(\"\\\"\")}"} \\ {g("\"")} [r'\\', {g("\"")}]
104 # {f("\\\\ {g(\"\\\"\")}"} \\ {g("\"")} [r'\\', {g("\"")}]
105 # ~~~~~~~~
105 # ~~~~~~~~
106 # escaped quoted string
106 # escaped quoted string
107 if c == 'r':
107 if c == 'r':
108 pos += 1
108 pos += 1
109 token = 'string'
109 token = 'string'
110 else:
110 else:
111 token = 'template'
111 token = 'template'
112 quote = program[pos:pos + 2]
112 quote = program[pos:pos + 2]
113 s = pos = pos + 2
113 s = pos = pos + 2
114 while pos < end: # find closing escaped quote
114 while pos < end: # find closing escaped quote
115 if program.startswith('\\\\\\', pos, end):
115 if program.startswith('\\\\\\', pos, end):
116 pos += 4 # skip over double escaped characters
116 pos += 4 # skip over double escaped characters
117 continue
117 continue
118 if program.startswith(quote, pos, end):
118 if program.startswith(quote, pos, end):
119 # interpret as if it were a part of an outer string
119 # interpret as if it were a part of an outer string
120 data = parser.unescapestr(program[s:pos])
120 data = parser.unescapestr(program[s:pos])
121 if token == 'template':
121 if token == 'template':
122 data = _parsetemplate(data, 0, len(data))[0]
122 data = _parsetemplate(data, 0, len(data))[0]
123 yield (token, data, s)
123 yield (token, data, s)
124 pos += 1
124 pos += 1
125 break
125 break
126 pos += 1
126 pos += 1
127 else:
127 else:
128 raise error.ParseError(_("unterminated string"), s)
128 raise error.ParseError(_("unterminated string"), s)
129 elif c.isalnum() or c in '_':
129 elif c.isalnum() or c in '_':
130 s = pos
130 s = pos
131 pos += 1
131 pos += 1
132 while pos < end: # find end of symbol
132 while pos < end: # find end of symbol
133 d = program[pos]
133 d = program[pos]
134 if not (d.isalnum() or d == "_"):
134 if not (d.isalnum() or d == "_"):
135 break
135 break
136 pos += 1
136 pos += 1
137 sym = program[s:pos]
137 sym = program[s:pos]
138 yield ('symbol', sym, s)
138 yield ('symbol', sym, s)
139 pos -= 1
139 pos -= 1
140 elif c == term:
140 elif c == term:
141 yield ('end', None, pos + 1)
141 yield ('end', None, pos + 1)
142 return
142 return
143 else:
143 else:
144 raise error.ParseError(_("syntax error"), pos)
144 raise error.ParseError(_("syntax error"), pos)
145 pos += 1
145 pos += 1
146 if term:
146 if term:
147 raise error.ParseError(_("unterminated template expansion"), start)
147 raise error.ParseError(_("unterminated template expansion"), start)
148 yield ('end', None, pos)
148 yield ('end', None, pos)
149
149
150 def _parsetemplate(tmpl, start, stop, quote=''):
150 def _parsetemplate(tmpl, start, stop, quote=''):
151 r"""
151 r"""
152 >>> _parsetemplate(b'foo{bar}"baz', 0, 12)
152 >>> _parsetemplate(b'foo{bar}"baz', 0, 12)
153 ([('string', 'foo'), ('symbol', 'bar'), ('string', '"baz')], 12)
153 ([('string', 'foo'), ('symbol', 'bar'), ('string', '"baz')], 12)
154 >>> _parsetemplate(b'foo{bar}"baz', 0, 12, quote=b'"')
154 >>> _parsetemplate(b'foo{bar}"baz', 0, 12, quote=b'"')
155 ([('string', 'foo'), ('symbol', 'bar')], 9)
155 ([('string', 'foo'), ('symbol', 'bar')], 9)
156 >>> _parsetemplate(b'foo"{bar}', 0, 9, quote=b'"')
156 >>> _parsetemplate(b'foo"{bar}', 0, 9, quote=b'"')
157 ([('string', 'foo')], 4)
157 ([('string', 'foo')], 4)
158 >>> _parsetemplate(br'foo\"bar"baz', 0, 12, quote=b'"')
158 >>> _parsetemplate(br'foo\"bar"baz', 0, 12, quote=b'"')
159 ([('string', 'foo"'), ('string', 'bar')], 9)
159 ([('string', 'foo"'), ('string', 'bar')], 9)
160 >>> _parsetemplate(br'foo\\"bar', 0, 10, quote=b'"')
160 >>> _parsetemplate(br'foo\\"bar', 0, 10, quote=b'"')
161 ([('string', 'foo\\')], 6)
161 ([('string', 'foo\\')], 6)
162 """
162 """
163 parsed = []
163 parsed = []
164 sepchars = '{' + quote
164 sepchars = '{' + quote
165 pos = start
165 pos = start
166 p = parser.parser(elements)
166 p = parser.parser(elements)
167 while pos < stop:
167 while pos < stop:
168 n = min((tmpl.find(c, pos, stop) for c in sepchars),
168 n = min((tmpl.find(c, pos, stop) for c in sepchars),
169 key=lambda n: (n < 0, n))
169 key=lambda n: (n < 0, n))
170 if n < 0:
170 if n < 0:
171 parsed.append(('string', parser.unescapestr(tmpl[pos:stop])))
171 parsed.append(('string', parser.unescapestr(tmpl[pos:stop])))
172 pos = stop
172 pos = stop
173 break
173 break
174 c = tmpl[n:n + 1]
174 c = tmpl[n:n + 1]
175 bs = (n - pos) - len(tmpl[pos:n].rstrip('\\'))
175 bs = (n - pos) - len(tmpl[pos:n].rstrip('\\'))
176 if bs % 2 == 1:
176 if bs % 2 == 1:
177 # escaped (e.g. '\{', '\\\{', but not '\\{')
177 # escaped (e.g. '\{', '\\\{', but not '\\{')
178 parsed.append(('string', parser.unescapestr(tmpl[pos:n - 1]) + c))
178 parsed.append(('string', parser.unescapestr(tmpl[pos:n - 1]) + c))
179 pos = n + 1
179 pos = n + 1
180 continue
180 continue
181 if n > pos:
181 if n > pos:
182 parsed.append(('string', parser.unescapestr(tmpl[pos:n])))
182 parsed.append(('string', parser.unescapestr(tmpl[pos:n])))
183 if c == quote:
183 if c == quote:
184 return parsed, n + 1
184 return parsed, n + 1
185
185
186 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop, '}'))
186 parseres, pos = p.parse(tokenize(tmpl, n + 1, stop, '}'))
187 parsed.append(parseres)
187 parsed.append(parseres)
188
188
189 if quote:
189 if quote:
190 raise error.ParseError(_("unterminated string"), start)
190 raise error.ParseError(_("unterminated string"), start)
191 return parsed, pos
191 return parsed, pos
192
192
193 def _unnesttemplatelist(tree):
193 def _unnesttemplatelist(tree):
194 """Expand list of templates to node tuple
194 """Expand list of templates to node tuple
195
195
196 >>> def f(tree):
196 >>> def f(tree):
197 ... print(pycompat.sysstr(prettyformat(_unnesttemplatelist(tree))))
197 ... print(pycompat.sysstr(prettyformat(_unnesttemplatelist(tree))))
198 >>> f((b'template', []))
198 >>> f((b'template', []))
199 (string '')
199 (string '')
200 >>> f((b'template', [(b'string', b'foo')]))
200 >>> f((b'template', [(b'string', b'foo')]))
201 (string 'foo')
201 (string 'foo')
202 >>> f((b'template', [(b'string', b'foo'), (b'symbol', b'rev')]))
202 >>> f((b'template', [(b'string', b'foo'), (b'symbol', b'rev')]))
203 (template
203 (template
204 (string 'foo')
204 (string 'foo')
205 (symbol 'rev'))
205 (symbol 'rev'))
206 >>> f((b'template', [(b'symbol', b'rev')])) # template(rev) -> str
206 >>> f((b'template', [(b'symbol', b'rev')])) # template(rev) -> str
207 (template
207 (template
208 (symbol 'rev'))
208 (symbol 'rev'))
209 >>> f((b'template', [(b'template', [(b'string', b'foo')])]))
209 >>> f((b'template', [(b'template', [(b'string', b'foo')])]))
210 (string 'foo')
210 (string 'foo')
211 """
211 """
212 if not isinstance(tree, tuple):
212 if not isinstance(tree, tuple):
213 return tree
213 return tree
214 op = tree[0]
214 op = tree[0]
215 if op != 'template':
215 if op != 'template':
216 return (op,) + tuple(_unnesttemplatelist(x) for x in tree[1:])
216 return (op,) + tuple(_unnesttemplatelist(x) for x in tree[1:])
217
217
218 assert len(tree) == 2
218 assert len(tree) == 2
219 xs = tuple(_unnesttemplatelist(x) for x in tree[1])
219 xs = tuple(_unnesttemplatelist(x) for x in tree[1])
220 if not xs:
220 if not xs:
221 return ('string', '') # empty template ""
221 return ('string', '') # empty template ""
222 elif len(xs) == 1 and xs[0][0] == 'string':
222 elif len(xs) == 1 and xs[0][0] == 'string':
223 return xs[0] # fast path for string with no template fragment "x"
223 return xs[0] # fast path for string with no template fragment "x"
224 else:
224 else:
225 return (op,) + xs
225 return (op,) + xs
226
226
227 def parse(tmpl):
227 def parse(tmpl):
228 """Parse template string into tree"""
228 """Parse template string into tree"""
229 parsed, pos = _parsetemplate(tmpl, 0, len(tmpl))
229 parsed, pos = _parsetemplate(tmpl, 0, len(tmpl))
230 assert pos == len(tmpl), 'unquoted template should be consumed'
230 assert pos == len(tmpl), 'unquoted template should be consumed'
231 return _unnesttemplatelist(('template', parsed))
231 return _unnesttemplatelist(('template', parsed))
232
232
233 def _parseexpr(expr):
233 def _parseexpr(expr):
234 """Parse a template expression into tree
234 """Parse a template expression into tree
235
235
236 >>> _parseexpr(b'"foo"')
236 >>> _parseexpr(b'"foo"')
237 ('string', 'foo')
237 ('string', 'foo')
238 >>> _parseexpr(b'foo(bar)')
238 >>> _parseexpr(b'foo(bar)')
239 ('func', ('symbol', 'foo'), ('symbol', 'bar'))
239 ('func', ('symbol', 'foo'), ('symbol', 'bar'))
240 >>> _parseexpr(b'foo(')
240 >>> _parseexpr(b'foo(')
241 Traceback (most recent call last):
241 Traceback (most recent call last):
242 ...
242 ...
243 ParseError: ('not a prefix: end', 4)
243 ParseError: ('not a prefix: end', 4)
244 >>> _parseexpr(b'"foo" "bar"')
244 >>> _parseexpr(b'"foo" "bar"')
245 Traceback (most recent call last):
245 Traceback (most recent call last):
246 ...
246 ...
247 ParseError: ('invalid token', 7)
247 ParseError: ('invalid token', 7)
248 """
248 """
249 p = parser.parser(elements)
249 p = parser.parser(elements)
250 tree, pos = p.parse(tokenize(expr, 0, len(expr)))
250 tree, pos = p.parse(tokenize(expr, 0, len(expr)))
251 if pos != len(expr):
251 if pos != len(expr):
252 raise error.ParseError(_('invalid token'), pos)
252 raise error.ParseError(_('invalid token'), pos)
253 return _unnesttemplatelist(tree)
253 return _unnesttemplatelist(tree)
254
254
255 def prettyformat(tree):
255 def prettyformat(tree):
256 return parser.prettyformat(tree, ('integer', 'string', 'symbol'))
256 return parser.prettyformat(tree, ('integer', 'string', 'symbol'))
257
257
258 def compileexp(exp, context, curmethods):
258 def compileexp(exp, context, curmethods):
259 """Compile parsed template tree to (func, data) pair"""
259 """Compile parsed template tree to (func, data) pair"""
260 t = exp[0]
260 t = exp[0]
261 if t in curmethods:
261 if t in curmethods:
262 return curmethods[t](exp, context)
262 return curmethods[t](exp, context)
263 raise error.ParseError(_("unknown method '%s'") % t)
263 raise error.ParseError(_("unknown method '%s'") % t)
264
264
265 # template evaluation
265 # template evaluation
266
266
267 def getsymbol(exp):
267 def getsymbol(exp):
268 if exp[0] == 'symbol':
268 if exp[0] == 'symbol':
269 return exp[1]
269 return exp[1]
270 raise error.ParseError(_("expected a symbol, got '%s'") % exp[0])
270 raise error.ParseError(_("expected a symbol, got '%s'") % exp[0])
271
271
272 def getlist(x):
272 def getlist(x):
273 if not x:
273 if not x:
274 return []
274 return []
275 if x[0] == 'list':
275 if x[0] == 'list':
276 return getlist(x[1]) + [x[2]]
276 return getlist(x[1]) + [x[2]]
277 return [x]
277 return [x]
278
278
279 def gettemplate(exp, context):
279 def gettemplate(exp, context):
280 """Compile given template tree or load named template from map file;
280 """Compile given template tree or load named template from map file;
281 returns (func, data) pair"""
281 returns (func, data) pair"""
282 if exp[0] in ('template', 'string'):
282 if exp[0] in ('template', 'string'):
283 return compileexp(exp, context, methods)
283 return compileexp(exp, context, methods)
284 if exp[0] == 'symbol':
284 if exp[0] == 'symbol':
285 # unlike runsymbol(), here 'symbol' is always taken as template name
285 # unlike runsymbol(), here 'symbol' is always taken as template name
286 # even if it exists in mapping. this allows us to override mapping
286 # even if it exists in mapping. this allows us to override mapping
287 # by web templates, e.g. 'changelogtag' is redefined in map file.
287 # by web templates, e.g. 'changelogtag' is redefined in map file.
288 return context._load(exp[1])
288 return context._load(exp[1])
289 raise error.ParseError(_("expected template specifier"))
289 raise error.ParseError(_("expected template specifier"))
290
290
291 def findsymbolicname(arg):
291 def findsymbolicname(arg):
292 """Find symbolic name for the given compiled expression; returns None
292 """Find symbolic name for the given compiled expression; returns None
293 if nothing found reliably"""
293 if nothing found reliably"""
294 while True:
294 while True:
295 func, data = arg
295 func, data = arg
296 if func is runsymbol:
296 if func is runsymbol:
297 return data
297 return data
298 elif func is runfilter:
298 elif func is runfilter:
299 arg = data[0]
299 arg = data[0]
300 else:
300 else:
301 return None
301 return None
302
302
303 def evalrawexp(context, mapping, arg):
303 def evalrawexp(context, mapping, arg):
304 """Evaluate given argument as a bare template object which may require
304 """Evaluate given argument as a bare template object which may require
305 further processing (such as folding generator of strings)"""
305 further processing (such as folding generator of strings)"""
306 func, data = arg
306 func, data = arg
307 return func(context, mapping, data)
307 return func(context, mapping, data)
308
308
309 def evalfuncarg(context, mapping, arg):
309 def evalfuncarg(context, mapping, arg):
310 """Evaluate given argument as value type"""
310 """Evaluate given argument as value type"""
311 thing = evalrawexp(context, mapping, arg)
311 thing = evalrawexp(context, mapping, arg)
312 thing = templatekw.unwrapvalue(thing)
312 thing = templatekw.unwrapvalue(thing)
313 # evalrawexp() may return string, generator of strings or arbitrary object
313 # evalrawexp() may return string, generator of strings or arbitrary object
314 # such as date tuple, but filter does not want generator.
314 # such as date tuple, but filter does not want generator.
315 if isinstance(thing, types.GeneratorType):
315 if isinstance(thing, types.GeneratorType):
316 thing = stringify(thing)
316 thing = stringify(thing)
317 return thing
317 return thing
318
318
319 def evalboolean(context, mapping, arg):
319 def evalboolean(context, mapping, arg):
320 """Evaluate given argument as boolean, but also takes boolean literals"""
320 """Evaluate given argument as boolean, but also takes boolean literals"""
321 func, data = arg
321 func, data = arg
322 if func is runsymbol:
322 if func is runsymbol:
323 thing = func(context, mapping, data, default=None)
323 thing = func(context, mapping, data, default=None)
324 if thing is None:
324 if thing is None:
325 # not a template keyword, takes as a boolean literal
325 # not a template keyword, takes as a boolean literal
326 thing = util.parsebool(data)
326 thing = util.parsebool(data)
327 else:
327 else:
328 thing = func(context, mapping, data)
328 thing = func(context, mapping, data)
329 thing = templatekw.unwrapvalue(thing)
329 thing = templatekw.unwrapvalue(thing)
330 if isinstance(thing, bool):
330 if isinstance(thing, bool):
331 return thing
331 return thing
332 # other objects are evaluated as strings, which means 0 is True, but
332 # other objects are evaluated as strings, which means 0 is True, but
333 # empty dict/list should be False as they are expected to be ''
333 # empty dict/list should be False as they are expected to be ''
334 return bool(stringify(thing))
334 return bool(stringify(thing))
335
335
336 def evalinteger(context, mapping, arg, err):
336 def evalinteger(context, mapping, arg, err=None):
337 v = evalfuncarg(context, mapping, arg)
337 v = evalfuncarg(context, mapping, arg)
338 try:
338 try:
339 return int(v)
339 return int(v)
340 except (TypeError, ValueError):
340 except (TypeError, ValueError):
341 raise error.ParseError(err)
341 raise error.ParseError(err or _('not an integer'))
342
342
343 def evalstring(context, mapping, arg):
343 def evalstring(context, mapping, arg):
344 return stringify(evalrawexp(context, mapping, arg))
344 return stringify(evalrawexp(context, mapping, arg))
345
345
346 def evalstringliteral(context, mapping, arg):
346 def evalstringliteral(context, mapping, arg):
347 """Evaluate given argument as string template, but returns symbol name
347 """Evaluate given argument as string template, but returns symbol name
348 if it is unknown"""
348 if it is unknown"""
349 func, data = arg
349 func, data = arg
350 if func is runsymbol:
350 if func is runsymbol:
351 thing = func(context, mapping, data, default=data)
351 thing = func(context, mapping, data, default=data)
352 else:
352 else:
353 thing = func(context, mapping, data)
353 thing = func(context, mapping, data)
354 return stringify(thing)
354 return stringify(thing)
355
355
356 _evalfuncbytype = {
357 bool: evalboolean,
358 bytes: evalstring,
359 int: evalinteger,
360 }
361
362 def evalastype(context, mapping, arg, typ):
363 """Evaluate given argument and coerce its type"""
364 try:
365 f = _evalfuncbytype[typ]
366 except KeyError:
367 raise error.ProgrammingError('invalid type specified: %r' % typ)
368 return f(context, mapping, arg)
369
356 def runinteger(context, mapping, data):
370 def runinteger(context, mapping, data):
357 return int(data)
371 return int(data)
358
372
359 def runstring(context, mapping, data):
373 def runstring(context, mapping, data):
360 return data
374 return data
361
375
362 def _recursivesymbolblocker(key):
376 def _recursivesymbolblocker(key):
363 def showrecursion(**args):
377 def showrecursion(**args):
364 raise error.Abort(_("recursive reference '%s' in template") % key)
378 raise error.Abort(_("recursive reference '%s' in template") % key)
365 return showrecursion
379 return showrecursion
366
380
367 def _runrecursivesymbol(context, mapping, key):
381 def _runrecursivesymbol(context, mapping, key):
368 raise error.Abort(_("recursive reference '%s' in template") % key)
382 raise error.Abort(_("recursive reference '%s' in template") % key)
369
383
370 def runsymbol(context, mapping, key, default=''):
384 def runsymbol(context, mapping, key, default=''):
371 v = mapping.get(key)
385 v = mapping.get(key)
372 if v is None:
386 if v is None:
373 v = context._defaults.get(key)
387 v = context._defaults.get(key)
374 if v is None:
388 if v is None:
375 # put poison to cut recursion. we can't move this to parsing phase
389 # put poison to cut recursion. we can't move this to parsing phase
376 # because "x = {x}" is allowed if "x" is a keyword. (issue4758)
390 # because "x = {x}" is allowed if "x" is a keyword. (issue4758)
377 safemapping = mapping.copy()
391 safemapping = mapping.copy()
378 safemapping[key] = _recursivesymbolblocker(key)
392 safemapping[key] = _recursivesymbolblocker(key)
379 try:
393 try:
380 v = context.process(key, safemapping)
394 v = context.process(key, safemapping)
381 except TemplateNotFound:
395 except TemplateNotFound:
382 v = default
396 v = default
383 if callable(v):
397 if callable(v):
384 return v(**pycompat.strkwargs(mapping))
398 return v(**pycompat.strkwargs(mapping))
385 return v
399 return v
386
400
387 def buildtemplate(exp, context):
401 def buildtemplate(exp, context):
388 ctmpl = [compileexp(e, context, methods) for e in exp[1:]]
402 ctmpl = [compileexp(e, context, methods) for e in exp[1:]]
389 return (runtemplate, ctmpl)
403 return (runtemplate, ctmpl)
390
404
391 def runtemplate(context, mapping, template):
405 def runtemplate(context, mapping, template):
392 for arg in template:
406 for arg in template:
393 yield evalrawexp(context, mapping, arg)
407 yield evalrawexp(context, mapping, arg)
394
408
395 def buildfilter(exp, context):
409 def buildfilter(exp, context):
396 n = getsymbol(exp[2])
410 n = getsymbol(exp[2])
397 if n in context._filters:
411 if n in context._filters:
398 filt = context._filters[n]
412 filt = context._filters[n]
399 arg = compileexp(exp[1], context, methods)
413 arg = compileexp(exp[1], context, methods)
400 return (runfilter, (arg, filt))
414 return (runfilter, (arg, filt))
401 if n in funcs:
415 if n in funcs:
402 f = funcs[n]
416 f = funcs[n]
403 args = _buildfuncargs(exp[1], context, methods, n, f._argspec)
417 args = _buildfuncargs(exp[1], context, methods, n, f._argspec)
404 return (f, args)
418 return (f, args)
405 raise error.ParseError(_("unknown function '%s'") % n)
419 raise error.ParseError(_("unknown function '%s'") % n)
406
420
407 def runfilter(context, mapping, data):
421 def runfilter(context, mapping, data):
408 arg, filt = data
422 arg, filt = data
409 thing = evalfuncarg(context, mapping, arg)
423 thing = evalfuncarg(context, mapping, arg)
410 try:
424 try:
411 return filt(thing)
425 return filt(thing)
412 except (ValueError, AttributeError, TypeError):
426 except (ValueError, AttributeError, TypeError):
413 sym = findsymbolicname(arg)
427 sym = findsymbolicname(arg)
414 if sym:
428 if sym:
415 msg = (_("template filter '%s' is not compatible with keyword '%s'")
429 msg = (_("template filter '%s' is not compatible with keyword '%s'")
416 % (filt.func_name, sym))
430 % (filt.func_name, sym))
417 else:
431 else:
418 msg = _("incompatible use of template filter '%s'") % filt.func_name
432 msg = _("incompatible use of template filter '%s'") % filt.func_name
419 raise error.Abort(msg)
433 raise error.Abort(msg)
420
434
421 def buildmap(exp, context):
435 def buildmap(exp, context):
422 darg = compileexp(exp[1], context, methods)
436 darg = compileexp(exp[1], context, methods)
423 targ = gettemplate(exp[2], context)
437 targ = gettemplate(exp[2], context)
424 return (runmap, (darg, targ))
438 return (runmap, (darg, targ))
425
439
426 def runmap(context, mapping, data):
440 def runmap(context, mapping, data):
427 darg, targ = data
441 darg, targ = data
428 d = evalrawexp(context, mapping, darg)
442 d = evalrawexp(context, mapping, darg)
429 if util.safehasattr(d, 'itermaps'):
443 if util.safehasattr(d, 'itermaps'):
430 diter = d.itermaps()
444 diter = d.itermaps()
431 else:
445 else:
432 try:
446 try:
433 diter = iter(d)
447 diter = iter(d)
434 except TypeError:
448 except TypeError:
435 sym = findsymbolicname(darg)
449 sym = findsymbolicname(darg)
436 if sym:
450 if sym:
437 raise error.ParseError(_("keyword '%s' is not iterable") % sym)
451 raise error.ParseError(_("keyword '%s' is not iterable") % sym)
438 else:
452 else:
439 raise error.ParseError(_("%r is not iterable") % d)
453 raise error.ParseError(_("%r is not iterable") % d)
440
454
441 for i, v in enumerate(diter):
455 for i, v in enumerate(diter):
442 lm = mapping.copy()
456 lm = mapping.copy()
443 lm['index'] = i
457 lm['index'] = i
444 if isinstance(v, dict):
458 if isinstance(v, dict):
445 lm.update(v)
459 lm.update(v)
446 lm['originalnode'] = mapping.get('node')
460 lm['originalnode'] = mapping.get('node')
447 yield evalrawexp(context, lm, targ)
461 yield evalrawexp(context, lm, targ)
448 else:
462 else:
449 # v is not an iterable of dicts, this happen when 'key'
463 # v is not an iterable of dicts, this happen when 'key'
450 # has been fully expanded already and format is useless.
464 # has been fully expanded already and format is useless.
451 # If so, return the expanded value.
465 # If so, return the expanded value.
452 yield v
466 yield v
453
467
454 def buildmember(exp, context):
468 def buildmember(exp, context):
455 darg = compileexp(exp[1], context, methods)
469 darg = compileexp(exp[1], context, methods)
456 memb = getsymbol(exp[2])
470 memb = getsymbol(exp[2])
457 return (runmember, (darg, memb))
471 return (runmember, (darg, memb))
458
472
459 def runmember(context, mapping, data):
473 def runmember(context, mapping, data):
460 darg, memb = data
474 darg, memb = data
461 d = evalrawexp(context, mapping, darg)
475 d = evalrawexp(context, mapping, darg)
462 if util.safehasattr(d, 'tomap'):
476 if util.safehasattr(d, 'tomap'):
463 lm = mapping.copy()
477 lm = mapping.copy()
464 lm.update(d.tomap())
478 lm.update(d.tomap())
465 return runsymbol(context, lm, memb)
479 return runsymbol(context, lm, memb)
466 if util.safehasattr(d, 'get'):
480 if util.safehasattr(d, 'get'):
467 return _getdictitem(d, memb)
481 return _getdictitem(d, memb)
468
482
469 sym = findsymbolicname(darg)
483 sym = findsymbolicname(darg)
470 if sym:
484 if sym:
471 raise error.ParseError(_("keyword '%s' has no member") % sym)
485 raise error.ParseError(_("keyword '%s' has no member") % sym)
472 else:
486 else:
473 raise error.ParseError(_("%r has no member") % d)
487 raise error.ParseError(_("%r has no member") % d)
474
488
475 def buildnegate(exp, context):
489 def buildnegate(exp, context):
476 arg = compileexp(exp[1], context, exprmethods)
490 arg = compileexp(exp[1], context, exprmethods)
477 return (runnegate, arg)
491 return (runnegate, arg)
478
492
479 def runnegate(context, mapping, data):
493 def runnegate(context, mapping, data):
480 data = evalinteger(context, mapping, data,
494 data = evalinteger(context, mapping, data,
481 _('negation needs an integer argument'))
495 _('negation needs an integer argument'))
482 return -data
496 return -data
483
497
484 def buildarithmetic(exp, context, func):
498 def buildarithmetic(exp, context, func):
485 left = compileexp(exp[1], context, exprmethods)
499 left = compileexp(exp[1], context, exprmethods)
486 right = compileexp(exp[2], context, exprmethods)
500 right = compileexp(exp[2], context, exprmethods)
487 return (runarithmetic, (func, left, right))
501 return (runarithmetic, (func, left, right))
488
502
489 def runarithmetic(context, mapping, data):
503 def runarithmetic(context, mapping, data):
490 func, left, right = data
504 func, left, right = data
491 left = evalinteger(context, mapping, left,
505 left = evalinteger(context, mapping, left,
492 _('arithmetic only defined on integers'))
506 _('arithmetic only defined on integers'))
493 right = evalinteger(context, mapping, right,
507 right = evalinteger(context, mapping, right,
494 _('arithmetic only defined on integers'))
508 _('arithmetic only defined on integers'))
495 try:
509 try:
496 return func(left, right)
510 return func(left, right)
497 except ZeroDivisionError:
511 except ZeroDivisionError:
498 raise error.Abort(_('division by zero is not defined'))
512 raise error.Abort(_('division by zero is not defined'))
499
513
500 def buildfunc(exp, context):
514 def buildfunc(exp, context):
501 n = getsymbol(exp[1])
515 n = getsymbol(exp[1])
502 if n in funcs:
516 if n in funcs:
503 f = funcs[n]
517 f = funcs[n]
504 args = _buildfuncargs(exp[2], context, exprmethods, n, f._argspec)
518 args = _buildfuncargs(exp[2], context, exprmethods, n, f._argspec)
505 return (f, args)
519 return (f, args)
506 if n in context._filters:
520 if n in context._filters:
507 args = _buildfuncargs(exp[2], context, exprmethods, n, argspec=None)
521 args = _buildfuncargs(exp[2], context, exprmethods, n, argspec=None)
508 if len(args) != 1:
522 if len(args) != 1:
509 raise error.ParseError(_("filter %s expects one argument") % n)
523 raise error.ParseError(_("filter %s expects one argument") % n)
510 f = context._filters[n]
524 f = context._filters[n]
511 return (runfilter, (args[0], f))
525 return (runfilter, (args[0], f))
512 raise error.ParseError(_("unknown function '%s'") % n)
526 raise error.ParseError(_("unknown function '%s'") % n)
513
527
514 def _buildfuncargs(exp, context, curmethods, funcname, argspec):
528 def _buildfuncargs(exp, context, curmethods, funcname, argspec):
515 """Compile parsed tree of function arguments into list or dict of
529 """Compile parsed tree of function arguments into list or dict of
516 (func, data) pairs
530 (func, data) pairs
517
531
518 >>> context = engine(lambda t: (runsymbol, t))
532 >>> context = engine(lambda t: (runsymbol, t))
519 >>> def fargs(expr, argspec):
533 >>> def fargs(expr, argspec):
520 ... x = _parseexpr(expr)
534 ... x = _parseexpr(expr)
521 ... n = getsymbol(x[1])
535 ... n = getsymbol(x[1])
522 ... return _buildfuncargs(x[2], context, exprmethods, n, argspec)
536 ... return _buildfuncargs(x[2], context, exprmethods, n, argspec)
523 >>> list(fargs(b'a(l=1, k=2)', b'k l m').keys())
537 >>> list(fargs(b'a(l=1, k=2)', b'k l m').keys())
524 ['l', 'k']
538 ['l', 'k']
525 >>> args = fargs(b'a(opts=1, k=2)', b'**opts')
539 >>> args = fargs(b'a(opts=1, k=2)', b'**opts')
526 >>> list(args.keys()), list(args[b'opts'].keys())
540 >>> list(args.keys()), list(args[b'opts'].keys())
527 (['opts'], ['opts', 'k'])
541 (['opts'], ['opts', 'k'])
528 """
542 """
529 def compiledict(xs):
543 def compiledict(xs):
530 return util.sortdict((k, compileexp(x, context, curmethods))
544 return util.sortdict((k, compileexp(x, context, curmethods))
531 for k, x in xs.iteritems())
545 for k, x in xs.iteritems())
532 def compilelist(xs):
546 def compilelist(xs):
533 return [compileexp(x, context, curmethods) for x in xs]
547 return [compileexp(x, context, curmethods) for x in xs]
534
548
535 if not argspec:
549 if not argspec:
536 # filter or function with no argspec: return list of positional args
550 # filter or function with no argspec: return list of positional args
537 return compilelist(getlist(exp))
551 return compilelist(getlist(exp))
538
552
539 # function with argspec: return dict of named args
553 # function with argspec: return dict of named args
540 _poskeys, varkey, _keys, optkey = argspec = parser.splitargspec(argspec)
554 _poskeys, varkey, _keys, optkey = argspec = parser.splitargspec(argspec)
541 treeargs = parser.buildargsdict(getlist(exp), funcname, argspec,
555 treeargs = parser.buildargsdict(getlist(exp), funcname, argspec,
542 keyvaluenode='keyvalue', keynode='symbol')
556 keyvaluenode='keyvalue', keynode='symbol')
543 compargs = util.sortdict()
557 compargs = util.sortdict()
544 if varkey:
558 if varkey:
545 compargs[varkey] = compilelist(treeargs.pop(varkey))
559 compargs[varkey] = compilelist(treeargs.pop(varkey))
546 if optkey:
560 if optkey:
547 compargs[optkey] = compiledict(treeargs.pop(optkey))
561 compargs[optkey] = compiledict(treeargs.pop(optkey))
548 compargs.update(compiledict(treeargs))
562 compargs.update(compiledict(treeargs))
549 return compargs
563 return compargs
550
564
551 def buildkeyvaluepair(exp, content):
565 def buildkeyvaluepair(exp, content):
552 raise error.ParseError(_("can't use a key-value pair in this context"))
566 raise error.ParseError(_("can't use a key-value pair in this context"))
553
567
554 # dict of template built-in functions
568 # dict of template built-in functions
555 funcs = {}
569 funcs = {}
556
570
557 templatefunc = registrar.templatefunc(funcs)
571 templatefunc = registrar.templatefunc(funcs)
558
572
559 @templatefunc('date(date[, fmt])')
573 @templatefunc('date(date[, fmt])')
560 def date(context, mapping, args):
574 def date(context, mapping, args):
561 """Format a date. See :hg:`help dates` for formatting
575 """Format a date. See :hg:`help dates` for formatting
562 strings. The default is a Unix date format, including the timezone:
576 strings. The default is a Unix date format, including the timezone:
563 "Mon Sep 04 15:13:13 2006 0700"."""
577 "Mon Sep 04 15:13:13 2006 0700"."""
564 if not (1 <= len(args) <= 2):
578 if not (1 <= len(args) <= 2):
565 # i18n: "date" is a keyword
579 # i18n: "date" is a keyword
566 raise error.ParseError(_("date expects one or two arguments"))
580 raise error.ParseError(_("date expects one or two arguments"))
567
581
568 date = evalfuncarg(context, mapping, args[0])
582 date = evalfuncarg(context, mapping, args[0])
569 fmt = None
583 fmt = None
570 if len(args) == 2:
584 if len(args) == 2:
571 fmt = evalstring(context, mapping, args[1])
585 fmt = evalstring(context, mapping, args[1])
572 try:
586 try:
573 if fmt is None:
587 if fmt is None:
574 return util.datestr(date)
588 return util.datestr(date)
575 else:
589 else:
576 return util.datestr(date, fmt)
590 return util.datestr(date, fmt)
577 except (TypeError, ValueError):
591 except (TypeError, ValueError):
578 # i18n: "date" is a keyword
592 # i18n: "date" is a keyword
579 raise error.ParseError(_("date expects a date information"))
593 raise error.ParseError(_("date expects a date information"))
580
594
581 @templatefunc('dict([[key=]value...])', argspec='*args **kwargs')
595 @templatefunc('dict([[key=]value...])', argspec='*args **kwargs')
582 def dict_(context, mapping, args):
596 def dict_(context, mapping, args):
583 """Construct a dict from key-value pairs. A key may be omitted if
597 """Construct a dict from key-value pairs. A key may be omitted if
584 a value expression can provide an unambiguous name."""
598 a value expression can provide an unambiguous name."""
585 data = util.sortdict()
599 data = util.sortdict()
586
600
587 for v in args['args']:
601 for v in args['args']:
588 k = findsymbolicname(v)
602 k = findsymbolicname(v)
589 if not k:
603 if not k:
590 raise error.ParseError(_('dict key cannot be inferred'))
604 raise error.ParseError(_('dict key cannot be inferred'))
591 if k in data or k in args['kwargs']:
605 if k in data or k in args['kwargs']:
592 raise error.ParseError(_("duplicated dict key '%s' inferred") % k)
606 raise error.ParseError(_("duplicated dict key '%s' inferred") % k)
593 data[k] = evalfuncarg(context, mapping, v)
607 data[k] = evalfuncarg(context, mapping, v)
594
608
595 data.update((k, evalfuncarg(context, mapping, v))
609 data.update((k, evalfuncarg(context, mapping, v))
596 for k, v in args['kwargs'].iteritems())
610 for k, v in args['kwargs'].iteritems())
597 return templatekw.hybriddict(data)
611 return templatekw.hybriddict(data)
598
612
599 @templatefunc('diff([includepattern [, excludepattern]])')
613 @templatefunc('diff([includepattern [, excludepattern]])')
600 def diff(context, mapping, args):
614 def diff(context, mapping, args):
601 """Show a diff, optionally
615 """Show a diff, optionally
602 specifying files to include or exclude."""
616 specifying files to include or exclude."""
603 if len(args) > 2:
617 if len(args) > 2:
604 # i18n: "diff" is a keyword
618 # i18n: "diff" is a keyword
605 raise error.ParseError(_("diff expects zero, one, or two arguments"))
619 raise error.ParseError(_("diff expects zero, one, or two arguments"))
606
620
607 def getpatterns(i):
621 def getpatterns(i):
608 if i < len(args):
622 if i < len(args):
609 s = evalstring(context, mapping, args[i]).strip()
623 s = evalstring(context, mapping, args[i]).strip()
610 if s:
624 if s:
611 return [s]
625 return [s]
612 return []
626 return []
613
627
614 ctx = mapping['ctx']
628 ctx = mapping['ctx']
615 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1)))
629 chunks = ctx.diff(match=ctx.match([], getpatterns(0), getpatterns(1)))
616
630
617 return ''.join(chunks)
631 return ''.join(chunks)
618
632
619 @templatefunc('extdata(source)', argspec='source')
633 @templatefunc('extdata(source)', argspec='source')
620 def extdata(context, mapping, args):
634 def extdata(context, mapping, args):
621 """Show a text read from the specified extdata source. (EXPERIMENTAL)"""
635 """Show a text read from the specified extdata source. (EXPERIMENTAL)"""
622 if 'source' not in args:
636 if 'source' not in args:
623 # i18n: "extdata" is a keyword
637 # i18n: "extdata" is a keyword
624 raise error.ParseError(_('extdata expects one argument'))
638 raise error.ParseError(_('extdata expects one argument'))
625
639
626 source = evalstring(context, mapping, args['source'])
640 source = evalstring(context, mapping, args['source'])
627 cache = mapping['cache'].setdefault('extdata', {})
641 cache = mapping['cache'].setdefault('extdata', {})
628 ctx = mapping['ctx']
642 ctx = mapping['ctx']
629 if source in cache:
643 if source in cache:
630 data = cache[source]
644 data = cache[source]
631 else:
645 else:
632 data = cache[source] = scmutil.extdatasource(ctx.repo(), source)
646 data = cache[source] = scmutil.extdatasource(ctx.repo(), source)
633 return data.get(ctx.rev(), '')
647 return data.get(ctx.rev(), '')
634
648
635 @templatefunc('files(pattern)')
649 @templatefunc('files(pattern)')
636 def files(context, mapping, args):
650 def files(context, mapping, args):
637 """All files of the current changeset matching the pattern. See
651 """All files of the current changeset matching the pattern. See
638 :hg:`help patterns`."""
652 :hg:`help patterns`."""
639 if not len(args) == 1:
653 if not len(args) == 1:
640 # i18n: "files" is a keyword
654 # i18n: "files" is a keyword
641 raise error.ParseError(_("files expects one argument"))
655 raise error.ParseError(_("files expects one argument"))
642
656
643 raw = evalstring(context, mapping, args[0])
657 raw = evalstring(context, mapping, args[0])
644 ctx = mapping['ctx']
658 ctx = mapping['ctx']
645 m = ctx.match([raw])
659 m = ctx.match([raw])
646 files = list(ctx.matches(m))
660 files = list(ctx.matches(m))
647 return templatekw.showlist("file", files, mapping)
661 return templatekw.showlist("file", files, mapping)
648
662
649 @templatefunc('fill(text[, width[, initialident[, hangindent]]])')
663 @templatefunc('fill(text[, width[, initialident[, hangindent]]])')
650 def fill(context, mapping, args):
664 def fill(context, mapping, args):
651 """Fill many
665 """Fill many
652 paragraphs with optional indentation. See the "fill" filter."""
666 paragraphs with optional indentation. See the "fill" filter."""
653 if not (1 <= len(args) <= 4):
667 if not (1 <= len(args) <= 4):
654 # i18n: "fill" is a keyword
668 # i18n: "fill" is a keyword
655 raise error.ParseError(_("fill expects one to four arguments"))
669 raise error.ParseError(_("fill expects one to four arguments"))
656
670
657 text = evalstring(context, mapping, args[0])
671 text = evalstring(context, mapping, args[0])
658 width = 76
672 width = 76
659 initindent = ''
673 initindent = ''
660 hangindent = ''
674 hangindent = ''
661 if 2 <= len(args) <= 4:
675 if 2 <= len(args) <= 4:
662 width = evalinteger(context, mapping, args[1],
676 width = evalinteger(context, mapping, args[1],
663 # i18n: "fill" is a keyword
677 # i18n: "fill" is a keyword
664 _("fill expects an integer width"))
678 _("fill expects an integer width"))
665 try:
679 try:
666 initindent = evalstring(context, mapping, args[2])
680 initindent = evalstring(context, mapping, args[2])
667 hangindent = evalstring(context, mapping, args[3])
681 hangindent = evalstring(context, mapping, args[3])
668 except IndexError:
682 except IndexError:
669 pass
683 pass
670
684
671 return templatefilters.fill(text, width, initindent, hangindent)
685 return templatefilters.fill(text, width, initindent, hangindent)
672
686
673 @templatefunc('formatnode(node)')
687 @templatefunc('formatnode(node)')
674 def formatnode(context, mapping, args):
688 def formatnode(context, mapping, args):
675 """Obtain the preferred form of a changeset hash. (DEPRECATED)"""
689 """Obtain the preferred form of a changeset hash. (DEPRECATED)"""
676 if len(args) != 1:
690 if len(args) != 1:
677 # i18n: "formatnode" is a keyword
691 # i18n: "formatnode" is a keyword
678 raise error.ParseError(_("formatnode expects one argument"))
692 raise error.ParseError(_("formatnode expects one argument"))
679
693
680 ui = mapping['ui']
694 ui = mapping['ui']
681 node = evalstring(context, mapping, args[0])
695 node = evalstring(context, mapping, args[0])
682 if ui.debugflag:
696 if ui.debugflag:
683 return node
697 return node
684 return templatefilters.short(node)
698 return templatefilters.short(node)
685
699
686 @templatefunc('pad(text, width[, fillchar=\' \'[, left=False]])',
700 @templatefunc('pad(text, width[, fillchar=\' \'[, left=False]])',
687 argspec='text width fillchar left')
701 argspec='text width fillchar left')
688 def pad(context, mapping, args):
702 def pad(context, mapping, args):
689 """Pad text with a
703 """Pad text with a
690 fill character."""
704 fill character."""
691 if 'text' not in args or 'width' not in args:
705 if 'text' not in args or 'width' not in args:
692 # i18n: "pad" is a keyword
706 # i18n: "pad" is a keyword
693 raise error.ParseError(_("pad() expects two to four arguments"))
707 raise error.ParseError(_("pad() expects two to four arguments"))
694
708
695 width = evalinteger(context, mapping, args['width'],
709 width = evalinteger(context, mapping, args['width'],
696 # i18n: "pad" is a keyword
710 # i18n: "pad" is a keyword
697 _("pad() expects an integer width"))
711 _("pad() expects an integer width"))
698
712
699 text = evalstring(context, mapping, args['text'])
713 text = evalstring(context, mapping, args['text'])
700
714
701 left = False
715 left = False
702 fillchar = ' '
716 fillchar = ' '
703 if 'fillchar' in args:
717 if 'fillchar' in args:
704 fillchar = evalstring(context, mapping, args['fillchar'])
718 fillchar = evalstring(context, mapping, args['fillchar'])
705 if len(color.stripeffects(fillchar)) != 1:
719 if len(color.stripeffects(fillchar)) != 1:
706 # i18n: "pad" is a keyword
720 # i18n: "pad" is a keyword
707 raise error.ParseError(_("pad() expects a single fill character"))
721 raise error.ParseError(_("pad() expects a single fill character"))
708 if 'left' in args:
722 if 'left' in args:
709 left = evalboolean(context, mapping, args['left'])
723 left = evalboolean(context, mapping, args['left'])
710
724
711 fillwidth = width - encoding.colwidth(color.stripeffects(text))
725 fillwidth = width - encoding.colwidth(color.stripeffects(text))
712 if fillwidth <= 0:
726 if fillwidth <= 0:
713 return text
727 return text
714 if left:
728 if left:
715 return fillchar * fillwidth + text
729 return fillchar * fillwidth + text
716 else:
730 else:
717 return text + fillchar * fillwidth
731 return text + fillchar * fillwidth
718
732
719 @templatefunc('indent(text, indentchars[, firstline])')
733 @templatefunc('indent(text, indentchars[, firstline])')
720 def indent(context, mapping, args):
734 def indent(context, mapping, args):
721 """Indents all non-empty lines
735 """Indents all non-empty lines
722 with the characters given in the indentchars string. An optional
736 with the characters given in the indentchars string. An optional
723 third parameter will override the indent for the first line only
737 third parameter will override the indent for the first line only
724 if present."""
738 if present."""
725 if not (2 <= len(args) <= 3):
739 if not (2 <= len(args) <= 3):
726 # i18n: "indent" is a keyword
740 # i18n: "indent" is a keyword
727 raise error.ParseError(_("indent() expects two or three arguments"))
741 raise error.ParseError(_("indent() expects two or three arguments"))
728
742
729 text = evalstring(context, mapping, args[0])
743 text = evalstring(context, mapping, args[0])
730 indent = evalstring(context, mapping, args[1])
744 indent = evalstring(context, mapping, args[1])
731
745
732 if len(args) == 3:
746 if len(args) == 3:
733 firstline = evalstring(context, mapping, args[2])
747 firstline = evalstring(context, mapping, args[2])
734 else:
748 else:
735 firstline = indent
749 firstline = indent
736
750
737 # the indent function doesn't indent the first line, so we do it here
751 # the indent function doesn't indent the first line, so we do it here
738 return templatefilters.indent(firstline + text, indent)
752 return templatefilters.indent(firstline + text, indent)
739
753
740 @templatefunc('get(dict, key)')
754 @templatefunc('get(dict, key)')
741 def get(context, mapping, args):
755 def get(context, mapping, args):
742 """Get an attribute/key from an object. Some keywords
756 """Get an attribute/key from an object. Some keywords
743 are complex types. This function allows you to obtain the value of an
757 are complex types. This function allows you to obtain the value of an
744 attribute on these types."""
758 attribute on these types."""
745 if len(args) != 2:
759 if len(args) != 2:
746 # i18n: "get" is a keyword
760 # i18n: "get" is a keyword
747 raise error.ParseError(_("get() expects two arguments"))
761 raise error.ParseError(_("get() expects two arguments"))
748
762
749 dictarg = evalfuncarg(context, mapping, args[0])
763 dictarg = evalfuncarg(context, mapping, args[0])
750 if not util.safehasattr(dictarg, 'get'):
764 if not util.safehasattr(dictarg, 'get'):
751 # i18n: "get" is a keyword
765 # i18n: "get" is a keyword
752 raise error.ParseError(_("get() expects a dict as first argument"))
766 raise error.ParseError(_("get() expects a dict as first argument"))
753
767
754 key = evalfuncarg(context, mapping, args[1])
768 key = evalfuncarg(context, mapping, args[1])
755 return _getdictitem(dictarg, key)
769 return _getdictitem(dictarg, key)
756
770
757 def _getdictitem(dictarg, key):
771 def _getdictitem(dictarg, key):
758 val = dictarg.get(key)
772 val = dictarg.get(key)
759 if val is None:
773 if val is None:
760 return
774 return
761 return templatekw.wraphybridvalue(dictarg, key, val)
775 return templatekw.wraphybridvalue(dictarg, key, val)
762
776
763 @templatefunc('if(expr, then[, else])')
777 @templatefunc('if(expr, then[, else])')
764 def if_(context, mapping, args):
778 def if_(context, mapping, args):
765 """Conditionally execute based on the result of
779 """Conditionally execute based on the result of
766 an expression."""
780 an expression."""
767 if not (2 <= len(args) <= 3):
781 if not (2 <= len(args) <= 3):
768 # i18n: "if" is a keyword
782 # i18n: "if" is a keyword
769 raise error.ParseError(_("if expects two or three arguments"))
783 raise error.ParseError(_("if expects two or three arguments"))
770
784
771 test = evalboolean(context, mapping, args[0])
785 test = evalboolean(context, mapping, args[0])
772 if test:
786 if test:
773 yield evalrawexp(context, mapping, args[1])
787 yield evalrawexp(context, mapping, args[1])
774 elif len(args) == 3:
788 elif len(args) == 3:
775 yield evalrawexp(context, mapping, args[2])
789 yield evalrawexp(context, mapping, args[2])
776
790
777 @templatefunc('ifcontains(needle, haystack, then[, else])')
791 @templatefunc('ifcontains(needle, haystack, then[, else])')
778 def ifcontains(context, mapping, args):
792 def ifcontains(context, mapping, args):
779 """Conditionally execute based
793 """Conditionally execute based
780 on whether the item "needle" is in "haystack"."""
794 on whether the item "needle" is in "haystack"."""
781 if not (3 <= len(args) <= 4):
795 if not (3 <= len(args) <= 4):
782 # i18n: "ifcontains" is a keyword
796 # i18n: "ifcontains" is a keyword
783 raise error.ParseError(_("ifcontains expects three or four arguments"))
797 raise error.ParseError(_("ifcontains expects three or four arguments"))
784
798
785 needle = evalstring(context, mapping, args[0])
786 haystack = evalfuncarg(context, mapping, args[1])
799 haystack = evalfuncarg(context, mapping, args[1])
800 needle = evalastype(context, mapping, args[0],
801 getattr(haystack, 'keytype', None) or bytes)
787
802
788 if needle in haystack:
803 if needle in haystack:
789 yield evalrawexp(context, mapping, args[2])
804 yield evalrawexp(context, mapping, args[2])
790 elif len(args) == 4:
805 elif len(args) == 4:
791 yield evalrawexp(context, mapping, args[3])
806 yield evalrawexp(context, mapping, args[3])
792
807
793 @templatefunc('ifeq(expr1, expr2, then[, else])')
808 @templatefunc('ifeq(expr1, expr2, then[, else])')
794 def ifeq(context, mapping, args):
809 def ifeq(context, mapping, args):
795 """Conditionally execute based on
810 """Conditionally execute based on
796 whether 2 items are equivalent."""
811 whether 2 items are equivalent."""
797 if not (3 <= len(args) <= 4):
812 if not (3 <= len(args) <= 4):
798 # i18n: "ifeq" is a keyword
813 # i18n: "ifeq" is a keyword
799 raise error.ParseError(_("ifeq expects three or four arguments"))
814 raise error.ParseError(_("ifeq expects three or four arguments"))
800
815
801 test = evalstring(context, mapping, args[0])
816 test = evalstring(context, mapping, args[0])
802 match = evalstring(context, mapping, args[1])
817 match = evalstring(context, mapping, args[1])
803 if test == match:
818 if test == match:
804 yield evalrawexp(context, mapping, args[2])
819 yield evalrawexp(context, mapping, args[2])
805 elif len(args) == 4:
820 elif len(args) == 4:
806 yield evalrawexp(context, mapping, args[3])
821 yield evalrawexp(context, mapping, args[3])
807
822
808 @templatefunc('join(list, sep)')
823 @templatefunc('join(list, sep)')
809 def join(context, mapping, args):
824 def join(context, mapping, args):
810 """Join items in a list with a delimiter."""
825 """Join items in a list with a delimiter."""
811 if not (1 <= len(args) <= 2):
826 if not (1 <= len(args) <= 2):
812 # i18n: "join" is a keyword
827 # i18n: "join" is a keyword
813 raise error.ParseError(_("join expects one or two arguments"))
828 raise error.ParseError(_("join expects one or two arguments"))
814
829
815 # TODO: perhaps this should be evalfuncarg(), but it can't because hgweb
830 # TODO: perhaps this should be evalfuncarg(), but it can't because hgweb
816 # abuses generator as a keyword that returns a list of dicts.
831 # abuses generator as a keyword that returns a list of dicts.
817 joinset = evalrawexp(context, mapping, args[0])
832 joinset = evalrawexp(context, mapping, args[0])
818 joinset = templatekw.unwrapvalue(joinset)
833 joinset = templatekw.unwrapvalue(joinset)
819 joinfmt = getattr(joinset, 'joinfmt', pycompat.identity)
834 joinfmt = getattr(joinset, 'joinfmt', pycompat.identity)
820 joiner = " "
835 joiner = " "
821 if len(args) > 1:
836 if len(args) > 1:
822 joiner = evalstring(context, mapping, args[1])
837 joiner = evalstring(context, mapping, args[1])
823
838
824 first = True
839 first = True
825 for x in joinset:
840 for x in joinset:
826 if first:
841 if first:
827 first = False
842 first = False
828 else:
843 else:
829 yield joiner
844 yield joiner
830 yield joinfmt(x)
845 yield joinfmt(x)
831
846
832 @templatefunc('label(label, expr)')
847 @templatefunc('label(label, expr)')
833 def label(context, mapping, args):
848 def label(context, mapping, args):
834 """Apply a label to generated content. Content with
849 """Apply a label to generated content. Content with
835 a label applied can result in additional post-processing, such as
850 a label applied can result in additional post-processing, such as
836 automatic colorization."""
851 automatic colorization."""
837 if len(args) != 2:
852 if len(args) != 2:
838 # i18n: "label" is a keyword
853 # i18n: "label" is a keyword
839 raise error.ParseError(_("label expects two arguments"))
854 raise error.ParseError(_("label expects two arguments"))
840
855
841 ui = mapping['ui']
856 ui = mapping['ui']
842 thing = evalstring(context, mapping, args[1])
857 thing = evalstring(context, mapping, args[1])
843 # preserve unknown symbol as literal so effects like 'red', 'bold',
858 # preserve unknown symbol as literal so effects like 'red', 'bold',
844 # etc. don't need to be quoted
859 # etc. don't need to be quoted
845 label = evalstringliteral(context, mapping, args[0])
860 label = evalstringliteral(context, mapping, args[0])
846
861
847 return ui.label(thing, label)
862 return ui.label(thing, label)
848
863
849 @templatefunc('latesttag([pattern])')
864 @templatefunc('latesttag([pattern])')
850 def latesttag(context, mapping, args):
865 def latesttag(context, mapping, args):
851 """The global tags matching the given pattern on the
866 """The global tags matching the given pattern on the
852 most recent globally tagged ancestor of this changeset.
867 most recent globally tagged ancestor of this changeset.
853 If no such tags exist, the "{tag}" template resolves to
868 If no such tags exist, the "{tag}" template resolves to
854 the string "null"."""
869 the string "null"."""
855 if len(args) > 1:
870 if len(args) > 1:
856 # i18n: "latesttag" is a keyword
871 # i18n: "latesttag" is a keyword
857 raise error.ParseError(_("latesttag expects at most one argument"))
872 raise error.ParseError(_("latesttag expects at most one argument"))
858
873
859 pattern = None
874 pattern = None
860 if len(args) == 1:
875 if len(args) == 1:
861 pattern = evalstring(context, mapping, args[0])
876 pattern = evalstring(context, mapping, args[0])
862
877
863 return templatekw.showlatesttags(pattern, **mapping)
878 return templatekw.showlatesttags(pattern, **mapping)
864
879
865 @templatefunc('localdate(date[, tz])')
880 @templatefunc('localdate(date[, tz])')
866 def localdate(context, mapping, args):
881 def localdate(context, mapping, args):
867 """Converts a date to the specified timezone.
882 """Converts a date to the specified timezone.
868 The default is local date."""
883 The default is local date."""
869 if not (1 <= len(args) <= 2):
884 if not (1 <= len(args) <= 2):
870 # i18n: "localdate" is a keyword
885 # i18n: "localdate" is a keyword
871 raise error.ParseError(_("localdate expects one or two arguments"))
886 raise error.ParseError(_("localdate expects one or two arguments"))
872
887
873 date = evalfuncarg(context, mapping, args[0])
888 date = evalfuncarg(context, mapping, args[0])
874 try:
889 try:
875 date = util.parsedate(date)
890 date = util.parsedate(date)
876 except AttributeError: # not str nor date tuple
891 except AttributeError: # not str nor date tuple
877 # i18n: "localdate" is a keyword
892 # i18n: "localdate" is a keyword
878 raise error.ParseError(_("localdate expects a date information"))
893 raise error.ParseError(_("localdate expects a date information"))
879 if len(args) >= 2:
894 if len(args) >= 2:
880 tzoffset = None
895 tzoffset = None
881 tz = evalfuncarg(context, mapping, args[1])
896 tz = evalfuncarg(context, mapping, args[1])
882 if isinstance(tz, str):
897 if isinstance(tz, str):
883 tzoffset, remainder = util.parsetimezone(tz)
898 tzoffset, remainder = util.parsetimezone(tz)
884 if remainder:
899 if remainder:
885 tzoffset = None
900 tzoffset = None
886 if tzoffset is None:
901 if tzoffset is None:
887 try:
902 try:
888 tzoffset = int(tz)
903 tzoffset = int(tz)
889 except (TypeError, ValueError):
904 except (TypeError, ValueError):
890 # i18n: "localdate" is a keyword
905 # i18n: "localdate" is a keyword
891 raise error.ParseError(_("localdate expects a timezone"))
906 raise error.ParseError(_("localdate expects a timezone"))
892 else:
907 else:
893 tzoffset = util.makedate()[1]
908 tzoffset = util.makedate()[1]
894 return (date[0], tzoffset)
909 return (date[0], tzoffset)
895
910
896 @templatefunc('max(iterable)')
911 @templatefunc('max(iterable)')
897 def max_(context, mapping, args, **kwargs):
912 def max_(context, mapping, args, **kwargs):
898 """Return the max of an iterable"""
913 """Return the max of an iterable"""
899 if len(args) != 1:
914 if len(args) != 1:
900 # i18n: "max" is a keyword
915 # i18n: "max" is a keyword
901 raise error.ParseError(_("max expects one arguments"))
916 raise error.ParseError(_("max expects one arguments"))
902
917
903 iterable = evalfuncarg(context, mapping, args[0])
918 iterable = evalfuncarg(context, mapping, args[0])
904 try:
919 try:
905 x = max(iterable)
920 x = max(iterable)
906 except (TypeError, ValueError):
921 except (TypeError, ValueError):
907 # i18n: "max" is a keyword
922 # i18n: "max" is a keyword
908 raise error.ParseError(_("max first argument should be an iterable"))
923 raise error.ParseError(_("max first argument should be an iterable"))
909 return templatekw.wraphybridvalue(iterable, x, x)
924 return templatekw.wraphybridvalue(iterable, x, x)
910
925
911 @templatefunc('min(iterable)')
926 @templatefunc('min(iterable)')
912 def min_(context, mapping, args, **kwargs):
927 def min_(context, mapping, args, **kwargs):
913 """Return the min of an iterable"""
928 """Return the min of an iterable"""
914 if len(args) != 1:
929 if len(args) != 1:
915 # i18n: "min" is a keyword
930 # i18n: "min" is a keyword
916 raise error.ParseError(_("min expects one arguments"))
931 raise error.ParseError(_("min expects one arguments"))
917
932
918 iterable = evalfuncarg(context, mapping, args[0])
933 iterable = evalfuncarg(context, mapping, args[0])
919 try:
934 try:
920 x = min(iterable)
935 x = min(iterable)
921 except (TypeError, ValueError):
936 except (TypeError, ValueError):
922 # i18n: "min" is a keyword
937 # i18n: "min" is a keyword
923 raise error.ParseError(_("min first argument should be an iterable"))
938 raise error.ParseError(_("min first argument should be an iterable"))
924 return templatekw.wraphybridvalue(iterable, x, x)
939 return templatekw.wraphybridvalue(iterable, x, x)
925
940
926 @templatefunc('mod(a, b)')
941 @templatefunc('mod(a, b)')
927 def mod(context, mapping, args):
942 def mod(context, mapping, args):
928 """Calculate a mod b such that a / b + a mod b == a"""
943 """Calculate a mod b such that a / b + a mod b == a"""
929 if not len(args) == 2:
944 if not len(args) == 2:
930 # i18n: "mod" is a keyword
945 # i18n: "mod" is a keyword
931 raise error.ParseError(_("mod expects two arguments"))
946 raise error.ParseError(_("mod expects two arguments"))
932
947
933 func = lambda a, b: a % b
948 func = lambda a, b: a % b
934 return runarithmetic(context, mapping, (func, args[0], args[1]))
949 return runarithmetic(context, mapping, (func, args[0], args[1]))
935
950
936 @templatefunc('obsfateoperations(markers)')
951 @templatefunc('obsfateoperations(markers)')
937 def obsfateoperations(context, mapping, args):
952 def obsfateoperations(context, mapping, args):
938 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
953 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
939 if len(args) != 1:
954 if len(args) != 1:
940 # i18n: "obsfateoperations" is a keyword
955 # i18n: "obsfateoperations" is a keyword
941 raise error.ParseError(_("obsfateoperations expects one arguments"))
956 raise error.ParseError(_("obsfateoperations expects one arguments"))
942
957
943 markers = evalfuncarg(context, mapping, args[0])
958 markers = evalfuncarg(context, mapping, args[0])
944
959
945 try:
960 try:
946 data = obsutil.markersoperations(markers)
961 data = obsutil.markersoperations(markers)
947 return templatekw.hybridlist(data, name='operation')
962 return templatekw.hybridlist(data, name='operation')
948 except (TypeError, KeyError):
963 except (TypeError, KeyError):
949 # i18n: "obsfateoperations" is a keyword
964 # i18n: "obsfateoperations" is a keyword
950 errmsg = _("obsfateoperations first argument should be an iterable")
965 errmsg = _("obsfateoperations first argument should be an iterable")
951 raise error.ParseError(errmsg)
966 raise error.ParseError(errmsg)
952
967
953 @templatefunc('obsfatedate(markers)')
968 @templatefunc('obsfatedate(markers)')
954 def obsfatedate(context, mapping, args):
969 def obsfatedate(context, mapping, args):
955 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
970 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
956 if len(args) != 1:
971 if len(args) != 1:
957 # i18n: "obsfatedate" is a keyword
972 # i18n: "obsfatedate" is a keyword
958 raise error.ParseError(_("obsfatedate expects one arguments"))
973 raise error.ParseError(_("obsfatedate expects one arguments"))
959
974
960 markers = evalfuncarg(context, mapping, args[0])
975 markers = evalfuncarg(context, mapping, args[0])
961
976
962 try:
977 try:
963 data = obsutil.markersdates(markers)
978 data = obsutil.markersdates(markers)
964 return templatekw.hybridlist(data, name='date', fmt='%d %d')
979 return templatekw.hybridlist(data, name='date', fmt='%d %d')
965 except (TypeError, KeyError):
980 except (TypeError, KeyError):
966 # i18n: "obsfatedate" is a keyword
981 # i18n: "obsfatedate" is a keyword
967 errmsg = _("obsfatedate first argument should be an iterable")
982 errmsg = _("obsfatedate first argument should be an iterable")
968 raise error.ParseError(errmsg)
983 raise error.ParseError(errmsg)
969
984
970 @templatefunc('obsfateusers(markers)')
985 @templatefunc('obsfateusers(markers)')
971 def obsfateusers(context, mapping, args):
986 def obsfateusers(context, mapping, args):
972 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
987 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
973 if len(args) != 1:
988 if len(args) != 1:
974 # i18n: "obsfateusers" is a keyword
989 # i18n: "obsfateusers" is a keyword
975 raise error.ParseError(_("obsfateusers expects one arguments"))
990 raise error.ParseError(_("obsfateusers expects one arguments"))
976
991
977 markers = evalfuncarg(context, mapping, args[0])
992 markers = evalfuncarg(context, mapping, args[0])
978
993
979 try:
994 try:
980 data = obsutil.markersusers(markers)
995 data = obsutil.markersusers(markers)
981 return templatekw.hybridlist(data, name='user')
996 return templatekw.hybridlist(data, name='user')
982 except (TypeError, KeyError, ValueError):
997 except (TypeError, KeyError, ValueError):
983 # i18n: "obsfateusers" is a keyword
998 # i18n: "obsfateusers" is a keyword
984 msg = _("obsfateusers first argument should be an iterable of "
999 msg = _("obsfateusers first argument should be an iterable of "
985 "obsmakers")
1000 "obsmakers")
986 raise error.ParseError(msg)
1001 raise error.ParseError(msg)
987
1002
988 @templatefunc('obsfateverb(successors)')
1003 @templatefunc('obsfateverb(successors)')
989 def obsfateverb(context, mapping, args):
1004 def obsfateverb(context, mapping, args):
990 """Compute obsfate related information based on successors (EXPERIMENTAL)"""
1005 """Compute obsfate related information based on successors (EXPERIMENTAL)"""
991 if len(args) != 1:
1006 if len(args) != 1:
992 # i18n: "obsfateverb" is a keyword
1007 # i18n: "obsfateverb" is a keyword
993 raise error.ParseError(_("obsfateverb expects one arguments"))
1008 raise error.ParseError(_("obsfateverb expects one arguments"))
994
1009
995 successors = evalfuncarg(context, mapping, args[0])
1010 successors = evalfuncarg(context, mapping, args[0])
996
1011
997 try:
1012 try:
998 return obsutil.successorsetverb(successors)
1013 return obsutil.successorsetverb(successors)
999 except TypeError:
1014 except TypeError:
1000 # i18n: "obsfateverb" is a keyword
1015 # i18n: "obsfateverb" is a keyword
1001 errmsg = _("obsfateverb first argument should be countable")
1016 errmsg = _("obsfateverb first argument should be countable")
1002 raise error.ParseError(errmsg)
1017 raise error.ParseError(errmsg)
1003
1018
1004 @templatefunc('relpath(path)')
1019 @templatefunc('relpath(path)')
1005 def relpath(context, mapping, args):
1020 def relpath(context, mapping, args):
1006 """Convert a repository-absolute path into a filesystem path relative to
1021 """Convert a repository-absolute path into a filesystem path relative to
1007 the current working directory."""
1022 the current working directory."""
1008 if len(args) != 1:
1023 if len(args) != 1:
1009 # i18n: "relpath" is a keyword
1024 # i18n: "relpath" is a keyword
1010 raise error.ParseError(_("relpath expects one argument"))
1025 raise error.ParseError(_("relpath expects one argument"))
1011
1026
1012 repo = mapping['ctx'].repo()
1027 repo = mapping['ctx'].repo()
1013 path = evalstring(context, mapping, args[0])
1028 path = evalstring(context, mapping, args[0])
1014 return repo.pathto(path)
1029 return repo.pathto(path)
1015
1030
1016 @templatefunc('revset(query[, formatargs...])')
1031 @templatefunc('revset(query[, formatargs...])')
1017 def revset(context, mapping, args):
1032 def revset(context, mapping, args):
1018 """Execute a revision set query. See
1033 """Execute a revision set query. See
1019 :hg:`help revset`."""
1034 :hg:`help revset`."""
1020 if not len(args) > 0:
1035 if not len(args) > 0:
1021 # i18n: "revset" is a keyword
1036 # i18n: "revset" is a keyword
1022 raise error.ParseError(_("revset expects one or more arguments"))
1037 raise error.ParseError(_("revset expects one or more arguments"))
1023
1038
1024 raw = evalstring(context, mapping, args[0])
1039 raw = evalstring(context, mapping, args[0])
1025 ctx = mapping['ctx']
1040 ctx = mapping['ctx']
1026 repo = ctx.repo()
1041 repo = ctx.repo()
1027
1042
1028 def query(expr):
1043 def query(expr):
1029 m = revsetmod.match(repo.ui, expr, repo=repo)
1044 m = revsetmod.match(repo.ui, expr, repo=repo)
1030 return m(repo)
1045 return m(repo)
1031
1046
1032 if len(args) > 1:
1047 if len(args) > 1:
1033 formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]]
1048 formatargs = [evalfuncarg(context, mapping, a) for a in args[1:]]
1034 revs = query(revsetlang.formatspec(raw, *formatargs))
1049 revs = query(revsetlang.formatspec(raw, *formatargs))
1035 revs = list(revs)
1050 revs = list(revs)
1036 else:
1051 else:
1037 revsetcache = mapping['cache'].setdefault("revsetcache", {})
1052 revsetcache = mapping['cache'].setdefault("revsetcache", {})
1038 if raw in revsetcache:
1053 if raw in revsetcache:
1039 revs = revsetcache[raw]
1054 revs = revsetcache[raw]
1040 else:
1055 else:
1041 revs = query(raw)
1056 revs = query(raw)
1042 revs = list(revs)
1057 revs = list(revs)
1043 revsetcache[raw] = revs
1058 revsetcache[raw] = revs
1044
1059
1045 return templatekw.showrevslist("revision", revs, **mapping)
1060 return templatekw.showrevslist("revision", revs, **mapping)
1046
1061
1047 @templatefunc('rstdoc(text, style)')
1062 @templatefunc('rstdoc(text, style)')
1048 def rstdoc(context, mapping, args):
1063 def rstdoc(context, mapping, args):
1049 """Format reStructuredText."""
1064 """Format reStructuredText."""
1050 if len(args) != 2:
1065 if len(args) != 2:
1051 # i18n: "rstdoc" is a keyword
1066 # i18n: "rstdoc" is a keyword
1052 raise error.ParseError(_("rstdoc expects two arguments"))
1067 raise error.ParseError(_("rstdoc expects two arguments"))
1053
1068
1054 text = evalstring(context, mapping, args[0])
1069 text = evalstring(context, mapping, args[0])
1055 style = evalstring(context, mapping, args[1])
1070 style = evalstring(context, mapping, args[1])
1056
1071
1057 return minirst.format(text, style=style, keep=['verbose'])
1072 return minirst.format(text, style=style, keep=['verbose'])
1058
1073
1059 @templatefunc('separate(sep, args)', argspec='sep *args')
1074 @templatefunc('separate(sep, args)', argspec='sep *args')
1060 def separate(context, mapping, args):
1075 def separate(context, mapping, args):
1061 """Add a separator between non-empty arguments."""
1076 """Add a separator between non-empty arguments."""
1062 if 'sep' not in args:
1077 if 'sep' not in args:
1063 # i18n: "separate" is a keyword
1078 # i18n: "separate" is a keyword
1064 raise error.ParseError(_("separate expects at least one argument"))
1079 raise error.ParseError(_("separate expects at least one argument"))
1065
1080
1066 sep = evalstring(context, mapping, args['sep'])
1081 sep = evalstring(context, mapping, args['sep'])
1067 first = True
1082 first = True
1068 for arg in args['args']:
1083 for arg in args['args']:
1069 argstr = evalstring(context, mapping, arg)
1084 argstr = evalstring(context, mapping, arg)
1070 if not argstr:
1085 if not argstr:
1071 continue
1086 continue
1072 if first:
1087 if first:
1073 first = False
1088 first = False
1074 else:
1089 else:
1075 yield sep
1090 yield sep
1076 yield argstr
1091 yield argstr
1077
1092
1078 @templatefunc('shortest(node, minlength=4)')
1093 @templatefunc('shortest(node, minlength=4)')
1079 def shortest(context, mapping, args):
1094 def shortest(context, mapping, args):
1080 """Obtain the shortest representation of
1095 """Obtain the shortest representation of
1081 a node."""
1096 a node."""
1082 if not (1 <= len(args) <= 2):
1097 if not (1 <= len(args) <= 2):
1083 # i18n: "shortest" is a keyword
1098 # i18n: "shortest" is a keyword
1084 raise error.ParseError(_("shortest() expects one or two arguments"))
1099 raise error.ParseError(_("shortest() expects one or two arguments"))
1085
1100
1086 node = evalstring(context, mapping, args[0])
1101 node = evalstring(context, mapping, args[0])
1087
1102
1088 minlength = 4
1103 minlength = 4
1089 if len(args) > 1:
1104 if len(args) > 1:
1090 minlength = evalinteger(context, mapping, args[1],
1105 minlength = evalinteger(context, mapping, args[1],
1091 # i18n: "shortest" is a keyword
1106 # i18n: "shortest" is a keyword
1092 _("shortest() expects an integer minlength"))
1107 _("shortest() expects an integer minlength"))
1093
1108
1094 # _partialmatch() of filtered changelog could take O(len(repo)) time,
1109 # _partialmatch() of filtered changelog could take O(len(repo)) time,
1095 # which would be unacceptably slow. so we look for hash collision in
1110 # which would be unacceptably slow. so we look for hash collision in
1096 # unfiltered space, which means some hashes may be slightly longer.
1111 # unfiltered space, which means some hashes may be slightly longer.
1097 cl = mapping['ctx']._repo.unfiltered().changelog
1112 cl = mapping['ctx']._repo.unfiltered().changelog
1098 return cl.shortest(node, minlength)
1113 return cl.shortest(node, minlength)
1099
1114
1100 @templatefunc('strip(text[, chars])')
1115 @templatefunc('strip(text[, chars])')
1101 def strip(context, mapping, args):
1116 def strip(context, mapping, args):
1102 """Strip characters from a string. By default,
1117 """Strip characters from a string. By default,
1103 strips all leading and trailing whitespace."""
1118 strips all leading and trailing whitespace."""
1104 if not (1 <= len(args) <= 2):
1119 if not (1 <= len(args) <= 2):
1105 # i18n: "strip" is a keyword
1120 # i18n: "strip" is a keyword
1106 raise error.ParseError(_("strip expects one or two arguments"))
1121 raise error.ParseError(_("strip expects one or two arguments"))
1107
1122
1108 text = evalstring(context, mapping, args[0])
1123 text = evalstring(context, mapping, args[0])
1109 if len(args) == 2:
1124 if len(args) == 2:
1110 chars = evalstring(context, mapping, args[1])
1125 chars = evalstring(context, mapping, args[1])
1111 return text.strip(chars)
1126 return text.strip(chars)
1112 return text.strip()
1127 return text.strip()
1113
1128
1114 @templatefunc('sub(pattern, replacement, expression)')
1129 @templatefunc('sub(pattern, replacement, expression)')
1115 def sub(context, mapping, args):
1130 def sub(context, mapping, args):
1116 """Perform text substitution
1131 """Perform text substitution
1117 using regular expressions."""
1132 using regular expressions."""
1118 if len(args) != 3:
1133 if len(args) != 3:
1119 # i18n: "sub" is a keyword
1134 # i18n: "sub" is a keyword
1120 raise error.ParseError(_("sub expects three arguments"))
1135 raise error.ParseError(_("sub expects three arguments"))
1121
1136
1122 pat = evalstring(context, mapping, args[0])
1137 pat = evalstring(context, mapping, args[0])
1123 rpl = evalstring(context, mapping, args[1])
1138 rpl = evalstring(context, mapping, args[1])
1124 src = evalstring(context, mapping, args[2])
1139 src = evalstring(context, mapping, args[2])
1125 try:
1140 try:
1126 patre = re.compile(pat)
1141 patre = re.compile(pat)
1127 except re.error:
1142 except re.error:
1128 # i18n: "sub" is a keyword
1143 # i18n: "sub" is a keyword
1129 raise error.ParseError(_("sub got an invalid pattern: %s") % pat)
1144 raise error.ParseError(_("sub got an invalid pattern: %s") % pat)
1130 try:
1145 try:
1131 yield patre.sub(rpl, src)
1146 yield patre.sub(rpl, src)
1132 except re.error:
1147 except re.error:
1133 # i18n: "sub" is a keyword
1148 # i18n: "sub" is a keyword
1134 raise error.ParseError(_("sub got an invalid replacement: %s") % rpl)
1149 raise error.ParseError(_("sub got an invalid replacement: %s") % rpl)
1135
1150
1136 @templatefunc('startswith(pattern, text)')
1151 @templatefunc('startswith(pattern, text)')
1137 def startswith(context, mapping, args):
1152 def startswith(context, mapping, args):
1138 """Returns the value from the "text" argument
1153 """Returns the value from the "text" argument
1139 if it begins with the content from the "pattern" argument."""
1154 if it begins with the content from the "pattern" argument."""
1140 if len(args) != 2:
1155 if len(args) != 2:
1141 # i18n: "startswith" is a keyword
1156 # i18n: "startswith" is a keyword
1142 raise error.ParseError(_("startswith expects two arguments"))
1157 raise error.ParseError(_("startswith expects two arguments"))
1143
1158
1144 patn = evalstring(context, mapping, args[0])
1159 patn = evalstring(context, mapping, args[0])
1145 text = evalstring(context, mapping, args[1])
1160 text = evalstring(context, mapping, args[1])
1146 if text.startswith(patn):
1161 if text.startswith(patn):
1147 return text
1162 return text
1148 return ''
1163 return ''
1149
1164
1150 @templatefunc('word(number, text[, separator])')
1165 @templatefunc('word(number, text[, separator])')
1151 def word(context, mapping, args):
1166 def word(context, mapping, args):
1152 """Return the nth word from a string."""
1167 """Return the nth word from a string."""
1153 if not (2 <= len(args) <= 3):
1168 if not (2 <= len(args) <= 3):
1154 # i18n: "word" is a keyword
1169 # i18n: "word" is a keyword
1155 raise error.ParseError(_("word expects two or three arguments, got %d")
1170 raise error.ParseError(_("word expects two or three arguments, got %d")
1156 % len(args))
1171 % len(args))
1157
1172
1158 num = evalinteger(context, mapping, args[0],
1173 num = evalinteger(context, mapping, args[0],
1159 # i18n: "word" is a keyword
1174 # i18n: "word" is a keyword
1160 _("word expects an integer index"))
1175 _("word expects an integer index"))
1161 text = evalstring(context, mapping, args[1])
1176 text = evalstring(context, mapping, args[1])
1162 if len(args) == 3:
1177 if len(args) == 3:
1163 splitter = evalstring(context, mapping, args[2])
1178 splitter = evalstring(context, mapping, args[2])
1164 else:
1179 else:
1165 splitter = None
1180 splitter = None
1166
1181
1167 tokens = text.split(splitter)
1182 tokens = text.split(splitter)
1168 if num >= len(tokens) or num < -len(tokens):
1183 if num >= len(tokens) or num < -len(tokens):
1169 return ''
1184 return ''
1170 else:
1185 else:
1171 return tokens[num]
1186 return tokens[num]
1172
1187
1173 # methods to interpret function arguments or inner expressions (e.g. {_(x)})
1188 # methods to interpret function arguments or inner expressions (e.g. {_(x)})
1174 exprmethods = {
1189 exprmethods = {
1175 "integer": lambda e, c: (runinteger, e[1]),
1190 "integer": lambda e, c: (runinteger, e[1]),
1176 "string": lambda e, c: (runstring, e[1]),
1191 "string": lambda e, c: (runstring, e[1]),
1177 "symbol": lambda e, c: (runsymbol, e[1]),
1192 "symbol": lambda e, c: (runsymbol, e[1]),
1178 "template": buildtemplate,
1193 "template": buildtemplate,
1179 "group": lambda e, c: compileexp(e[1], c, exprmethods),
1194 "group": lambda e, c: compileexp(e[1], c, exprmethods),
1180 ".": buildmember,
1195 ".": buildmember,
1181 "|": buildfilter,
1196 "|": buildfilter,
1182 "%": buildmap,
1197 "%": buildmap,
1183 "func": buildfunc,
1198 "func": buildfunc,
1184 "keyvalue": buildkeyvaluepair,
1199 "keyvalue": buildkeyvaluepair,
1185 "+": lambda e, c: buildarithmetic(e, c, lambda a, b: a + b),
1200 "+": lambda e, c: buildarithmetic(e, c, lambda a, b: a + b),
1186 "-": lambda e, c: buildarithmetic(e, c, lambda a, b: a - b),
1201 "-": lambda e, c: buildarithmetic(e, c, lambda a, b: a - b),
1187 "negate": buildnegate,
1202 "negate": buildnegate,
1188 "*": lambda e, c: buildarithmetic(e, c, lambda a, b: a * b),
1203 "*": lambda e, c: buildarithmetic(e, c, lambda a, b: a * b),
1189 "/": lambda e, c: buildarithmetic(e, c, lambda a, b: a // b),
1204 "/": lambda e, c: buildarithmetic(e, c, lambda a, b: a // b),
1190 }
1205 }
1191
1206
1192 # methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"})
1207 # methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"})
1193 methods = exprmethods.copy()
1208 methods = exprmethods.copy()
1194 methods["integer"] = exprmethods["symbol"] # '{1}' as variable
1209 methods["integer"] = exprmethods["symbol"] # '{1}' as variable
1195
1210
1196 class _aliasrules(parser.basealiasrules):
1211 class _aliasrules(parser.basealiasrules):
1197 """Parsing and expansion rule set of template aliases"""
1212 """Parsing and expansion rule set of template aliases"""
1198 _section = _('template alias')
1213 _section = _('template alias')
1199 _parse = staticmethod(_parseexpr)
1214 _parse = staticmethod(_parseexpr)
1200
1215
1201 @staticmethod
1216 @staticmethod
1202 def _trygetfunc(tree):
1217 def _trygetfunc(tree):
1203 """Return (name, args) if tree is func(...) or ...|filter; otherwise
1218 """Return (name, args) if tree is func(...) or ...|filter; otherwise
1204 None"""
1219 None"""
1205 if tree[0] == 'func' and tree[1][0] == 'symbol':
1220 if tree[0] == 'func' and tree[1][0] == 'symbol':
1206 return tree[1][1], getlist(tree[2])
1221 return tree[1][1], getlist(tree[2])
1207 if tree[0] == '|' and tree[2][0] == 'symbol':
1222 if tree[0] == '|' and tree[2][0] == 'symbol':
1208 return tree[2][1], [tree[1]]
1223 return tree[2][1], [tree[1]]
1209
1224
1210 def expandaliases(tree, aliases):
1225 def expandaliases(tree, aliases):
1211 """Return new tree of aliases are expanded"""
1226 """Return new tree of aliases are expanded"""
1212 aliasmap = _aliasrules.buildmap(aliases)
1227 aliasmap = _aliasrules.buildmap(aliases)
1213 return _aliasrules.expand(aliasmap, tree)
1228 return _aliasrules.expand(aliasmap, tree)
1214
1229
1215 # template engine
1230 # template engine
1216
1231
1217 stringify = templatefilters.stringify
1232 stringify = templatefilters.stringify
1218
1233
1219 def _flatten(thing):
1234 def _flatten(thing):
1220 '''yield a single stream from a possibly nested set of iterators'''
1235 '''yield a single stream from a possibly nested set of iterators'''
1221 thing = templatekw.unwraphybrid(thing)
1236 thing = templatekw.unwraphybrid(thing)
1222 if isinstance(thing, bytes):
1237 if isinstance(thing, bytes):
1223 yield thing
1238 yield thing
1224 elif thing is None:
1239 elif thing is None:
1225 pass
1240 pass
1226 elif not util.safehasattr(thing, '__iter__'):
1241 elif not util.safehasattr(thing, '__iter__'):
1227 yield pycompat.bytestr(thing)
1242 yield pycompat.bytestr(thing)
1228 else:
1243 else:
1229 for i in thing:
1244 for i in thing:
1230 i = templatekw.unwraphybrid(i)
1245 i = templatekw.unwraphybrid(i)
1231 if isinstance(i, bytes):
1246 if isinstance(i, bytes):
1232 yield i
1247 yield i
1233 elif i is None:
1248 elif i is None:
1234 pass
1249 pass
1235 elif not util.safehasattr(i, '__iter__'):
1250 elif not util.safehasattr(i, '__iter__'):
1236 yield pycompat.bytestr(i)
1251 yield pycompat.bytestr(i)
1237 else:
1252 else:
1238 for j in _flatten(i):
1253 for j in _flatten(i):
1239 yield j
1254 yield j
1240
1255
1241 def unquotestring(s):
1256 def unquotestring(s):
1242 '''unwrap quotes if any; otherwise returns unmodified string'''
1257 '''unwrap quotes if any; otherwise returns unmodified string'''
1243 if len(s) < 2 or s[0] not in "'\"" or s[0] != s[-1]:
1258 if len(s) < 2 or s[0] not in "'\"" or s[0] != s[-1]:
1244 return s
1259 return s
1245 return s[1:-1]
1260 return s[1:-1]
1246
1261
1247 class engine(object):
1262 class engine(object):
1248 '''template expansion engine.
1263 '''template expansion engine.
1249
1264
1250 template expansion works like this. a map file contains key=value
1265 template expansion works like this. a map file contains key=value
1251 pairs. if value is quoted, it is treated as string. otherwise, it
1266 pairs. if value is quoted, it is treated as string. otherwise, it
1252 is treated as name of template file.
1267 is treated as name of template file.
1253
1268
1254 templater is asked to expand a key in map. it looks up key, and
1269 templater is asked to expand a key in map. it looks up key, and
1255 looks for strings like this: {foo}. it expands {foo} by looking up
1270 looks for strings like this: {foo}. it expands {foo} by looking up
1256 foo in map, and substituting it. expansion is recursive: it stops
1271 foo in map, and substituting it. expansion is recursive: it stops
1257 when there is no more {foo} to replace.
1272 when there is no more {foo} to replace.
1258
1273
1259 expansion also allows formatting and filtering.
1274 expansion also allows formatting and filtering.
1260
1275
1261 format uses key to expand each item in list. syntax is
1276 format uses key to expand each item in list. syntax is
1262 {key%format}.
1277 {key%format}.
1263
1278
1264 filter uses function to transform value. syntax is
1279 filter uses function to transform value. syntax is
1265 {key|filter1|filter2|...}.'''
1280 {key|filter1|filter2|...}.'''
1266
1281
1267 def __init__(self, loader, filters=None, defaults=None, aliases=()):
1282 def __init__(self, loader, filters=None, defaults=None, aliases=()):
1268 self._loader = loader
1283 self._loader = loader
1269 if filters is None:
1284 if filters is None:
1270 filters = {}
1285 filters = {}
1271 self._filters = filters
1286 self._filters = filters
1272 if defaults is None:
1287 if defaults is None:
1273 defaults = {}
1288 defaults = {}
1274 self._defaults = defaults
1289 self._defaults = defaults
1275 self._aliasmap = _aliasrules.buildmap(aliases)
1290 self._aliasmap = _aliasrules.buildmap(aliases)
1276 self._cache = {} # key: (func, data)
1291 self._cache = {} # key: (func, data)
1277
1292
1278 def _load(self, t):
1293 def _load(self, t):
1279 '''load, parse, and cache a template'''
1294 '''load, parse, and cache a template'''
1280 if t not in self._cache:
1295 if t not in self._cache:
1281 # put poison to cut recursion while compiling 't'
1296 # put poison to cut recursion while compiling 't'
1282 self._cache[t] = (_runrecursivesymbol, t)
1297 self._cache[t] = (_runrecursivesymbol, t)
1283 try:
1298 try:
1284 x = parse(self._loader(t))
1299 x = parse(self._loader(t))
1285 if self._aliasmap:
1300 if self._aliasmap:
1286 x = _aliasrules.expand(self._aliasmap, x)
1301 x = _aliasrules.expand(self._aliasmap, x)
1287 self._cache[t] = compileexp(x, self, methods)
1302 self._cache[t] = compileexp(x, self, methods)
1288 except: # re-raises
1303 except: # re-raises
1289 del self._cache[t]
1304 del self._cache[t]
1290 raise
1305 raise
1291 return self._cache[t]
1306 return self._cache[t]
1292
1307
1293 def process(self, t, mapping):
1308 def process(self, t, mapping):
1294 '''Perform expansion. t is name of map element to expand.
1309 '''Perform expansion. t is name of map element to expand.
1295 mapping contains added elements for use during expansion. Is a
1310 mapping contains added elements for use during expansion. Is a
1296 generator.'''
1311 generator.'''
1297 func, data = self._load(t)
1312 func, data = self._load(t)
1298 return _flatten(func(self, mapping, data))
1313 return _flatten(func(self, mapping, data))
1299
1314
1300 engines = {'default': engine}
1315 engines = {'default': engine}
1301
1316
1302 def stylelist():
1317 def stylelist():
1303 paths = templatepaths()
1318 paths = templatepaths()
1304 if not paths:
1319 if not paths:
1305 return _('no templates found, try `hg debuginstall` for more info')
1320 return _('no templates found, try `hg debuginstall` for more info')
1306 dirlist = os.listdir(paths[0])
1321 dirlist = os.listdir(paths[0])
1307 stylelist = []
1322 stylelist = []
1308 for file in dirlist:
1323 for file in dirlist:
1309 split = file.split(".")
1324 split = file.split(".")
1310 if split[-1] in ('orig', 'rej'):
1325 if split[-1] in ('orig', 'rej'):
1311 continue
1326 continue
1312 if split[0] == "map-cmdline":
1327 if split[0] == "map-cmdline":
1313 stylelist.append(split[1])
1328 stylelist.append(split[1])
1314 return ", ".join(sorted(stylelist))
1329 return ", ".join(sorted(stylelist))
1315
1330
1316 def _readmapfile(mapfile):
1331 def _readmapfile(mapfile):
1317 """Load template elements from the given map file"""
1332 """Load template elements from the given map file"""
1318 if not os.path.exists(mapfile):
1333 if not os.path.exists(mapfile):
1319 raise error.Abort(_("style '%s' not found") % mapfile,
1334 raise error.Abort(_("style '%s' not found") % mapfile,
1320 hint=_("available styles: %s") % stylelist())
1335 hint=_("available styles: %s") % stylelist())
1321
1336
1322 base = os.path.dirname(mapfile)
1337 base = os.path.dirname(mapfile)
1323 conf = config.config(includepaths=templatepaths())
1338 conf = config.config(includepaths=templatepaths())
1324 conf.read(mapfile)
1339 conf.read(mapfile)
1325
1340
1326 cache = {}
1341 cache = {}
1327 tmap = {}
1342 tmap = {}
1328 for key, val in conf[''].items():
1343 for key, val in conf[''].items():
1329 if not val:
1344 if not val:
1330 raise error.ParseError(_('missing value'), conf.source('', key))
1345 raise error.ParseError(_('missing value'), conf.source('', key))
1331 if val[0] in "'\"":
1346 if val[0] in "'\"":
1332 if val[0] != val[-1]:
1347 if val[0] != val[-1]:
1333 raise error.ParseError(_('unmatched quotes'),
1348 raise error.ParseError(_('unmatched quotes'),
1334 conf.source('', key))
1349 conf.source('', key))
1335 cache[key] = unquotestring(val)
1350 cache[key] = unquotestring(val)
1336 elif key == "__base__":
1351 elif key == "__base__":
1337 # treat as a pointer to a base class for this style
1352 # treat as a pointer to a base class for this style
1338 path = util.normpath(os.path.join(base, val))
1353 path = util.normpath(os.path.join(base, val))
1339
1354
1340 # fallback check in template paths
1355 # fallback check in template paths
1341 if not os.path.exists(path):
1356 if not os.path.exists(path):
1342 for p in templatepaths():
1357 for p in templatepaths():
1343 p2 = util.normpath(os.path.join(p, val))
1358 p2 = util.normpath(os.path.join(p, val))
1344 if os.path.isfile(p2):
1359 if os.path.isfile(p2):
1345 path = p2
1360 path = p2
1346 break
1361 break
1347 p3 = util.normpath(os.path.join(p2, "map"))
1362 p3 = util.normpath(os.path.join(p2, "map"))
1348 if os.path.isfile(p3):
1363 if os.path.isfile(p3):
1349 path = p3
1364 path = p3
1350 break
1365 break
1351
1366
1352 bcache, btmap = _readmapfile(path)
1367 bcache, btmap = _readmapfile(path)
1353 for k in bcache:
1368 for k in bcache:
1354 if k not in cache:
1369 if k not in cache:
1355 cache[k] = bcache[k]
1370 cache[k] = bcache[k]
1356 for k in btmap:
1371 for k in btmap:
1357 if k not in tmap:
1372 if k not in tmap:
1358 tmap[k] = btmap[k]
1373 tmap[k] = btmap[k]
1359 else:
1374 else:
1360 val = 'default', val
1375 val = 'default', val
1361 if ':' in val[1]:
1376 if ':' in val[1]:
1362 val = val[1].split(':', 1)
1377 val = val[1].split(':', 1)
1363 tmap[key] = val[0], os.path.join(base, val[1])
1378 tmap[key] = val[0], os.path.join(base, val[1])
1364 return cache, tmap
1379 return cache, tmap
1365
1380
1366 class TemplateNotFound(error.Abort):
1381 class TemplateNotFound(error.Abort):
1367 pass
1382 pass
1368
1383
1369 class templater(object):
1384 class templater(object):
1370
1385
1371 def __init__(self, filters=None, defaults=None, cache=None, aliases=(),
1386 def __init__(self, filters=None, defaults=None, cache=None, aliases=(),
1372 minchunk=1024, maxchunk=65536):
1387 minchunk=1024, maxchunk=65536):
1373 '''set up template engine.
1388 '''set up template engine.
1374 filters is dict of functions. each transforms a value into another.
1389 filters is dict of functions. each transforms a value into another.
1375 defaults is dict of default map definitions.
1390 defaults is dict of default map definitions.
1376 aliases is list of alias (name, replacement) pairs.
1391 aliases is list of alias (name, replacement) pairs.
1377 '''
1392 '''
1378 if filters is None:
1393 if filters is None:
1379 filters = {}
1394 filters = {}
1380 if defaults is None:
1395 if defaults is None:
1381 defaults = {}
1396 defaults = {}
1382 if cache is None:
1397 if cache is None:
1383 cache = {}
1398 cache = {}
1384 self.cache = cache.copy()
1399 self.cache = cache.copy()
1385 self.map = {}
1400 self.map = {}
1386 self.filters = templatefilters.filters.copy()
1401 self.filters = templatefilters.filters.copy()
1387 self.filters.update(filters)
1402 self.filters.update(filters)
1388 self.defaults = defaults
1403 self.defaults = defaults
1389 self._aliases = aliases
1404 self._aliases = aliases
1390 self.minchunk, self.maxchunk = minchunk, maxchunk
1405 self.minchunk, self.maxchunk = minchunk, maxchunk
1391 self.ecache = {}
1406 self.ecache = {}
1392
1407
1393 @classmethod
1408 @classmethod
1394 def frommapfile(cls, mapfile, filters=None, defaults=None, cache=None,
1409 def frommapfile(cls, mapfile, filters=None, defaults=None, cache=None,
1395 minchunk=1024, maxchunk=65536):
1410 minchunk=1024, maxchunk=65536):
1396 """Create templater from the specified map file"""
1411 """Create templater from the specified map file"""
1397 t = cls(filters, defaults, cache, [], minchunk, maxchunk)
1412 t = cls(filters, defaults, cache, [], minchunk, maxchunk)
1398 cache, tmap = _readmapfile(mapfile)
1413 cache, tmap = _readmapfile(mapfile)
1399 t.cache.update(cache)
1414 t.cache.update(cache)
1400 t.map = tmap
1415 t.map = tmap
1401 return t
1416 return t
1402
1417
1403 def __contains__(self, key):
1418 def __contains__(self, key):
1404 return key in self.cache or key in self.map
1419 return key in self.cache or key in self.map
1405
1420
1406 def load(self, t):
1421 def load(self, t):
1407 '''Get the template for the given template name. Use a local cache.'''
1422 '''Get the template for the given template name. Use a local cache.'''
1408 if t not in self.cache:
1423 if t not in self.cache:
1409 try:
1424 try:
1410 self.cache[t] = util.readfile(self.map[t][1])
1425 self.cache[t] = util.readfile(self.map[t][1])
1411 except KeyError as inst:
1426 except KeyError as inst:
1412 raise TemplateNotFound(_('"%s" not in template map') %
1427 raise TemplateNotFound(_('"%s" not in template map') %
1413 inst.args[0])
1428 inst.args[0])
1414 except IOError as inst:
1429 except IOError as inst:
1415 raise IOError(inst.args[0], _('template file %s: %s') %
1430 raise IOError(inst.args[0], _('template file %s: %s') %
1416 (self.map[t][1], inst.args[1]))
1431 (self.map[t][1], inst.args[1]))
1417 return self.cache[t]
1432 return self.cache[t]
1418
1433
1419 def render(self, mapping):
1434 def render(self, mapping):
1420 """Render the default unnamed template and return result as string"""
1435 """Render the default unnamed template and return result as string"""
1421 mapping = pycompat.strkwargs(mapping)
1436 mapping = pycompat.strkwargs(mapping)
1422 return stringify(self('', **mapping))
1437 return stringify(self('', **mapping))
1423
1438
1424 def __call__(self, t, **mapping):
1439 def __call__(self, t, **mapping):
1425 mapping = pycompat.byteskwargs(mapping)
1440 mapping = pycompat.byteskwargs(mapping)
1426 ttype = t in self.map and self.map[t][0] or 'default'
1441 ttype = t in self.map and self.map[t][0] or 'default'
1427 if ttype not in self.ecache:
1442 if ttype not in self.ecache:
1428 try:
1443 try:
1429 ecls = engines[ttype]
1444 ecls = engines[ttype]
1430 except KeyError:
1445 except KeyError:
1431 raise error.Abort(_('invalid template engine: %s') % ttype)
1446 raise error.Abort(_('invalid template engine: %s') % ttype)
1432 self.ecache[ttype] = ecls(self.load, self.filters, self.defaults,
1447 self.ecache[ttype] = ecls(self.load, self.filters, self.defaults,
1433 self._aliases)
1448 self._aliases)
1434 proc = self.ecache[ttype]
1449 proc = self.ecache[ttype]
1435
1450
1436 stream = proc.process(t, mapping)
1451 stream = proc.process(t, mapping)
1437 if self.minchunk:
1452 if self.minchunk:
1438 stream = util.increasingchunks(stream, min=self.minchunk,
1453 stream = util.increasingchunks(stream, min=self.minchunk,
1439 max=self.maxchunk)
1454 max=self.maxchunk)
1440 return stream
1455 return stream
1441
1456
1442 def templatepaths():
1457 def templatepaths():
1443 '''return locations used for template files.'''
1458 '''return locations used for template files.'''
1444 pathsrel = ['templates']
1459 pathsrel = ['templates']
1445 paths = [os.path.normpath(os.path.join(util.datapath, f))
1460 paths = [os.path.normpath(os.path.join(util.datapath, f))
1446 for f in pathsrel]
1461 for f in pathsrel]
1447 return [p for p in paths if os.path.isdir(p)]
1462 return [p for p in paths if os.path.isdir(p)]
1448
1463
1449 def templatepath(name):
1464 def templatepath(name):
1450 '''return location of template file. returns None if not found.'''
1465 '''return location of template file. returns None if not found.'''
1451 for p in templatepaths():
1466 for p in templatepaths():
1452 f = os.path.join(p, name)
1467 f = os.path.join(p, name)
1453 if os.path.exists(f):
1468 if os.path.exists(f):
1454 return f
1469 return f
1455 return None
1470 return None
1456
1471
1457 def stylemap(styles, paths=None):
1472 def stylemap(styles, paths=None):
1458 """Return path to mapfile for a given style.
1473 """Return path to mapfile for a given style.
1459
1474
1460 Searches mapfile in the following locations:
1475 Searches mapfile in the following locations:
1461 1. templatepath/style/map
1476 1. templatepath/style/map
1462 2. templatepath/map-style
1477 2. templatepath/map-style
1463 3. templatepath/map
1478 3. templatepath/map
1464 """
1479 """
1465
1480
1466 if paths is None:
1481 if paths is None:
1467 paths = templatepaths()
1482 paths = templatepaths()
1468 elif isinstance(paths, str):
1483 elif isinstance(paths, str):
1469 paths = [paths]
1484 paths = [paths]
1470
1485
1471 if isinstance(styles, str):
1486 if isinstance(styles, str):
1472 styles = [styles]
1487 styles = [styles]
1473
1488
1474 for style in styles:
1489 for style in styles:
1475 # only plain name is allowed to honor template paths
1490 # only plain name is allowed to honor template paths
1476 if (not style
1491 if (not style
1477 or style in (os.curdir, os.pardir)
1492 or style in (os.curdir, os.pardir)
1478 or pycompat.ossep in style
1493 or pycompat.ossep in style
1479 or pycompat.osaltsep and pycompat.osaltsep in style):
1494 or pycompat.osaltsep and pycompat.osaltsep in style):
1480 continue
1495 continue
1481 locations = [os.path.join(style, 'map'), 'map-' + style]
1496 locations = [os.path.join(style, 'map'), 'map-' + style]
1482 locations.append('map')
1497 locations.append('map')
1483
1498
1484 for path in paths:
1499 for path in paths:
1485 for location in locations:
1500 for location in locations:
1486 mapfile = os.path.join(path, location)
1501 mapfile = os.path.join(path, location)
1487 if os.path.isfile(mapfile):
1502 if os.path.isfile(mapfile):
1488 return style, mapfile
1503 return style, mapfile
1489
1504
1490 raise RuntimeError("No hgweb templates found in %r" % paths)
1505 raise RuntimeError("No hgweb templates found in %r" % paths)
1491
1506
1492 def loadfunction(ui, extname, registrarobj):
1507 def loadfunction(ui, extname, registrarobj):
1493 """Load template function from specified registrarobj
1508 """Load template function from specified registrarobj
1494 """
1509 """
1495 for name, func in registrarobj._table.iteritems():
1510 for name, func in registrarobj._table.iteritems():
1496 funcs[name] = func
1511 funcs[name] = func
1497
1512
1498 # tell hggettext to extract docstrings from these functions:
1513 # tell hggettext to extract docstrings from these functions:
1499 i18nfunctions = funcs.values()
1514 i18nfunctions = funcs.values()
@@ -1,4663 +1,4670
1 $ hg init a
1 $ hg init a
2 $ cd a
2 $ cd a
3 $ echo a > a
3 $ echo a > a
4 $ hg add a
4 $ hg add a
5 $ echo line 1 > b
5 $ echo line 1 > b
6 $ echo line 2 >> b
6 $ echo line 2 >> b
7 $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>'
7 $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>'
8
8
9 $ hg add b
9 $ hg add b
10 $ echo other 1 > c
10 $ echo other 1 > c
11 $ echo other 2 >> c
11 $ echo other 2 >> c
12 $ echo >> c
12 $ echo >> c
13 $ echo other 3 >> c
13 $ echo other 3 >> c
14 $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>'
14 $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>'
15
15
16 $ hg add c
16 $ hg add c
17 $ hg commit -m 'no person' -d '1200000 0' -u 'other@place'
17 $ hg commit -m 'no person' -d '1200000 0' -u 'other@place'
18 $ echo c >> c
18 $ echo c >> c
19 $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person'
19 $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person'
20
20
21 $ echo foo > .hg/branch
21 $ echo foo > .hg/branch
22 $ hg commit -m 'new branch' -d '1400000 0' -u 'person'
22 $ hg commit -m 'new branch' -d '1400000 0' -u 'person'
23
23
24 $ hg co -q 3
24 $ hg co -q 3
25 $ echo other 4 >> d
25 $ echo other 4 >> d
26 $ hg add d
26 $ hg add d
27 $ hg commit -m 'new head' -d '1500000 0' -u 'person'
27 $ hg commit -m 'new head' -d '1500000 0' -u 'person'
28
28
29 $ hg merge -q foo
29 $ hg merge -q foo
30 $ hg commit -m 'merge' -d '1500001 0' -u 'person'
30 $ hg commit -m 'merge' -d '1500001 0' -u 'person'
31
31
32 Test arithmetic operators have the right precedence:
32 Test arithmetic operators have the right precedence:
33
33
34 $ hg log -l 1 -T '{date(date, "%Y") + 5 * 10} {date(date, "%Y") - 2 * 3}\n'
34 $ hg log -l 1 -T '{date(date, "%Y") + 5 * 10} {date(date, "%Y") - 2 * 3}\n'
35 2020 1964
35 2020 1964
36 $ hg log -l 1 -T '{date(date, "%Y") * 5 + 10} {date(date, "%Y") * 3 - 2}\n'
36 $ hg log -l 1 -T '{date(date, "%Y") * 5 + 10} {date(date, "%Y") * 3 - 2}\n'
37 9860 5908
37 9860 5908
38
38
39 Test division:
39 Test division:
40
40
41 $ hg debugtemplate -r0 -v '{5 / 2} {mod(5, 2)}\n'
41 $ hg debugtemplate -r0 -v '{5 / 2} {mod(5, 2)}\n'
42 (template
42 (template
43 (/
43 (/
44 (integer '5')
44 (integer '5')
45 (integer '2'))
45 (integer '2'))
46 (string ' ')
46 (string ' ')
47 (func
47 (func
48 (symbol 'mod')
48 (symbol 'mod')
49 (list
49 (list
50 (integer '5')
50 (integer '5')
51 (integer '2')))
51 (integer '2')))
52 (string '\n'))
52 (string '\n'))
53 2 1
53 2 1
54 $ hg debugtemplate -r0 -v '{5 / -2} {mod(5, -2)}\n'
54 $ hg debugtemplate -r0 -v '{5 / -2} {mod(5, -2)}\n'
55 (template
55 (template
56 (/
56 (/
57 (integer '5')
57 (integer '5')
58 (negate
58 (negate
59 (integer '2')))
59 (integer '2')))
60 (string ' ')
60 (string ' ')
61 (func
61 (func
62 (symbol 'mod')
62 (symbol 'mod')
63 (list
63 (list
64 (integer '5')
64 (integer '5')
65 (negate
65 (negate
66 (integer '2'))))
66 (integer '2'))))
67 (string '\n'))
67 (string '\n'))
68 -3 -1
68 -3 -1
69 $ hg debugtemplate -r0 -v '{-5 / 2} {mod(-5, 2)}\n'
69 $ hg debugtemplate -r0 -v '{-5 / 2} {mod(-5, 2)}\n'
70 (template
70 (template
71 (/
71 (/
72 (negate
72 (negate
73 (integer '5'))
73 (integer '5'))
74 (integer '2'))
74 (integer '2'))
75 (string ' ')
75 (string ' ')
76 (func
76 (func
77 (symbol 'mod')
77 (symbol 'mod')
78 (list
78 (list
79 (negate
79 (negate
80 (integer '5'))
80 (integer '5'))
81 (integer '2')))
81 (integer '2')))
82 (string '\n'))
82 (string '\n'))
83 -3 1
83 -3 1
84 $ hg debugtemplate -r0 -v '{-5 / -2} {mod(-5, -2)}\n'
84 $ hg debugtemplate -r0 -v '{-5 / -2} {mod(-5, -2)}\n'
85 (template
85 (template
86 (/
86 (/
87 (negate
87 (negate
88 (integer '5'))
88 (integer '5'))
89 (negate
89 (negate
90 (integer '2')))
90 (integer '2')))
91 (string ' ')
91 (string ' ')
92 (func
92 (func
93 (symbol 'mod')
93 (symbol 'mod')
94 (list
94 (list
95 (negate
95 (negate
96 (integer '5'))
96 (integer '5'))
97 (negate
97 (negate
98 (integer '2'))))
98 (integer '2'))))
99 (string '\n'))
99 (string '\n'))
100 2 -1
100 2 -1
101
101
102 Filters bind closer than arithmetic:
102 Filters bind closer than arithmetic:
103
103
104 $ hg debugtemplate -r0 -v '{revset(".")|count - 1}\n'
104 $ hg debugtemplate -r0 -v '{revset(".")|count - 1}\n'
105 (template
105 (template
106 (-
106 (-
107 (|
107 (|
108 (func
108 (func
109 (symbol 'revset')
109 (symbol 'revset')
110 (string '.'))
110 (string '.'))
111 (symbol 'count'))
111 (symbol 'count'))
112 (integer '1'))
112 (integer '1'))
113 (string '\n'))
113 (string '\n'))
114 0
114 0
115
115
116 But negate binds closer still:
116 But negate binds closer still:
117
117
118 $ hg debugtemplate -r0 -v '{1-3|stringify}\n'
118 $ hg debugtemplate -r0 -v '{1-3|stringify}\n'
119 (template
119 (template
120 (-
120 (-
121 (integer '1')
121 (integer '1')
122 (|
122 (|
123 (integer '3')
123 (integer '3')
124 (symbol 'stringify')))
124 (symbol 'stringify')))
125 (string '\n'))
125 (string '\n'))
126 hg: parse error: arithmetic only defined on integers
126 hg: parse error: arithmetic only defined on integers
127 [255]
127 [255]
128 $ hg debugtemplate -r0 -v '{-3|stringify}\n'
128 $ hg debugtemplate -r0 -v '{-3|stringify}\n'
129 (template
129 (template
130 (|
130 (|
131 (negate
131 (negate
132 (integer '3'))
132 (integer '3'))
133 (symbol 'stringify'))
133 (symbol 'stringify'))
134 (string '\n'))
134 (string '\n'))
135 -3
135 -3
136
136
137 Filters bind as close as map operator:
137 Filters bind as close as map operator:
138
138
139 $ hg debugtemplate -r0 -v '{desc|splitlines % "{line}\n"}'
139 $ hg debugtemplate -r0 -v '{desc|splitlines % "{line}\n"}'
140 (template
140 (template
141 (%
141 (%
142 (|
142 (|
143 (symbol 'desc')
143 (symbol 'desc')
144 (symbol 'splitlines'))
144 (symbol 'splitlines'))
145 (template
145 (template
146 (symbol 'line')
146 (symbol 'line')
147 (string '\n'))))
147 (string '\n'))))
148 line 1
148 line 1
149 line 2
149 line 2
150
150
151 Keyword arguments:
151 Keyword arguments:
152
152
153 $ hg debugtemplate -r0 -v '{foo=bar|baz}'
153 $ hg debugtemplate -r0 -v '{foo=bar|baz}'
154 (template
154 (template
155 (keyvalue
155 (keyvalue
156 (symbol 'foo')
156 (symbol 'foo')
157 (|
157 (|
158 (symbol 'bar')
158 (symbol 'bar')
159 (symbol 'baz'))))
159 (symbol 'baz'))))
160 hg: parse error: can't use a key-value pair in this context
160 hg: parse error: can't use a key-value pair in this context
161 [255]
161 [255]
162
162
163 $ hg debugtemplate '{pad("foo", width=10, left=true)}\n'
163 $ hg debugtemplate '{pad("foo", width=10, left=true)}\n'
164 foo
164 foo
165
165
166 Call function which takes named arguments by filter syntax:
166 Call function which takes named arguments by filter syntax:
167
167
168 $ hg debugtemplate '{" "|separate}'
168 $ hg debugtemplate '{" "|separate}'
169 $ hg debugtemplate '{("not", "an", "argument", "list")|separate}'
169 $ hg debugtemplate '{("not", "an", "argument", "list")|separate}'
170 hg: parse error: unknown method 'list'
170 hg: parse error: unknown method 'list'
171 [255]
171 [255]
172
172
173 Second branch starting at nullrev:
173 Second branch starting at nullrev:
174
174
175 $ hg update null
175 $ hg update null
176 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
176 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
177 $ echo second > second
177 $ echo second > second
178 $ hg add second
178 $ hg add second
179 $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
179 $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
180 created new head
180 created new head
181
181
182 $ echo third > third
182 $ echo third > third
183 $ hg add third
183 $ hg add third
184 $ hg mv second fourth
184 $ hg mv second fourth
185 $ hg commit -m third -d "2020-01-01 10:01"
185 $ hg commit -m third -d "2020-01-01 10:01"
186
186
187 $ hg log --template '{join(file_copies, ",\n")}\n' -r .
187 $ hg log --template '{join(file_copies, ",\n")}\n' -r .
188 fourth (second)
188 fourth (second)
189 $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r .
189 $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r .
190 second -> fourth
190 second -> fourth
191 $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7
191 $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7
192 8 t
192 8 t
193 7 f
193 7 f
194
194
195 Working-directory revision has special identifiers, though they are still
195 Working-directory revision has special identifiers, though they are still
196 experimental:
196 experimental:
197
197
198 $ hg log -r 'wdir()' -T '{rev}:{node}\n'
198 $ hg log -r 'wdir()' -T '{rev}:{node}\n'
199 2147483647:ffffffffffffffffffffffffffffffffffffffff
199 2147483647:ffffffffffffffffffffffffffffffffffffffff
200
200
201 Some keywords are invalid for working-directory revision, but they should
201 Some keywords are invalid for working-directory revision, but they should
202 never cause crash:
202 never cause crash:
203
203
204 $ hg log -r 'wdir()' -T '{manifest}\n'
204 $ hg log -r 'wdir()' -T '{manifest}\n'
205
205
206
206
207 Quoting for ui.logtemplate
207 Quoting for ui.logtemplate
208
208
209 $ hg tip --config "ui.logtemplate={rev}\n"
209 $ hg tip --config "ui.logtemplate={rev}\n"
210 8
210 8
211 $ hg tip --config "ui.logtemplate='{rev}\n'"
211 $ hg tip --config "ui.logtemplate='{rev}\n'"
212 8
212 8
213 $ hg tip --config 'ui.logtemplate="{rev}\n"'
213 $ hg tip --config 'ui.logtemplate="{rev}\n"'
214 8
214 8
215 $ hg tip --config 'ui.logtemplate=n{rev}\n'
215 $ hg tip --config 'ui.logtemplate=n{rev}\n'
216 n8
216 n8
217
217
218 Make sure user/global hgrc does not affect tests
218 Make sure user/global hgrc does not affect tests
219
219
220 $ echo '[ui]' > .hg/hgrc
220 $ echo '[ui]' > .hg/hgrc
221 $ echo 'logtemplate =' >> .hg/hgrc
221 $ echo 'logtemplate =' >> .hg/hgrc
222 $ echo 'style =' >> .hg/hgrc
222 $ echo 'style =' >> .hg/hgrc
223
223
224 Add some simple styles to settings
224 Add some simple styles to settings
225
225
226 $ cat <<'EOF' >> .hg/hgrc
226 $ cat <<'EOF' >> .hg/hgrc
227 > [templates]
227 > [templates]
228 > simple = "{rev}\n"
228 > simple = "{rev}\n"
229 > simple2 = {rev}\n
229 > simple2 = {rev}\n
230 > rev = "should not precede {rev} keyword\n"
230 > rev = "should not precede {rev} keyword\n"
231 > EOF
231 > EOF
232
232
233 $ hg log -l1 -Tsimple
233 $ hg log -l1 -Tsimple
234 8
234 8
235 $ hg log -l1 -Tsimple2
235 $ hg log -l1 -Tsimple2
236 8
236 8
237 $ hg log -l1 -Trev
237 $ hg log -l1 -Trev
238 should not precede 8 keyword
238 should not precede 8 keyword
239 $ hg log -l1 -T '{simple}'
239 $ hg log -l1 -T '{simple}'
240 8
240 8
241
241
242 Map file shouldn't see user templates:
242 Map file shouldn't see user templates:
243
243
244 $ cat <<EOF > tmpl
244 $ cat <<EOF > tmpl
245 > changeset = 'nothing expanded:{simple}\n'
245 > changeset = 'nothing expanded:{simple}\n'
246 > EOF
246 > EOF
247 $ hg log -l1 --style ./tmpl
247 $ hg log -l1 --style ./tmpl
248 nothing expanded:
248 nothing expanded:
249
249
250 Test templates and style maps in files:
250 Test templates and style maps in files:
251
251
252 $ echo "{rev}" > tmpl
252 $ echo "{rev}" > tmpl
253 $ hg log -l1 -T./tmpl
253 $ hg log -l1 -T./tmpl
254 8
254 8
255 $ hg log -l1 -Tblah/blah
255 $ hg log -l1 -Tblah/blah
256 blah/blah (no-eol)
256 blah/blah (no-eol)
257
257
258 $ printf 'changeset = "{rev}\\n"\n' > map-simple
258 $ printf 'changeset = "{rev}\\n"\n' > map-simple
259 $ hg log -l1 -T./map-simple
259 $ hg log -l1 -T./map-simple
260 8
260 8
261
261
262 Test template map inheritance
262 Test template map inheritance
263
263
264 $ echo "__base__ = map-cmdline.default" > map-simple
264 $ echo "__base__ = map-cmdline.default" > map-simple
265 $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple
265 $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple
266 $ hg log -l1 -T./map-simple
266 $ hg log -l1 -T./map-simple
267 changeset: ***8***
267 changeset: ***8***
268 tag: tip
268 tag: tip
269 user: test
269 user: test
270 date: Wed Jan 01 10:01:00 2020 +0000
270 date: Wed Jan 01 10:01:00 2020 +0000
271 summary: third
271 summary: third
272
272
273
273
274 Test docheader, docfooter and separator in template map
274 Test docheader, docfooter and separator in template map
275
275
276 $ cat <<'EOF' > map-myjson
276 $ cat <<'EOF' > map-myjson
277 > docheader = '\{\n'
277 > docheader = '\{\n'
278 > docfooter = '\n}\n'
278 > docfooter = '\n}\n'
279 > separator = ',\n'
279 > separator = ',\n'
280 > changeset = ' {dict(rev, node|short)|json}'
280 > changeset = ' {dict(rev, node|short)|json}'
281 > EOF
281 > EOF
282 $ hg log -l2 -T./map-myjson
282 $ hg log -l2 -T./map-myjson
283 {
283 {
284 {"node": "95c24699272e", "rev": 8},
284 {"node": "95c24699272e", "rev": 8},
285 {"node": "29114dbae42b", "rev": 7}
285 {"node": "29114dbae42b", "rev": 7}
286 }
286 }
287
287
288 Test docheader, docfooter and separator in [templates] section
288 Test docheader, docfooter and separator in [templates] section
289
289
290 $ cat <<'EOF' >> .hg/hgrc
290 $ cat <<'EOF' >> .hg/hgrc
291 > [templates]
291 > [templates]
292 > myjson = ' {dict(rev, node|short)|json}'
292 > myjson = ' {dict(rev, node|short)|json}'
293 > myjson:docheader = '\{\n'
293 > myjson:docheader = '\{\n'
294 > myjson:docfooter = '\n}\n'
294 > myjson:docfooter = '\n}\n'
295 > myjson:separator = ',\n'
295 > myjson:separator = ',\n'
296 > :docheader = 'should not be selected as a docheader for literal templates\n'
296 > :docheader = 'should not be selected as a docheader for literal templates\n'
297 > EOF
297 > EOF
298 $ hg log -l2 -Tmyjson
298 $ hg log -l2 -Tmyjson
299 {
299 {
300 {"node": "95c24699272e", "rev": 8},
300 {"node": "95c24699272e", "rev": 8},
301 {"node": "29114dbae42b", "rev": 7}
301 {"node": "29114dbae42b", "rev": 7}
302 }
302 }
303 $ hg log -l1 -T'{rev}\n'
303 $ hg log -l1 -T'{rev}\n'
304 8
304 8
305
305
306 Template should precede style option
306 Template should precede style option
307
307
308 $ hg log -l1 --style default -T '{rev}\n'
308 $ hg log -l1 --style default -T '{rev}\n'
309 8
309 8
310
310
311 Add a commit with empty description, to ensure that the templates
311 Add a commit with empty description, to ensure that the templates
312 below will omit the description line.
312 below will omit the description line.
313
313
314 $ echo c >> c
314 $ echo c >> c
315 $ hg add c
315 $ hg add c
316 $ hg commit -qm ' '
316 $ hg commit -qm ' '
317
317
318 Default style is like normal output. Phases style should be the same
318 Default style is like normal output. Phases style should be the same
319 as default style, except for extra phase lines.
319 as default style, except for extra phase lines.
320
320
321 $ hg log > log.out
321 $ hg log > log.out
322 $ hg log --style default > style.out
322 $ hg log --style default > style.out
323 $ cmp log.out style.out || diff -u log.out style.out
323 $ cmp log.out style.out || diff -u log.out style.out
324 $ hg log -T phases > phases.out
324 $ hg log -T phases > phases.out
325 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
325 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
326 +phase: draft
326 +phase: draft
327 +phase: draft
327 +phase: draft
328 +phase: draft
328 +phase: draft
329 +phase: draft
329 +phase: draft
330 +phase: draft
330 +phase: draft
331 +phase: draft
331 +phase: draft
332 +phase: draft
332 +phase: draft
333 +phase: draft
333 +phase: draft
334 +phase: draft
334 +phase: draft
335 +phase: draft
335 +phase: draft
336
336
337 $ hg log -v > log.out
337 $ hg log -v > log.out
338 $ hg log -v --style default > style.out
338 $ hg log -v --style default > style.out
339 $ cmp log.out style.out || diff -u log.out style.out
339 $ cmp log.out style.out || diff -u log.out style.out
340 $ hg log -v -T phases > phases.out
340 $ hg log -v -T phases > phases.out
341 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
341 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
342 +phase: draft
342 +phase: draft
343 +phase: draft
343 +phase: draft
344 +phase: draft
344 +phase: draft
345 +phase: draft
345 +phase: draft
346 +phase: draft
346 +phase: draft
347 +phase: draft
347 +phase: draft
348 +phase: draft
348 +phase: draft
349 +phase: draft
349 +phase: draft
350 +phase: draft
350 +phase: draft
351 +phase: draft
351 +phase: draft
352
352
353 $ hg log -q > log.out
353 $ hg log -q > log.out
354 $ hg log -q --style default > style.out
354 $ hg log -q --style default > style.out
355 $ cmp log.out style.out || diff -u log.out style.out
355 $ cmp log.out style.out || diff -u log.out style.out
356 $ hg log -q -T phases > phases.out
356 $ hg log -q -T phases > phases.out
357 $ cmp log.out phases.out || diff -u log.out phases.out
357 $ cmp log.out phases.out || diff -u log.out phases.out
358
358
359 $ hg log --debug > log.out
359 $ hg log --debug > log.out
360 $ hg log --debug --style default > style.out
360 $ hg log --debug --style default > style.out
361 $ cmp log.out style.out || diff -u log.out style.out
361 $ cmp log.out style.out || diff -u log.out style.out
362 $ hg log --debug -T phases > phases.out
362 $ hg log --debug -T phases > phases.out
363 $ cmp log.out phases.out || diff -u log.out phases.out
363 $ cmp log.out phases.out || diff -u log.out phases.out
364
364
365 Default style of working-directory revision should also be the same (but
365 Default style of working-directory revision should also be the same (but
366 date may change while running tests):
366 date may change while running tests):
367
367
368 $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out
368 $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out
369 $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out
369 $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out
370 $ cmp log.out style.out || diff -u log.out style.out
370 $ cmp log.out style.out || diff -u log.out style.out
371
371
372 $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out
372 $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out
373 $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out
373 $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out
374 $ cmp log.out style.out || diff -u log.out style.out
374 $ cmp log.out style.out || diff -u log.out style.out
375
375
376 $ hg log -r 'wdir()' -q > log.out
376 $ hg log -r 'wdir()' -q > log.out
377 $ hg log -r 'wdir()' -q --style default > style.out
377 $ hg log -r 'wdir()' -q --style default > style.out
378 $ cmp log.out style.out || diff -u log.out style.out
378 $ cmp log.out style.out || diff -u log.out style.out
379
379
380 $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out
380 $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out
381 $ hg log -r 'wdir()' --debug --style default \
381 $ hg log -r 'wdir()' --debug --style default \
382 > | sed 's|^date:.*|date:|' > style.out
382 > | sed 's|^date:.*|date:|' > style.out
383 $ cmp log.out style.out || diff -u log.out style.out
383 $ cmp log.out style.out || diff -u log.out style.out
384
384
385 Default style should also preserve color information (issue2866):
385 Default style should also preserve color information (issue2866):
386
386
387 $ cp $HGRCPATH $HGRCPATH-bak
387 $ cp $HGRCPATH $HGRCPATH-bak
388 $ cat <<EOF >> $HGRCPATH
388 $ cat <<EOF >> $HGRCPATH
389 > [extensions]
389 > [extensions]
390 > color=
390 > color=
391 > EOF
391 > EOF
392
392
393 $ hg --color=debug log > log.out
393 $ hg --color=debug log > log.out
394 $ hg --color=debug log --style default > style.out
394 $ hg --color=debug log --style default > style.out
395 $ cmp log.out style.out || diff -u log.out style.out
395 $ cmp log.out style.out || diff -u log.out style.out
396 $ hg --color=debug log -T phases > phases.out
396 $ hg --color=debug log -T phases > phases.out
397 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
397 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
398 +[log.phase|phase: draft]
398 +[log.phase|phase: draft]
399 +[log.phase|phase: draft]
399 +[log.phase|phase: draft]
400 +[log.phase|phase: draft]
400 +[log.phase|phase: draft]
401 +[log.phase|phase: draft]
401 +[log.phase|phase: draft]
402 +[log.phase|phase: draft]
402 +[log.phase|phase: draft]
403 +[log.phase|phase: draft]
403 +[log.phase|phase: draft]
404 +[log.phase|phase: draft]
404 +[log.phase|phase: draft]
405 +[log.phase|phase: draft]
405 +[log.phase|phase: draft]
406 +[log.phase|phase: draft]
406 +[log.phase|phase: draft]
407 +[log.phase|phase: draft]
407 +[log.phase|phase: draft]
408
408
409 $ hg --color=debug -v log > log.out
409 $ hg --color=debug -v log > log.out
410 $ hg --color=debug -v log --style default > style.out
410 $ hg --color=debug -v log --style default > style.out
411 $ cmp log.out style.out || diff -u log.out style.out
411 $ cmp log.out style.out || diff -u log.out style.out
412 $ hg --color=debug -v log -T phases > phases.out
412 $ hg --color=debug -v log -T phases > phases.out
413 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
413 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
414 +[log.phase|phase: draft]
414 +[log.phase|phase: draft]
415 +[log.phase|phase: draft]
415 +[log.phase|phase: draft]
416 +[log.phase|phase: draft]
416 +[log.phase|phase: draft]
417 +[log.phase|phase: draft]
417 +[log.phase|phase: draft]
418 +[log.phase|phase: draft]
418 +[log.phase|phase: draft]
419 +[log.phase|phase: draft]
419 +[log.phase|phase: draft]
420 +[log.phase|phase: draft]
420 +[log.phase|phase: draft]
421 +[log.phase|phase: draft]
421 +[log.phase|phase: draft]
422 +[log.phase|phase: draft]
422 +[log.phase|phase: draft]
423 +[log.phase|phase: draft]
423 +[log.phase|phase: draft]
424
424
425 $ hg --color=debug -q log > log.out
425 $ hg --color=debug -q log > log.out
426 $ hg --color=debug -q log --style default > style.out
426 $ hg --color=debug -q log --style default > style.out
427 $ cmp log.out style.out || diff -u log.out style.out
427 $ cmp log.out style.out || diff -u log.out style.out
428 $ hg --color=debug -q log -T phases > phases.out
428 $ hg --color=debug -q log -T phases > phases.out
429 $ cmp log.out phases.out || diff -u log.out phases.out
429 $ cmp log.out phases.out || diff -u log.out phases.out
430
430
431 $ hg --color=debug --debug log > log.out
431 $ hg --color=debug --debug log > log.out
432 $ hg --color=debug --debug log --style default > style.out
432 $ hg --color=debug --debug log --style default > style.out
433 $ cmp log.out style.out || diff -u log.out style.out
433 $ cmp log.out style.out || diff -u log.out style.out
434 $ hg --color=debug --debug log -T phases > phases.out
434 $ hg --color=debug --debug log -T phases > phases.out
435 $ cmp log.out phases.out || diff -u log.out phases.out
435 $ cmp log.out phases.out || diff -u log.out phases.out
436
436
437 $ mv $HGRCPATH-bak $HGRCPATH
437 $ mv $HGRCPATH-bak $HGRCPATH
438
438
439 Remove commit with empty commit message, so as to not pollute further
439 Remove commit with empty commit message, so as to not pollute further
440 tests.
440 tests.
441
441
442 $ hg --config extensions.strip= strip -q .
442 $ hg --config extensions.strip= strip -q .
443
443
444 Revision with no copies (used to print a traceback):
444 Revision with no copies (used to print a traceback):
445
445
446 $ hg tip -v --template '\n'
446 $ hg tip -v --template '\n'
447
447
448
448
449 Compact style works:
449 Compact style works:
450
450
451 $ hg log -Tcompact
451 $ hg log -Tcompact
452 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
452 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
453 third
453 third
454
454
455 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user
455 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user
456 second
456 second
457
457
458 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
458 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
459 merge
459 merge
460
460
461 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
461 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
462 new head
462 new head
463
463
464 4 bbe44766e73d 1970-01-17 04:53 +0000 person
464 4 bbe44766e73d 1970-01-17 04:53 +0000 person
465 new branch
465 new branch
466
466
467 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
467 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
468 no user, no domain
468 no user, no domain
469
469
470 2 97054abb4ab8 1970-01-14 21:20 +0000 other
470 2 97054abb4ab8 1970-01-14 21:20 +0000 other
471 no person
471 no person
472
472
473 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other
473 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other
474 other 1
474 other 1
475
475
476 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user
476 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user
477 line 1
477 line 1
478
478
479
479
480 $ hg log -v --style compact
480 $ hg log -v --style compact
481 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
481 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
482 third
482 third
483
483
484 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
484 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
485 second
485 second
486
486
487 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
487 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
488 merge
488 merge
489
489
490 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
490 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
491 new head
491 new head
492
492
493 4 bbe44766e73d 1970-01-17 04:53 +0000 person
493 4 bbe44766e73d 1970-01-17 04:53 +0000 person
494 new branch
494 new branch
495
495
496 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
496 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
497 no user, no domain
497 no user, no domain
498
498
499 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place
499 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place
500 no person
500 no person
501
501
502 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
502 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
503 other 1
503 other 1
504 other 2
504 other 2
505
505
506 other 3
506 other 3
507
507
508 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
508 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
509 line 1
509 line 1
510 line 2
510 line 2
511
511
512
512
513 $ hg log --debug --style compact
513 $ hg log --debug --style compact
514 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test
514 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test
515 third
515 third
516
516
517 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
517 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
518 second
518 second
519
519
520 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
520 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
521 merge
521 merge
522
522
523 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person
523 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person
524 new head
524 new head
525
525
526 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person
526 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person
527 new branch
527 new branch
528
528
529 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person
529 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person
530 no user, no domain
530 no user, no domain
531
531
532 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place
532 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place
533 no person
533 no person
534
534
535 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
535 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
536 other 1
536 other 1
537 other 2
537 other 2
538
538
539 other 3
539 other 3
540
540
541 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
541 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
542 line 1
542 line 1
543 line 2
543 line 2
544
544
545
545
546 Test xml styles:
546 Test xml styles:
547
547
548 $ hg log --style xml -r 'not all()'
548 $ hg log --style xml -r 'not all()'
549 <?xml version="1.0"?>
549 <?xml version="1.0"?>
550 <log>
550 <log>
551 </log>
551 </log>
552
552
553 $ hg log --style xml
553 $ hg log --style xml
554 <?xml version="1.0"?>
554 <?xml version="1.0"?>
555 <log>
555 <log>
556 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
556 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
557 <tag>tip</tag>
557 <tag>tip</tag>
558 <author email="test">test</author>
558 <author email="test">test</author>
559 <date>2020-01-01T10:01:00+00:00</date>
559 <date>2020-01-01T10:01:00+00:00</date>
560 <msg xml:space="preserve">third</msg>
560 <msg xml:space="preserve">third</msg>
561 </logentry>
561 </logentry>
562 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
562 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
563 <parent revision="-1" node="0000000000000000000000000000000000000000" />
563 <parent revision="-1" node="0000000000000000000000000000000000000000" />
564 <author email="user@hostname">User Name</author>
564 <author email="user@hostname">User Name</author>
565 <date>1970-01-12T13:46:40+00:00</date>
565 <date>1970-01-12T13:46:40+00:00</date>
566 <msg xml:space="preserve">second</msg>
566 <msg xml:space="preserve">second</msg>
567 </logentry>
567 </logentry>
568 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
568 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
569 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
569 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
570 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
570 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
571 <author email="person">person</author>
571 <author email="person">person</author>
572 <date>1970-01-18T08:40:01+00:00</date>
572 <date>1970-01-18T08:40:01+00:00</date>
573 <msg xml:space="preserve">merge</msg>
573 <msg xml:space="preserve">merge</msg>
574 </logentry>
574 </logentry>
575 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
575 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
576 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
576 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
577 <author email="person">person</author>
577 <author email="person">person</author>
578 <date>1970-01-18T08:40:00+00:00</date>
578 <date>1970-01-18T08:40:00+00:00</date>
579 <msg xml:space="preserve">new head</msg>
579 <msg xml:space="preserve">new head</msg>
580 </logentry>
580 </logentry>
581 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
581 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
582 <branch>foo</branch>
582 <branch>foo</branch>
583 <author email="person">person</author>
583 <author email="person">person</author>
584 <date>1970-01-17T04:53:20+00:00</date>
584 <date>1970-01-17T04:53:20+00:00</date>
585 <msg xml:space="preserve">new branch</msg>
585 <msg xml:space="preserve">new branch</msg>
586 </logentry>
586 </logentry>
587 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
587 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
588 <author email="person">person</author>
588 <author email="person">person</author>
589 <date>1970-01-16T01:06:40+00:00</date>
589 <date>1970-01-16T01:06:40+00:00</date>
590 <msg xml:space="preserve">no user, no domain</msg>
590 <msg xml:space="preserve">no user, no domain</msg>
591 </logentry>
591 </logentry>
592 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
592 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
593 <author email="other@place">other</author>
593 <author email="other@place">other</author>
594 <date>1970-01-14T21:20:00+00:00</date>
594 <date>1970-01-14T21:20:00+00:00</date>
595 <msg xml:space="preserve">no person</msg>
595 <msg xml:space="preserve">no person</msg>
596 </logentry>
596 </logentry>
597 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
597 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
598 <author email="other@place">A. N. Other</author>
598 <author email="other@place">A. N. Other</author>
599 <date>1970-01-13T17:33:20+00:00</date>
599 <date>1970-01-13T17:33:20+00:00</date>
600 <msg xml:space="preserve">other 1
600 <msg xml:space="preserve">other 1
601 other 2
601 other 2
602
602
603 other 3</msg>
603 other 3</msg>
604 </logentry>
604 </logentry>
605 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
605 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
606 <author email="user@hostname">User Name</author>
606 <author email="user@hostname">User Name</author>
607 <date>1970-01-12T13:46:40+00:00</date>
607 <date>1970-01-12T13:46:40+00:00</date>
608 <msg xml:space="preserve">line 1
608 <msg xml:space="preserve">line 1
609 line 2</msg>
609 line 2</msg>
610 </logentry>
610 </logentry>
611 </log>
611 </log>
612
612
613 $ hg log -v --style xml
613 $ hg log -v --style xml
614 <?xml version="1.0"?>
614 <?xml version="1.0"?>
615 <log>
615 <log>
616 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
616 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
617 <tag>tip</tag>
617 <tag>tip</tag>
618 <author email="test">test</author>
618 <author email="test">test</author>
619 <date>2020-01-01T10:01:00+00:00</date>
619 <date>2020-01-01T10:01:00+00:00</date>
620 <msg xml:space="preserve">third</msg>
620 <msg xml:space="preserve">third</msg>
621 <paths>
621 <paths>
622 <path action="A">fourth</path>
622 <path action="A">fourth</path>
623 <path action="A">third</path>
623 <path action="A">third</path>
624 <path action="R">second</path>
624 <path action="R">second</path>
625 </paths>
625 </paths>
626 <copies>
626 <copies>
627 <copy source="second">fourth</copy>
627 <copy source="second">fourth</copy>
628 </copies>
628 </copies>
629 </logentry>
629 </logentry>
630 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
630 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
631 <parent revision="-1" node="0000000000000000000000000000000000000000" />
631 <parent revision="-1" node="0000000000000000000000000000000000000000" />
632 <author email="user@hostname">User Name</author>
632 <author email="user@hostname">User Name</author>
633 <date>1970-01-12T13:46:40+00:00</date>
633 <date>1970-01-12T13:46:40+00:00</date>
634 <msg xml:space="preserve">second</msg>
634 <msg xml:space="preserve">second</msg>
635 <paths>
635 <paths>
636 <path action="A">second</path>
636 <path action="A">second</path>
637 </paths>
637 </paths>
638 </logentry>
638 </logentry>
639 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
639 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
640 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
640 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
641 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
641 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
642 <author email="person">person</author>
642 <author email="person">person</author>
643 <date>1970-01-18T08:40:01+00:00</date>
643 <date>1970-01-18T08:40:01+00:00</date>
644 <msg xml:space="preserve">merge</msg>
644 <msg xml:space="preserve">merge</msg>
645 <paths>
645 <paths>
646 </paths>
646 </paths>
647 </logentry>
647 </logentry>
648 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
648 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
649 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
649 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
650 <author email="person">person</author>
650 <author email="person">person</author>
651 <date>1970-01-18T08:40:00+00:00</date>
651 <date>1970-01-18T08:40:00+00:00</date>
652 <msg xml:space="preserve">new head</msg>
652 <msg xml:space="preserve">new head</msg>
653 <paths>
653 <paths>
654 <path action="A">d</path>
654 <path action="A">d</path>
655 </paths>
655 </paths>
656 </logentry>
656 </logentry>
657 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
657 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
658 <branch>foo</branch>
658 <branch>foo</branch>
659 <author email="person">person</author>
659 <author email="person">person</author>
660 <date>1970-01-17T04:53:20+00:00</date>
660 <date>1970-01-17T04:53:20+00:00</date>
661 <msg xml:space="preserve">new branch</msg>
661 <msg xml:space="preserve">new branch</msg>
662 <paths>
662 <paths>
663 </paths>
663 </paths>
664 </logentry>
664 </logentry>
665 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
665 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
666 <author email="person">person</author>
666 <author email="person">person</author>
667 <date>1970-01-16T01:06:40+00:00</date>
667 <date>1970-01-16T01:06:40+00:00</date>
668 <msg xml:space="preserve">no user, no domain</msg>
668 <msg xml:space="preserve">no user, no domain</msg>
669 <paths>
669 <paths>
670 <path action="M">c</path>
670 <path action="M">c</path>
671 </paths>
671 </paths>
672 </logentry>
672 </logentry>
673 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
673 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
674 <author email="other@place">other</author>
674 <author email="other@place">other</author>
675 <date>1970-01-14T21:20:00+00:00</date>
675 <date>1970-01-14T21:20:00+00:00</date>
676 <msg xml:space="preserve">no person</msg>
676 <msg xml:space="preserve">no person</msg>
677 <paths>
677 <paths>
678 <path action="A">c</path>
678 <path action="A">c</path>
679 </paths>
679 </paths>
680 </logentry>
680 </logentry>
681 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
681 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
682 <author email="other@place">A. N. Other</author>
682 <author email="other@place">A. N. Other</author>
683 <date>1970-01-13T17:33:20+00:00</date>
683 <date>1970-01-13T17:33:20+00:00</date>
684 <msg xml:space="preserve">other 1
684 <msg xml:space="preserve">other 1
685 other 2
685 other 2
686
686
687 other 3</msg>
687 other 3</msg>
688 <paths>
688 <paths>
689 <path action="A">b</path>
689 <path action="A">b</path>
690 </paths>
690 </paths>
691 </logentry>
691 </logentry>
692 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
692 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
693 <author email="user@hostname">User Name</author>
693 <author email="user@hostname">User Name</author>
694 <date>1970-01-12T13:46:40+00:00</date>
694 <date>1970-01-12T13:46:40+00:00</date>
695 <msg xml:space="preserve">line 1
695 <msg xml:space="preserve">line 1
696 line 2</msg>
696 line 2</msg>
697 <paths>
697 <paths>
698 <path action="A">a</path>
698 <path action="A">a</path>
699 </paths>
699 </paths>
700 </logentry>
700 </logentry>
701 </log>
701 </log>
702
702
703 $ hg log --debug --style xml
703 $ hg log --debug --style xml
704 <?xml version="1.0"?>
704 <?xml version="1.0"?>
705 <log>
705 <log>
706 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
706 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
707 <tag>tip</tag>
707 <tag>tip</tag>
708 <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" />
708 <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" />
709 <parent revision="-1" node="0000000000000000000000000000000000000000" />
709 <parent revision="-1" node="0000000000000000000000000000000000000000" />
710 <author email="test">test</author>
710 <author email="test">test</author>
711 <date>2020-01-01T10:01:00+00:00</date>
711 <date>2020-01-01T10:01:00+00:00</date>
712 <msg xml:space="preserve">third</msg>
712 <msg xml:space="preserve">third</msg>
713 <paths>
713 <paths>
714 <path action="A">fourth</path>
714 <path action="A">fourth</path>
715 <path action="A">third</path>
715 <path action="A">third</path>
716 <path action="R">second</path>
716 <path action="R">second</path>
717 </paths>
717 </paths>
718 <copies>
718 <copies>
719 <copy source="second">fourth</copy>
719 <copy source="second">fourth</copy>
720 </copies>
720 </copies>
721 <extra key="branch">default</extra>
721 <extra key="branch">default</extra>
722 </logentry>
722 </logentry>
723 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
723 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
724 <parent revision="-1" node="0000000000000000000000000000000000000000" />
724 <parent revision="-1" node="0000000000000000000000000000000000000000" />
725 <parent revision="-1" node="0000000000000000000000000000000000000000" />
725 <parent revision="-1" node="0000000000000000000000000000000000000000" />
726 <author email="user@hostname">User Name</author>
726 <author email="user@hostname">User Name</author>
727 <date>1970-01-12T13:46:40+00:00</date>
727 <date>1970-01-12T13:46:40+00:00</date>
728 <msg xml:space="preserve">second</msg>
728 <msg xml:space="preserve">second</msg>
729 <paths>
729 <paths>
730 <path action="A">second</path>
730 <path action="A">second</path>
731 </paths>
731 </paths>
732 <extra key="branch">default</extra>
732 <extra key="branch">default</extra>
733 </logentry>
733 </logentry>
734 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
734 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
735 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
735 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
736 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
736 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
737 <author email="person">person</author>
737 <author email="person">person</author>
738 <date>1970-01-18T08:40:01+00:00</date>
738 <date>1970-01-18T08:40:01+00:00</date>
739 <msg xml:space="preserve">merge</msg>
739 <msg xml:space="preserve">merge</msg>
740 <paths>
740 <paths>
741 </paths>
741 </paths>
742 <extra key="branch">default</extra>
742 <extra key="branch">default</extra>
743 </logentry>
743 </logentry>
744 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
744 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
745 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
745 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
746 <parent revision="-1" node="0000000000000000000000000000000000000000" />
746 <parent revision="-1" node="0000000000000000000000000000000000000000" />
747 <author email="person">person</author>
747 <author email="person">person</author>
748 <date>1970-01-18T08:40:00+00:00</date>
748 <date>1970-01-18T08:40:00+00:00</date>
749 <msg xml:space="preserve">new head</msg>
749 <msg xml:space="preserve">new head</msg>
750 <paths>
750 <paths>
751 <path action="A">d</path>
751 <path action="A">d</path>
752 </paths>
752 </paths>
753 <extra key="branch">default</extra>
753 <extra key="branch">default</extra>
754 </logentry>
754 </logentry>
755 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
755 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
756 <branch>foo</branch>
756 <branch>foo</branch>
757 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
757 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
758 <parent revision="-1" node="0000000000000000000000000000000000000000" />
758 <parent revision="-1" node="0000000000000000000000000000000000000000" />
759 <author email="person">person</author>
759 <author email="person">person</author>
760 <date>1970-01-17T04:53:20+00:00</date>
760 <date>1970-01-17T04:53:20+00:00</date>
761 <msg xml:space="preserve">new branch</msg>
761 <msg xml:space="preserve">new branch</msg>
762 <paths>
762 <paths>
763 </paths>
763 </paths>
764 <extra key="branch">foo</extra>
764 <extra key="branch">foo</extra>
765 </logentry>
765 </logentry>
766 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
766 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
767 <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" />
767 <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" />
768 <parent revision="-1" node="0000000000000000000000000000000000000000" />
768 <parent revision="-1" node="0000000000000000000000000000000000000000" />
769 <author email="person">person</author>
769 <author email="person">person</author>
770 <date>1970-01-16T01:06:40+00:00</date>
770 <date>1970-01-16T01:06:40+00:00</date>
771 <msg xml:space="preserve">no user, no domain</msg>
771 <msg xml:space="preserve">no user, no domain</msg>
772 <paths>
772 <paths>
773 <path action="M">c</path>
773 <path action="M">c</path>
774 </paths>
774 </paths>
775 <extra key="branch">default</extra>
775 <extra key="branch">default</extra>
776 </logentry>
776 </logentry>
777 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
777 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
778 <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" />
778 <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" />
779 <parent revision="-1" node="0000000000000000000000000000000000000000" />
779 <parent revision="-1" node="0000000000000000000000000000000000000000" />
780 <author email="other@place">other</author>
780 <author email="other@place">other</author>
781 <date>1970-01-14T21:20:00+00:00</date>
781 <date>1970-01-14T21:20:00+00:00</date>
782 <msg xml:space="preserve">no person</msg>
782 <msg xml:space="preserve">no person</msg>
783 <paths>
783 <paths>
784 <path action="A">c</path>
784 <path action="A">c</path>
785 </paths>
785 </paths>
786 <extra key="branch">default</extra>
786 <extra key="branch">default</extra>
787 </logentry>
787 </logentry>
788 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
788 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
789 <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" />
789 <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" />
790 <parent revision="-1" node="0000000000000000000000000000000000000000" />
790 <parent revision="-1" node="0000000000000000000000000000000000000000" />
791 <author email="other@place">A. N. Other</author>
791 <author email="other@place">A. N. Other</author>
792 <date>1970-01-13T17:33:20+00:00</date>
792 <date>1970-01-13T17:33:20+00:00</date>
793 <msg xml:space="preserve">other 1
793 <msg xml:space="preserve">other 1
794 other 2
794 other 2
795
795
796 other 3</msg>
796 other 3</msg>
797 <paths>
797 <paths>
798 <path action="A">b</path>
798 <path action="A">b</path>
799 </paths>
799 </paths>
800 <extra key="branch">default</extra>
800 <extra key="branch">default</extra>
801 </logentry>
801 </logentry>
802 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
802 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
803 <parent revision="-1" node="0000000000000000000000000000000000000000" />
803 <parent revision="-1" node="0000000000000000000000000000000000000000" />
804 <parent revision="-1" node="0000000000000000000000000000000000000000" />
804 <parent revision="-1" node="0000000000000000000000000000000000000000" />
805 <author email="user@hostname">User Name</author>
805 <author email="user@hostname">User Name</author>
806 <date>1970-01-12T13:46:40+00:00</date>
806 <date>1970-01-12T13:46:40+00:00</date>
807 <msg xml:space="preserve">line 1
807 <msg xml:space="preserve">line 1
808 line 2</msg>
808 line 2</msg>
809 <paths>
809 <paths>
810 <path action="A">a</path>
810 <path action="A">a</path>
811 </paths>
811 </paths>
812 <extra key="branch">default</extra>
812 <extra key="branch">default</extra>
813 </logentry>
813 </logentry>
814 </log>
814 </log>
815
815
816
816
817 Test JSON style:
817 Test JSON style:
818
818
819 $ hg log -k nosuch -Tjson
819 $ hg log -k nosuch -Tjson
820 []
820 []
821
821
822 $ hg log -qr . -Tjson
822 $ hg log -qr . -Tjson
823 [
823 [
824 {
824 {
825 "rev": 8,
825 "rev": 8,
826 "node": "95c24699272ef57d062b8bccc32c878bf841784a"
826 "node": "95c24699272ef57d062b8bccc32c878bf841784a"
827 }
827 }
828 ]
828 ]
829
829
830 $ hg log -vpr . -Tjson --stat
830 $ hg log -vpr . -Tjson --stat
831 [
831 [
832 {
832 {
833 "rev": 8,
833 "rev": 8,
834 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
834 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
835 "branch": "default",
835 "branch": "default",
836 "phase": "draft",
836 "phase": "draft",
837 "user": "test",
837 "user": "test",
838 "date": [1577872860, 0],
838 "date": [1577872860, 0],
839 "desc": "third",
839 "desc": "third",
840 "bookmarks": [],
840 "bookmarks": [],
841 "tags": ["tip"],
841 "tags": ["tip"],
842 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
842 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
843 "files": ["fourth", "second", "third"],
843 "files": ["fourth", "second", "third"],
844 "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n",
844 "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n",
845 "diff": "diff -r 29114dbae42b -r 95c24699272e fourth\n--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/fourth\tWed Jan 01 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+second\ndiff -r 29114dbae42b -r 95c24699272e second\n--- a/second\tMon Jan 12 13:46:40 1970 +0000\n+++ /dev/null\tThu Jan 01 00:00:00 1970 +0000\n@@ -1,1 +0,0 @@\n-second\ndiff -r 29114dbae42b -r 95c24699272e third\n--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/third\tWed Jan 01 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+third\n"
845 "diff": "diff -r 29114dbae42b -r 95c24699272e fourth\n--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/fourth\tWed Jan 01 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+second\ndiff -r 29114dbae42b -r 95c24699272e second\n--- a/second\tMon Jan 12 13:46:40 1970 +0000\n+++ /dev/null\tThu Jan 01 00:00:00 1970 +0000\n@@ -1,1 +0,0 @@\n-second\ndiff -r 29114dbae42b -r 95c24699272e third\n--- /dev/null\tThu Jan 01 00:00:00 1970 +0000\n+++ b/third\tWed Jan 01 10:01:00 2020 +0000\n@@ -0,0 +1,1 @@\n+third\n"
846 }
846 }
847 ]
847 ]
848
848
849 honor --git but not format-breaking diffopts
849 honor --git but not format-breaking diffopts
850 $ hg --config diff.noprefix=True log --git -vpr . -Tjson
850 $ hg --config diff.noprefix=True log --git -vpr . -Tjson
851 [
851 [
852 {
852 {
853 "rev": 8,
853 "rev": 8,
854 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
854 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
855 "branch": "default",
855 "branch": "default",
856 "phase": "draft",
856 "phase": "draft",
857 "user": "test",
857 "user": "test",
858 "date": [1577872860, 0],
858 "date": [1577872860, 0],
859 "desc": "third",
859 "desc": "third",
860 "bookmarks": [],
860 "bookmarks": [],
861 "tags": ["tip"],
861 "tags": ["tip"],
862 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
862 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
863 "files": ["fourth", "second", "third"],
863 "files": ["fourth", "second", "third"],
864 "diff": "diff --git a/second b/fourth\nrename from second\nrename to fourth\ndiff --git a/third b/third\nnew file mode 100644\n--- /dev/null\n+++ b/third\n@@ -0,0 +1,1 @@\n+third\n"
864 "diff": "diff --git a/second b/fourth\nrename from second\nrename to fourth\ndiff --git a/third b/third\nnew file mode 100644\n--- /dev/null\n+++ b/third\n@@ -0,0 +1,1 @@\n+third\n"
865 }
865 }
866 ]
866 ]
867
867
868 $ hg log -T json
868 $ hg log -T json
869 [
869 [
870 {
870 {
871 "rev": 8,
871 "rev": 8,
872 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
872 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
873 "branch": "default",
873 "branch": "default",
874 "phase": "draft",
874 "phase": "draft",
875 "user": "test",
875 "user": "test",
876 "date": [1577872860, 0],
876 "date": [1577872860, 0],
877 "desc": "third",
877 "desc": "third",
878 "bookmarks": [],
878 "bookmarks": [],
879 "tags": ["tip"],
879 "tags": ["tip"],
880 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"]
880 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"]
881 },
881 },
882 {
882 {
883 "rev": 7,
883 "rev": 7,
884 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
884 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
885 "branch": "default",
885 "branch": "default",
886 "phase": "draft",
886 "phase": "draft",
887 "user": "User Name <user@hostname>",
887 "user": "User Name <user@hostname>",
888 "date": [1000000, 0],
888 "date": [1000000, 0],
889 "desc": "second",
889 "desc": "second",
890 "bookmarks": [],
890 "bookmarks": [],
891 "tags": [],
891 "tags": [],
892 "parents": ["0000000000000000000000000000000000000000"]
892 "parents": ["0000000000000000000000000000000000000000"]
893 },
893 },
894 {
894 {
895 "rev": 6,
895 "rev": 6,
896 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
896 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
897 "branch": "default",
897 "branch": "default",
898 "phase": "draft",
898 "phase": "draft",
899 "user": "person",
899 "user": "person",
900 "date": [1500001, 0],
900 "date": [1500001, 0],
901 "desc": "merge",
901 "desc": "merge",
902 "bookmarks": [],
902 "bookmarks": [],
903 "tags": [],
903 "tags": [],
904 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"]
904 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"]
905 },
905 },
906 {
906 {
907 "rev": 5,
907 "rev": 5,
908 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
908 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
909 "branch": "default",
909 "branch": "default",
910 "phase": "draft",
910 "phase": "draft",
911 "user": "person",
911 "user": "person",
912 "date": [1500000, 0],
912 "date": [1500000, 0],
913 "desc": "new head",
913 "desc": "new head",
914 "bookmarks": [],
914 "bookmarks": [],
915 "tags": [],
915 "tags": [],
916 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
916 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
917 },
917 },
918 {
918 {
919 "rev": 4,
919 "rev": 4,
920 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
920 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
921 "branch": "foo",
921 "branch": "foo",
922 "phase": "draft",
922 "phase": "draft",
923 "user": "person",
923 "user": "person",
924 "date": [1400000, 0],
924 "date": [1400000, 0],
925 "desc": "new branch",
925 "desc": "new branch",
926 "bookmarks": [],
926 "bookmarks": [],
927 "tags": [],
927 "tags": [],
928 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
928 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
929 },
929 },
930 {
930 {
931 "rev": 3,
931 "rev": 3,
932 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
932 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
933 "branch": "default",
933 "branch": "default",
934 "phase": "draft",
934 "phase": "draft",
935 "user": "person",
935 "user": "person",
936 "date": [1300000, 0],
936 "date": [1300000, 0],
937 "desc": "no user, no domain",
937 "desc": "no user, no domain",
938 "bookmarks": [],
938 "bookmarks": [],
939 "tags": [],
939 "tags": [],
940 "parents": ["97054abb4ab824450e9164180baf491ae0078465"]
940 "parents": ["97054abb4ab824450e9164180baf491ae0078465"]
941 },
941 },
942 {
942 {
943 "rev": 2,
943 "rev": 2,
944 "node": "97054abb4ab824450e9164180baf491ae0078465",
944 "node": "97054abb4ab824450e9164180baf491ae0078465",
945 "branch": "default",
945 "branch": "default",
946 "phase": "draft",
946 "phase": "draft",
947 "user": "other@place",
947 "user": "other@place",
948 "date": [1200000, 0],
948 "date": [1200000, 0],
949 "desc": "no person",
949 "desc": "no person",
950 "bookmarks": [],
950 "bookmarks": [],
951 "tags": [],
951 "tags": [],
952 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"]
952 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"]
953 },
953 },
954 {
954 {
955 "rev": 1,
955 "rev": 1,
956 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
956 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
957 "branch": "default",
957 "branch": "default",
958 "phase": "draft",
958 "phase": "draft",
959 "user": "A. N. Other <other@place>",
959 "user": "A. N. Other <other@place>",
960 "date": [1100000, 0],
960 "date": [1100000, 0],
961 "desc": "other 1\nother 2\n\nother 3",
961 "desc": "other 1\nother 2\n\nother 3",
962 "bookmarks": [],
962 "bookmarks": [],
963 "tags": [],
963 "tags": [],
964 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"]
964 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"]
965 },
965 },
966 {
966 {
967 "rev": 0,
967 "rev": 0,
968 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
968 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
969 "branch": "default",
969 "branch": "default",
970 "phase": "draft",
970 "phase": "draft",
971 "user": "User Name <user@hostname>",
971 "user": "User Name <user@hostname>",
972 "date": [1000000, 0],
972 "date": [1000000, 0],
973 "desc": "line 1\nline 2",
973 "desc": "line 1\nline 2",
974 "bookmarks": [],
974 "bookmarks": [],
975 "tags": [],
975 "tags": [],
976 "parents": ["0000000000000000000000000000000000000000"]
976 "parents": ["0000000000000000000000000000000000000000"]
977 }
977 }
978 ]
978 ]
979
979
980 $ hg heads -v -Tjson
980 $ hg heads -v -Tjson
981 [
981 [
982 {
982 {
983 "rev": 8,
983 "rev": 8,
984 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
984 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
985 "branch": "default",
985 "branch": "default",
986 "phase": "draft",
986 "phase": "draft",
987 "user": "test",
987 "user": "test",
988 "date": [1577872860, 0],
988 "date": [1577872860, 0],
989 "desc": "third",
989 "desc": "third",
990 "bookmarks": [],
990 "bookmarks": [],
991 "tags": ["tip"],
991 "tags": ["tip"],
992 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
992 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
993 "files": ["fourth", "second", "third"]
993 "files": ["fourth", "second", "third"]
994 },
994 },
995 {
995 {
996 "rev": 6,
996 "rev": 6,
997 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
997 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
998 "branch": "default",
998 "branch": "default",
999 "phase": "draft",
999 "phase": "draft",
1000 "user": "person",
1000 "user": "person",
1001 "date": [1500001, 0],
1001 "date": [1500001, 0],
1002 "desc": "merge",
1002 "desc": "merge",
1003 "bookmarks": [],
1003 "bookmarks": [],
1004 "tags": [],
1004 "tags": [],
1005 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1005 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1006 "files": []
1006 "files": []
1007 },
1007 },
1008 {
1008 {
1009 "rev": 4,
1009 "rev": 4,
1010 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1010 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1011 "branch": "foo",
1011 "branch": "foo",
1012 "phase": "draft",
1012 "phase": "draft",
1013 "user": "person",
1013 "user": "person",
1014 "date": [1400000, 0],
1014 "date": [1400000, 0],
1015 "desc": "new branch",
1015 "desc": "new branch",
1016 "bookmarks": [],
1016 "bookmarks": [],
1017 "tags": [],
1017 "tags": [],
1018 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1018 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1019 "files": []
1019 "files": []
1020 }
1020 }
1021 ]
1021 ]
1022
1022
1023 $ hg log --debug -Tjson
1023 $ hg log --debug -Tjson
1024 [
1024 [
1025 {
1025 {
1026 "rev": 8,
1026 "rev": 8,
1027 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
1027 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
1028 "branch": "default",
1028 "branch": "default",
1029 "phase": "draft",
1029 "phase": "draft",
1030 "user": "test",
1030 "user": "test",
1031 "date": [1577872860, 0],
1031 "date": [1577872860, 0],
1032 "desc": "third",
1032 "desc": "third",
1033 "bookmarks": [],
1033 "bookmarks": [],
1034 "tags": ["tip"],
1034 "tags": ["tip"],
1035 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
1035 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
1036 "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64",
1036 "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64",
1037 "extra": {"branch": "default"},
1037 "extra": {"branch": "default"},
1038 "modified": [],
1038 "modified": [],
1039 "added": ["fourth", "third"],
1039 "added": ["fourth", "third"],
1040 "removed": ["second"]
1040 "removed": ["second"]
1041 },
1041 },
1042 {
1042 {
1043 "rev": 7,
1043 "rev": 7,
1044 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
1044 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
1045 "branch": "default",
1045 "branch": "default",
1046 "phase": "draft",
1046 "phase": "draft",
1047 "user": "User Name <user@hostname>",
1047 "user": "User Name <user@hostname>",
1048 "date": [1000000, 0],
1048 "date": [1000000, 0],
1049 "desc": "second",
1049 "desc": "second",
1050 "bookmarks": [],
1050 "bookmarks": [],
1051 "tags": [],
1051 "tags": [],
1052 "parents": ["0000000000000000000000000000000000000000"],
1052 "parents": ["0000000000000000000000000000000000000000"],
1053 "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf",
1053 "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf",
1054 "extra": {"branch": "default"},
1054 "extra": {"branch": "default"},
1055 "modified": [],
1055 "modified": [],
1056 "added": ["second"],
1056 "added": ["second"],
1057 "removed": []
1057 "removed": []
1058 },
1058 },
1059 {
1059 {
1060 "rev": 6,
1060 "rev": 6,
1061 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
1061 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
1062 "branch": "default",
1062 "branch": "default",
1063 "phase": "draft",
1063 "phase": "draft",
1064 "user": "person",
1064 "user": "person",
1065 "date": [1500001, 0],
1065 "date": [1500001, 0],
1066 "desc": "merge",
1066 "desc": "merge",
1067 "bookmarks": [],
1067 "bookmarks": [],
1068 "tags": [],
1068 "tags": [],
1069 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1069 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1070 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1070 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1071 "extra": {"branch": "default"},
1071 "extra": {"branch": "default"},
1072 "modified": [],
1072 "modified": [],
1073 "added": [],
1073 "added": [],
1074 "removed": []
1074 "removed": []
1075 },
1075 },
1076 {
1076 {
1077 "rev": 5,
1077 "rev": 5,
1078 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
1078 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
1079 "branch": "default",
1079 "branch": "default",
1080 "phase": "draft",
1080 "phase": "draft",
1081 "user": "person",
1081 "user": "person",
1082 "date": [1500000, 0],
1082 "date": [1500000, 0],
1083 "desc": "new head",
1083 "desc": "new head",
1084 "bookmarks": [],
1084 "bookmarks": [],
1085 "tags": [],
1085 "tags": [],
1086 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1086 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1087 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1087 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1088 "extra": {"branch": "default"},
1088 "extra": {"branch": "default"},
1089 "modified": [],
1089 "modified": [],
1090 "added": ["d"],
1090 "added": ["d"],
1091 "removed": []
1091 "removed": []
1092 },
1092 },
1093 {
1093 {
1094 "rev": 4,
1094 "rev": 4,
1095 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1095 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1096 "branch": "foo",
1096 "branch": "foo",
1097 "phase": "draft",
1097 "phase": "draft",
1098 "user": "person",
1098 "user": "person",
1099 "date": [1400000, 0],
1099 "date": [1400000, 0],
1100 "desc": "new branch",
1100 "desc": "new branch",
1101 "bookmarks": [],
1101 "bookmarks": [],
1102 "tags": [],
1102 "tags": [],
1103 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1103 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1104 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1104 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1105 "extra": {"branch": "foo"},
1105 "extra": {"branch": "foo"},
1106 "modified": [],
1106 "modified": [],
1107 "added": [],
1107 "added": [],
1108 "removed": []
1108 "removed": []
1109 },
1109 },
1110 {
1110 {
1111 "rev": 3,
1111 "rev": 3,
1112 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
1112 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
1113 "branch": "default",
1113 "branch": "default",
1114 "phase": "draft",
1114 "phase": "draft",
1115 "user": "person",
1115 "user": "person",
1116 "date": [1300000, 0],
1116 "date": [1300000, 0],
1117 "desc": "no user, no domain",
1117 "desc": "no user, no domain",
1118 "bookmarks": [],
1118 "bookmarks": [],
1119 "tags": [],
1119 "tags": [],
1120 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
1120 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
1121 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1121 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1122 "extra": {"branch": "default"},
1122 "extra": {"branch": "default"},
1123 "modified": ["c"],
1123 "modified": ["c"],
1124 "added": [],
1124 "added": [],
1125 "removed": []
1125 "removed": []
1126 },
1126 },
1127 {
1127 {
1128 "rev": 2,
1128 "rev": 2,
1129 "node": "97054abb4ab824450e9164180baf491ae0078465",
1129 "node": "97054abb4ab824450e9164180baf491ae0078465",
1130 "branch": "default",
1130 "branch": "default",
1131 "phase": "draft",
1131 "phase": "draft",
1132 "user": "other@place",
1132 "user": "other@place",
1133 "date": [1200000, 0],
1133 "date": [1200000, 0],
1134 "desc": "no person",
1134 "desc": "no person",
1135 "bookmarks": [],
1135 "bookmarks": [],
1136 "tags": [],
1136 "tags": [],
1137 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
1137 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
1138 "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1",
1138 "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1",
1139 "extra": {"branch": "default"},
1139 "extra": {"branch": "default"},
1140 "modified": [],
1140 "modified": [],
1141 "added": ["c"],
1141 "added": ["c"],
1142 "removed": []
1142 "removed": []
1143 },
1143 },
1144 {
1144 {
1145 "rev": 1,
1145 "rev": 1,
1146 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
1146 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
1147 "branch": "default",
1147 "branch": "default",
1148 "phase": "draft",
1148 "phase": "draft",
1149 "user": "A. N. Other <other@place>",
1149 "user": "A. N. Other <other@place>",
1150 "date": [1100000, 0],
1150 "date": [1100000, 0],
1151 "desc": "other 1\nother 2\n\nother 3",
1151 "desc": "other 1\nother 2\n\nother 3",
1152 "bookmarks": [],
1152 "bookmarks": [],
1153 "tags": [],
1153 "tags": [],
1154 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
1154 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
1155 "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55",
1155 "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55",
1156 "extra": {"branch": "default"},
1156 "extra": {"branch": "default"},
1157 "modified": [],
1157 "modified": [],
1158 "added": ["b"],
1158 "added": ["b"],
1159 "removed": []
1159 "removed": []
1160 },
1160 },
1161 {
1161 {
1162 "rev": 0,
1162 "rev": 0,
1163 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1163 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1164 "branch": "default",
1164 "branch": "default",
1165 "phase": "draft",
1165 "phase": "draft",
1166 "user": "User Name <user@hostname>",
1166 "user": "User Name <user@hostname>",
1167 "date": [1000000, 0],
1167 "date": [1000000, 0],
1168 "desc": "line 1\nline 2",
1168 "desc": "line 1\nline 2",
1169 "bookmarks": [],
1169 "bookmarks": [],
1170 "tags": [],
1170 "tags": [],
1171 "parents": ["0000000000000000000000000000000000000000"],
1171 "parents": ["0000000000000000000000000000000000000000"],
1172 "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0",
1172 "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0",
1173 "extra": {"branch": "default"},
1173 "extra": {"branch": "default"},
1174 "modified": [],
1174 "modified": [],
1175 "added": ["a"],
1175 "added": ["a"],
1176 "removed": []
1176 "removed": []
1177 }
1177 }
1178 ]
1178 ]
1179
1179
1180 Error if style not readable:
1180 Error if style not readable:
1181
1181
1182 #if unix-permissions no-root
1182 #if unix-permissions no-root
1183 $ touch q
1183 $ touch q
1184 $ chmod 0 q
1184 $ chmod 0 q
1185 $ hg log --style ./q
1185 $ hg log --style ./q
1186 abort: Permission denied: ./q
1186 abort: Permission denied: ./q
1187 [255]
1187 [255]
1188 #endif
1188 #endif
1189
1189
1190 Error if no style:
1190 Error if no style:
1191
1191
1192 $ hg log --style notexist
1192 $ hg log --style notexist
1193 abort: style 'notexist' not found
1193 abort: style 'notexist' not found
1194 (available styles: bisect, changelog, compact, default, phases, show, status, xml)
1194 (available styles: bisect, changelog, compact, default, phases, show, status, xml)
1195 [255]
1195 [255]
1196
1196
1197 $ hg log -T list
1197 $ hg log -T list
1198 available styles: bisect, changelog, compact, default, phases, show, status, xml
1198 available styles: bisect, changelog, compact, default, phases, show, status, xml
1199 abort: specify a template
1199 abort: specify a template
1200 [255]
1200 [255]
1201
1201
1202 Error if style missing key:
1202 Error if style missing key:
1203
1203
1204 $ echo 'q = q' > t
1204 $ echo 'q = q' > t
1205 $ hg log --style ./t
1205 $ hg log --style ./t
1206 abort: "changeset" not in template map
1206 abort: "changeset" not in template map
1207 [255]
1207 [255]
1208
1208
1209 Error if style missing value:
1209 Error if style missing value:
1210
1210
1211 $ echo 'changeset =' > t
1211 $ echo 'changeset =' > t
1212 $ hg log --style t
1212 $ hg log --style t
1213 hg: parse error at t:1: missing value
1213 hg: parse error at t:1: missing value
1214 [255]
1214 [255]
1215
1215
1216 Error if include fails:
1216 Error if include fails:
1217
1217
1218 $ echo 'changeset = q' >> t
1218 $ echo 'changeset = q' >> t
1219 #if unix-permissions no-root
1219 #if unix-permissions no-root
1220 $ hg log --style ./t
1220 $ hg log --style ./t
1221 abort: template file ./q: Permission denied
1221 abort: template file ./q: Permission denied
1222 [255]
1222 [255]
1223 $ rm -f q
1223 $ rm -f q
1224 #endif
1224 #endif
1225
1225
1226 Include works:
1226 Include works:
1227
1227
1228 $ echo '{rev}' > q
1228 $ echo '{rev}' > q
1229 $ hg log --style ./t
1229 $ hg log --style ./t
1230 8
1230 8
1231 7
1231 7
1232 6
1232 6
1233 5
1233 5
1234 4
1234 4
1235 3
1235 3
1236 2
1236 2
1237 1
1237 1
1238 0
1238 0
1239
1239
1240 Check that recursive reference does not fall into RuntimeError (issue4758):
1240 Check that recursive reference does not fall into RuntimeError (issue4758):
1241
1241
1242 common mistake:
1242 common mistake:
1243
1243
1244 $ cat << EOF > issue4758
1244 $ cat << EOF > issue4758
1245 > changeset = '{changeset}\n'
1245 > changeset = '{changeset}\n'
1246 > EOF
1246 > EOF
1247 $ hg log --style ./issue4758
1247 $ hg log --style ./issue4758
1248 abort: recursive reference 'changeset' in template
1248 abort: recursive reference 'changeset' in template
1249 [255]
1249 [255]
1250
1250
1251 circular reference:
1251 circular reference:
1252
1252
1253 $ cat << EOF > issue4758
1253 $ cat << EOF > issue4758
1254 > changeset = '{foo}'
1254 > changeset = '{foo}'
1255 > foo = '{changeset}'
1255 > foo = '{changeset}'
1256 > EOF
1256 > EOF
1257 $ hg log --style ./issue4758
1257 $ hg log --style ./issue4758
1258 abort: recursive reference 'foo' in template
1258 abort: recursive reference 'foo' in template
1259 [255]
1259 [255]
1260
1260
1261 buildmap() -> gettemplate(), where no thunk was made:
1261 buildmap() -> gettemplate(), where no thunk was made:
1262
1262
1263 $ cat << EOF > issue4758
1263 $ cat << EOF > issue4758
1264 > changeset = '{files % changeset}\n'
1264 > changeset = '{files % changeset}\n'
1265 > EOF
1265 > EOF
1266 $ hg log --style ./issue4758
1266 $ hg log --style ./issue4758
1267 abort: recursive reference 'changeset' in template
1267 abort: recursive reference 'changeset' in template
1268 [255]
1268 [255]
1269
1269
1270 not a recursion if a keyword of the same name exists:
1270 not a recursion if a keyword of the same name exists:
1271
1271
1272 $ cat << EOF > issue4758
1272 $ cat << EOF > issue4758
1273 > changeset = '{tags % rev}'
1273 > changeset = '{tags % rev}'
1274 > rev = '{rev} {tag}\n'
1274 > rev = '{rev} {tag}\n'
1275 > EOF
1275 > EOF
1276 $ hg log --style ./issue4758 -r tip
1276 $ hg log --style ./issue4758 -r tip
1277 8 tip
1277 8 tip
1278
1278
1279 Check that {phase} works correctly on parents:
1279 Check that {phase} works correctly on parents:
1280
1280
1281 $ cat << EOF > parentphase
1281 $ cat << EOF > parentphase
1282 > changeset_debug = '{rev} ({phase}):{parents}\n'
1282 > changeset_debug = '{rev} ({phase}):{parents}\n'
1283 > parent = ' {rev} ({phase})'
1283 > parent = ' {rev} ({phase})'
1284 > EOF
1284 > EOF
1285 $ hg phase -r 5 --public
1285 $ hg phase -r 5 --public
1286 $ hg phase -r 7 --secret --force
1286 $ hg phase -r 7 --secret --force
1287 $ hg log --debug -G --style ./parentphase
1287 $ hg log --debug -G --style ./parentphase
1288 @ 8 (secret): 7 (secret) -1 (public)
1288 @ 8 (secret): 7 (secret) -1 (public)
1289 |
1289 |
1290 o 7 (secret): -1 (public) -1 (public)
1290 o 7 (secret): -1 (public) -1 (public)
1291
1291
1292 o 6 (draft): 5 (public) 4 (draft)
1292 o 6 (draft): 5 (public) 4 (draft)
1293 |\
1293 |\
1294 | o 5 (public): 3 (public) -1 (public)
1294 | o 5 (public): 3 (public) -1 (public)
1295 | |
1295 | |
1296 o | 4 (draft): 3 (public) -1 (public)
1296 o | 4 (draft): 3 (public) -1 (public)
1297 |/
1297 |/
1298 o 3 (public): 2 (public) -1 (public)
1298 o 3 (public): 2 (public) -1 (public)
1299 |
1299 |
1300 o 2 (public): 1 (public) -1 (public)
1300 o 2 (public): 1 (public) -1 (public)
1301 |
1301 |
1302 o 1 (public): 0 (public) -1 (public)
1302 o 1 (public): 0 (public) -1 (public)
1303 |
1303 |
1304 o 0 (public): -1 (public) -1 (public)
1304 o 0 (public): -1 (public) -1 (public)
1305
1305
1306
1306
1307 Missing non-standard names give no error (backward compatibility):
1307 Missing non-standard names give no error (backward compatibility):
1308
1308
1309 $ echo "changeset = '{c}'" > t
1309 $ echo "changeset = '{c}'" > t
1310 $ hg log --style ./t
1310 $ hg log --style ./t
1311
1311
1312 Defining non-standard name works:
1312 Defining non-standard name works:
1313
1313
1314 $ cat <<EOF > t
1314 $ cat <<EOF > t
1315 > changeset = '{c}'
1315 > changeset = '{c}'
1316 > c = q
1316 > c = q
1317 > EOF
1317 > EOF
1318 $ hg log --style ./t
1318 $ hg log --style ./t
1319 8
1319 8
1320 7
1320 7
1321 6
1321 6
1322 5
1322 5
1323 4
1323 4
1324 3
1324 3
1325 2
1325 2
1326 1
1326 1
1327 0
1327 0
1328
1328
1329 ui.style works:
1329 ui.style works:
1330
1330
1331 $ echo '[ui]' > .hg/hgrc
1331 $ echo '[ui]' > .hg/hgrc
1332 $ echo 'style = t' >> .hg/hgrc
1332 $ echo 'style = t' >> .hg/hgrc
1333 $ hg log
1333 $ hg log
1334 8
1334 8
1335 7
1335 7
1336 6
1336 6
1337 5
1337 5
1338 4
1338 4
1339 3
1339 3
1340 2
1340 2
1341 1
1341 1
1342 0
1342 0
1343
1343
1344
1344
1345 Issue338:
1345 Issue338:
1346
1346
1347 $ hg log --style=changelog > changelog
1347 $ hg log --style=changelog > changelog
1348
1348
1349 $ cat changelog
1349 $ cat changelog
1350 2020-01-01 test <test>
1350 2020-01-01 test <test>
1351
1351
1352 * fourth, second, third:
1352 * fourth, second, third:
1353 third
1353 third
1354 [95c24699272e] [tip]
1354 [95c24699272e] [tip]
1355
1355
1356 1970-01-12 User Name <user@hostname>
1356 1970-01-12 User Name <user@hostname>
1357
1357
1358 * second:
1358 * second:
1359 second
1359 second
1360 [29114dbae42b]
1360 [29114dbae42b]
1361
1361
1362 1970-01-18 person <person>
1362 1970-01-18 person <person>
1363
1363
1364 * merge
1364 * merge
1365 [d41e714fe50d]
1365 [d41e714fe50d]
1366
1366
1367 * d:
1367 * d:
1368 new head
1368 new head
1369 [13207e5a10d9]
1369 [13207e5a10d9]
1370
1370
1371 1970-01-17 person <person>
1371 1970-01-17 person <person>
1372
1372
1373 * new branch
1373 * new branch
1374 [bbe44766e73d] <foo>
1374 [bbe44766e73d] <foo>
1375
1375
1376 1970-01-16 person <person>
1376 1970-01-16 person <person>
1377
1377
1378 * c:
1378 * c:
1379 no user, no domain
1379 no user, no domain
1380 [10e46f2dcbf4]
1380 [10e46f2dcbf4]
1381
1381
1382 1970-01-14 other <other@place>
1382 1970-01-14 other <other@place>
1383
1383
1384 * c:
1384 * c:
1385 no person
1385 no person
1386 [97054abb4ab8]
1386 [97054abb4ab8]
1387
1387
1388 1970-01-13 A. N. Other <other@place>
1388 1970-01-13 A. N. Other <other@place>
1389
1389
1390 * b:
1390 * b:
1391 other 1 other 2
1391 other 1 other 2
1392
1392
1393 other 3
1393 other 3
1394 [b608e9d1a3f0]
1394 [b608e9d1a3f0]
1395
1395
1396 1970-01-12 User Name <user@hostname>
1396 1970-01-12 User Name <user@hostname>
1397
1397
1398 * a:
1398 * a:
1399 line 1 line 2
1399 line 1 line 2
1400 [1e4e1b8f71e0]
1400 [1e4e1b8f71e0]
1401
1401
1402
1402
1403 Issue2130: xml output for 'hg heads' is malformed
1403 Issue2130: xml output for 'hg heads' is malformed
1404
1404
1405 $ hg heads --style changelog
1405 $ hg heads --style changelog
1406 2020-01-01 test <test>
1406 2020-01-01 test <test>
1407
1407
1408 * fourth, second, third:
1408 * fourth, second, third:
1409 third
1409 third
1410 [95c24699272e] [tip]
1410 [95c24699272e] [tip]
1411
1411
1412 1970-01-18 person <person>
1412 1970-01-18 person <person>
1413
1413
1414 * merge
1414 * merge
1415 [d41e714fe50d]
1415 [d41e714fe50d]
1416
1416
1417 1970-01-17 person <person>
1417 1970-01-17 person <person>
1418
1418
1419 * new branch
1419 * new branch
1420 [bbe44766e73d] <foo>
1420 [bbe44766e73d] <foo>
1421
1421
1422
1422
1423 Keys work:
1423 Keys work:
1424
1424
1425 $ for key in author branch branches date desc file_adds file_dels file_mods \
1425 $ for key in author branch branches date desc file_adds file_dels file_mods \
1426 > file_copies file_copies_switch files \
1426 > file_copies file_copies_switch files \
1427 > manifest node parents rev tags diffstat extras \
1427 > manifest node parents rev tags diffstat extras \
1428 > p1rev p2rev p1node p2node; do
1428 > p1rev p2rev p1node p2node; do
1429 > for mode in '' --verbose --debug; do
1429 > for mode in '' --verbose --debug; do
1430 > hg log $mode --template "$key$mode: {$key}\n"
1430 > hg log $mode --template "$key$mode: {$key}\n"
1431 > done
1431 > done
1432 > done
1432 > done
1433 author: test
1433 author: test
1434 author: User Name <user@hostname>
1434 author: User Name <user@hostname>
1435 author: person
1435 author: person
1436 author: person
1436 author: person
1437 author: person
1437 author: person
1438 author: person
1438 author: person
1439 author: other@place
1439 author: other@place
1440 author: A. N. Other <other@place>
1440 author: A. N. Other <other@place>
1441 author: User Name <user@hostname>
1441 author: User Name <user@hostname>
1442 author--verbose: test
1442 author--verbose: test
1443 author--verbose: User Name <user@hostname>
1443 author--verbose: User Name <user@hostname>
1444 author--verbose: person
1444 author--verbose: person
1445 author--verbose: person
1445 author--verbose: person
1446 author--verbose: person
1446 author--verbose: person
1447 author--verbose: person
1447 author--verbose: person
1448 author--verbose: other@place
1448 author--verbose: other@place
1449 author--verbose: A. N. Other <other@place>
1449 author--verbose: A. N. Other <other@place>
1450 author--verbose: User Name <user@hostname>
1450 author--verbose: User Name <user@hostname>
1451 author--debug: test
1451 author--debug: test
1452 author--debug: User Name <user@hostname>
1452 author--debug: User Name <user@hostname>
1453 author--debug: person
1453 author--debug: person
1454 author--debug: person
1454 author--debug: person
1455 author--debug: person
1455 author--debug: person
1456 author--debug: person
1456 author--debug: person
1457 author--debug: other@place
1457 author--debug: other@place
1458 author--debug: A. N. Other <other@place>
1458 author--debug: A. N. Other <other@place>
1459 author--debug: User Name <user@hostname>
1459 author--debug: User Name <user@hostname>
1460 branch: default
1460 branch: default
1461 branch: default
1461 branch: default
1462 branch: default
1462 branch: default
1463 branch: default
1463 branch: default
1464 branch: foo
1464 branch: foo
1465 branch: default
1465 branch: default
1466 branch: default
1466 branch: default
1467 branch: default
1467 branch: default
1468 branch: default
1468 branch: default
1469 branch--verbose: default
1469 branch--verbose: default
1470 branch--verbose: default
1470 branch--verbose: default
1471 branch--verbose: default
1471 branch--verbose: default
1472 branch--verbose: default
1472 branch--verbose: default
1473 branch--verbose: foo
1473 branch--verbose: foo
1474 branch--verbose: default
1474 branch--verbose: default
1475 branch--verbose: default
1475 branch--verbose: default
1476 branch--verbose: default
1476 branch--verbose: default
1477 branch--verbose: default
1477 branch--verbose: default
1478 branch--debug: default
1478 branch--debug: default
1479 branch--debug: default
1479 branch--debug: default
1480 branch--debug: default
1480 branch--debug: default
1481 branch--debug: default
1481 branch--debug: default
1482 branch--debug: foo
1482 branch--debug: foo
1483 branch--debug: default
1483 branch--debug: default
1484 branch--debug: default
1484 branch--debug: default
1485 branch--debug: default
1485 branch--debug: default
1486 branch--debug: default
1486 branch--debug: default
1487 branches:
1487 branches:
1488 branches:
1488 branches:
1489 branches:
1489 branches:
1490 branches:
1490 branches:
1491 branches: foo
1491 branches: foo
1492 branches:
1492 branches:
1493 branches:
1493 branches:
1494 branches:
1494 branches:
1495 branches:
1495 branches:
1496 branches--verbose:
1496 branches--verbose:
1497 branches--verbose:
1497 branches--verbose:
1498 branches--verbose:
1498 branches--verbose:
1499 branches--verbose:
1499 branches--verbose:
1500 branches--verbose: foo
1500 branches--verbose: foo
1501 branches--verbose:
1501 branches--verbose:
1502 branches--verbose:
1502 branches--verbose:
1503 branches--verbose:
1503 branches--verbose:
1504 branches--verbose:
1504 branches--verbose:
1505 branches--debug:
1505 branches--debug:
1506 branches--debug:
1506 branches--debug:
1507 branches--debug:
1507 branches--debug:
1508 branches--debug:
1508 branches--debug:
1509 branches--debug: foo
1509 branches--debug: foo
1510 branches--debug:
1510 branches--debug:
1511 branches--debug:
1511 branches--debug:
1512 branches--debug:
1512 branches--debug:
1513 branches--debug:
1513 branches--debug:
1514 date: 1577872860.00
1514 date: 1577872860.00
1515 date: 1000000.00
1515 date: 1000000.00
1516 date: 1500001.00
1516 date: 1500001.00
1517 date: 1500000.00
1517 date: 1500000.00
1518 date: 1400000.00
1518 date: 1400000.00
1519 date: 1300000.00
1519 date: 1300000.00
1520 date: 1200000.00
1520 date: 1200000.00
1521 date: 1100000.00
1521 date: 1100000.00
1522 date: 1000000.00
1522 date: 1000000.00
1523 date--verbose: 1577872860.00
1523 date--verbose: 1577872860.00
1524 date--verbose: 1000000.00
1524 date--verbose: 1000000.00
1525 date--verbose: 1500001.00
1525 date--verbose: 1500001.00
1526 date--verbose: 1500000.00
1526 date--verbose: 1500000.00
1527 date--verbose: 1400000.00
1527 date--verbose: 1400000.00
1528 date--verbose: 1300000.00
1528 date--verbose: 1300000.00
1529 date--verbose: 1200000.00
1529 date--verbose: 1200000.00
1530 date--verbose: 1100000.00
1530 date--verbose: 1100000.00
1531 date--verbose: 1000000.00
1531 date--verbose: 1000000.00
1532 date--debug: 1577872860.00
1532 date--debug: 1577872860.00
1533 date--debug: 1000000.00
1533 date--debug: 1000000.00
1534 date--debug: 1500001.00
1534 date--debug: 1500001.00
1535 date--debug: 1500000.00
1535 date--debug: 1500000.00
1536 date--debug: 1400000.00
1536 date--debug: 1400000.00
1537 date--debug: 1300000.00
1537 date--debug: 1300000.00
1538 date--debug: 1200000.00
1538 date--debug: 1200000.00
1539 date--debug: 1100000.00
1539 date--debug: 1100000.00
1540 date--debug: 1000000.00
1540 date--debug: 1000000.00
1541 desc: third
1541 desc: third
1542 desc: second
1542 desc: second
1543 desc: merge
1543 desc: merge
1544 desc: new head
1544 desc: new head
1545 desc: new branch
1545 desc: new branch
1546 desc: no user, no domain
1546 desc: no user, no domain
1547 desc: no person
1547 desc: no person
1548 desc: other 1
1548 desc: other 1
1549 other 2
1549 other 2
1550
1550
1551 other 3
1551 other 3
1552 desc: line 1
1552 desc: line 1
1553 line 2
1553 line 2
1554 desc--verbose: third
1554 desc--verbose: third
1555 desc--verbose: second
1555 desc--verbose: second
1556 desc--verbose: merge
1556 desc--verbose: merge
1557 desc--verbose: new head
1557 desc--verbose: new head
1558 desc--verbose: new branch
1558 desc--verbose: new branch
1559 desc--verbose: no user, no domain
1559 desc--verbose: no user, no domain
1560 desc--verbose: no person
1560 desc--verbose: no person
1561 desc--verbose: other 1
1561 desc--verbose: other 1
1562 other 2
1562 other 2
1563
1563
1564 other 3
1564 other 3
1565 desc--verbose: line 1
1565 desc--verbose: line 1
1566 line 2
1566 line 2
1567 desc--debug: third
1567 desc--debug: third
1568 desc--debug: second
1568 desc--debug: second
1569 desc--debug: merge
1569 desc--debug: merge
1570 desc--debug: new head
1570 desc--debug: new head
1571 desc--debug: new branch
1571 desc--debug: new branch
1572 desc--debug: no user, no domain
1572 desc--debug: no user, no domain
1573 desc--debug: no person
1573 desc--debug: no person
1574 desc--debug: other 1
1574 desc--debug: other 1
1575 other 2
1575 other 2
1576
1576
1577 other 3
1577 other 3
1578 desc--debug: line 1
1578 desc--debug: line 1
1579 line 2
1579 line 2
1580 file_adds: fourth third
1580 file_adds: fourth third
1581 file_adds: second
1581 file_adds: second
1582 file_adds:
1582 file_adds:
1583 file_adds: d
1583 file_adds: d
1584 file_adds:
1584 file_adds:
1585 file_adds:
1585 file_adds:
1586 file_adds: c
1586 file_adds: c
1587 file_adds: b
1587 file_adds: b
1588 file_adds: a
1588 file_adds: a
1589 file_adds--verbose: fourth third
1589 file_adds--verbose: fourth third
1590 file_adds--verbose: second
1590 file_adds--verbose: second
1591 file_adds--verbose:
1591 file_adds--verbose:
1592 file_adds--verbose: d
1592 file_adds--verbose: d
1593 file_adds--verbose:
1593 file_adds--verbose:
1594 file_adds--verbose:
1594 file_adds--verbose:
1595 file_adds--verbose: c
1595 file_adds--verbose: c
1596 file_adds--verbose: b
1596 file_adds--verbose: b
1597 file_adds--verbose: a
1597 file_adds--verbose: a
1598 file_adds--debug: fourth third
1598 file_adds--debug: fourth third
1599 file_adds--debug: second
1599 file_adds--debug: second
1600 file_adds--debug:
1600 file_adds--debug:
1601 file_adds--debug: d
1601 file_adds--debug: d
1602 file_adds--debug:
1602 file_adds--debug:
1603 file_adds--debug:
1603 file_adds--debug:
1604 file_adds--debug: c
1604 file_adds--debug: c
1605 file_adds--debug: b
1605 file_adds--debug: b
1606 file_adds--debug: a
1606 file_adds--debug: a
1607 file_dels: second
1607 file_dels: second
1608 file_dels:
1608 file_dels:
1609 file_dels:
1609 file_dels:
1610 file_dels:
1610 file_dels:
1611 file_dels:
1611 file_dels:
1612 file_dels:
1612 file_dels:
1613 file_dels:
1613 file_dels:
1614 file_dels:
1614 file_dels:
1615 file_dels:
1615 file_dels:
1616 file_dels--verbose: second
1616 file_dels--verbose: second
1617 file_dels--verbose:
1617 file_dels--verbose:
1618 file_dels--verbose:
1618 file_dels--verbose:
1619 file_dels--verbose:
1619 file_dels--verbose:
1620 file_dels--verbose:
1620 file_dels--verbose:
1621 file_dels--verbose:
1621 file_dels--verbose:
1622 file_dels--verbose:
1622 file_dels--verbose:
1623 file_dels--verbose:
1623 file_dels--verbose:
1624 file_dels--verbose:
1624 file_dels--verbose:
1625 file_dels--debug: second
1625 file_dels--debug: second
1626 file_dels--debug:
1626 file_dels--debug:
1627 file_dels--debug:
1627 file_dels--debug:
1628 file_dels--debug:
1628 file_dels--debug:
1629 file_dels--debug:
1629 file_dels--debug:
1630 file_dels--debug:
1630 file_dels--debug:
1631 file_dels--debug:
1631 file_dels--debug:
1632 file_dels--debug:
1632 file_dels--debug:
1633 file_dels--debug:
1633 file_dels--debug:
1634 file_mods:
1634 file_mods:
1635 file_mods:
1635 file_mods:
1636 file_mods:
1636 file_mods:
1637 file_mods:
1637 file_mods:
1638 file_mods:
1638 file_mods:
1639 file_mods: c
1639 file_mods: c
1640 file_mods:
1640 file_mods:
1641 file_mods:
1641 file_mods:
1642 file_mods:
1642 file_mods:
1643 file_mods--verbose:
1643 file_mods--verbose:
1644 file_mods--verbose:
1644 file_mods--verbose:
1645 file_mods--verbose:
1645 file_mods--verbose:
1646 file_mods--verbose:
1646 file_mods--verbose:
1647 file_mods--verbose:
1647 file_mods--verbose:
1648 file_mods--verbose: c
1648 file_mods--verbose: c
1649 file_mods--verbose:
1649 file_mods--verbose:
1650 file_mods--verbose:
1650 file_mods--verbose:
1651 file_mods--verbose:
1651 file_mods--verbose:
1652 file_mods--debug:
1652 file_mods--debug:
1653 file_mods--debug:
1653 file_mods--debug:
1654 file_mods--debug:
1654 file_mods--debug:
1655 file_mods--debug:
1655 file_mods--debug:
1656 file_mods--debug:
1656 file_mods--debug:
1657 file_mods--debug: c
1657 file_mods--debug: c
1658 file_mods--debug:
1658 file_mods--debug:
1659 file_mods--debug:
1659 file_mods--debug:
1660 file_mods--debug:
1660 file_mods--debug:
1661 file_copies: fourth (second)
1661 file_copies: fourth (second)
1662 file_copies:
1662 file_copies:
1663 file_copies:
1663 file_copies:
1664 file_copies:
1664 file_copies:
1665 file_copies:
1665 file_copies:
1666 file_copies:
1666 file_copies:
1667 file_copies:
1667 file_copies:
1668 file_copies:
1668 file_copies:
1669 file_copies:
1669 file_copies:
1670 file_copies--verbose: fourth (second)
1670 file_copies--verbose: fourth (second)
1671 file_copies--verbose:
1671 file_copies--verbose:
1672 file_copies--verbose:
1672 file_copies--verbose:
1673 file_copies--verbose:
1673 file_copies--verbose:
1674 file_copies--verbose:
1674 file_copies--verbose:
1675 file_copies--verbose:
1675 file_copies--verbose:
1676 file_copies--verbose:
1676 file_copies--verbose:
1677 file_copies--verbose:
1677 file_copies--verbose:
1678 file_copies--verbose:
1678 file_copies--verbose:
1679 file_copies--debug: fourth (second)
1679 file_copies--debug: fourth (second)
1680 file_copies--debug:
1680 file_copies--debug:
1681 file_copies--debug:
1681 file_copies--debug:
1682 file_copies--debug:
1682 file_copies--debug:
1683 file_copies--debug:
1683 file_copies--debug:
1684 file_copies--debug:
1684 file_copies--debug:
1685 file_copies--debug:
1685 file_copies--debug:
1686 file_copies--debug:
1686 file_copies--debug:
1687 file_copies--debug:
1687 file_copies--debug:
1688 file_copies_switch:
1688 file_copies_switch:
1689 file_copies_switch:
1689 file_copies_switch:
1690 file_copies_switch:
1690 file_copies_switch:
1691 file_copies_switch:
1691 file_copies_switch:
1692 file_copies_switch:
1692 file_copies_switch:
1693 file_copies_switch:
1693 file_copies_switch:
1694 file_copies_switch:
1694 file_copies_switch:
1695 file_copies_switch:
1695 file_copies_switch:
1696 file_copies_switch:
1696 file_copies_switch:
1697 file_copies_switch--verbose:
1697 file_copies_switch--verbose:
1698 file_copies_switch--verbose:
1698 file_copies_switch--verbose:
1699 file_copies_switch--verbose:
1699 file_copies_switch--verbose:
1700 file_copies_switch--verbose:
1700 file_copies_switch--verbose:
1701 file_copies_switch--verbose:
1701 file_copies_switch--verbose:
1702 file_copies_switch--verbose:
1702 file_copies_switch--verbose:
1703 file_copies_switch--verbose:
1703 file_copies_switch--verbose:
1704 file_copies_switch--verbose:
1704 file_copies_switch--verbose:
1705 file_copies_switch--verbose:
1705 file_copies_switch--verbose:
1706 file_copies_switch--debug:
1706 file_copies_switch--debug:
1707 file_copies_switch--debug:
1707 file_copies_switch--debug:
1708 file_copies_switch--debug:
1708 file_copies_switch--debug:
1709 file_copies_switch--debug:
1709 file_copies_switch--debug:
1710 file_copies_switch--debug:
1710 file_copies_switch--debug:
1711 file_copies_switch--debug:
1711 file_copies_switch--debug:
1712 file_copies_switch--debug:
1712 file_copies_switch--debug:
1713 file_copies_switch--debug:
1713 file_copies_switch--debug:
1714 file_copies_switch--debug:
1714 file_copies_switch--debug:
1715 files: fourth second third
1715 files: fourth second third
1716 files: second
1716 files: second
1717 files:
1717 files:
1718 files: d
1718 files: d
1719 files:
1719 files:
1720 files: c
1720 files: c
1721 files: c
1721 files: c
1722 files: b
1722 files: b
1723 files: a
1723 files: a
1724 files--verbose: fourth second third
1724 files--verbose: fourth second third
1725 files--verbose: second
1725 files--verbose: second
1726 files--verbose:
1726 files--verbose:
1727 files--verbose: d
1727 files--verbose: d
1728 files--verbose:
1728 files--verbose:
1729 files--verbose: c
1729 files--verbose: c
1730 files--verbose: c
1730 files--verbose: c
1731 files--verbose: b
1731 files--verbose: b
1732 files--verbose: a
1732 files--verbose: a
1733 files--debug: fourth second third
1733 files--debug: fourth second third
1734 files--debug: second
1734 files--debug: second
1735 files--debug:
1735 files--debug:
1736 files--debug: d
1736 files--debug: d
1737 files--debug:
1737 files--debug:
1738 files--debug: c
1738 files--debug: c
1739 files--debug: c
1739 files--debug: c
1740 files--debug: b
1740 files--debug: b
1741 files--debug: a
1741 files--debug: a
1742 manifest: 6:94961b75a2da
1742 manifest: 6:94961b75a2da
1743 manifest: 5:f2dbc354b94e
1743 manifest: 5:f2dbc354b94e
1744 manifest: 4:4dc3def4f9b4
1744 manifest: 4:4dc3def4f9b4
1745 manifest: 4:4dc3def4f9b4
1745 manifest: 4:4dc3def4f9b4
1746 manifest: 3:cb5a1327723b
1746 manifest: 3:cb5a1327723b
1747 manifest: 3:cb5a1327723b
1747 manifest: 3:cb5a1327723b
1748 manifest: 2:6e0e82995c35
1748 manifest: 2:6e0e82995c35
1749 manifest: 1:4e8d705b1e53
1749 manifest: 1:4e8d705b1e53
1750 manifest: 0:a0c8bcbbb45c
1750 manifest: 0:a0c8bcbbb45c
1751 manifest--verbose: 6:94961b75a2da
1751 manifest--verbose: 6:94961b75a2da
1752 manifest--verbose: 5:f2dbc354b94e
1752 manifest--verbose: 5:f2dbc354b94e
1753 manifest--verbose: 4:4dc3def4f9b4
1753 manifest--verbose: 4:4dc3def4f9b4
1754 manifest--verbose: 4:4dc3def4f9b4
1754 manifest--verbose: 4:4dc3def4f9b4
1755 manifest--verbose: 3:cb5a1327723b
1755 manifest--verbose: 3:cb5a1327723b
1756 manifest--verbose: 3:cb5a1327723b
1756 manifest--verbose: 3:cb5a1327723b
1757 manifest--verbose: 2:6e0e82995c35
1757 manifest--verbose: 2:6e0e82995c35
1758 manifest--verbose: 1:4e8d705b1e53
1758 manifest--verbose: 1:4e8d705b1e53
1759 manifest--verbose: 0:a0c8bcbbb45c
1759 manifest--verbose: 0:a0c8bcbbb45c
1760 manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64
1760 manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64
1761 manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf
1761 manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf
1762 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1762 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1763 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1763 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1764 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1764 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1765 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1765 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1766 manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
1766 manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
1767 manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
1767 manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
1768 manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
1768 manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
1769 node: 95c24699272ef57d062b8bccc32c878bf841784a
1769 node: 95c24699272ef57d062b8bccc32c878bf841784a
1770 node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1770 node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1771 node: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1771 node: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1772 node: 13207e5a10d9fd28ec424934298e176197f2c67f
1772 node: 13207e5a10d9fd28ec424934298e176197f2c67f
1773 node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1773 node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1774 node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1774 node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1775 node: 97054abb4ab824450e9164180baf491ae0078465
1775 node: 97054abb4ab824450e9164180baf491ae0078465
1776 node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1776 node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1777 node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1777 node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1778 node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a
1778 node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a
1779 node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1779 node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1780 node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1780 node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1781 node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1781 node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1782 node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1782 node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1783 node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1783 node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1784 node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1784 node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1785 node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1785 node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1786 node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
1786 node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
1787 node--debug: 95c24699272ef57d062b8bccc32c878bf841784a
1787 node--debug: 95c24699272ef57d062b8bccc32c878bf841784a
1788 node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1788 node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1789 node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1789 node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1790 node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
1790 node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
1791 node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1791 node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1792 node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1792 node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1793 node--debug: 97054abb4ab824450e9164180baf491ae0078465
1793 node--debug: 97054abb4ab824450e9164180baf491ae0078465
1794 node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1794 node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1795 node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
1795 node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
1796 parents:
1796 parents:
1797 parents: -1:000000000000
1797 parents: -1:000000000000
1798 parents: 5:13207e5a10d9 4:bbe44766e73d
1798 parents: 5:13207e5a10d9 4:bbe44766e73d
1799 parents: 3:10e46f2dcbf4
1799 parents: 3:10e46f2dcbf4
1800 parents:
1800 parents:
1801 parents:
1801 parents:
1802 parents:
1802 parents:
1803 parents:
1803 parents:
1804 parents:
1804 parents:
1805 parents--verbose:
1805 parents--verbose:
1806 parents--verbose: -1:000000000000
1806 parents--verbose: -1:000000000000
1807 parents--verbose: 5:13207e5a10d9 4:bbe44766e73d
1807 parents--verbose: 5:13207e5a10d9 4:bbe44766e73d
1808 parents--verbose: 3:10e46f2dcbf4
1808 parents--verbose: 3:10e46f2dcbf4
1809 parents--verbose:
1809 parents--verbose:
1810 parents--verbose:
1810 parents--verbose:
1811 parents--verbose:
1811 parents--verbose:
1812 parents--verbose:
1812 parents--verbose:
1813 parents--verbose:
1813 parents--verbose:
1814 parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000
1814 parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000
1815 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1815 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1816 parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1816 parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1817 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1817 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1818 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1818 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1819 parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000
1819 parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000
1820 parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000
1820 parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000
1821 parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000
1821 parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000
1822 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1822 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1823 rev: 8
1823 rev: 8
1824 rev: 7
1824 rev: 7
1825 rev: 6
1825 rev: 6
1826 rev: 5
1826 rev: 5
1827 rev: 4
1827 rev: 4
1828 rev: 3
1828 rev: 3
1829 rev: 2
1829 rev: 2
1830 rev: 1
1830 rev: 1
1831 rev: 0
1831 rev: 0
1832 rev--verbose: 8
1832 rev--verbose: 8
1833 rev--verbose: 7
1833 rev--verbose: 7
1834 rev--verbose: 6
1834 rev--verbose: 6
1835 rev--verbose: 5
1835 rev--verbose: 5
1836 rev--verbose: 4
1836 rev--verbose: 4
1837 rev--verbose: 3
1837 rev--verbose: 3
1838 rev--verbose: 2
1838 rev--verbose: 2
1839 rev--verbose: 1
1839 rev--verbose: 1
1840 rev--verbose: 0
1840 rev--verbose: 0
1841 rev--debug: 8
1841 rev--debug: 8
1842 rev--debug: 7
1842 rev--debug: 7
1843 rev--debug: 6
1843 rev--debug: 6
1844 rev--debug: 5
1844 rev--debug: 5
1845 rev--debug: 4
1845 rev--debug: 4
1846 rev--debug: 3
1846 rev--debug: 3
1847 rev--debug: 2
1847 rev--debug: 2
1848 rev--debug: 1
1848 rev--debug: 1
1849 rev--debug: 0
1849 rev--debug: 0
1850 tags: tip
1850 tags: tip
1851 tags:
1851 tags:
1852 tags:
1852 tags:
1853 tags:
1853 tags:
1854 tags:
1854 tags:
1855 tags:
1855 tags:
1856 tags:
1856 tags:
1857 tags:
1857 tags:
1858 tags:
1858 tags:
1859 tags--verbose: tip
1859 tags--verbose: tip
1860 tags--verbose:
1860 tags--verbose:
1861 tags--verbose:
1861 tags--verbose:
1862 tags--verbose:
1862 tags--verbose:
1863 tags--verbose:
1863 tags--verbose:
1864 tags--verbose:
1864 tags--verbose:
1865 tags--verbose:
1865 tags--verbose:
1866 tags--verbose:
1866 tags--verbose:
1867 tags--verbose:
1867 tags--verbose:
1868 tags--debug: tip
1868 tags--debug: tip
1869 tags--debug:
1869 tags--debug:
1870 tags--debug:
1870 tags--debug:
1871 tags--debug:
1871 tags--debug:
1872 tags--debug:
1872 tags--debug:
1873 tags--debug:
1873 tags--debug:
1874 tags--debug:
1874 tags--debug:
1875 tags--debug:
1875 tags--debug:
1876 tags--debug:
1876 tags--debug:
1877 diffstat: 3: +2/-1
1877 diffstat: 3: +2/-1
1878 diffstat: 1: +1/-0
1878 diffstat: 1: +1/-0
1879 diffstat: 0: +0/-0
1879 diffstat: 0: +0/-0
1880 diffstat: 1: +1/-0
1880 diffstat: 1: +1/-0
1881 diffstat: 0: +0/-0
1881 diffstat: 0: +0/-0
1882 diffstat: 1: +1/-0
1882 diffstat: 1: +1/-0
1883 diffstat: 1: +4/-0
1883 diffstat: 1: +4/-0
1884 diffstat: 1: +2/-0
1884 diffstat: 1: +2/-0
1885 diffstat: 1: +1/-0
1885 diffstat: 1: +1/-0
1886 diffstat--verbose: 3: +2/-1
1886 diffstat--verbose: 3: +2/-1
1887 diffstat--verbose: 1: +1/-0
1887 diffstat--verbose: 1: +1/-0
1888 diffstat--verbose: 0: +0/-0
1888 diffstat--verbose: 0: +0/-0
1889 diffstat--verbose: 1: +1/-0
1889 diffstat--verbose: 1: +1/-0
1890 diffstat--verbose: 0: +0/-0
1890 diffstat--verbose: 0: +0/-0
1891 diffstat--verbose: 1: +1/-0
1891 diffstat--verbose: 1: +1/-0
1892 diffstat--verbose: 1: +4/-0
1892 diffstat--verbose: 1: +4/-0
1893 diffstat--verbose: 1: +2/-0
1893 diffstat--verbose: 1: +2/-0
1894 diffstat--verbose: 1: +1/-0
1894 diffstat--verbose: 1: +1/-0
1895 diffstat--debug: 3: +2/-1
1895 diffstat--debug: 3: +2/-1
1896 diffstat--debug: 1: +1/-0
1896 diffstat--debug: 1: +1/-0
1897 diffstat--debug: 0: +0/-0
1897 diffstat--debug: 0: +0/-0
1898 diffstat--debug: 1: +1/-0
1898 diffstat--debug: 1: +1/-0
1899 diffstat--debug: 0: +0/-0
1899 diffstat--debug: 0: +0/-0
1900 diffstat--debug: 1: +1/-0
1900 diffstat--debug: 1: +1/-0
1901 diffstat--debug: 1: +4/-0
1901 diffstat--debug: 1: +4/-0
1902 diffstat--debug: 1: +2/-0
1902 diffstat--debug: 1: +2/-0
1903 diffstat--debug: 1: +1/-0
1903 diffstat--debug: 1: +1/-0
1904 extras: branch=default
1904 extras: branch=default
1905 extras: branch=default
1905 extras: branch=default
1906 extras: branch=default
1906 extras: branch=default
1907 extras: branch=default
1907 extras: branch=default
1908 extras: branch=foo
1908 extras: branch=foo
1909 extras: branch=default
1909 extras: branch=default
1910 extras: branch=default
1910 extras: branch=default
1911 extras: branch=default
1911 extras: branch=default
1912 extras: branch=default
1912 extras: branch=default
1913 extras--verbose: branch=default
1913 extras--verbose: branch=default
1914 extras--verbose: branch=default
1914 extras--verbose: branch=default
1915 extras--verbose: branch=default
1915 extras--verbose: branch=default
1916 extras--verbose: branch=default
1916 extras--verbose: branch=default
1917 extras--verbose: branch=foo
1917 extras--verbose: branch=foo
1918 extras--verbose: branch=default
1918 extras--verbose: branch=default
1919 extras--verbose: branch=default
1919 extras--verbose: branch=default
1920 extras--verbose: branch=default
1920 extras--verbose: branch=default
1921 extras--verbose: branch=default
1921 extras--verbose: branch=default
1922 extras--debug: branch=default
1922 extras--debug: branch=default
1923 extras--debug: branch=default
1923 extras--debug: branch=default
1924 extras--debug: branch=default
1924 extras--debug: branch=default
1925 extras--debug: branch=default
1925 extras--debug: branch=default
1926 extras--debug: branch=foo
1926 extras--debug: branch=foo
1927 extras--debug: branch=default
1927 extras--debug: branch=default
1928 extras--debug: branch=default
1928 extras--debug: branch=default
1929 extras--debug: branch=default
1929 extras--debug: branch=default
1930 extras--debug: branch=default
1930 extras--debug: branch=default
1931 p1rev: 7
1931 p1rev: 7
1932 p1rev: -1
1932 p1rev: -1
1933 p1rev: 5
1933 p1rev: 5
1934 p1rev: 3
1934 p1rev: 3
1935 p1rev: 3
1935 p1rev: 3
1936 p1rev: 2
1936 p1rev: 2
1937 p1rev: 1
1937 p1rev: 1
1938 p1rev: 0
1938 p1rev: 0
1939 p1rev: -1
1939 p1rev: -1
1940 p1rev--verbose: 7
1940 p1rev--verbose: 7
1941 p1rev--verbose: -1
1941 p1rev--verbose: -1
1942 p1rev--verbose: 5
1942 p1rev--verbose: 5
1943 p1rev--verbose: 3
1943 p1rev--verbose: 3
1944 p1rev--verbose: 3
1944 p1rev--verbose: 3
1945 p1rev--verbose: 2
1945 p1rev--verbose: 2
1946 p1rev--verbose: 1
1946 p1rev--verbose: 1
1947 p1rev--verbose: 0
1947 p1rev--verbose: 0
1948 p1rev--verbose: -1
1948 p1rev--verbose: -1
1949 p1rev--debug: 7
1949 p1rev--debug: 7
1950 p1rev--debug: -1
1950 p1rev--debug: -1
1951 p1rev--debug: 5
1951 p1rev--debug: 5
1952 p1rev--debug: 3
1952 p1rev--debug: 3
1953 p1rev--debug: 3
1953 p1rev--debug: 3
1954 p1rev--debug: 2
1954 p1rev--debug: 2
1955 p1rev--debug: 1
1955 p1rev--debug: 1
1956 p1rev--debug: 0
1956 p1rev--debug: 0
1957 p1rev--debug: -1
1957 p1rev--debug: -1
1958 p2rev: -1
1958 p2rev: -1
1959 p2rev: -1
1959 p2rev: -1
1960 p2rev: 4
1960 p2rev: 4
1961 p2rev: -1
1961 p2rev: -1
1962 p2rev: -1
1962 p2rev: -1
1963 p2rev: -1
1963 p2rev: -1
1964 p2rev: -1
1964 p2rev: -1
1965 p2rev: -1
1965 p2rev: -1
1966 p2rev: -1
1966 p2rev: -1
1967 p2rev--verbose: -1
1967 p2rev--verbose: -1
1968 p2rev--verbose: -1
1968 p2rev--verbose: -1
1969 p2rev--verbose: 4
1969 p2rev--verbose: 4
1970 p2rev--verbose: -1
1970 p2rev--verbose: -1
1971 p2rev--verbose: -1
1971 p2rev--verbose: -1
1972 p2rev--verbose: -1
1972 p2rev--verbose: -1
1973 p2rev--verbose: -1
1973 p2rev--verbose: -1
1974 p2rev--verbose: -1
1974 p2rev--verbose: -1
1975 p2rev--verbose: -1
1975 p2rev--verbose: -1
1976 p2rev--debug: -1
1976 p2rev--debug: -1
1977 p2rev--debug: -1
1977 p2rev--debug: -1
1978 p2rev--debug: 4
1978 p2rev--debug: 4
1979 p2rev--debug: -1
1979 p2rev--debug: -1
1980 p2rev--debug: -1
1980 p2rev--debug: -1
1981 p2rev--debug: -1
1981 p2rev--debug: -1
1982 p2rev--debug: -1
1982 p2rev--debug: -1
1983 p2rev--debug: -1
1983 p2rev--debug: -1
1984 p2rev--debug: -1
1984 p2rev--debug: -1
1985 p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1985 p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1986 p1node: 0000000000000000000000000000000000000000
1986 p1node: 0000000000000000000000000000000000000000
1987 p1node: 13207e5a10d9fd28ec424934298e176197f2c67f
1987 p1node: 13207e5a10d9fd28ec424934298e176197f2c67f
1988 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1988 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1989 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1989 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1990 p1node: 97054abb4ab824450e9164180baf491ae0078465
1990 p1node: 97054abb4ab824450e9164180baf491ae0078465
1991 p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1991 p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1992 p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1992 p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1993 p1node: 0000000000000000000000000000000000000000
1993 p1node: 0000000000000000000000000000000000000000
1994 p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1994 p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1995 p1node--verbose: 0000000000000000000000000000000000000000
1995 p1node--verbose: 0000000000000000000000000000000000000000
1996 p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1996 p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1997 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1997 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1998 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1998 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1999 p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1999 p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465
2000 p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2000 p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2001 p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
2001 p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
2002 p1node--verbose: 0000000000000000000000000000000000000000
2002 p1node--verbose: 0000000000000000000000000000000000000000
2003 p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
2003 p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
2004 p1node--debug: 0000000000000000000000000000000000000000
2004 p1node--debug: 0000000000000000000000000000000000000000
2005 p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
2005 p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
2006 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2006 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2007 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2007 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2008 p1node--debug: 97054abb4ab824450e9164180baf491ae0078465
2008 p1node--debug: 97054abb4ab824450e9164180baf491ae0078465
2009 p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2009 p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2010 p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
2010 p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
2011 p1node--debug: 0000000000000000000000000000000000000000
2011 p1node--debug: 0000000000000000000000000000000000000000
2012 p2node: 0000000000000000000000000000000000000000
2012 p2node: 0000000000000000000000000000000000000000
2013 p2node: 0000000000000000000000000000000000000000
2013 p2node: 0000000000000000000000000000000000000000
2014 p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2014 p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2015 p2node: 0000000000000000000000000000000000000000
2015 p2node: 0000000000000000000000000000000000000000
2016 p2node: 0000000000000000000000000000000000000000
2016 p2node: 0000000000000000000000000000000000000000
2017 p2node: 0000000000000000000000000000000000000000
2017 p2node: 0000000000000000000000000000000000000000
2018 p2node: 0000000000000000000000000000000000000000
2018 p2node: 0000000000000000000000000000000000000000
2019 p2node: 0000000000000000000000000000000000000000
2019 p2node: 0000000000000000000000000000000000000000
2020 p2node: 0000000000000000000000000000000000000000
2020 p2node: 0000000000000000000000000000000000000000
2021 p2node--verbose: 0000000000000000000000000000000000000000
2021 p2node--verbose: 0000000000000000000000000000000000000000
2022 p2node--verbose: 0000000000000000000000000000000000000000
2022 p2node--verbose: 0000000000000000000000000000000000000000
2023 p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2023 p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2024 p2node--verbose: 0000000000000000000000000000000000000000
2024 p2node--verbose: 0000000000000000000000000000000000000000
2025 p2node--verbose: 0000000000000000000000000000000000000000
2025 p2node--verbose: 0000000000000000000000000000000000000000
2026 p2node--verbose: 0000000000000000000000000000000000000000
2026 p2node--verbose: 0000000000000000000000000000000000000000
2027 p2node--verbose: 0000000000000000000000000000000000000000
2027 p2node--verbose: 0000000000000000000000000000000000000000
2028 p2node--verbose: 0000000000000000000000000000000000000000
2028 p2node--verbose: 0000000000000000000000000000000000000000
2029 p2node--verbose: 0000000000000000000000000000000000000000
2029 p2node--verbose: 0000000000000000000000000000000000000000
2030 p2node--debug: 0000000000000000000000000000000000000000
2030 p2node--debug: 0000000000000000000000000000000000000000
2031 p2node--debug: 0000000000000000000000000000000000000000
2031 p2node--debug: 0000000000000000000000000000000000000000
2032 p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2032 p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2033 p2node--debug: 0000000000000000000000000000000000000000
2033 p2node--debug: 0000000000000000000000000000000000000000
2034 p2node--debug: 0000000000000000000000000000000000000000
2034 p2node--debug: 0000000000000000000000000000000000000000
2035 p2node--debug: 0000000000000000000000000000000000000000
2035 p2node--debug: 0000000000000000000000000000000000000000
2036 p2node--debug: 0000000000000000000000000000000000000000
2036 p2node--debug: 0000000000000000000000000000000000000000
2037 p2node--debug: 0000000000000000000000000000000000000000
2037 p2node--debug: 0000000000000000000000000000000000000000
2038 p2node--debug: 0000000000000000000000000000000000000000
2038 p2node--debug: 0000000000000000000000000000000000000000
2039
2039
2040 Filters work:
2040 Filters work:
2041
2041
2042 $ hg log --template '{author|domain}\n'
2042 $ hg log --template '{author|domain}\n'
2043
2043
2044 hostname
2044 hostname
2045
2045
2046
2046
2047
2047
2048
2048
2049 place
2049 place
2050 place
2050 place
2051 hostname
2051 hostname
2052
2052
2053 $ hg log --template '{author|person}\n'
2053 $ hg log --template '{author|person}\n'
2054 test
2054 test
2055 User Name
2055 User Name
2056 person
2056 person
2057 person
2057 person
2058 person
2058 person
2059 person
2059 person
2060 other
2060 other
2061 A. N. Other
2061 A. N. Other
2062 User Name
2062 User Name
2063
2063
2064 $ hg log --template '{author|user}\n'
2064 $ hg log --template '{author|user}\n'
2065 test
2065 test
2066 user
2066 user
2067 person
2067 person
2068 person
2068 person
2069 person
2069 person
2070 person
2070 person
2071 other
2071 other
2072 other
2072 other
2073 user
2073 user
2074
2074
2075 $ hg log --template '{date|date}\n'
2075 $ hg log --template '{date|date}\n'
2076 Wed Jan 01 10:01:00 2020 +0000
2076 Wed Jan 01 10:01:00 2020 +0000
2077 Mon Jan 12 13:46:40 1970 +0000
2077 Mon Jan 12 13:46:40 1970 +0000
2078 Sun Jan 18 08:40:01 1970 +0000
2078 Sun Jan 18 08:40:01 1970 +0000
2079 Sun Jan 18 08:40:00 1970 +0000
2079 Sun Jan 18 08:40:00 1970 +0000
2080 Sat Jan 17 04:53:20 1970 +0000
2080 Sat Jan 17 04:53:20 1970 +0000
2081 Fri Jan 16 01:06:40 1970 +0000
2081 Fri Jan 16 01:06:40 1970 +0000
2082 Wed Jan 14 21:20:00 1970 +0000
2082 Wed Jan 14 21:20:00 1970 +0000
2083 Tue Jan 13 17:33:20 1970 +0000
2083 Tue Jan 13 17:33:20 1970 +0000
2084 Mon Jan 12 13:46:40 1970 +0000
2084 Mon Jan 12 13:46:40 1970 +0000
2085
2085
2086 $ hg log --template '{date|isodate}\n'
2086 $ hg log --template '{date|isodate}\n'
2087 2020-01-01 10:01 +0000
2087 2020-01-01 10:01 +0000
2088 1970-01-12 13:46 +0000
2088 1970-01-12 13:46 +0000
2089 1970-01-18 08:40 +0000
2089 1970-01-18 08:40 +0000
2090 1970-01-18 08:40 +0000
2090 1970-01-18 08:40 +0000
2091 1970-01-17 04:53 +0000
2091 1970-01-17 04:53 +0000
2092 1970-01-16 01:06 +0000
2092 1970-01-16 01:06 +0000
2093 1970-01-14 21:20 +0000
2093 1970-01-14 21:20 +0000
2094 1970-01-13 17:33 +0000
2094 1970-01-13 17:33 +0000
2095 1970-01-12 13:46 +0000
2095 1970-01-12 13:46 +0000
2096
2096
2097 $ hg log --template '{date|isodatesec}\n'
2097 $ hg log --template '{date|isodatesec}\n'
2098 2020-01-01 10:01:00 +0000
2098 2020-01-01 10:01:00 +0000
2099 1970-01-12 13:46:40 +0000
2099 1970-01-12 13:46:40 +0000
2100 1970-01-18 08:40:01 +0000
2100 1970-01-18 08:40:01 +0000
2101 1970-01-18 08:40:00 +0000
2101 1970-01-18 08:40:00 +0000
2102 1970-01-17 04:53:20 +0000
2102 1970-01-17 04:53:20 +0000
2103 1970-01-16 01:06:40 +0000
2103 1970-01-16 01:06:40 +0000
2104 1970-01-14 21:20:00 +0000
2104 1970-01-14 21:20:00 +0000
2105 1970-01-13 17:33:20 +0000
2105 1970-01-13 17:33:20 +0000
2106 1970-01-12 13:46:40 +0000
2106 1970-01-12 13:46:40 +0000
2107
2107
2108 $ hg log --template '{date|rfc822date}\n'
2108 $ hg log --template '{date|rfc822date}\n'
2109 Wed, 01 Jan 2020 10:01:00 +0000
2109 Wed, 01 Jan 2020 10:01:00 +0000
2110 Mon, 12 Jan 1970 13:46:40 +0000
2110 Mon, 12 Jan 1970 13:46:40 +0000
2111 Sun, 18 Jan 1970 08:40:01 +0000
2111 Sun, 18 Jan 1970 08:40:01 +0000
2112 Sun, 18 Jan 1970 08:40:00 +0000
2112 Sun, 18 Jan 1970 08:40:00 +0000
2113 Sat, 17 Jan 1970 04:53:20 +0000
2113 Sat, 17 Jan 1970 04:53:20 +0000
2114 Fri, 16 Jan 1970 01:06:40 +0000
2114 Fri, 16 Jan 1970 01:06:40 +0000
2115 Wed, 14 Jan 1970 21:20:00 +0000
2115 Wed, 14 Jan 1970 21:20:00 +0000
2116 Tue, 13 Jan 1970 17:33:20 +0000
2116 Tue, 13 Jan 1970 17:33:20 +0000
2117 Mon, 12 Jan 1970 13:46:40 +0000
2117 Mon, 12 Jan 1970 13:46:40 +0000
2118
2118
2119 $ hg log --template '{desc|firstline}\n'
2119 $ hg log --template '{desc|firstline}\n'
2120 third
2120 third
2121 second
2121 second
2122 merge
2122 merge
2123 new head
2123 new head
2124 new branch
2124 new branch
2125 no user, no domain
2125 no user, no domain
2126 no person
2126 no person
2127 other 1
2127 other 1
2128 line 1
2128 line 1
2129
2129
2130 $ hg log --template '{node|short}\n'
2130 $ hg log --template '{node|short}\n'
2131 95c24699272e
2131 95c24699272e
2132 29114dbae42b
2132 29114dbae42b
2133 d41e714fe50d
2133 d41e714fe50d
2134 13207e5a10d9
2134 13207e5a10d9
2135 bbe44766e73d
2135 bbe44766e73d
2136 10e46f2dcbf4
2136 10e46f2dcbf4
2137 97054abb4ab8
2137 97054abb4ab8
2138 b608e9d1a3f0
2138 b608e9d1a3f0
2139 1e4e1b8f71e0
2139 1e4e1b8f71e0
2140
2140
2141 $ hg log --template '<changeset author="{author|xmlescape}"/>\n'
2141 $ hg log --template '<changeset author="{author|xmlescape}"/>\n'
2142 <changeset author="test"/>
2142 <changeset author="test"/>
2143 <changeset author="User Name &lt;user@hostname&gt;"/>
2143 <changeset author="User Name &lt;user@hostname&gt;"/>
2144 <changeset author="person"/>
2144 <changeset author="person"/>
2145 <changeset author="person"/>
2145 <changeset author="person"/>
2146 <changeset author="person"/>
2146 <changeset author="person"/>
2147 <changeset author="person"/>
2147 <changeset author="person"/>
2148 <changeset author="other@place"/>
2148 <changeset author="other@place"/>
2149 <changeset author="A. N. Other &lt;other@place&gt;"/>
2149 <changeset author="A. N. Other &lt;other@place&gt;"/>
2150 <changeset author="User Name &lt;user@hostname&gt;"/>
2150 <changeset author="User Name &lt;user@hostname&gt;"/>
2151
2151
2152 $ hg log --template '{rev}: {children}\n'
2152 $ hg log --template '{rev}: {children}\n'
2153 8:
2153 8:
2154 7: 8:95c24699272e
2154 7: 8:95c24699272e
2155 6:
2155 6:
2156 5: 6:d41e714fe50d
2156 5: 6:d41e714fe50d
2157 4: 6:d41e714fe50d
2157 4: 6:d41e714fe50d
2158 3: 4:bbe44766e73d 5:13207e5a10d9
2158 3: 4:bbe44766e73d 5:13207e5a10d9
2159 2: 3:10e46f2dcbf4
2159 2: 3:10e46f2dcbf4
2160 1: 2:97054abb4ab8
2160 1: 2:97054abb4ab8
2161 0: 1:b608e9d1a3f0
2161 0: 1:b608e9d1a3f0
2162
2162
2163 Formatnode filter works:
2163 Formatnode filter works:
2164
2164
2165 $ hg -q log -r 0 --template '{node|formatnode}\n'
2165 $ hg -q log -r 0 --template '{node|formatnode}\n'
2166 1e4e1b8f71e0
2166 1e4e1b8f71e0
2167
2167
2168 $ hg log -r 0 --template '{node|formatnode}\n'
2168 $ hg log -r 0 --template '{node|formatnode}\n'
2169 1e4e1b8f71e0
2169 1e4e1b8f71e0
2170
2170
2171 $ hg -v log -r 0 --template '{node|formatnode}\n'
2171 $ hg -v log -r 0 --template '{node|formatnode}\n'
2172 1e4e1b8f71e0
2172 1e4e1b8f71e0
2173
2173
2174 $ hg --debug log -r 0 --template '{node|formatnode}\n'
2174 $ hg --debug log -r 0 --template '{node|formatnode}\n'
2175 1e4e1b8f71e05681d422154f5421e385fec3454f
2175 1e4e1b8f71e05681d422154f5421e385fec3454f
2176
2176
2177 Age filter:
2177 Age filter:
2178
2178
2179 $ hg init unstable-hash
2179 $ hg init unstable-hash
2180 $ cd unstable-hash
2180 $ cd unstable-hash
2181 $ hg log --template '{date|age}\n' > /dev/null || exit 1
2181 $ hg log --template '{date|age}\n' > /dev/null || exit 1
2182
2182
2183 >>> from __future__ import absolute_import
2183 >>> from __future__ import absolute_import
2184 >>> import datetime
2184 >>> import datetime
2185 >>> fp = open('a', 'w')
2185 >>> fp = open('a', 'w')
2186 >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
2186 >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
2187 >>> fp.write('%d-%d-%d 00:00' % (n.year, n.month, n.day))
2187 >>> fp.write('%d-%d-%d 00:00' % (n.year, n.month, n.day))
2188 >>> fp.close()
2188 >>> fp.close()
2189 $ hg add a
2189 $ hg add a
2190 $ hg commit -m future -d "`cat a`"
2190 $ hg commit -m future -d "`cat a`"
2191
2191
2192 $ hg log -l1 --template '{date|age}\n'
2192 $ hg log -l1 --template '{date|age}\n'
2193 7 years from now
2193 7 years from now
2194
2194
2195 $ cd ..
2195 $ cd ..
2196 $ rm -rf unstable-hash
2196 $ rm -rf unstable-hash
2197
2197
2198 Add a dummy commit to make up for the instability of the above:
2198 Add a dummy commit to make up for the instability of the above:
2199
2199
2200 $ echo a > a
2200 $ echo a > a
2201 $ hg add a
2201 $ hg add a
2202 $ hg ci -m future
2202 $ hg ci -m future
2203
2203
2204 Count filter:
2204 Count filter:
2205
2205
2206 $ hg log -l1 --template '{node|count} {node|short|count}\n'
2206 $ hg log -l1 --template '{node|count} {node|short|count}\n'
2207 40 12
2207 40 12
2208
2208
2209 $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n'
2209 $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n'
2210 0 1 4
2210 0 1 4
2211
2211
2212 $ hg log -G --template '{rev}: children: {children|count}, \
2212 $ hg log -G --template '{rev}: children: {children|count}, \
2213 > tags: {tags|count}, file_adds: {file_adds|count}, \
2213 > tags: {tags|count}, file_adds: {file_adds|count}, \
2214 > ancestors: {revset("ancestors(%s)", rev)|count}'
2214 > ancestors: {revset("ancestors(%s)", rev)|count}'
2215 @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3
2215 @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3
2216 |
2216 |
2217 o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2
2217 o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2
2218 |
2218 |
2219 o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1
2219 o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1
2220
2220
2221 o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7
2221 o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7
2222 |\
2222 |\
2223 | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5
2223 | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5
2224 | |
2224 | |
2225 o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5
2225 o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5
2226 |/
2226 |/
2227 o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4
2227 o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4
2228 |
2228 |
2229 o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3
2229 o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3
2230 |
2230 |
2231 o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2
2231 o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2
2232 |
2232 |
2233 o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1
2233 o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1
2234
2234
2235
2235
2236 Upper/lower filters:
2236 Upper/lower filters:
2237
2237
2238 $ hg log -r0 --template '{branch|upper}\n'
2238 $ hg log -r0 --template '{branch|upper}\n'
2239 DEFAULT
2239 DEFAULT
2240 $ hg log -r0 --template '{author|lower}\n'
2240 $ hg log -r0 --template '{author|lower}\n'
2241 user name <user@hostname>
2241 user name <user@hostname>
2242 $ hg log -r0 --template '{date|upper}\n'
2242 $ hg log -r0 --template '{date|upper}\n'
2243 abort: template filter 'upper' is not compatible with keyword 'date'
2243 abort: template filter 'upper' is not compatible with keyword 'date'
2244 [255]
2244 [255]
2245
2245
2246 Add a commit that does all possible modifications at once
2246 Add a commit that does all possible modifications at once
2247
2247
2248 $ echo modify >> third
2248 $ echo modify >> third
2249 $ touch b
2249 $ touch b
2250 $ hg add b
2250 $ hg add b
2251 $ hg mv fourth fifth
2251 $ hg mv fourth fifth
2252 $ hg rm a
2252 $ hg rm a
2253 $ hg ci -m "Modify, add, remove, rename"
2253 $ hg ci -m "Modify, add, remove, rename"
2254
2254
2255 Check the status template
2255 Check the status template
2256
2256
2257 $ cat <<EOF >> $HGRCPATH
2257 $ cat <<EOF >> $HGRCPATH
2258 > [extensions]
2258 > [extensions]
2259 > color=
2259 > color=
2260 > EOF
2260 > EOF
2261
2261
2262 $ hg log -T status -r 10
2262 $ hg log -T status -r 10
2263 changeset: 10:0f9759ec227a
2263 changeset: 10:0f9759ec227a
2264 tag: tip
2264 tag: tip
2265 user: test
2265 user: test
2266 date: Thu Jan 01 00:00:00 1970 +0000
2266 date: Thu Jan 01 00:00:00 1970 +0000
2267 summary: Modify, add, remove, rename
2267 summary: Modify, add, remove, rename
2268 files:
2268 files:
2269 M third
2269 M third
2270 A b
2270 A b
2271 A fifth
2271 A fifth
2272 R a
2272 R a
2273 R fourth
2273 R fourth
2274
2274
2275 $ hg log -T status -C -r 10
2275 $ hg log -T status -C -r 10
2276 changeset: 10:0f9759ec227a
2276 changeset: 10:0f9759ec227a
2277 tag: tip
2277 tag: tip
2278 user: test
2278 user: test
2279 date: Thu Jan 01 00:00:00 1970 +0000
2279 date: Thu Jan 01 00:00:00 1970 +0000
2280 summary: Modify, add, remove, rename
2280 summary: Modify, add, remove, rename
2281 files:
2281 files:
2282 M third
2282 M third
2283 A b
2283 A b
2284 A fifth
2284 A fifth
2285 fourth
2285 fourth
2286 R a
2286 R a
2287 R fourth
2287 R fourth
2288
2288
2289 $ hg log -T status -C -r 10 -v
2289 $ hg log -T status -C -r 10 -v
2290 changeset: 10:0f9759ec227a
2290 changeset: 10:0f9759ec227a
2291 tag: tip
2291 tag: tip
2292 user: test
2292 user: test
2293 date: Thu Jan 01 00:00:00 1970 +0000
2293 date: Thu Jan 01 00:00:00 1970 +0000
2294 description:
2294 description:
2295 Modify, add, remove, rename
2295 Modify, add, remove, rename
2296
2296
2297 files:
2297 files:
2298 M third
2298 M third
2299 A b
2299 A b
2300 A fifth
2300 A fifth
2301 fourth
2301 fourth
2302 R a
2302 R a
2303 R fourth
2303 R fourth
2304
2304
2305 $ hg log -T status -C -r 10 --debug
2305 $ hg log -T status -C -r 10 --debug
2306 changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c
2306 changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c
2307 tag: tip
2307 tag: tip
2308 phase: secret
2308 phase: secret
2309 parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066
2309 parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066
2310 parent: -1:0000000000000000000000000000000000000000
2310 parent: -1:0000000000000000000000000000000000000000
2311 manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567
2311 manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567
2312 user: test
2312 user: test
2313 date: Thu Jan 01 00:00:00 1970 +0000
2313 date: Thu Jan 01 00:00:00 1970 +0000
2314 extra: branch=default
2314 extra: branch=default
2315 description:
2315 description:
2316 Modify, add, remove, rename
2316 Modify, add, remove, rename
2317
2317
2318 files:
2318 files:
2319 M third
2319 M third
2320 A b
2320 A b
2321 A fifth
2321 A fifth
2322 fourth
2322 fourth
2323 R a
2323 R a
2324 R fourth
2324 R fourth
2325
2325
2326 $ hg log -T status -C -r 10 --quiet
2326 $ hg log -T status -C -r 10 --quiet
2327 10:0f9759ec227a
2327 10:0f9759ec227a
2328 $ hg --color=debug log -T status -r 10
2328 $ hg --color=debug log -T status -r 10
2329 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2329 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2330 [log.tag|tag: tip]
2330 [log.tag|tag: tip]
2331 [log.user|user: test]
2331 [log.user|user: test]
2332 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2332 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2333 [log.summary|summary: Modify, add, remove, rename]
2333 [log.summary|summary: Modify, add, remove, rename]
2334 [ui.note log.files|files:]
2334 [ui.note log.files|files:]
2335 [status.modified|M third]
2335 [status.modified|M third]
2336 [status.added|A b]
2336 [status.added|A b]
2337 [status.added|A fifth]
2337 [status.added|A fifth]
2338 [status.removed|R a]
2338 [status.removed|R a]
2339 [status.removed|R fourth]
2339 [status.removed|R fourth]
2340
2340
2341 $ hg --color=debug log -T status -C -r 10
2341 $ hg --color=debug log -T status -C -r 10
2342 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2342 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2343 [log.tag|tag: tip]
2343 [log.tag|tag: tip]
2344 [log.user|user: test]
2344 [log.user|user: test]
2345 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2345 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2346 [log.summary|summary: Modify, add, remove, rename]
2346 [log.summary|summary: Modify, add, remove, rename]
2347 [ui.note log.files|files:]
2347 [ui.note log.files|files:]
2348 [status.modified|M third]
2348 [status.modified|M third]
2349 [status.added|A b]
2349 [status.added|A b]
2350 [status.added|A fifth]
2350 [status.added|A fifth]
2351 [status.copied| fourth]
2351 [status.copied| fourth]
2352 [status.removed|R a]
2352 [status.removed|R a]
2353 [status.removed|R fourth]
2353 [status.removed|R fourth]
2354
2354
2355 $ hg --color=debug log -T status -C -r 10 -v
2355 $ hg --color=debug log -T status -C -r 10 -v
2356 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2356 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2357 [log.tag|tag: tip]
2357 [log.tag|tag: tip]
2358 [log.user|user: test]
2358 [log.user|user: test]
2359 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2359 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2360 [ui.note log.description|description:]
2360 [ui.note log.description|description:]
2361 [ui.note log.description|Modify, add, remove, rename]
2361 [ui.note log.description|Modify, add, remove, rename]
2362
2362
2363 [ui.note log.files|files:]
2363 [ui.note log.files|files:]
2364 [status.modified|M third]
2364 [status.modified|M third]
2365 [status.added|A b]
2365 [status.added|A b]
2366 [status.added|A fifth]
2366 [status.added|A fifth]
2367 [status.copied| fourth]
2367 [status.copied| fourth]
2368 [status.removed|R a]
2368 [status.removed|R a]
2369 [status.removed|R fourth]
2369 [status.removed|R fourth]
2370
2370
2371 $ hg --color=debug log -T status -C -r 10 --debug
2371 $ hg --color=debug log -T status -C -r 10 --debug
2372 [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c]
2372 [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c]
2373 [log.tag|tag: tip]
2373 [log.tag|tag: tip]
2374 [log.phase|phase: secret]
2374 [log.phase|phase: secret]
2375 [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066]
2375 [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066]
2376 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2376 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2377 [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567]
2377 [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567]
2378 [log.user|user: test]
2378 [log.user|user: test]
2379 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2379 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2380 [ui.debug log.extra|extra: branch=default]
2380 [ui.debug log.extra|extra: branch=default]
2381 [ui.note log.description|description:]
2381 [ui.note log.description|description:]
2382 [ui.note log.description|Modify, add, remove, rename]
2382 [ui.note log.description|Modify, add, remove, rename]
2383
2383
2384 [ui.note log.files|files:]
2384 [ui.note log.files|files:]
2385 [status.modified|M third]
2385 [status.modified|M third]
2386 [status.added|A b]
2386 [status.added|A b]
2387 [status.added|A fifth]
2387 [status.added|A fifth]
2388 [status.copied| fourth]
2388 [status.copied| fourth]
2389 [status.removed|R a]
2389 [status.removed|R a]
2390 [status.removed|R fourth]
2390 [status.removed|R fourth]
2391
2391
2392 $ hg --color=debug log -T status -C -r 10 --quiet
2392 $ hg --color=debug log -T status -C -r 10 --quiet
2393 [log.node|10:0f9759ec227a]
2393 [log.node|10:0f9759ec227a]
2394
2394
2395 Check the bisect template
2395 Check the bisect template
2396
2396
2397 $ hg bisect -g 1
2397 $ hg bisect -g 1
2398 $ hg bisect -b 3 --noupdate
2398 $ hg bisect -b 3 --noupdate
2399 Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests)
2399 Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests)
2400 $ hg log -T bisect -r 0:4
2400 $ hg log -T bisect -r 0:4
2401 changeset: 0:1e4e1b8f71e0
2401 changeset: 0:1e4e1b8f71e0
2402 bisect: good (implicit)
2402 bisect: good (implicit)
2403 user: User Name <user@hostname>
2403 user: User Name <user@hostname>
2404 date: Mon Jan 12 13:46:40 1970 +0000
2404 date: Mon Jan 12 13:46:40 1970 +0000
2405 summary: line 1
2405 summary: line 1
2406
2406
2407 changeset: 1:b608e9d1a3f0
2407 changeset: 1:b608e9d1a3f0
2408 bisect: good
2408 bisect: good
2409 user: A. N. Other <other@place>
2409 user: A. N. Other <other@place>
2410 date: Tue Jan 13 17:33:20 1970 +0000
2410 date: Tue Jan 13 17:33:20 1970 +0000
2411 summary: other 1
2411 summary: other 1
2412
2412
2413 changeset: 2:97054abb4ab8
2413 changeset: 2:97054abb4ab8
2414 bisect: untested
2414 bisect: untested
2415 user: other@place
2415 user: other@place
2416 date: Wed Jan 14 21:20:00 1970 +0000
2416 date: Wed Jan 14 21:20:00 1970 +0000
2417 summary: no person
2417 summary: no person
2418
2418
2419 changeset: 3:10e46f2dcbf4
2419 changeset: 3:10e46f2dcbf4
2420 bisect: bad
2420 bisect: bad
2421 user: person
2421 user: person
2422 date: Fri Jan 16 01:06:40 1970 +0000
2422 date: Fri Jan 16 01:06:40 1970 +0000
2423 summary: no user, no domain
2423 summary: no user, no domain
2424
2424
2425 changeset: 4:bbe44766e73d
2425 changeset: 4:bbe44766e73d
2426 bisect: bad (implicit)
2426 bisect: bad (implicit)
2427 branch: foo
2427 branch: foo
2428 user: person
2428 user: person
2429 date: Sat Jan 17 04:53:20 1970 +0000
2429 date: Sat Jan 17 04:53:20 1970 +0000
2430 summary: new branch
2430 summary: new branch
2431
2431
2432 $ hg log --debug -T bisect -r 0:4
2432 $ hg log --debug -T bisect -r 0:4
2433 changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2433 changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2434 bisect: good (implicit)
2434 bisect: good (implicit)
2435 phase: public
2435 phase: public
2436 parent: -1:0000000000000000000000000000000000000000
2436 parent: -1:0000000000000000000000000000000000000000
2437 parent: -1:0000000000000000000000000000000000000000
2437 parent: -1:0000000000000000000000000000000000000000
2438 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
2438 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
2439 user: User Name <user@hostname>
2439 user: User Name <user@hostname>
2440 date: Mon Jan 12 13:46:40 1970 +0000
2440 date: Mon Jan 12 13:46:40 1970 +0000
2441 files+: a
2441 files+: a
2442 extra: branch=default
2442 extra: branch=default
2443 description:
2443 description:
2444 line 1
2444 line 1
2445 line 2
2445 line 2
2446
2446
2447
2447
2448 changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2448 changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2449 bisect: good
2449 bisect: good
2450 phase: public
2450 phase: public
2451 parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2451 parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2452 parent: -1:0000000000000000000000000000000000000000
2452 parent: -1:0000000000000000000000000000000000000000
2453 manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
2453 manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
2454 user: A. N. Other <other@place>
2454 user: A. N. Other <other@place>
2455 date: Tue Jan 13 17:33:20 1970 +0000
2455 date: Tue Jan 13 17:33:20 1970 +0000
2456 files+: b
2456 files+: b
2457 extra: branch=default
2457 extra: branch=default
2458 description:
2458 description:
2459 other 1
2459 other 1
2460 other 2
2460 other 2
2461
2461
2462 other 3
2462 other 3
2463
2463
2464
2464
2465 changeset: 2:97054abb4ab824450e9164180baf491ae0078465
2465 changeset: 2:97054abb4ab824450e9164180baf491ae0078465
2466 bisect: untested
2466 bisect: untested
2467 phase: public
2467 phase: public
2468 parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2468 parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2469 parent: -1:0000000000000000000000000000000000000000
2469 parent: -1:0000000000000000000000000000000000000000
2470 manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
2470 manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
2471 user: other@place
2471 user: other@place
2472 date: Wed Jan 14 21:20:00 1970 +0000
2472 date: Wed Jan 14 21:20:00 1970 +0000
2473 files+: c
2473 files+: c
2474 extra: branch=default
2474 extra: branch=default
2475 description:
2475 description:
2476 no person
2476 no person
2477
2477
2478
2478
2479 changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2479 changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2480 bisect: bad
2480 bisect: bad
2481 phase: public
2481 phase: public
2482 parent: 2:97054abb4ab824450e9164180baf491ae0078465
2482 parent: 2:97054abb4ab824450e9164180baf491ae0078465
2483 parent: -1:0000000000000000000000000000000000000000
2483 parent: -1:0000000000000000000000000000000000000000
2484 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2484 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2485 user: person
2485 user: person
2486 date: Fri Jan 16 01:06:40 1970 +0000
2486 date: Fri Jan 16 01:06:40 1970 +0000
2487 files: c
2487 files: c
2488 extra: branch=default
2488 extra: branch=default
2489 description:
2489 description:
2490 no user, no domain
2490 no user, no domain
2491
2491
2492
2492
2493 changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
2493 changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
2494 bisect: bad (implicit)
2494 bisect: bad (implicit)
2495 branch: foo
2495 branch: foo
2496 phase: draft
2496 phase: draft
2497 parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2497 parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2498 parent: -1:0000000000000000000000000000000000000000
2498 parent: -1:0000000000000000000000000000000000000000
2499 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2499 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2500 user: person
2500 user: person
2501 date: Sat Jan 17 04:53:20 1970 +0000
2501 date: Sat Jan 17 04:53:20 1970 +0000
2502 extra: branch=foo
2502 extra: branch=foo
2503 description:
2503 description:
2504 new branch
2504 new branch
2505
2505
2506
2506
2507 $ hg log -v -T bisect -r 0:4
2507 $ hg log -v -T bisect -r 0:4
2508 changeset: 0:1e4e1b8f71e0
2508 changeset: 0:1e4e1b8f71e0
2509 bisect: good (implicit)
2509 bisect: good (implicit)
2510 user: User Name <user@hostname>
2510 user: User Name <user@hostname>
2511 date: Mon Jan 12 13:46:40 1970 +0000
2511 date: Mon Jan 12 13:46:40 1970 +0000
2512 files: a
2512 files: a
2513 description:
2513 description:
2514 line 1
2514 line 1
2515 line 2
2515 line 2
2516
2516
2517
2517
2518 changeset: 1:b608e9d1a3f0
2518 changeset: 1:b608e9d1a3f0
2519 bisect: good
2519 bisect: good
2520 user: A. N. Other <other@place>
2520 user: A. N. Other <other@place>
2521 date: Tue Jan 13 17:33:20 1970 +0000
2521 date: Tue Jan 13 17:33:20 1970 +0000
2522 files: b
2522 files: b
2523 description:
2523 description:
2524 other 1
2524 other 1
2525 other 2
2525 other 2
2526
2526
2527 other 3
2527 other 3
2528
2528
2529
2529
2530 changeset: 2:97054abb4ab8
2530 changeset: 2:97054abb4ab8
2531 bisect: untested
2531 bisect: untested
2532 user: other@place
2532 user: other@place
2533 date: Wed Jan 14 21:20:00 1970 +0000
2533 date: Wed Jan 14 21:20:00 1970 +0000
2534 files: c
2534 files: c
2535 description:
2535 description:
2536 no person
2536 no person
2537
2537
2538
2538
2539 changeset: 3:10e46f2dcbf4
2539 changeset: 3:10e46f2dcbf4
2540 bisect: bad
2540 bisect: bad
2541 user: person
2541 user: person
2542 date: Fri Jan 16 01:06:40 1970 +0000
2542 date: Fri Jan 16 01:06:40 1970 +0000
2543 files: c
2543 files: c
2544 description:
2544 description:
2545 no user, no domain
2545 no user, no domain
2546
2546
2547
2547
2548 changeset: 4:bbe44766e73d
2548 changeset: 4:bbe44766e73d
2549 bisect: bad (implicit)
2549 bisect: bad (implicit)
2550 branch: foo
2550 branch: foo
2551 user: person
2551 user: person
2552 date: Sat Jan 17 04:53:20 1970 +0000
2552 date: Sat Jan 17 04:53:20 1970 +0000
2553 description:
2553 description:
2554 new branch
2554 new branch
2555
2555
2556
2556
2557 $ hg --color=debug log -T bisect -r 0:4
2557 $ hg --color=debug log -T bisect -r 0:4
2558 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2558 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2559 [log.bisect bisect.good|bisect: good (implicit)]
2559 [log.bisect bisect.good|bisect: good (implicit)]
2560 [log.user|user: User Name <user@hostname>]
2560 [log.user|user: User Name <user@hostname>]
2561 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2561 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2562 [log.summary|summary: line 1]
2562 [log.summary|summary: line 1]
2563
2563
2564 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2564 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2565 [log.bisect bisect.good|bisect: good]
2565 [log.bisect bisect.good|bisect: good]
2566 [log.user|user: A. N. Other <other@place>]
2566 [log.user|user: A. N. Other <other@place>]
2567 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2567 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2568 [log.summary|summary: other 1]
2568 [log.summary|summary: other 1]
2569
2569
2570 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2570 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2571 [log.bisect bisect.untested|bisect: untested]
2571 [log.bisect bisect.untested|bisect: untested]
2572 [log.user|user: other@place]
2572 [log.user|user: other@place]
2573 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2573 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2574 [log.summary|summary: no person]
2574 [log.summary|summary: no person]
2575
2575
2576 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2576 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2577 [log.bisect bisect.bad|bisect: bad]
2577 [log.bisect bisect.bad|bisect: bad]
2578 [log.user|user: person]
2578 [log.user|user: person]
2579 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2579 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2580 [log.summary|summary: no user, no domain]
2580 [log.summary|summary: no user, no domain]
2581
2581
2582 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2582 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2583 [log.bisect bisect.bad|bisect: bad (implicit)]
2583 [log.bisect bisect.bad|bisect: bad (implicit)]
2584 [log.branch|branch: foo]
2584 [log.branch|branch: foo]
2585 [log.user|user: person]
2585 [log.user|user: person]
2586 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2586 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2587 [log.summary|summary: new branch]
2587 [log.summary|summary: new branch]
2588
2588
2589 $ hg --color=debug log --debug -T bisect -r 0:4
2589 $ hg --color=debug log --debug -T bisect -r 0:4
2590 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2590 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2591 [log.bisect bisect.good|bisect: good (implicit)]
2591 [log.bisect bisect.good|bisect: good (implicit)]
2592 [log.phase|phase: public]
2592 [log.phase|phase: public]
2593 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2593 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2594 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2594 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2595 [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0]
2595 [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0]
2596 [log.user|user: User Name <user@hostname>]
2596 [log.user|user: User Name <user@hostname>]
2597 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2597 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2598 [ui.debug log.files|files+: a]
2598 [ui.debug log.files|files+: a]
2599 [ui.debug log.extra|extra: branch=default]
2599 [ui.debug log.extra|extra: branch=default]
2600 [ui.note log.description|description:]
2600 [ui.note log.description|description:]
2601 [ui.note log.description|line 1
2601 [ui.note log.description|line 1
2602 line 2]
2602 line 2]
2603
2603
2604
2604
2605 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2605 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2606 [log.bisect bisect.good|bisect: good]
2606 [log.bisect bisect.good|bisect: good]
2607 [log.phase|phase: public]
2607 [log.phase|phase: public]
2608 [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2608 [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2609 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2609 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2610 [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55]
2610 [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55]
2611 [log.user|user: A. N. Other <other@place>]
2611 [log.user|user: A. N. Other <other@place>]
2612 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2612 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2613 [ui.debug log.files|files+: b]
2613 [ui.debug log.files|files+: b]
2614 [ui.debug log.extra|extra: branch=default]
2614 [ui.debug log.extra|extra: branch=default]
2615 [ui.note log.description|description:]
2615 [ui.note log.description|description:]
2616 [ui.note log.description|other 1
2616 [ui.note log.description|other 1
2617 other 2
2617 other 2
2618
2618
2619 other 3]
2619 other 3]
2620
2620
2621
2621
2622 [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465]
2622 [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465]
2623 [log.bisect bisect.untested|bisect: untested]
2623 [log.bisect bisect.untested|bisect: untested]
2624 [log.phase|phase: public]
2624 [log.phase|phase: public]
2625 [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2625 [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2626 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2626 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2627 [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1]
2627 [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1]
2628 [log.user|user: other@place]
2628 [log.user|user: other@place]
2629 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2629 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2630 [ui.debug log.files|files+: c]
2630 [ui.debug log.files|files+: c]
2631 [ui.debug log.extra|extra: branch=default]
2631 [ui.debug log.extra|extra: branch=default]
2632 [ui.note log.description|description:]
2632 [ui.note log.description|description:]
2633 [ui.note log.description|no person]
2633 [ui.note log.description|no person]
2634
2634
2635
2635
2636 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2636 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2637 [log.bisect bisect.bad|bisect: bad]
2637 [log.bisect bisect.bad|bisect: bad]
2638 [log.phase|phase: public]
2638 [log.phase|phase: public]
2639 [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465]
2639 [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465]
2640 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2640 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2641 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2641 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2642 [log.user|user: person]
2642 [log.user|user: person]
2643 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2643 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2644 [ui.debug log.files|files: c]
2644 [ui.debug log.files|files: c]
2645 [ui.debug log.extra|extra: branch=default]
2645 [ui.debug log.extra|extra: branch=default]
2646 [ui.note log.description|description:]
2646 [ui.note log.description|description:]
2647 [ui.note log.description|no user, no domain]
2647 [ui.note log.description|no user, no domain]
2648
2648
2649
2649
2650 [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74]
2650 [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74]
2651 [log.bisect bisect.bad|bisect: bad (implicit)]
2651 [log.bisect bisect.bad|bisect: bad (implicit)]
2652 [log.branch|branch: foo]
2652 [log.branch|branch: foo]
2653 [log.phase|phase: draft]
2653 [log.phase|phase: draft]
2654 [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2654 [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2655 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2655 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2656 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2656 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2657 [log.user|user: person]
2657 [log.user|user: person]
2658 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2658 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2659 [ui.debug log.extra|extra: branch=foo]
2659 [ui.debug log.extra|extra: branch=foo]
2660 [ui.note log.description|description:]
2660 [ui.note log.description|description:]
2661 [ui.note log.description|new branch]
2661 [ui.note log.description|new branch]
2662
2662
2663
2663
2664 $ hg --color=debug log -v -T bisect -r 0:4
2664 $ hg --color=debug log -v -T bisect -r 0:4
2665 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2665 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2666 [log.bisect bisect.good|bisect: good (implicit)]
2666 [log.bisect bisect.good|bisect: good (implicit)]
2667 [log.user|user: User Name <user@hostname>]
2667 [log.user|user: User Name <user@hostname>]
2668 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2668 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2669 [ui.note log.files|files: a]
2669 [ui.note log.files|files: a]
2670 [ui.note log.description|description:]
2670 [ui.note log.description|description:]
2671 [ui.note log.description|line 1
2671 [ui.note log.description|line 1
2672 line 2]
2672 line 2]
2673
2673
2674
2674
2675 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2675 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2676 [log.bisect bisect.good|bisect: good]
2676 [log.bisect bisect.good|bisect: good]
2677 [log.user|user: A. N. Other <other@place>]
2677 [log.user|user: A. N. Other <other@place>]
2678 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2678 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2679 [ui.note log.files|files: b]
2679 [ui.note log.files|files: b]
2680 [ui.note log.description|description:]
2680 [ui.note log.description|description:]
2681 [ui.note log.description|other 1
2681 [ui.note log.description|other 1
2682 other 2
2682 other 2
2683
2683
2684 other 3]
2684 other 3]
2685
2685
2686
2686
2687 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2687 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2688 [log.bisect bisect.untested|bisect: untested]
2688 [log.bisect bisect.untested|bisect: untested]
2689 [log.user|user: other@place]
2689 [log.user|user: other@place]
2690 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2690 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2691 [ui.note log.files|files: c]
2691 [ui.note log.files|files: c]
2692 [ui.note log.description|description:]
2692 [ui.note log.description|description:]
2693 [ui.note log.description|no person]
2693 [ui.note log.description|no person]
2694
2694
2695
2695
2696 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2696 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2697 [log.bisect bisect.bad|bisect: bad]
2697 [log.bisect bisect.bad|bisect: bad]
2698 [log.user|user: person]
2698 [log.user|user: person]
2699 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2699 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2700 [ui.note log.files|files: c]
2700 [ui.note log.files|files: c]
2701 [ui.note log.description|description:]
2701 [ui.note log.description|description:]
2702 [ui.note log.description|no user, no domain]
2702 [ui.note log.description|no user, no domain]
2703
2703
2704
2704
2705 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2705 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2706 [log.bisect bisect.bad|bisect: bad (implicit)]
2706 [log.bisect bisect.bad|bisect: bad (implicit)]
2707 [log.branch|branch: foo]
2707 [log.branch|branch: foo]
2708 [log.user|user: person]
2708 [log.user|user: person]
2709 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2709 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2710 [ui.note log.description|description:]
2710 [ui.note log.description|description:]
2711 [ui.note log.description|new branch]
2711 [ui.note log.description|new branch]
2712
2712
2713
2713
2714 $ hg bisect --reset
2714 $ hg bisect --reset
2715
2715
2716 Error on syntax:
2716 Error on syntax:
2717
2717
2718 $ echo 'x = "f' >> t
2718 $ echo 'x = "f' >> t
2719 $ hg log
2719 $ hg log
2720 hg: parse error at t:3: unmatched quotes
2720 hg: parse error at t:3: unmatched quotes
2721 [255]
2721 [255]
2722
2722
2723 $ hg log -T '{date'
2723 $ hg log -T '{date'
2724 hg: parse error at 1: unterminated template expansion
2724 hg: parse error at 1: unterminated template expansion
2725 [255]
2725 [255]
2726
2726
2727 Behind the scenes, this will throw TypeError
2727 Behind the scenes, this will throw TypeError
2728
2728
2729 $ hg log -l 3 --template '{date|obfuscate}\n'
2729 $ hg log -l 3 --template '{date|obfuscate}\n'
2730 abort: template filter 'obfuscate' is not compatible with keyword 'date'
2730 abort: template filter 'obfuscate' is not compatible with keyword 'date'
2731 [255]
2731 [255]
2732
2732
2733 Behind the scenes, this will throw a ValueError
2733 Behind the scenes, this will throw a ValueError
2734
2734
2735 $ hg log -l 3 --template 'line: {desc|shortdate}\n'
2735 $ hg log -l 3 --template 'line: {desc|shortdate}\n'
2736 abort: template filter 'shortdate' is not compatible with keyword 'desc'
2736 abort: template filter 'shortdate' is not compatible with keyword 'desc'
2737 [255]
2737 [255]
2738
2738
2739 Behind the scenes, this will throw AttributeError
2739 Behind the scenes, this will throw AttributeError
2740
2740
2741 $ hg log -l 3 --template 'line: {date|escape}\n'
2741 $ hg log -l 3 --template 'line: {date|escape}\n'
2742 abort: template filter 'escape' is not compatible with keyword 'date'
2742 abort: template filter 'escape' is not compatible with keyword 'date'
2743 [255]
2743 [255]
2744
2744
2745 $ hg log -l 3 --template 'line: {extras|localdate}\n'
2745 $ hg log -l 3 --template 'line: {extras|localdate}\n'
2746 hg: parse error: localdate expects a date information
2746 hg: parse error: localdate expects a date information
2747 [255]
2747 [255]
2748
2748
2749 Behind the scenes, this will throw ValueError
2749 Behind the scenes, this will throw ValueError
2750
2750
2751 $ hg tip --template '{author|email|date}\n'
2751 $ hg tip --template '{author|email|date}\n'
2752 hg: parse error: date expects a date information
2752 hg: parse error: date expects a date information
2753 [255]
2753 [255]
2754
2754
2755 $ hg tip -T '{author|email|shortdate}\n'
2755 $ hg tip -T '{author|email|shortdate}\n'
2756 abort: template filter 'shortdate' is not compatible with keyword 'author'
2756 abort: template filter 'shortdate' is not compatible with keyword 'author'
2757 [255]
2757 [255]
2758
2758
2759 $ hg tip -T '{get(extras, "branch")|shortdate}\n'
2759 $ hg tip -T '{get(extras, "branch")|shortdate}\n'
2760 abort: incompatible use of template filter 'shortdate'
2760 abort: incompatible use of template filter 'shortdate'
2761 [255]
2761 [255]
2762
2762
2763 Error in nested template:
2763 Error in nested template:
2764
2764
2765 $ hg log -T '{"date'
2765 $ hg log -T '{"date'
2766 hg: parse error at 2: unterminated string
2766 hg: parse error at 2: unterminated string
2767 [255]
2767 [255]
2768
2768
2769 $ hg log -T '{"foo{date|?}"}'
2769 $ hg log -T '{"foo{date|?}"}'
2770 hg: parse error at 11: syntax error
2770 hg: parse error at 11: syntax error
2771 [255]
2771 [255]
2772
2772
2773 Thrown an error if a template function doesn't exist
2773 Thrown an error if a template function doesn't exist
2774
2774
2775 $ hg tip --template '{foo()}\n'
2775 $ hg tip --template '{foo()}\n'
2776 hg: parse error: unknown function 'foo'
2776 hg: parse error: unknown function 'foo'
2777 [255]
2777 [255]
2778
2778
2779 Pass generator object created by template function to filter
2779 Pass generator object created by template function to filter
2780
2780
2781 $ hg log -l 1 --template '{if(author, author)|user}\n'
2781 $ hg log -l 1 --template '{if(author, author)|user}\n'
2782 test
2782 test
2783
2783
2784 Test index keyword:
2784 Test index keyword:
2785
2785
2786 $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n'
2786 $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n'
2787 10 0:a 1:b 2:fifth 3:fourth 4:third
2787 10 0:a 1:b 2:fifth 3:fourth 4:third
2788 11 0:a
2788 11 0:a
2789
2789
2790 $ hg branches -T '{index} {branch}\n'
2790 $ hg branches -T '{index} {branch}\n'
2791 0 default
2791 0 default
2792 1 foo
2792 1 foo
2793
2793
2794 Test diff function:
2794 Test diff function:
2795
2795
2796 $ hg diff -c 8
2796 $ hg diff -c 8
2797 diff -r 29114dbae42b -r 95c24699272e fourth
2797 diff -r 29114dbae42b -r 95c24699272e fourth
2798 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2798 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2799 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2799 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2800 @@ -0,0 +1,1 @@
2800 @@ -0,0 +1,1 @@
2801 +second
2801 +second
2802 diff -r 29114dbae42b -r 95c24699272e second
2802 diff -r 29114dbae42b -r 95c24699272e second
2803 --- a/second Mon Jan 12 13:46:40 1970 +0000
2803 --- a/second Mon Jan 12 13:46:40 1970 +0000
2804 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2804 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2805 @@ -1,1 +0,0 @@
2805 @@ -1,1 +0,0 @@
2806 -second
2806 -second
2807 diff -r 29114dbae42b -r 95c24699272e third
2807 diff -r 29114dbae42b -r 95c24699272e third
2808 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2808 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2809 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2809 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2810 @@ -0,0 +1,1 @@
2810 @@ -0,0 +1,1 @@
2811 +third
2811 +third
2812
2812
2813 $ hg log -r 8 -T "{diff()}"
2813 $ hg log -r 8 -T "{diff()}"
2814 diff -r 29114dbae42b -r 95c24699272e fourth
2814 diff -r 29114dbae42b -r 95c24699272e fourth
2815 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2815 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2816 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2816 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2817 @@ -0,0 +1,1 @@
2817 @@ -0,0 +1,1 @@
2818 +second
2818 +second
2819 diff -r 29114dbae42b -r 95c24699272e second
2819 diff -r 29114dbae42b -r 95c24699272e second
2820 --- a/second Mon Jan 12 13:46:40 1970 +0000
2820 --- a/second Mon Jan 12 13:46:40 1970 +0000
2821 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2821 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2822 @@ -1,1 +0,0 @@
2822 @@ -1,1 +0,0 @@
2823 -second
2823 -second
2824 diff -r 29114dbae42b -r 95c24699272e third
2824 diff -r 29114dbae42b -r 95c24699272e third
2825 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2825 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2826 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2826 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2827 @@ -0,0 +1,1 @@
2827 @@ -0,0 +1,1 @@
2828 +third
2828 +third
2829
2829
2830 $ hg log -r 8 -T "{diff('glob:f*')}"
2830 $ hg log -r 8 -T "{diff('glob:f*')}"
2831 diff -r 29114dbae42b -r 95c24699272e fourth
2831 diff -r 29114dbae42b -r 95c24699272e fourth
2832 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2832 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2833 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2833 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2834 @@ -0,0 +1,1 @@
2834 @@ -0,0 +1,1 @@
2835 +second
2835 +second
2836
2836
2837 $ hg log -r 8 -T "{diff('', 'glob:f*')}"
2837 $ hg log -r 8 -T "{diff('', 'glob:f*')}"
2838 diff -r 29114dbae42b -r 95c24699272e second
2838 diff -r 29114dbae42b -r 95c24699272e second
2839 --- a/second Mon Jan 12 13:46:40 1970 +0000
2839 --- a/second Mon Jan 12 13:46:40 1970 +0000
2840 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2840 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2841 @@ -1,1 +0,0 @@
2841 @@ -1,1 +0,0 @@
2842 -second
2842 -second
2843 diff -r 29114dbae42b -r 95c24699272e third
2843 diff -r 29114dbae42b -r 95c24699272e third
2844 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2844 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2845 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2845 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2846 @@ -0,0 +1,1 @@
2846 @@ -0,0 +1,1 @@
2847 +third
2847 +third
2848
2848
2849 $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
2849 $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
2850 diff -r 29114dbae42b -r 95c24699272e fourth
2850 diff -r 29114dbae42b -r 95c24699272e fourth
2851 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2851 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2852 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2852 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2853 @@ -0,0 +1,1 @@
2853 @@ -0,0 +1,1 @@
2854 +second
2854 +second
2855
2855
2856 $ cd ..
2856 $ cd ..
2857
2857
2858
2858
2859 latesttag:
2859 latesttag:
2860
2860
2861 $ hg init latesttag
2861 $ hg init latesttag
2862 $ cd latesttag
2862 $ cd latesttag
2863
2863
2864 $ echo a > file
2864 $ echo a > file
2865 $ hg ci -Am a -d '0 0'
2865 $ hg ci -Am a -d '0 0'
2866 adding file
2866 adding file
2867
2867
2868 $ echo b >> file
2868 $ echo b >> file
2869 $ hg ci -m b -d '1 0'
2869 $ hg ci -m b -d '1 0'
2870
2870
2871 $ echo c >> head1
2871 $ echo c >> head1
2872 $ hg ci -Am h1c -d '2 0'
2872 $ hg ci -Am h1c -d '2 0'
2873 adding head1
2873 adding head1
2874
2874
2875 $ hg update -q 1
2875 $ hg update -q 1
2876 $ echo d >> head2
2876 $ echo d >> head2
2877 $ hg ci -Am h2d -d '3 0'
2877 $ hg ci -Am h2d -d '3 0'
2878 adding head2
2878 adding head2
2879 created new head
2879 created new head
2880
2880
2881 $ echo e >> head2
2881 $ echo e >> head2
2882 $ hg ci -m h2e -d '4 0'
2882 $ hg ci -m h2e -d '4 0'
2883
2883
2884 $ hg merge -q
2884 $ hg merge -q
2885 $ hg ci -m merge -d '5 -3600'
2885 $ hg ci -m merge -d '5 -3600'
2886
2886
2887 No tag set:
2887 No tag set:
2888
2888
2889 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2889 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2890 @ 5: null+5
2890 @ 5: null+5
2891 |\
2891 |\
2892 | o 4: null+4
2892 | o 4: null+4
2893 | |
2893 | |
2894 | o 3: null+3
2894 | o 3: null+3
2895 | |
2895 | |
2896 o | 2: null+3
2896 o | 2: null+3
2897 |/
2897 |/
2898 o 1: null+2
2898 o 1: null+2
2899 |
2899 |
2900 o 0: null+1
2900 o 0: null+1
2901
2901
2902
2902
2903 One common tag: longest path wins for {latesttagdistance}:
2903 One common tag: longest path wins for {latesttagdistance}:
2904
2904
2905 $ hg tag -r 1 -m t1 -d '6 0' t1
2905 $ hg tag -r 1 -m t1 -d '6 0' t1
2906 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2906 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2907 @ 6: t1+4
2907 @ 6: t1+4
2908 |
2908 |
2909 o 5: t1+3
2909 o 5: t1+3
2910 |\
2910 |\
2911 | o 4: t1+2
2911 | o 4: t1+2
2912 | |
2912 | |
2913 | o 3: t1+1
2913 | o 3: t1+1
2914 | |
2914 | |
2915 o | 2: t1+1
2915 o | 2: t1+1
2916 |/
2916 |/
2917 o 1: t1+0
2917 o 1: t1+0
2918 |
2918 |
2919 o 0: null+1
2919 o 0: null+1
2920
2920
2921
2921
2922 One ancestor tag: closest wins:
2922 One ancestor tag: closest wins:
2923
2923
2924 $ hg tag -r 2 -m t2 -d '7 0' t2
2924 $ hg tag -r 2 -m t2 -d '7 0' t2
2925 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2925 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2926 @ 7: t2+3
2926 @ 7: t2+3
2927 |
2927 |
2928 o 6: t2+2
2928 o 6: t2+2
2929 |
2929 |
2930 o 5: t2+1
2930 o 5: t2+1
2931 |\
2931 |\
2932 | o 4: t1+2
2932 | o 4: t1+2
2933 | |
2933 | |
2934 | o 3: t1+1
2934 | o 3: t1+1
2935 | |
2935 | |
2936 o | 2: t2+0
2936 o | 2: t2+0
2937 |/
2937 |/
2938 o 1: t1+0
2938 o 1: t1+0
2939 |
2939 |
2940 o 0: null+1
2940 o 0: null+1
2941
2941
2942
2942
2943 Two branch tags: more recent wins if same number of changes:
2943 Two branch tags: more recent wins if same number of changes:
2944
2944
2945 $ hg tag -r 3 -m t3 -d '8 0' t3
2945 $ hg tag -r 3 -m t3 -d '8 0' t3
2946 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2946 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2947 @ 8: t3+5
2947 @ 8: t3+5
2948 |
2948 |
2949 o 7: t3+4
2949 o 7: t3+4
2950 |
2950 |
2951 o 6: t3+3
2951 o 6: t3+3
2952 |
2952 |
2953 o 5: t3+2
2953 o 5: t3+2
2954 |\
2954 |\
2955 | o 4: t3+1
2955 | o 4: t3+1
2956 | |
2956 | |
2957 | o 3: t3+0
2957 | o 3: t3+0
2958 | |
2958 | |
2959 o | 2: t2+0
2959 o | 2: t2+0
2960 |/
2960 |/
2961 o 1: t1+0
2961 o 1: t1+0
2962 |
2962 |
2963 o 0: null+1
2963 o 0: null+1
2964
2964
2965
2965
2966 Two branch tags: fewest changes wins:
2966 Two branch tags: fewest changes wins:
2967
2967
2968 $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
2968 $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
2969 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
2969 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
2970 @ 9: t4+5,6
2970 @ 9: t4+5,6
2971 |
2971 |
2972 o 8: t4+4,5
2972 o 8: t4+4,5
2973 |
2973 |
2974 o 7: t4+3,4
2974 o 7: t4+3,4
2975 |
2975 |
2976 o 6: t4+2,3
2976 o 6: t4+2,3
2977 |
2977 |
2978 o 5: t4+1,2
2978 o 5: t4+1,2
2979 |\
2979 |\
2980 | o 4: t4+0,0
2980 | o 4: t4+0,0
2981 | |
2981 | |
2982 | o 3: t3+0,0
2982 | o 3: t3+0,0
2983 | |
2983 | |
2984 o | 2: t2+0,0
2984 o | 2: t2+0,0
2985 |/
2985 |/
2986 o 1: t1+0,0
2986 o 1: t1+0,0
2987 |
2987 |
2988 o 0: null+1,1
2988 o 0: null+1,1
2989
2989
2990
2990
2991 Merged tag overrides:
2991 Merged tag overrides:
2992
2992
2993 $ hg tag -r 5 -m t5 -d '9 0' t5
2993 $ hg tag -r 5 -m t5 -d '9 0' t5
2994 $ hg tag -r 3 -m at3 -d '10 0' at3
2994 $ hg tag -r 3 -m at3 -d '10 0' at3
2995 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2995 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2996 @ 11: t5+6
2996 @ 11: t5+6
2997 |
2997 |
2998 o 10: t5+5
2998 o 10: t5+5
2999 |
2999 |
3000 o 9: t5+4
3000 o 9: t5+4
3001 |
3001 |
3002 o 8: t5+3
3002 o 8: t5+3
3003 |
3003 |
3004 o 7: t5+2
3004 o 7: t5+2
3005 |
3005 |
3006 o 6: t5+1
3006 o 6: t5+1
3007 |
3007 |
3008 o 5: t5+0
3008 o 5: t5+0
3009 |\
3009 |\
3010 | o 4: t4+0
3010 | o 4: t4+0
3011 | |
3011 | |
3012 | o 3: at3:t3+0
3012 | o 3: at3:t3+0
3013 | |
3013 | |
3014 o | 2: t2+0
3014 o | 2: t2+0
3015 |/
3015 |/
3016 o 1: t1+0
3016 o 1: t1+0
3017 |
3017 |
3018 o 0: null+1
3018 o 0: null+1
3019
3019
3020
3020
3021 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
3021 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
3022 @ 11: t5+6,6
3022 @ 11: t5+6,6
3023 |
3023 |
3024 o 10: t5+5,5
3024 o 10: t5+5,5
3025 |
3025 |
3026 o 9: t5+4,4
3026 o 9: t5+4,4
3027 |
3027 |
3028 o 8: t5+3,3
3028 o 8: t5+3,3
3029 |
3029 |
3030 o 7: t5+2,2
3030 o 7: t5+2,2
3031 |
3031 |
3032 o 6: t5+1,1
3032 o 6: t5+1,1
3033 |
3033 |
3034 o 5: t5+0,0
3034 o 5: t5+0,0
3035 |\
3035 |\
3036 | o 4: t4+0,0
3036 | o 4: t4+0,0
3037 | |
3037 | |
3038 | o 3: at3+0,0 t3+0,0
3038 | o 3: at3+0,0 t3+0,0
3039 | |
3039 | |
3040 o | 2: t2+0,0
3040 o | 2: t2+0,0
3041 |/
3041 |/
3042 o 1: t1+0,0
3042 o 1: t1+0,0
3043 |
3043 |
3044 o 0: null+1,1
3044 o 0: null+1,1
3045
3045
3046
3046
3047 $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n"
3047 $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n"
3048 @ 11: t3, C: 9, D: 8
3048 @ 11: t3, C: 9, D: 8
3049 |
3049 |
3050 o 10: t3, C: 8, D: 7
3050 o 10: t3, C: 8, D: 7
3051 |
3051 |
3052 o 9: t3, C: 7, D: 6
3052 o 9: t3, C: 7, D: 6
3053 |
3053 |
3054 o 8: t3, C: 6, D: 5
3054 o 8: t3, C: 6, D: 5
3055 |
3055 |
3056 o 7: t3, C: 5, D: 4
3056 o 7: t3, C: 5, D: 4
3057 |
3057 |
3058 o 6: t3, C: 4, D: 3
3058 o 6: t3, C: 4, D: 3
3059 |
3059 |
3060 o 5: t3, C: 3, D: 2
3060 o 5: t3, C: 3, D: 2
3061 |\
3061 |\
3062 | o 4: t3, C: 1, D: 1
3062 | o 4: t3, C: 1, D: 1
3063 | |
3063 | |
3064 | o 3: t3, C: 0, D: 0
3064 | o 3: t3, C: 0, D: 0
3065 | |
3065 | |
3066 o | 2: t1, C: 1, D: 1
3066 o | 2: t1, C: 1, D: 1
3067 |/
3067 |/
3068 o 1: t1, C: 0, D: 0
3068 o 1: t1, C: 0, D: 0
3069 |
3069 |
3070 o 0: null, C: 1, D: 1
3070 o 0: null, C: 1, D: 1
3071
3071
3072
3072
3073 $ cd ..
3073 $ cd ..
3074
3074
3075
3075
3076 Style path expansion: issue1948 - ui.style option doesn't work on OSX
3076 Style path expansion: issue1948 - ui.style option doesn't work on OSX
3077 if it is a relative path
3077 if it is a relative path
3078
3078
3079 $ mkdir -p home/styles
3079 $ mkdir -p home/styles
3080
3080
3081 $ cat > home/styles/teststyle <<EOF
3081 $ cat > home/styles/teststyle <<EOF
3082 > changeset = 'test {rev}:{node|short}\n'
3082 > changeset = 'test {rev}:{node|short}\n'
3083 > EOF
3083 > EOF
3084
3084
3085 $ HOME=`pwd`/home; export HOME
3085 $ HOME=`pwd`/home; export HOME
3086
3086
3087 $ cat > latesttag/.hg/hgrc <<EOF
3087 $ cat > latesttag/.hg/hgrc <<EOF
3088 > [ui]
3088 > [ui]
3089 > style = ~/styles/teststyle
3089 > style = ~/styles/teststyle
3090 > EOF
3090 > EOF
3091
3091
3092 $ hg -R latesttag tip
3092 $ hg -R latesttag tip
3093 test 11:97e5943b523a
3093 test 11:97e5943b523a
3094
3094
3095 Test recursive showlist template (issue1989):
3095 Test recursive showlist template (issue1989):
3096
3096
3097 $ cat > style1989 <<EOF
3097 $ cat > style1989 <<EOF
3098 > changeset = '{file_mods}{manifest}{extras}'
3098 > changeset = '{file_mods}{manifest}{extras}'
3099 > file_mod = 'M|{author|person}\n'
3099 > file_mod = 'M|{author|person}\n'
3100 > manifest = '{rev},{author}\n'
3100 > manifest = '{rev},{author}\n'
3101 > extra = '{key}: {author}\n'
3101 > extra = '{key}: {author}\n'
3102 > EOF
3102 > EOF
3103
3103
3104 $ hg -R latesttag log -r tip --style=style1989
3104 $ hg -R latesttag log -r tip --style=style1989
3105 M|test
3105 M|test
3106 11,test
3106 11,test
3107 branch: test
3107 branch: test
3108
3108
3109 Test new-style inline templating:
3109 Test new-style inline templating:
3110
3110
3111 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
3111 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
3112 modified files: .hgtags
3112 modified files: .hgtags
3113
3113
3114
3114
3115 $ hg log -R latesttag -r tip -T '{rev % "a"}\n'
3115 $ hg log -R latesttag -r tip -T '{rev % "a"}\n'
3116 hg: parse error: keyword 'rev' is not iterable
3116 hg: parse error: keyword 'rev' is not iterable
3117 [255]
3117 [255]
3118 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n'
3118 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n'
3119 hg: parse error: None is not iterable
3119 hg: parse error: None is not iterable
3120 [255]
3120 [255]
3121
3121
3122 Test new-style inline templating of non-list/dict type:
3122 Test new-style inline templating of non-list/dict type:
3123
3123
3124 $ hg log -R latesttag -r tip -T '{manifest}\n'
3124 $ hg log -R latesttag -r tip -T '{manifest}\n'
3125 11:2bc6e9006ce2
3125 11:2bc6e9006ce2
3126 $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n'
3126 $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n'
3127 string length: 15
3127 string length: 15
3128 $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n'
3128 $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n'
3129 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc
3129 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc
3130
3130
3131 $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}'
3131 $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}'
3132 branch: default
3132 branch: default
3133 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}'
3133 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}'
3134 hg: parse error: None is not iterable
3134 hg: parse error: None is not iterable
3135 [255]
3135 [255]
3136 $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}'
3136 $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}'
3137 branch: default
3137 branch: default
3138 $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}'
3138 $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}'
3139 0:ce3cec86e6c2
3139 0:ce3cec86e6c2
3140 $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}'
3140 $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}'
3141 9:fbc7cd862e9c
3141 9:fbc7cd862e9c
3142
3142
3143 Test manifest/get() can be join()-ed as before, though it's silly:
3143 Test manifest/get() can be join()-ed as before, though it's silly:
3144
3144
3145 $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n'
3145 $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n'
3146 11:2bc6e9006ce2
3146 11:2bc6e9006ce2
3147 $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n'
3147 $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n'
3148 default
3148 default
3149
3149
3150 Test min/max of integers
3151
3152 $ hg log -R latesttag -l1 -T '{min(revset("9:10"))}\n'
3153 9
3154 $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n'
3155 10
3156
3150 Test dot operator precedence:
3157 Test dot operator precedence:
3151
3158
3152 $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n'
3159 $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n'
3153 (template
3160 (template
3154 (|
3161 (|
3155 (.
3162 (.
3156 (symbol 'manifest')
3163 (symbol 'manifest')
3157 (symbol 'node'))
3164 (symbol 'node'))
3158 (symbol 'short'))
3165 (symbol 'short'))
3159 (string '\n'))
3166 (string '\n'))
3160 89f4071fec70
3167 89f4071fec70
3161
3168
3162 (the following examples are invalid, but seem natural in parsing POV)
3169 (the following examples are invalid, but seem natural in parsing POV)
3163
3170
3164 $ hg debugtemplate -R latesttag -r0 -v '{foo|bar.baz}\n' 2> /dev/null
3171 $ hg debugtemplate -R latesttag -r0 -v '{foo|bar.baz}\n' 2> /dev/null
3165 (template
3172 (template
3166 (|
3173 (|
3167 (symbol 'foo')
3174 (symbol 'foo')
3168 (.
3175 (.
3169 (symbol 'bar')
3176 (symbol 'bar')
3170 (symbol 'baz')))
3177 (symbol 'baz')))
3171 (string '\n'))
3178 (string '\n'))
3172 [255]
3179 [255]
3173 $ hg debugtemplate -R latesttag -r0 -v '{foo.bar()}\n' 2> /dev/null
3180 $ hg debugtemplate -R latesttag -r0 -v '{foo.bar()}\n' 2> /dev/null
3174 (template
3181 (template
3175 (.
3182 (.
3176 (symbol 'foo')
3183 (symbol 'foo')
3177 (func
3184 (func
3178 (symbol 'bar')
3185 (symbol 'bar')
3179 None))
3186 None))
3180 (string '\n'))
3187 (string '\n'))
3181 [255]
3188 [255]
3182
3189
3183 Test evaluation of dot operator:
3190 Test evaluation of dot operator:
3184
3191
3185 $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n'
3192 $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n'
3186 ce3cec86e6c26bd9bdfc590a6b92abc9680f1796
3193 ce3cec86e6c26bd9bdfc590a6b92abc9680f1796
3187 $ hg log -R latesttag -r0 -T '{extras.branch}\n'
3194 $ hg log -R latesttag -r0 -T '{extras.branch}\n'
3188 default
3195 default
3189
3196
3190 $ hg log -R latesttag -l1 -T '{author.invalid}\n'
3197 $ hg log -R latesttag -l1 -T '{author.invalid}\n'
3191 hg: parse error: keyword 'author' has no member
3198 hg: parse error: keyword 'author' has no member
3192 [255]
3199 [255]
3193 $ hg log -R latesttag -l1 -T '{min("abc").invalid}\n'
3200 $ hg log -R latesttag -l1 -T '{min("abc").invalid}\n'
3194 hg: parse error: 'a' has no member
3201 hg: parse error: 'a' has no member
3195 [255]
3202 [255]
3196
3203
3197 Test the sub function of templating for expansion:
3204 Test the sub function of templating for expansion:
3198
3205
3199 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
3206 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
3200 xx
3207 xx
3201
3208
3202 $ hg log -R latesttag -r 10 -T '{sub("[", "x", rev)}\n'
3209 $ hg log -R latesttag -r 10 -T '{sub("[", "x", rev)}\n'
3203 hg: parse error: sub got an invalid pattern: [
3210 hg: parse error: sub got an invalid pattern: [
3204 [255]
3211 [255]
3205 $ hg log -R latesttag -r 10 -T '{sub("[0-9]", r"\1", rev)}\n'
3212 $ hg log -R latesttag -r 10 -T '{sub("[0-9]", r"\1", rev)}\n'
3206 hg: parse error: sub got an invalid replacement: \1
3213 hg: parse error: sub got an invalid replacement: \1
3207 [255]
3214 [255]
3208
3215
3209 Test the strip function with chars specified:
3216 Test the strip function with chars specified:
3210
3217
3211 $ hg log -R latesttag --template '{desc}\n'
3218 $ hg log -R latesttag --template '{desc}\n'
3212 at3
3219 at3
3213 t5
3220 t5
3214 t4
3221 t4
3215 t3
3222 t3
3216 t2
3223 t2
3217 t1
3224 t1
3218 merge
3225 merge
3219 h2e
3226 h2e
3220 h2d
3227 h2d
3221 h1c
3228 h1c
3222 b
3229 b
3223 a
3230 a
3224
3231
3225 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
3232 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
3226 at3
3233 at3
3227 5
3234 5
3228 4
3235 4
3229 3
3236 3
3230 2
3237 2
3231 1
3238 1
3232 merg
3239 merg
3233 h2
3240 h2
3234 h2d
3241 h2d
3235 h1c
3242 h1c
3236 b
3243 b
3237 a
3244 a
3238
3245
3239 Test date format:
3246 Test date format:
3240
3247
3241 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
3248 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
3242 date: 70 01 01 10 +0000
3249 date: 70 01 01 10 +0000
3243 date: 70 01 01 09 +0000
3250 date: 70 01 01 09 +0000
3244 date: 70 01 01 04 +0000
3251 date: 70 01 01 04 +0000
3245 date: 70 01 01 08 +0000
3252 date: 70 01 01 08 +0000
3246 date: 70 01 01 07 +0000
3253 date: 70 01 01 07 +0000
3247 date: 70 01 01 06 +0000
3254 date: 70 01 01 06 +0000
3248 date: 70 01 01 05 +0100
3255 date: 70 01 01 05 +0100
3249 date: 70 01 01 04 +0000
3256 date: 70 01 01 04 +0000
3250 date: 70 01 01 03 +0000
3257 date: 70 01 01 03 +0000
3251 date: 70 01 01 02 +0000
3258 date: 70 01 01 02 +0000
3252 date: 70 01 01 01 +0000
3259 date: 70 01 01 01 +0000
3253 date: 70 01 01 00 +0000
3260 date: 70 01 01 00 +0000
3254
3261
3255 Test invalid date:
3262 Test invalid date:
3256
3263
3257 $ hg log -R latesttag -T '{date(rev)}\n'
3264 $ hg log -R latesttag -T '{date(rev)}\n'
3258 hg: parse error: date expects a date information
3265 hg: parse error: date expects a date information
3259 [255]
3266 [255]
3260
3267
3261 Test integer literal:
3268 Test integer literal:
3262
3269
3263 $ hg debugtemplate -v '{(0)}\n'
3270 $ hg debugtemplate -v '{(0)}\n'
3264 (template
3271 (template
3265 (group
3272 (group
3266 (integer '0'))
3273 (integer '0'))
3267 (string '\n'))
3274 (string '\n'))
3268 0
3275 0
3269 $ hg debugtemplate -v '{(123)}\n'
3276 $ hg debugtemplate -v '{(123)}\n'
3270 (template
3277 (template
3271 (group
3278 (group
3272 (integer '123'))
3279 (integer '123'))
3273 (string '\n'))
3280 (string '\n'))
3274 123
3281 123
3275 $ hg debugtemplate -v '{(-4)}\n'
3282 $ hg debugtemplate -v '{(-4)}\n'
3276 (template
3283 (template
3277 (group
3284 (group
3278 (negate
3285 (negate
3279 (integer '4')))
3286 (integer '4')))
3280 (string '\n'))
3287 (string '\n'))
3281 -4
3288 -4
3282 $ hg debugtemplate '{(-)}\n'
3289 $ hg debugtemplate '{(-)}\n'
3283 hg: parse error at 3: not a prefix: )
3290 hg: parse error at 3: not a prefix: )
3284 [255]
3291 [255]
3285 $ hg debugtemplate '{(-a)}\n'
3292 $ hg debugtemplate '{(-a)}\n'
3286 hg: parse error: negation needs an integer argument
3293 hg: parse error: negation needs an integer argument
3287 [255]
3294 [255]
3288
3295
3289 top-level integer literal is interpreted as symbol (i.e. variable name):
3296 top-level integer literal is interpreted as symbol (i.e. variable name):
3290
3297
3291 $ hg debugtemplate -D 1=one -v '{1}\n'
3298 $ hg debugtemplate -D 1=one -v '{1}\n'
3292 (template
3299 (template
3293 (integer '1')
3300 (integer '1')
3294 (string '\n'))
3301 (string '\n'))
3295 one
3302 one
3296 $ hg debugtemplate -D 1=one -v '{if("t", "{1}")}\n'
3303 $ hg debugtemplate -D 1=one -v '{if("t", "{1}")}\n'
3297 (template
3304 (template
3298 (func
3305 (func
3299 (symbol 'if')
3306 (symbol 'if')
3300 (list
3307 (list
3301 (string 't')
3308 (string 't')
3302 (template
3309 (template
3303 (integer '1'))))
3310 (integer '1'))))
3304 (string '\n'))
3311 (string '\n'))
3305 one
3312 one
3306 $ hg debugtemplate -D 1=one -v '{1|stringify}\n'
3313 $ hg debugtemplate -D 1=one -v '{1|stringify}\n'
3307 (template
3314 (template
3308 (|
3315 (|
3309 (integer '1')
3316 (integer '1')
3310 (symbol 'stringify'))
3317 (symbol 'stringify'))
3311 (string '\n'))
3318 (string '\n'))
3312 one
3319 one
3313
3320
3314 unless explicit symbol is expected:
3321 unless explicit symbol is expected:
3315
3322
3316 $ hg log -Ra -r0 -T '{desc|1}\n'
3323 $ hg log -Ra -r0 -T '{desc|1}\n'
3317 hg: parse error: expected a symbol, got 'integer'
3324 hg: parse error: expected a symbol, got 'integer'
3318 [255]
3325 [255]
3319 $ hg log -Ra -r0 -T '{1()}\n'
3326 $ hg log -Ra -r0 -T '{1()}\n'
3320 hg: parse error: expected a symbol, got 'integer'
3327 hg: parse error: expected a symbol, got 'integer'
3321 [255]
3328 [255]
3322
3329
3323 Test string literal:
3330 Test string literal:
3324
3331
3325 $ hg debugtemplate -Ra -r0 -v '{"string with no template fragment"}\n'
3332 $ hg debugtemplate -Ra -r0 -v '{"string with no template fragment"}\n'
3326 (template
3333 (template
3327 (string 'string with no template fragment')
3334 (string 'string with no template fragment')
3328 (string '\n'))
3335 (string '\n'))
3329 string with no template fragment
3336 string with no template fragment
3330 $ hg debugtemplate -Ra -r0 -v '{"template: {rev}"}\n'
3337 $ hg debugtemplate -Ra -r0 -v '{"template: {rev}"}\n'
3331 (template
3338 (template
3332 (template
3339 (template
3333 (string 'template: ')
3340 (string 'template: ')
3334 (symbol 'rev'))
3341 (symbol 'rev'))
3335 (string '\n'))
3342 (string '\n'))
3336 template: 0
3343 template: 0
3337 $ hg debugtemplate -Ra -r0 -v '{r"rawstring: {rev}"}\n'
3344 $ hg debugtemplate -Ra -r0 -v '{r"rawstring: {rev}"}\n'
3338 (template
3345 (template
3339 (string 'rawstring: {rev}')
3346 (string 'rawstring: {rev}')
3340 (string '\n'))
3347 (string '\n'))
3341 rawstring: {rev}
3348 rawstring: {rev}
3342 $ hg debugtemplate -Ra -r0 -v '{files % r"rawstring: {file}"}\n'
3349 $ hg debugtemplate -Ra -r0 -v '{files % r"rawstring: {file}"}\n'
3343 (template
3350 (template
3344 (%
3351 (%
3345 (symbol 'files')
3352 (symbol 'files')
3346 (string 'rawstring: {file}'))
3353 (string 'rawstring: {file}'))
3347 (string '\n'))
3354 (string '\n'))
3348 rawstring: {file}
3355 rawstring: {file}
3349
3356
3350 Test string escaping:
3357 Test string escaping:
3351
3358
3352 $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3359 $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3353 >
3360 >
3354 <>\n<[>
3361 <>\n<[>
3355 <>\n<]>
3362 <>\n<]>
3356 <>\n<
3363 <>\n<
3357
3364
3358 $ hg log -R latesttag -r 0 \
3365 $ hg log -R latesttag -r 0 \
3359 > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3366 > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3360 >
3367 >
3361 <>\n<[>
3368 <>\n<[>
3362 <>\n<]>
3369 <>\n<]>
3363 <>\n<
3370 <>\n<
3364
3371
3365 $ hg log -R latesttag -r 0 -T esc \
3372 $ hg log -R latesttag -r 0 -T esc \
3366 > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3373 > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3367 >
3374 >
3368 <>\n<[>
3375 <>\n<[>
3369 <>\n<]>
3376 <>\n<]>
3370 <>\n<
3377 <>\n<
3371
3378
3372 $ cat <<'EOF' > esctmpl
3379 $ cat <<'EOF' > esctmpl
3373 > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3380 > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3374 > EOF
3381 > EOF
3375 $ hg log -R latesttag -r 0 --style ./esctmpl
3382 $ hg log -R latesttag -r 0 --style ./esctmpl
3376 >
3383 >
3377 <>\n<[>
3384 <>\n<[>
3378 <>\n<]>
3385 <>\n<]>
3379 <>\n<
3386 <>\n<
3380
3387
3381 Test string escaping of quotes:
3388 Test string escaping of quotes:
3382
3389
3383 $ hg log -Ra -r0 -T '{"\""}\n'
3390 $ hg log -Ra -r0 -T '{"\""}\n'
3384 "
3391 "
3385 $ hg log -Ra -r0 -T '{"\\\""}\n'
3392 $ hg log -Ra -r0 -T '{"\\\""}\n'
3386 \"
3393 \"
3387 $ hg log -Ra -r0 -T '{r"\""}\n'
3394 $ hg log -Ra -r0 -T '{r"\""}\n'
3388 \"
3395 \"
3389 $ hg log -Ra -r0 -T '{r"\\\""}\n'
3396 $ hg log -Ra -r0 -T '{r"\\\""}\n'
3390 \\\"
3397 \\\"
3391
3398
3392
3399
3393 $ hg log -Ra -r0 -T '{"\""}\n'
3400 $ hg log -Ra -r0 -T '{"\""}\n'
3394 "
3401 "
3395 $ hg log -Ra -r0 -T '{"\\\""}\n'
3402 $ hg log -Ra -r0 -T '{"\\\""}\n'
3396 \"
3403 \"
3397 $ hg log -Ra -r0 -T '{r"\""}\n'
3404 $ hg log -Ra -r0 -T '{r"\""}\n'
3398 \"
3405 \"
3399 $ hg log -Ra -r0 -T '{r"\\\""}\n'
3406 $ hg log -Ra -r0 -T '{r"\\\""}\n'
3400 \\\"
3407 \\\"
3401
3408
3402 Test exception in quoted template. single backslash before quotation mark is
3409 Test exception in quoted template. single backslash before quotation mark is
3403 stripped before parsing:
3410 stripped before parsing:
3404
3411
3405 $ cat <<'EOF' > escquotetmpl
3412 $ cat <<'EOF' > escquotetmpl
3406 > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n"
3413 > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n"
3407 > EOF
3414 > EOF
3408 $ cd latesttag
3415 $ cd latesttag
3409 $ hg log -r 2 --style ../escquotetmpl
3416 $ hg log -r 2 --style ../escquotetmpl
3410 " \" \" \\" head1
3417 " \" \" \\" head1
3411
3418
3412 $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"'
3419 $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"'
3413 valid
3420 valid
3414 $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'"
3421 $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'"
3415 valid
3422 valid
3416
3423
3417 Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested
3424 Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested
3418 _evalifliteral() templates (issue4733):
3425 _evalifliteral() templates (issue4733):
3419
3426
3420 $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n'
3427 $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n'
3421 "2
3428 "2
3422 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n'
3429 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n'
3423 "2
3430 "2
3424 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n'
3431 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n'
3425 "2
3432 "2
3426
3433
3427 $ hg log -r 2 -T '{if(rev, "\\\"")}\n'
3434 $ hg log -r 2 -T '{if(rev, "\\\"")}\n'
3428 \"
3435 \"
3429 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n'
3436 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n'
3430 \"
3437 \"
3431 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
3438 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
3432 \"
3439 \"
3433
3440
3434 $ hg log -r 2 -T '{if(rev, r"\\\"")}\n'
3441 $ hg log -r 2 -T '{if(rev, r"\\\"")}\n'
3435 \\\"
3442 \\\"
3436 $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n'
3443 $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n'
3437 \\\"
3444 \\\"
3438 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
3445 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
3439 \\\"
3446 \\\"
3440
3447
3441 escaped single quotes and errors:
3448 escaped single quotes and errors:
3442
3449
3443 $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n'
3450 $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n'
3444 foo
3451 foo
3445 $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n'
3452 $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n'
3446 foo
3453 foo
3447 $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n'
3454 $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n'
3448 hg: parse error at 21: unterminated string
3455 hg: parse error at 21: unterminated string
3449 [255]
3456 [255]
3450 $ hg log -r 2 -T '{if(rev, \"\\"")}\n'
3457 $ hg log -r 2 -T '{if(rev, \"\\"")}\n'
3451 hg: parse error: trailing \ in string
3458 hg: parse error: trailing \ in string
3452 [255]
3459 [255]
3453 $ hg log -r 2 -T '{if(rev, r\"\\"")}\n'
3460 $ hg log -r 2 -T '{if(rev, r\"\\"")}\n'
3454 hg: parse error: trailing \ in string
3461 hg: parse error: trailing \ in string
3455 [255]
3462 [255]
3456
3463
3457 $ cd ..
3464 $ cd ..
3458
3465
3459 Test leading backslashes:
3466 Test leading backslashes:
3460
3467
3461 $ cd latesttag
3468 $ cd latesttag
3462 $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n'
3469 $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n'
3463 {rev} {file}
3470 {rev} {file}
3464 $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n'
3471 $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n'
3465 \2 \head1
3472 \2 \head1
3466 $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n'
3473 $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n'
3467 \{rev} \{file}
3474 \{rev} \{file}
3468 $ cd ..
3475 $ cd ..
3469
3476
3470 Test leading backslashes in "if" expression (issue4714):
3477 Test leading backslashes in "if" expression (issue4714):
3471
3478
3472 $ cd latesttag
3479 $ cd latesttag
3473 $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n'
3480 $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n'
3474 {rev} \{rev}
3481 {rev} \{rev}
3475 $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n'
3482 $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n'
3476 \2 \\{rev}
3483 \2 \\{rev}
3477 $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n'
3484 $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n'
3478 \{rev} \\\{rev}
3485 \{rev} \\\{rev}
3479 $ cd ..
3486 $ cd ..
3480
3487
3481 "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
3488 "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
3482
3489
3483 $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
3490 $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
3484 \x6e
3491 \x6e
3485 $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
3492 $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
3486 \x5c\x786e
3493 \x5c\x786e
3487 $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
3494 $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
3488 \x6e
3495 \x6e
3489 $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
3496 $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
3490 \x5c\x786e
3497 \x5c\x786e
3491
3498
3492 $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
3499 $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
3493 \x6e
3500 \x6e
3494 $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
3501 $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
3495 \x5c\x786e
3502 \x5c\x786e
3496 $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
3503 $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
3497 \x6e
3504 \x6e
3498 $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
3505 $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
3499 \x5c\x786e
3506 \x5c\x786e
3500
3507
3501 $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
3508 $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
3502 fourth
3509 fourth
3503 second
3510 second
3504 third
3511 third
3505 $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
3512 $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
3506 fourth\nsecond\nthird
3513 fourth\nsecond\nthird
3507
3514
3508 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
3515 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
3509 <p>
3516 <p>
3510 1st
3517 1st
3511 </p>
3518 </p>
3512 <p>
3519 <p>
3513 2nd
3520 2nd
3514 </p>
3521 </p>
3515 $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
3522 $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
3516 <p>
3523 <p>
3517 1st\n\n2nd
3524 1st\n\n2nd
3518 </p>
3525 </p>
3519 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
3526 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
3520 1st
3527 1st
3521
3528
3522 2nd
3529 2nd
3523
3530
3524 $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
3531 $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
3525 o perso
3532 o perso
3526 $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
3533 $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
3527 no person
3534 no person
3528 $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
3535 $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
3529 o perso
3536 o perso
3530 $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
3537 $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
3531 no perso
3538 no perso
3532
3539
3533 $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
3540 $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
3534 -o perso-
3541 -o perso-
3535 $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
3542 $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
3536 no person
3543 no person
3537 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
3544 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
3538 \x2do perso\x2d
3545 \x2do perso\x2d
3539 $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
3546 $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
3540 -o perso-
3547 -o perso-
3541 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
3548 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
3542 \x2do perso\x6e
3549 \x2do perso\x6e
3543
3550
3544 $ hg log -R a -r 8 --template '{files % "{file}\n"}'
3551 $ hg log -R a -r 8 --template '{files % "{file}\n"}'
3545 fourth
3552 fourth
3546 second
3553 second
3547 third
3554 third
3548
3555
3549 Test string escaping in nested expression:
3556 Test string escaping in nested expression:
3550
3557
3551 $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
3558 $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
3552 fourth\x6esecond\x6ethird
3559 fourth\x6esecond\x6ethird
3553 $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
3560 $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
3554 fourth\x6esecond\x6ethird
3561 fourth\x6esecond\x6ethird
3555
3562
3556 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
3563 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
3557 fourth\x6esecond\x6ethird
3564 fourth\x6esecond\x6ethird
3558 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
3565 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
3559 fourth\x5c\x786esecond\x5c\x786ethird
3566 fourth\x5c\x786esecond\x5c\x786ethird
3560
3567
3561 $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
3568 $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
3562 3:\x6eo user, \x6eo domai\x6e
3569 3:\x6eo user, \x6eo domai\x6e
3563 4:\x5c\x786eew bra\x5c\x786ech
3570 4:\x5c\x786eew bra\x5c\x786ech
3564
3571
3565 Test quotes in nested expression are evaluated just like a $(command)
3572 Test quotes in nested expression are evaluated just like a $(command)
3566 substitution in POSIX shells:
3573 substitution in POSIX shells:
3567
3574
3568 $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n'
3575 $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n'
3569 8:95c24699272e
3576 8:95c24699272e
3570 $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n'
3577 $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n'
3571 {8} "95c24699272e"
3578 {8} "95c24699272e"
3572
3579
3573 Test recursive evaluation:
3580 Test recursive evaluation:
3574
3581
3575 $ hg init r
3582 $ hg init r
3576 $ cd r
3583 $ cd r
3577 $ echo a > a
3584 $ echo a > a
3578 $ hg ci -Am '{rev}'
3585 $ hg ci -Am '{rev}'
3579 adding a
3586 adding a
3580 $ hg log -r 0 --template '{if(rev, desc)}\n'
3587 $ hg log -r 0 --template '{if(rev, desc)}\n'
3581 {rev}
3588 {rev}
3582 $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n'
3589 $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n'
3583 test 0
3590 test 0
3584
3591
3585 $ hg branch -q 'text.{rev}'
3592 $ hg branch -q 'text.{rev}'
3586 $ echo aa >> aa
3593 $ echo aa >> aa
3587 $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
3594 $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
3588
3595
3589 $ hg log -l1 --template '{fill(desc, "20", author, branch)}'
3596 $ hg log -l1 --template '{fill(desc, "20", author, branch)}'
3590 {node|short}desc to
3597 {node|short}desc to
3591 text.{rev}be wrapped
3598 text.{rev}be wrapped
3592 text.{rev}desc to be
3599 text.{rev}desc to be
3593 text.{rev}wrapped (no-eol)
3600 text.{rev}wrapped (no-eol)
3594 $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}'
3601 $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}'
3595 bcc7ff960b8e:desc to
3602 bcc7ff960b8e:desc to
3596 text.1:be wrapped
3603 text.1:be wrapped
3597 text.1:desc to be
3604 text.1:desc to be
3598 text.1:wrapped (no-eol)
3605 text.1:wrapped (no-eol)
3599 $ hg log -l1 -T '{fill(desc, date, "", "")}\n'
3606 $ hg log -l1 -T '{fill(desc, date, "", "")}\n'
3600 hg: parse error: fill expects an integer width
3607 hg: parse error: fill expects an integer width
3601 [255]
3608 [255]
3602
3609
3603 $ COLUMNS=25 hg log -l1 --template '{fill(desc, termwidth, "{node|short}:", "termwidth.{rev}:")}'
3610 $ COLUMNS=25 hg log -l1 --template '{fill(desc, termwidth, "{node|short}:", "termwidth.{rev}:")}'
3604 bcc7ff960b8e:desc to be
3611 bcc7ff960b8e:desc to be
3605 termwidth.1:wrapped desc
3612 termwidth.1:wrapped desc
3606 termwidth.1:to be wrapped (no-eol)
3613 termwidth.1:to be wrapped (no-eol)
3607
3614
3608 $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}'
3615 $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}'
3609 {node|short} (no-eol)
3616 {node|short} (no-eol)
3610 $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}'
3617 $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}'
3611 bcc-ff---b-e (no-eol)
3618 bcc-ff---b-e (no-eol)
3612
3619
3613 $ cat >> .hg/hgrc <<EOF
3620 $ cat >> .hg/hgrc <<EOF
3614 > [extensions]
3621 > [extensions]
3615 > color=
3622 > color=
3616 > [color]
3623 > [color]
3617 > mode=ansi
3624 > mode=ansi
3618 > text.{rev} = red
3625 > text.{rev} = red
3619 > text.1 = green
3626 > text.1 = green
3620 > EOF
3627 > EOF
3621 $ hg log --color=always -l 1 --template '{label(branch, "text\n")}'
3628 $ hg log --color=always -l 1 --template '{label(branch, "text\n")}'
3622 \x1b[0;31mtext\x1b[0m (esc)
3629 \x1b[0;31mtext\x1b[0m (esc)
3623 $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}'
3630 $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}'
3624 \x1b[0;32mtext\x1b[0m (esc)
3631 \x1b[0;32mtext\x1b[0m (esc)
3625
3632
3626 color effect can be specified without quoting:
3633 color effect can be specified without quoting:
3627
3634
3628 $ hg log --color=always -l 1 --template '{label(red, "text\n")}'
3635 $ hg log --color=always -l 1 --template '{label(red, "text\n")}'
3629 \x1b[0;31mtext\x1b[0m (esc)
3636 \x1b[0;31mtext\x1b[0m (esc)
3630
3637
3631 color effects can be nested (issue5413)
3638 color effects can be nested (issue5413)
3632
3639
3633 $ hg debugtemplate --color=always \
3640 $ hg debugtemplate --color=always \
3634 > '{label(red, "red{label(magenta, "ma{label(cyan, "cyan")}{label(yellow, "yellow")}genta")}")}\n'
3641 > '{label(red, "red{label(magenta, "ma{label(cyan, "cyan")}{label(yellow, "yellow")}genta")}")}\n'
3635 \x1b[0;31mred\x1b[0;35mma\x1b[0;36mcyan\x1b[0m\x1b[0;31m\x1b[0;35m\x1b[0;33myellow\x1b[0m\x1b[0;31m\x1b[0;35mgenta\x1b[0m (esc)
3642 \x1b[0;31mred\x1b[0;35mma\x1b[0;36mcyan\x1b[0m\x1b[0;31m\x1b[0;35m\x1b[0;33myellow\x1b[0m\x1b[0;31m\x1b[0;35mgenta\x1b[0m (esc)
3636
3643
3637 pad() should interact well with color codes (issue5416)
3644 pad() should interact well with color codes (issue5416)
3638
3645
3639 $ hg debugtemplate --color=always \
3646 $ hg debugtemplate --color=always \
3640 > '{pad(label(red, "red"), 5, label(cyan, "-"))}\n'
3647 > '{pad(label(red, "red"), 5, label(cyan, "-"))}\n'
3641 \x1b[0;31mred\x1b[0m\x1b[0;36m-\x1b[0m\x1b[0;36m-\x1b[0m (esc)
3648 \x1b[0;31mred\x1b[0m\x1b[0;36m-\x1b[0m\x1b[0;36m-\x1b[0m (esc)
3642
3649
3643 label should be no-op if color is disabled:
3650 label should be no-op if color is disabled:
3644
3651
3645 $ hg log --color=never -l 1 --template '{label(red, "text\n")}'
3652 $ hg log --color=never -l 1 --template '{label(red, "text\n")}'
3646 text
3653 text
3647 $ hg log --config extensions.color=! -l 1 --template '{label(red, "text\n")}'
3654 $ hg log --config extensions.color=! -l 1 --template '{label(red, "text\n")}'
3648 text
3655 text
3649
3656
3650 Test branches inside if statement:
3657 Test branches inside if statement:
3651
3658
3652 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
3659 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
3653 no
3660 no
3654
3661
3655 Test dict constructor:
3662 Test dict constructor:
3656
3663
3657 $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n'
3664 $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n'
3658 y=f7769ec2ab97 x=0
3665 y=f7769ec2ab97 x=0
3659 $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}'
3666 $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}'
3660 x=0
3667 x=0
3661 y=f7769ec2ab97
3668 y=f7769ec2ab97
3662 $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n'
3669 $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n'
3663 {"x": 0, "y": "f7769ec2ab97"}
3670 {"x": 0, "y": "f7769ec2ab97"}
3664 $ hg log -r 0 -T '{dict()|json}\n'
3671 $ hg log -r 0 -T '{dict()|json}\n'
3665 {}
3672 {}
3666
3673
3667 $ hg log -r 0 -T '{dict(rev, node=node|short)}\n'
3674 $ hg log -r 0 -T '{dict(rev, node=node|short)}\n'
3668 rev=0 node=f7769ec2ab97
3675 rev=0 node=f7769ec2ab97
3669 $ hg log -r 0 -T '{dict(rev, node|short)}\n'
3676 $ hg log -r 0 -T '{dict(rev, node|short)}\n'
3670 rev=0 node=f7769ec2ab97
3677 rev=0 node=f7769ec2ab97
3671
3678
3672 $ hg log -r 0 -T '{dict(rev, rev=rev)}\n'
3679 $ hg log -r 0 -T '{dict(rev, rev=rev)}\n'
3673 hg: parse error: duplicated dict key 'rev' inferred
3680 hg: parse error: duplicated dict key 'rev' inferred
3674 [255]
3681 [255]
3675 $ hg log -r 0 -T '{dict(node, node|short)}\n'
3682 $ hg log -r 0 -T '{dict(node, node|short)}\n'
3676 hg: parse error: duplicated dict key 'node' inferred
3683 hg: parse error: duplicated dict key 'node' inferred
3677 [255]
3684 [255]
3678 $ hg log -r 0 -T '{dict(1 + 2)}'
3685 $ hg log -r 0 -T '{dict(1 + 2)}'
3679 hg: parse error: dict key cannot be inferred
3686 hg: parse error: dict key cannot be inferred
3680 [255]
3687 [255]
3681
3688
3682 $ hg log -r 0 -T '{dict(x=rev, x=node)}'
3689 $ hg log -r 0 -T '{dict(x=rev, x=node)}'
3683 hg: parse error: dict got multiple values for keyword argument 'x'
3690 hg: parse error: dict got multiple values for keyword argument 'x'
3684 [255]
3691 [255]
3685
3692
3686 Test get function:
3693 Test get function:
3687
3694
3688 $ hg log -r 0 --template '{get(extras, "branch")}\n'
3695 $ hg log -r 0 --template '{get(extras, "branch")}\n'
3689 default
3696 default
3690 $ hg log -r 0 --template '{get(extras, "br{"anch"}")}\n'
3697 $ hg log -r 0 --template '{get(extras, "br{"anch"}")}\n'
3691 default
3698 default
3692 $ hg log -r 0 --template '{get(files, "should_fail")}\n'
3699 $ hg log -r 0 --template '{get(files, "should_fail")}\n'
3693 hg: parse error: get() expects a dict as first argument
3700 hg: parse error: get() expects a dict as first argument
3694 [255]
3701 [255]
3695
3702
3696 Test json filter applied to hybrid object:
3703 Test json filter applied to hybrid object:
3697
3704
3698 $ hg log -r0 -T '{files|json}\n'
3705 $ hg log -r0 -T '{files|json}\n'
3699 ["a"]
3706 ["a"]
3700 $ hg log -r0 -T '{extras|json}\n'
3707 $ hg log -r0 -T '{extras|json}\n'
3701 {"branch": "default"}
3708 {"branch": "default"}
3702
3709
3703 Test localdate(date, tz) function:
3710 Test localdate(date, tz) function:
3704
3711
3705 $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n'
3712 $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n'
3706 1970-01-01 09:00 +0900
3713 1970-01-01 09:00 +0900
3707 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n'
3714 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n'
3708 1970-01-01 00:00 +0000
3715 1970-01-01 00:00 +0000
3709 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "blahUTC")|isodate}\n'
3716 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "blahUTC")|isodate}\n'
3710 hg: parse error: localdate expects a timezone
3717 hg: parse error: localdate expects a timezone
3711 [255]
3718 [255]
3712 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n'
3719 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n'
3713 1970-01-01 02:00 +0200
3720 1970-01-01 02:00 +0200
3714 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n'
3721 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n'
3715 1970-01-01 00:00 +0000
3722 1970-01-01 00:00 +0000
3716 $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n'
3723 $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n'
3717 1970-01-01 00:00 +0000
3724 1970-01-01 00:00 +0000
3718 $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n'
3725 $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n'
3719 hg: parse error: localdate expects a timezone
3726 hg: parse error: localdate expects a timezone
3720 [255]
3727 [255]
3721 $ hg log -r0 -T '{localdate(date, date)|isodate}\n'
3728 $ hg log -r0 -T '{localdate(date, date)|isodate}\n'
3722 hg: parse error: localdate expects a timezone
3729 hg: parse error: localdate expects a timezone
3723 [255]
3730 [255]
3724
3731
3725 Test shortest(node) function:
3732 Test shortest(node) function:
3726
3733
3727 $ echo b > b
3734 $ echo b > b
3728 $ hg ci -qAm b
3735 $ hg ci -qAm b
3729 $ hg log --template '{shortest(node)}\n'
3736 $ hg log --template '{shortest(node)}\n'
3730 e777
3737 e777
3731 bcc7
3738 bcc7
3732 f776
3739 f776
3733 $ hg log --template '{shortest(node, 10)}\n'
3740 $ hg log --template '{shortest(node, 10)}\n'
3734 e777603221
3741 e777603221
3735 bcc7ff960b
3742 bcc7ff960b
3736 f7769ec2ab
3743 f7769ec2ab
3737 $ hg log --template '{node|shortest}\n' -l1
3744 $ hg log --template '{node|shortest}\n' -l1
3738 e777
3745 e777
3739
3746
3740 $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n'
3747 $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n'
3741 f7769ec2ab
3748 f7769ec2ab
3742 $ hg log -r 0 -T '{shortest(node, "not an int")}\n'
3749 $ hg log -r 0 -T '{shortest(node, "not an int")}\n'
3743 hg: parse error: shortest() expects an integer minlength
3750 hg: parse error: shortest() expects an integer minlength
3744 [255]
3751 [255]
3745
3752
3746 $ hg log -r 'wdir()' -T '{node|shortest}\n'
3753 $ hg log -r 'wdir()' -T '{node|shortest}\n'
3747 ffff
3754 ffff
3748
3755
3749 $ cd ..
3756 $ cd ..
3750
3757
3751 Test shortest(node) with the repo having short hash collision:
3758 Test shortest(node) with the repo having short hash collision:
3752
3759
3753 $ hg init hashcollision
3760 $ hg init hashcollision
3754 $ cd hashcollision
3761 $ cd hashcollision
3755 $ cat <<EOF >> .hg/hgrc
3762 $ cat <<EOF >> .hg/hgrc
3756 > [experimental]
3763 > [experimental]
3757 > stabilization = createmarkers
3764 > stabilization = createmarkers
3758 > EOF
3765 > EOF
3759 $ echo 0 > a
3766 $ echo 0 > a
3760 $ hg ci -qAm 0
3767 $ hg ci -qAm 0
3761 $ for i in 17 129 248 242 480 580 617 1057 2857 4025; do
3768 $ for i in 17 129 248 242 480 580 617 1057 2857 4025; do
3762 > hg up -q 0
3769 > hg up -q 0
3763 > echo $i > a
3770 > echo $i > a
3764 > hg ci -qm $i
3771 > hg ci -qm $i
3765 > done
3772 > done
3766 $ hg up -q null
3773 $ hg up -q null
3767 $ hg log -r0: -T '{rev}:{node}\n'
3774 $ hg log -r0: -T '{rev}:{node}\n'
3768 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
3775 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
3769 1:11424df6dc1dd4ea255eae2b58eaca7831973bbc
3776 1:11424df6dc1dd4ea255eae2b58eaca7831973bbc
3770 2:11407b3f1b9c3e76a79c1ec5373924df096f0499
3777 2:11407b3f1b9c3e76a79c1ec5373924df096f0499
3771 3:11dd92fe0f39dfdaacdaa5f3997edc533875cfc4
3778 3:11dd92fe0f39dfdaacdaa5f3997edc533875cfc4
3772 4:10776689e627b465361ad5c296a20a487e153ca4
3779 4:10776689e627b465361ad5c296a20a487e153ca4
3773 5:a00be79088084cb3aff086ab799f8790e01a976b
3780 5:a00be79088084cb3aff086ab799f8790e01a976b
3774 6:a0b0acd79b4498d0052993d35a6a748dd51d13e6
3781 6:a0b0acd79b4498d0052993d35a6a748dd51d13e6
3775 7:a0457b3450b8e1b778f1163b31a435802987fe5d
3782 7:a0457b3450b8e1b778f1163b31a435802987fe5d
3776 8:c56256a09cd28e5764f32e8e2810d0f01e2e357a
3783 8:c56256a09cd28e5764f32e8e2810d0f01e2e357a
3777 9:c5623987d205cd6d9d8389bfc40fff9dbb670b48
3784 9:c5623987d205cd6d9d8389bfc40fff9dbb670b48
3778 10:c562ddd9c94164376c20b86b0b4991636a3bf84f
3785 10:c562ddd9c94164376c20b86b0b4991636a3bf84f
3779 $ hg debugobsolete a00be79088084cb3aff086ab799f8790e01a976b
3786 $ hg debugobsolete a00be79088084cb3aff086ab799f8790e01a976b
3780 obsoleted 1 changesets
3787 obsoleted 1 changesets
3781 $ hg debugobsolete c5623987d205cd6d9d8389bfc40fff9dbb670b48
3788 $ hg debugobsolete c5623987d205cd6d9d8389bfc40fff9dbb670b48
3782 obsoleted 1 changesets
3789 obsoleted 1 changesets
3783 $ hg debugobsolete c562ddd9c94164376c20b86b0b4991636a3bf84f
3790 $ hg debugobsolete c562ddd9c94164376c20b86b0b4991636a3bf84f
3784 obsoleted 1 changesets
3791 obsoleted 1 changesets
3785
3792
3786 nodes starting with '11' (we don't have the revision number '11' though)
3793 nodes starting with '11' (we don't have the revision number '11' though)
3787
3794
3788 $ hg log -r 1:3 -T '{rev}:{shortest(node, 0)}\n'
3795 $ hg log -r 1:3 -T '{rev}:{shortest(node, 0)}\n'
3789 1:1142
3796 1:1142
3790 2:1140
3797 2:1140
3791 3:11d
3798 3:11d
3792
3799
3793 '5:a00' is hidden, but still we have two nodes starting with 'a0'
3800 '5:a00' is hidden, but still we have two nodes starting with 'a0'
3794
3801
3795 $ hg log -r 6:7 -T '{rev}:{shortest(node, 0)}\n'
3802 $ hg log -r 6:7 -T '{rev}:{shortest(node, 0)}\n'
3796 6:a0b
3803 6:a0b
3797 7:a04
3804 7:a04
3798
3805
3799 node '10' conflicts with the revision number '10' even if it is hidden
3806 node '10' conflicts with the revision number '10' even if it is hidden
3800 (we could exclude hidden revision numbers, but currently we don't)
3807 (we could exclude hidden revision numbers, but currently we don't)
3801
3808
3802 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n'
3809 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n'
3803 4:107
3810 4:107
3804 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden
3811 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden
3805 4:107
3812 4:107
3806
3813
3807 node 'c562' should be unique if the other 'c562' nodes are hidden
3814 node 'c562' should be unique if the other 'c562' nodes are hidden
3808 (but we don't try the slow path to filter out hidden nodes for now)
3815 (but we don't try the slow path to filter out hidden nodes for now)
3809
3816
3810 $ hg log -r 8 -T '{rev}:{node|shortest}\n'
3817 $ hg log -r 8 -T '{rev}:{node|shortest}\n'
3811 8:c5625
3818 8:c5625
3812 $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden
3819 $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden
3813 8:c5625
3820 8:c5625
3814 9:c5623
3821 9:c5623
3815 10:c562d
3822 10:c562d
3816
3823
3817 $ cd ..
3824 $ cd ..
3818
3825
3819 Test pad function
3826 Test pad function
3820
3827
3821 $ cd r
3828 $ cd r
3822
3829
3823 $ hg log --template '{pad(rev, 20)} {author|user}\n'
3830 $ hg log --template '{pad(rev, 20)} {author|user}\n'
3824 2 test
3831 2 test
3825 1 {node|short}
3832 1 {node|short}
3826 0 test
3833 0 test
3827
3834
3828 $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n'
3835 $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n'
3829 2 test
3836 2 test
3830 1 {node|short}
3837 1 {node|short}
3831 0 test
3838 0 test
3832
3839
3833 $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n'
3840 $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n'
3834 2------------------- test
3841 2------------------- test
3835 1------------------- {node|short}
3842 1------------------- {node|short}
3836 0------------------- test
3843 0------------------- test
3837
3844
3838 Test template string in pad function
3845 Test template string in pad function
3839
3846
3840 $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n'
3847 $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n'
3841 {0} test
3848 {0} test
3842
3849
3843 $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n'
3850 $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n'
3844 \{rev} test
3851 \{rev} test
3845
3852
3846 Test width argument passed to pad function
3853 Test width argument passed to pad function
3847
3854
3848 $ hg log -r 0 -T '{pad(rev, "1{"0"}")} {author|user}\n'
3855 $ hg log -r 0 -T '{pad(rev, "1{"0"}")} {author|user}\n'
3849 0 test
3856 0 test
3850 $ hg log -r 0 -T '{pad(rev, "not an int")}\n'
3857 $ hg log -r 0 -T '{pad(rev, "not an int")}\n'
3851 hg: parse error: pad() expects an integer width
3858 hg: parse error: pad() expects an integer width
3852 [255]
3859 [255]
3853
3860
3854 Test invalid fillchar passed to pad function
3861 Test invalid fillchar passed to pad function
3855
3862
3856 $ hg log -r 0 -T '{pad(rev, 10, "")}\n'
3863 $ hg log -r 0 -T '{pad(rev, 10, "")}\n'
3857 hg: parse error: pad() expects a single fill character
3864 hg: parse error: pad() expects a single fill character
3858 [255]
3865 [255]
3859 $ hg log -r 0 -T '{pad(rev, 10, "--")}\n'
3866 $ hg log -r 0 -T '{pad(rev, 10, "--")}\n'
3860 hg: parse error: pad() expects a single fill character
3867 hg: parse error: pad() expects a single fill character
3861 [255]
3868 [255]
3862
3869
3863 Test boolean argument passed to pad function
3870 Test boolean argument passed to pad function
3864
3871
3865 no crash
3872 no crash
3866
3873
3867 $ hg log -r 0 -T '{pad(rev, 10, "-", "f{"oo"}")}\n'
3874 $ hg log -r 0 -T '{pad(rev, 10, "-", "f{"oo"}")}\n'
3868 ---------0
3875 ---------0
3869
3876
3870 string/literal
3877 string/literal
3871
3878
3872 $ hg log -r 0 -T '{pad(rev, 10, "-", "false")}\n'
3879 $ hg log -r 0 -T '{pad(rev, 10, "-", "false")}\n'
3873 ---------0
3880 ---------0
3874 $ hg log -r 0 -T '{pad(rev, 10, "-", false)}\n'
3881 $ hg log -r 0 -T '{pad(rev, 10, "-", false)}\n'
3875 0---------
3882 0---------
3876 $ hg log -r 0 -T '{pad(rev, 10, "-", "")}\n'
3883 $ hg log -r 0 -T '{pad(rev, 10, "-", "")}\n'
3877 0---------
3884 0---------
3878
3885
3879 unknown keyword is evaluated to ''
3886 unknown keyword is evaluated to ''
3880
3887
3881 $ hg log -r 0 -T '{pad(rev, 10, "-", unknownkeyword)}\n'
3888 $ hg log -r 0 -T '{pad(rev, 10, "-", unknownkeyword)}\n'
3882 0---------
3889 0---------
3883
3890
3884 Test separate function
3891 Test separate function
3885
3892
3886 $ hg log -r 0 -T '{separate("-", "", "a", "b", "", "", "c", "")}\n'
3893 $ hg log -r 0 -T '{separate("-", "", "a", "b", "", "", "c", "")}\n'
3887 a-b-c
3894 a-b-c
3888 $ hg log -r 0 -T '{separate(" ", "{rev}:{node|short}", author|user, branch)}\n'
3895 $ hg log -r 0 -T '{separate(" ", "{rev}:{node|short}", author|user, branch)}\n'
3889 0:f7769ec2ab97 test default
3896 0:f7769ec2ab97 test default
3890 $ hg log -r 0 --color=always -T '{separate(" ", "a", label(red, "b"), "c", label(red, ""), "d")}\n'
3897 $ hg log -r 0 --color=always -T '{separate(" ", "a", label(red, "b"), "c", label(red, ""), "d")}\n'
3891 a \x1b[0;31mb\x1b[0m c d (esc)
3898 a \x1b[0;31mb\x1b[0m c d (esc)
3892
3899
3893 Test boolean expression/literal passed to if function
3900 Test boolean expression/literal passed to if function
3894
3901
3895 $ hg log -r 0 -T '{if(rev, "rev 0 is True")}\n'
3902 $ hg log -r 0 -T '{if(rev, "rev 0 is True")}\n'
3896 rev 0 is True
3903 rev 0 is True
3897 $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n'
3904 $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n'
3898 literal 0 is True as well
3905 literal 0 is True as well
3899 $ hg log -r 0 -T '{if("", "", "empty string is False")}\n'
3906 $ hg log -r 0 -T '{if("", "", "empty string is False")}\n'
3900 empty string is False
3907 empty string is False
3901 $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n'
3908 $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n'
3902 empty list is False
3909 empty list is False
3903 $ hg log -r 0 -T '{if(true, "true is True")}\n'
3910 $ hg log -r 0 -T '{if(true, "true is True")}\n'
3904 true is True
3911 true is True
3905 $ hg log -r 0 -T '{if(false, "", "false is False")}\n'
3912 $ hg log -r 0 -T '{if(false, "", "false is False")}\n'
3906 false is False
3913 false is False
3907 $ hg log -r 0 -T '{if("false", "non-empty string is True")}\n'
3914 $ hg log -r 0 -T '{if("false", "non-empty string is True")}\n'
3908 non-empty string is True
3915 non-empty string is True
3909
3916
3910 Test ifcontains function
3917 Test ifcontains function
3911
3918
3912 $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n'
3919 $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n'
3913 2 is in the string
3920 2 is in the string
3914 1 is not
3921 1 is not
3915 0 is in the string
3922 0 is in the string
3916
3923
3917 $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n'
3924 $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n'
3918 2 is in the string
3925 2 is in the string
3919 1 is not
3926 1 is not
3920 0 is in the string
3927 0 is in the string
3921
3928
3922 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
3929 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
3923 2 did not add a
3930 2 did not add a
3924 1 did not add a
3931 1 did not add a
3925 0 added a
3932 0 added a
3926
3933
3927 $ hg log --debug -T '{rev}{ifcontains(1, parents, " is parent of 1")}\n'
3934 $ hg log --debug -T '{rev}{ifcontains(1, parents, " is parent of 1")}\n'
3928 2 is parent of 1
3935 2 is parent of 1
3929 1
3936 1
3930 0
3937 0
3931
3938
3932 Test revset function
3939 Test revset function
3933
3940
3934 $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n'
3941 $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n'
3935 2 current rev
3942 2 current rev
3936 1 not current rev
3943 1 not current rev
3937 0 not current rev
3944 0 not current rev
3938
3945
3939 $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n'
3946 $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n'
3940 2 match rev
3947 2 match rev
3941 1 match rev
3948 1 match rev
3942 0 not match rev
3949 0 not match rev
3943
3950
3944 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n'
3951 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n'
3945 2 Parents: 1
3952 2 Parents: 1
3946 1 Parents: 0
3953 1 Parents: 0
3947 0 Parents:
3954 0 Parents:
3948
3955
3949 $ cat >> .hg/hgrc <<EOF
3956 $ cat >> .hg/hgrc <<EOF
3950 > [revsetalias]
3957 > [revsetalias]
3951 > myparents(\$1) = parents(\$1)
3958 > myparents(\$1) = parents(\$1)
3952 > EOF
3959 > EOF
3953 $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n'
3960 $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n'
3954 2 Parents: 1
3961 2 Parents: 1
3955 1 Parents: 0
3962 1 Parents: 0
3956 0 Parents:
3963 0 Parents:
3957
3964
3958 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
3965 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
3959 Rev: 2
3966 Rev: 2
3960 Ancestor: 0
3967 Ancestor: 0
3961 Ancestor: 1
3968 Ancestor: 1
3962 Ancestor: 2
3969 Ancestor: 2
3963
3970
3964 Rev: 1
3971 Rev: 1
3965 Ancestor: 0
3972 Ancestor: 0
3966 Ancestor: 1
3973 Ancestor: 1
3967
3974
3968 Rev: 0
3975 Rev: 0
3969 Ancestor: 0
3976 Ancestor: 0
3970
3977
3971 $ hg log --template '{revset("TIP"|lower)}\n' -l1
3978 $ hg log --template '{revset("TIP"|lower)}\n' -l1
3972 2
3979 2
3973
3980
3974 $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1
3981 $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1
3975 2
3982 2
3976
3983
3977 a list template is evaluated for each item of revset/parents
3984 a list template is evaluated for each item of revset/parents
3978
3985
3979 $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n'
3986 $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n'
3980 2 p: 1:bcc7ff960b8e
3987 2 p: 1:bcc7ff960b8e
3981 1 p: 0:f7769ec2ab97
3988 1 p: 0:f7769ec2ab97
3982 0 p:
3989 0 p:
3983
3990
3984 $ hg log --debug -T '{rev} p:{parents % " {rev}:{node|short}"}\n'
3991 $ hg log --debug -T '{rev} p:{parents % " {rev}:{node|short}"}\n'
3985 2 p: 1:bcc7ff960b8e -1:000000000000
3992 2 p: 1:bcc7ff960b8e -1:000000000000
3986 1 p: 0:f7769ec2ab97 -1:000000000000
3993 1 p: 0:f7769ec2ab97 -1:000000000000
3987 0 p: -1:000000000000 -1:000000000000
3994 0 p: -1:000000000000 -1:000000000000
3988
3995
3989 therefore, 'revcache' should be recreated for each rev
3996 therefore, 'revcache' should be recreated for each rev
3990
3997
3991 $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n'
3998 $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n'
3992 2 aa b
3999 2 aa b
3993 p
4000 p
3994 1
4001 1
3995 p a
4002 p a
3996 0 a
4003 0 a
3997 p
4004 p
3998
4005
3999 $ hg log --debug -T '{rev} {file_adds}\np {parents % "{file_adds}"}\n'
4006 $ hg log --debug -T '{rev} {file_adds}\np {parents % "{file_adds}"}\n'
4000 2 aa b
4007 2 aa b
4001 p
4008 p
4002 1
4009 1
4003 p a
4010 p a
4004 0 a
4011 0 a
4005 p
4012 p
4006
4013
4007 a revset item must be evaluated as an integer revision, not an offset from tip
4014 a revset item must be evaluated as an integer revision, not an offset from tip
4008
4015
4009 $ hg log -l 1 -T '{revset("null") % "{rev}:{node|short}"}\n'
4016 $ hg log -l 1 -T '{revset("null") % "{rev}:{node|short}"}\n'
4010 -1:000000000000
4017 -1:000000000000
4011 $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n'
4018 $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n'
4012 -1:000000000000
4019 -1:000000000000
4013
4020
4014 join() should pick '{rev}' from revset items:
4021 join() should pick '{rev}' from revset items:
4015
4022
4016 $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6
4023 $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6
4017 4, 5
4024 4, 5
4018
4025
4019 on the other hand, parents are formatted as '{rev}:{node|formatnode}' by
4026 on the other hand, parents are formatted as '{rev}:{node|formatnode}' by
4020 default. join() should agree with the default formatting:
4027 default. join() should agree with the default formatting:
4021
4028
4022 $ hg log -R ../a -T '{join(parents, ", ")}\n' -r6
4029 $ hg log -R ../a -T '{join(parents, ", ")}\n' -r6
4023 5:13207e5a10d9, 4:bbe44766e73d
4030 5:13207e5a10d9, 4:bbe44766e73d
4024
4031
4025 $ hg log -R ../a -T '{join(parents, ",\n")}\n' -r6 --debug
4032 $ hg log -R ../a -T '{join(parents, ",\n")}\n' -r6 --debug
4026 5:13207e5a10d9fd28ec424934298e176197f2c67f,
4033 5:13207e5a10d9fd28ec424934298e176197f2c67f,
4027 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
4034 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
4028
4035
4029 Test files function
4036 Test files function
4030
4037
4031 $ hg log -T "{rev}\n{join(files('*'), '\n')}\n"
4038 $ hg log -T "{rev}\n{join(files('*'), '\n')}\n"
4032 2
4039 2
4033 a
4040 a
4034 aa
4041 aa
4035 b
4042 b
4036 1
4043 1
4037 a
4044 a
4038 0
4045 0
4039 a
4046 a
4040
4047
4041 $ hg log -T "{rev}\n{join(files('aa'), '\n')}\n"
4048 $ hg log -T "{rev}\n{join(files('aa'), '\n')}\n"
4042 2
4049 2
4043 aa
4050 aa
4044 1
4051 1
4045
4052
4046 0
4053 0
4047
4054
4048
4055
4049 Test relpath function
4056 Test relpath function
4050
4057
4051 $ hg log -r0 -T '{files % "{file|relpath}\n"}'
4058 $ hg log -r0 -T '{files % "{file|relpath}\n"}'
4052 a
4059 a
4053 $ cd ..
4060 $ cd ..
4054 $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}'
4061 $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}'
4055 r/a
4062 r/a
4056 $ cd r
4063 $ cd r
4057
4064
4058 Test active bookmark templating
4065 Test active bookmark templating
4059
4066
4060 $ hg book foo
4067 $ hg book foo
4061 $ hg book bar
4068 $ hg book bar
4062 $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n"
4069 $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n"
4063 2 bar* foo
4070 2 bar* foo
4064 1
4071 1
4065 0
4072 0
4066 $ hg log --template "{rev} {activebookmark}\n"
4073 $ hg log --template "{rev} {activebookmark}\n"
4067 2 bar
4074 2 bar
4068 1
4075 1
4069 0
4076 0
4070 $ hg bookmarks --inactive bar
4077 $ hg bookmarks --inactive bar
4071 $ hg log --template "{rev} {activebookmark}\n"
4078 $ hg log --template "{rev} {activebookmark}\n"
4072 2
4079 2
4073 1
4080 1
4074 0
4081 0
4075 $ hg book -r1 baz
4082 $ hg book -r1 baz
4076 $ hg log --template "{rev} {join(bookmarks, ' ')}\n"
4083 $ hg log --template "{rev} {join(bookmarks, ' ')}\n"
4077 2 bar foo
4084 2 bar foo
4078 1 baz
4085 1 baz
4079 0
4086 0
4080 $ hg log --template "{rev} {ifcontains('foo', bookmarks, 't', 'f')}\n"
4087 $ hg log --template "{rev} {ifcontains('foo', bookmarks, 't', 'f')}\n"
4081 2 t
4088 2 t
4082 1 f
4089 1 f
4083 0 f
4090 0 f
4084
4091
4085 Test namespaces dict
4092 Test namespaces dict
4086
4093
4087 $ hg --config extensions.revnamesext=$TESTDIR/revnamesext.py log -T '{rev}\n{namespaces % " {namespace} color={colorname} builtin={builtin}\n {join(names, ",")}\n"}\n'
4094 $ hg --config extensions.revnamesext=$TESTDIR/revnamesext.py log -T '{rev}\n{namespaces % " {namespace} color={colorname} builtin={builtin}\n {join(names, ",")}\n"}\n'
4088 2
4095 2
4089 bookmarks color=bookmark builtin=True
4096 bookmarks color=bookmark builtin=True
4090 bar,foo
4097 bar,foo
4091 tags color=tag builtin=True
4098 tags color=tag builtin=True
4092 tip
4099 tip
4093 branches color=branch builtin=True
4100 branches color=branch builtin=True
4094 text.{rev}
4101 text.{rev}
4095 revnames color=revname builtin=False
4102 revnames color=revname builtin=False
4096 r2
4103 r2
4097
4104
4098 1
4105 1
4099 bookmarks color=bookmark builtin=True
4106 bookmarks color=bookmark builtin=True
4100 baz
4107 baz
4101 tags color=tag builtin=True
4108 tags color=tag builtin=True
4102
4109
4103 branches color=branch builtin=True
4110 branches color=branch builtin=True
4104 text.{rev}
4111 text.{rev}
4105 revnames color=revname builtin=False
4112 revnames color=revname builtin=False
4106 r1
4113 r1
4107
4114
4108 0
4115 0
4109 bookmarks color=bookmark builtin=True
4116 bookmarks color=bookmark builtin=True
4110
4117
4111 tags color=tag builtin=True
4118 tags color=tag builtin=True
4112
4119
4113 branches color=branch builtin=True
4120 branches color=branch builtin=True
4114 default
4121 default
4115 revnames color=revname builtin=False
4122 revnames color=revname builtin=False
4116 r0
4123 r0
4117
4124
4118 $ hg log -r2 -T '{namespaces % "{namespace}: {names}\n"}'
4125 $ hg log -r2 -T '{namespaces % "{namespace}: {names}\n"}'
4119 bookmarks: bar foo
4126 bookmarks: bar foo
4120 tags: tip
4127 tags: tip
4121 branches: text.{rev}
4128 branches: text.{rev}
4122 $ hg log -r2 -T '{namespaces % "{namespace}:\n{names % " {name}\n"}"}'
4129 $ hg log -r2 -T '{namespaces % "{namespace}:\n{names % " {name}\n"}"}'
4123 bookmarks:
4130 bookmarks:
4124 bar
4131 bar
4125 foo
4132 foo
4126 tags:
4133 tags:
4127 tip
4134 tip
4128 branches:
4135 branches:
4129 text.{rev}
4136 text.{rev}
4130 $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}'
4137 $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}'
4131 bar
4138 bar
4132 foo
4139 foo
4133 $ hg log -r2 -T '{namespaces.bookmarks % "{bookmark}\n"}'
4140 $ hg log -r2 -T '{namespaces.bookmarks % "{bookmark}\n"}'
4134 bar
4141 bar
4135 foo
4142 foo
4136
4143
4137 Test stringify on sub expressions
4144 Test stringify on sub expressions
4138
4145
4139 $ cd ..
4146 $ cd ..
4140 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
4147 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
4141 fourth, second, third
4148 fourth, second, third
4142 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
4149 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
4143 abc
4150 abc
4144
4151
4145 Test splitlines
4152 Test splitlines
4146
4153
4147 $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}"
4154 $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}"
4148 @ foo Modify, add, remove, rename
4155 @ foo Modify, add, remove, rename
4149 |
4156 |
4150 o foo future
4157 o foo future
4151 |
4158 |
4152 o foo third
4159 o foo third
4153 |
4160 |
4154 o foo second
4161 o foo second
4155
4162
4156 o foo merge
4163 o foo merge
4157 |\
4164 |\
4158 | o foo new head
4165 | o foo new head
4159 | |
4166 | |
4160 o | foo new branch
4167 o | foo new branch
4161 |/
4168 |/
4162 o foo no user, no domain
4169 o foo no user, no domain
4163 |
4170 |
4164 o foo no person
4171 o foo no person
4165 |
4172 |
4166 o foo other 1
4173 o foo other 1
4167 | foo other 2
4174 | foo other 2
4168 | foo
4175 | foo
4169 | foo other 3
4176 | foo other 3
4170 o foo line 1
4177 o foo line 1
4171 foo line 2
4178 foo line 2
4172
4179
4173 $ hg log -R a -r0 -T '{desc|splitlines}\n'
4180 $ hg log -R a -r0 -T '{desc|splitlines}\n'
4174 line 1 line 2
4181 line 1 line 2
4175 $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n'
4182 $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n'
4176 line 1|line 2
4183 line 1|line 2
4177
4184
4178 Test startswith
4185 Test startswith
4179 $ hg log -Gv -R a --template "{startswith(desc)}"
4186 $ hg log -Gv -R a --template "{startswith(desc)}"
4180 hg: parse error: startswith expects two arguments
4187 hg: parse error: startswith expects two arguments
4181 [255]
4188 [255]
4182
4189
4183 $ hg log -Gv -R a --template "{startswith('line', desc)}"
4190 $ hg log -Gv -R a --template "{startswith('line', desc)}"
4184 @
4191 @
4185 |
4192 |
4186 o
4193 o
4187 |
4194 |
4188 o
4195 o
4189 |
4196 |
4190 o
4197 o
4191
4198
4192 o
4199 o
4193 |\
4200 |\
4194 | o
4201 | o
4195 | |
4202 | |
4196 o |
4203 o |
4197 |/
4204 |/
4198 o
4205 o
4199 |
4206 |
4200 o
4207 o
4201 |
4208 |
4202 o
4209 o
4203 |
4210 |
4204 o line 1
4211 o line 1
4205 line 2
4212 line 2
4206
4213
4207 Test bad template with better error message
4214 Test bad template with better error message
4208
4215
4209 $ hg log -Gv -R a --template '{desc|user()}'
4216 $ hg log -Gv -R a --template '{desc|user()}'
4210 hg: parse error: expected a symbol, got 'func'
4217 hg: parse error: expected a symbol, got 'func'
4211 [255]
4218 [255]
4212
4219
4213 Test word function (including index out of bounds graceful failure)
4220 Test word function (including index out of bounds graceful failure)
4214
4221
4215 $ hg log -Gv -R a --template "{word('1', desc)}"
4222 $ hg log -Gv -R a --template "{word('1', desc)}"
4216 @ add,
4223 @ add,
4217 |
4224 |
4218 o
4225 o
4219 |
4226 |
4220 o
4227 o
4221 |
4228 |
4222 o
4229 o
4223
4230
4224 o
4231 o
4225 |\
4232 |\
4226 | o head
4233 | o head
4227 | |
4234 | |
4228 o | branch
4235 o | branch
4229 |/
4236 |/
4230 o user,
4237 o user,
4231 |
4238 |
4232 o person
4239 o person
4233 |
4240 |
4234 o 1
4241 o 1
4235 |
4242 |
4236 o 1
4243 o 1
4237
4244
4238
4245
4239 Test word third parameter used as splitter
4246 Test word third parameter used as splitter
4240
4247
4241 $ hg log -Gv -R a --template "{word('0', desc, 'o')}"
4248 $ hg log -Gv -R a --template "{word('0', desc, 'o')}"
4242 @ M
4249 @ M
4243 |
4250 |
4244 o future
4251 o future
4245 |
4252 |
4246 o third
4253 o third
4247 |
4254 |
4248 o sec
4255 o sec
4249
4256
4250 o merge
4257 o merge
4251 |\
4258 |\
4252 | o new head
4259 | o new head
4253 | |
4260 | |
4254 o | new branch
4261 o | new branch
4255 |/
4262 |/
4256 o n
4263 o n
4257 |
4264 |
4258 o n
4265 o n
4259 |
4266 |
4260 o
4267 o
4261 |
4268 |
4262 o line 1
4269 o line 1
4263 line 2
4270 line 2
4264
4271
4265 Test word error messages for not enough and too many arguments
4272 Test word error messages for not enough and too many arguments
4266
4273
4267 $ hg log -Gv -R a --template "{word('0')}"
4274 $ hg log -Gv -R a --template "{word('0')}"
4268 hg: parse error: word expects two or three arguments, got 1
4275 hg: parse error: word expects two or three arguments, got 1
4269 [255]
4276 [255]
4270
4277
4271 $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}"
4278 $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}"
4272 hg: parse error: word expects two or three arguments, got 7
4279 hg: parse error: word expects two or three arguments, got 7
4273 [255]
4280 [255]
4274
4281
4275 Test word for integer literal
4282 Test word for integer literal
4276
4283
4277 $ hg log -R a --template "{word(2, desc)}\n" -r0
4284 $ hg log -R a --template "{word(2, desc)}\n" -r0
4278 line
4285 line
4279
4286
4280 Test word for invalid numbers
4287 Test word for invalid numbers
4281
4288
4282 $ hg log -Gv -R a --template "{word('a', desc)}"
4289 $ hg log -Gv -R a --template "{word('a', desc)}"
4283 hg: parse error: word expects an integer index
4290 hg: parse error: word expects an integer index
4284 [255]
4291 [255]
4285
4292
4286 Test word for out of range
4293 Test word for out of range
4287
4294
4288 $ hg log -R a --template "{word(10000, desc)}"
4295 $ hg log -R a --template "{word(10000, desc)}"
4289 $ hg log -R a --template "{word(-10000, desc)}"
4296 $ hg log -R a --template "{word(-10000, desc)}"
4290
4297
4291 Test indent and not adding to empty lines
4298 Test indent and not adding to empty lines
4292
4299
4293 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
4300 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
4294 -----
4301 -----
4295 > line 1
4302 > line 1
4296 >> line 2
4303 >> line 2
4297 -----
4304 -----
4298 > other 1
4305 > other 1
4299 >> other 2
4306 >> other 2
4300
4307
4301 >> other 3
4308 >> other 3
4302
4309
4303 Test with non-strings like dates
4310 Test with non-strings like dates
4304
4311
4305 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a
4312 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a
4306 1200000.00
4313 1200000.00
4307 1300000.00
4314 1300000.00
4308
4315
4309 Test broken string escapes:
4316 Test broken string escapes:
4310
4317
4311 $ hg log -T "bogus\\" -R a
4318 $ hg log -T "bogus\\" -R a
4312 hg: parse error: trailing \ in string
4319 hg: parse error: trailing \ in string
4313 [255]
4320 [255]
4314 $ hg log -T "\\xy" -R a
4321 $ hg log -T "\\xy" -R a
4315 hg: parse error: invalid \x escape
4322 hg: parse error: invalid \x escape
4316 [255]
4323 [255]
4317
4324
4318 json filter should escape HTML tags so that the output can be embedded in hgweb:
4325 json filter should escape HTML tags so that the output can be embedded in hgweb:
4319
4326
4320 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
4327 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
4321 "\u003cfoo@example.org\u003e"
4328 "\u003cfoo@example.org\u003e"
4322
4329
4323 Templater supports aliases of symbol and func() styles:
4330 Templater supports aliases of symbol and func() styles:
4324
4331
4325 $ hg clone -q a aliases
4332 $ hg clone -q a aliases
4326 $ cd aliases
4333 $ cd aliases
4327 $ cat <<EOF >> .hg/hgrc
4334 $ cat <<EOF >> .hg/hgrc
4328 > [templatealias]
4335 > [templatealias]
4329 > r = rev
4336 > r = rev
4330 > rn = "{r}:{node|short}"
4337 > rn = "{r}:{node|short}"
4331 > status(c, files) = files % "{c} {file}\n"
4338 > status(c, files) = files % "{c} {file}\n"
4332 > utcdate(d) = localdate(d, "UTC")
4339 > utcdate(d) = localdate(d, "UTC")
4333 > EOF
4340 > EOF
4334
4341
4335 $ hg debugtemplate -vr0 '{rn} {utcdate(date)|isodate}\n'
4342 $ hg debugtemplate -vr0 '{rn} {utcdate(date)|isodate}\n'
4336 (template
4343 (template
4337 (symbol 'rn')
4344 (symbol 'rn')
4338 (string ' ')
4345 (string ' ')
4339 (|
4346 (|
4340 (func
4347 (func
4341 (symbol 'utcdate')
4348 (symbol 'utcdate')
4342 (symbol 'date'))
4349 (symbol 'date'))
4343 (symbol 'isodate'))
4350 (symbol 'isodate'))
4344 (string '\n'))
4351 (string '\n'))
4345 * expanded:
4352 * expanded:
4346 (template
4353 (template
4347 (template
4354 (template
4348 (symbol 'rev')
4355 (symbol 'rev')
4349 (string ':')
4356 (string ':')
4350 (|
4357 (|
4351 (symbol 'node')
4358 (symbol 'node')
4352 (symbol 'short')))
4359 (symbol 'short')))
4353 (string ' ')
4360 (string ' ')
4354 (|
4361 (|
4355 (func
4362 (func
4356 (symbol 'localdate')
4363 (symbol 'localdate')
4357 (list
4364 (list
4358 (symbol 'date')
4365 (symbol 'date')
4359 (string 'UTC')))
4366 (string 'UTC')))
4360 (symbol 'isodate'))
4367 (symbol 'isodate'))
4361 (string '\n'))
4368 (string '\n'))
4362 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4369 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4363
4370
4364 $ hg debugtemplate -vr0 '{status("A", file_adds)}'
4371 $ hg debugtemplate -vr0 '{status("A", file_adds)}'
4365 (template
4372 (template
4366 (func
4373 (func
4367 (symbol 'status')
4374 (symbol 'status')
4368 (list
4375 (list
4369 (string 'A')
4376 (string 'A')
4370 (symbol 'file_adds'))))
4377 (symbol 'file_adds'))))
4371 * expanded:
4378 * expanded:
4372 (template
4379 (template
4373 (%
4380 (%
4374 (symbol 'file_adds')
4381 (symbol 'file_adds')
4375 (template
4382 (template
4376 (string 'A')
4383 (string 'A')
4377 (string ' ')
4384 (string ' ')
4378 (symbol 'file')
4385 (symbol 'file')
4379 (string '\n'))))
4386 (string '\n'))))
4380 A a
4387 A a
4381
4388
4382 A unary function alias can be called as a filter:
4389 A unary function alias can be called as a filter:
4383
4390
4384 $ hg debugtemplate -vr0 '{date|utcdate|isodate}\n'
4391 $ hg debugtemplate -vr0 '{date|utcdate|isodate}\n'
4385 (template
4392 (template
4386 (|
4393 (|
4387 (|
4394 (|
4388 (symbol 'date')
4395 (symbol 'date')
4389 (symbol 'utcdate'))
4396 (symbol 'utcdate'))
4390 (symbol 'isodate'))
4397 (symbol 'isodate'))
4391 (string '\n'))
4398 (string '\n'))
4392 * expanded:
4399 * expanded:
4393 (template
4400 (template
4394 (|
4401 (|
4395 (func
4402 (func
4396 (symbol 'localdate')
4403 (symbol 'localdate')
4397 (list
4404 (list
4398 (symbol 'date')
4405 (symbol 'date')
4399 (string 'UTC')))
4406 (string 'UTC')))
4400 (symbol 'isodate'))
4407 (symbol 'isodate'))
4401 (string '\n'))
4408 (string '\n'))
4402 1970-01-12 13:46 +0000
4409 1970-01-12 13:46 +0000
4403
4410
4404 Aliases should be applied only to command arguments and templates in hgrc.
4411 Aliases should be applied only to command arguments and templates in hgrc.
4405 Otherwise, our stock styles and web templates could be corrupted:
4412 Otherwise, our stock styles and web templates could be corrupted:
4406
4413
4407 $ hg log -r0 -T '{rn} {utcdate(date)|isodate}\n'
4414 $ hg log -r0 -T '{rn} {utcdate(date)|isodate}\n'
4408 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4415 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4409
4416
4410 $ hg log -r0 --config ui.logtemplate='"{rn} {utcdate(date)|isodate}\n"'
4417 $ hg log -r0 --config ui.logtemplate='"{rn} {utcdate(date)|isodate}\n"'
4411 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4418 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4412
4419
4413 $ cat <<EOF > tmpl
4420 $ cat <<EOF > tmpl
4414 > changeset = 'nothing expanded:{rn}\n'
4421 > changeset = 'nothing expanded:{rn}\n'
4415 > EOF
4422 > EOF
4416 $ hg log -r0 --style ./tmpl
4423 $ hg log -r0 --style ./tmpl
4417 nothing expanded:
4424 nothing expanded:
4418
4425
4419 Aliases in formatter:
4426 Aliases in formatter:
4420
4427
4421 $ hg branches -T '{pad(branch, 7)} {rn}\n'
4428 $ hg branches -T '{pad(branch, 7)} {rn}\n'
4422 default 6:d41e714fe50d
4429 default 6:d41e714fe50d
4423 foo 4:bbe44766e73d
4430 foo 4:bbe44766e73d
4424
4431
4425 Aliases should honor HGPLAIN:
4432 Aliases should honor HGPLAIN:
4426
4433
4427 $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n'
4434 $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n'
4428 nothing expanded:
4435 nothing expanded:
4429 $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n'
4436 $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n'
4430 0:1e4e1b8f71e0
4437 0:1e4e1b8f71e0
4431
4438
4432 Unparsable alias:
4439 Unparsable alias:
4433
4440
4434 $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}'
4441 $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}'
4435 (template
4442 (template
4436 (symbol 'bad'))
4443 (symbol 'bad'))
4437 abort: bad definition of template alias "bad": at 2: not a prefix: end
4444 abort: bad definition of template alias "bad": at 2: not a prefix: end
4438 [255]
4445 [255]
4439 $ hg log --config templatealias.bad='x(' -T '{bad}'
4446 $ hg log --config templatealias.bad='x(' -T '{bad}'
4440 abort: bad definition of template alias "bad": at 2: not a prefix: end
4447 abort: bad definition of template alias "bad": at 2: not a prefix: end
4441 [255]
4448 [255]
4442
4449
4443 $ cd ..
4450 $ cd ..
4444
4451
4445 Set up repository for non-ascii encoding tests:
4452 Set up repository for non-ascii encoding tests:
4446
4453
4447 $ hg init nonascii
4454 $ hg init nonascii
4448 $ cd nonascii
4455 $ cd nonascii
4449 $ $PYTHON <<EOF
4456 $ $PYTHON <<EOF
4450 > open('latin1', 'w').write('\xe9')
4457 > open('latin1', 'w').write('\xe9')
4451 > open('utf-8', 'w').write('\xc3\xa9')
4458 > open('utf-8', 'w').write('\xc3\xa9')
4452 > EOF
4459 > EOF
4453 $ HGENCODING=utf-8 hg branch -q `cat utf-8`
4460 $ HGENCODING=utf-8 hg branch -q `cat utf-8`
4454 $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8
4461 $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8
4455
4462
4456 json filter should try round-trip conversion to utf-8:
4463 json filter should try round-trip conversion to utf-8:
4457
4464
4458 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
4465 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
4459 "\u00e9"
4466 "\u00e9"
4460 $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0
4467 $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0
4461 "non-ascii branch: \u00e9"
4468 "non-ascii branch: \u00e9"
4462
4469
4463 json filter takes input as utf-8b:
4470 json filter takes input as utf-8b:
4464
4471
4465 $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1
4472 $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1
4466 "\u00e9"
4473 "\u00e9"
4467 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
4474 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
4468 "\udce9"
4475 "\udce9"
4469
4476
4470 utf8 filter:
4477 utf8 filter:
4471
4478
4472 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
4479 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
4473 round-trip: c3a9
4480 round-trip: c3a9
4474 $ HGENCODING=latin1 hg log -T "decoded: {'`cat latin1`'|utf8|hex}\n" -l1
4481 $ HGENCODING=latin1 hg log -T "decoded: {'`cat latin1`'|utf8|hex}\n" -l1
4475 decoded: c3a9
4482 decoded: c3a9
4476 $ HGENCODING=ascii hg log -T "replaced: {'`cat latin1`'|utf8|hex}\n" -l1
4483 $ HGENCODING=ascii hg log -T "replaced: {'`cat latin1`'|utf8|hex}\n" -l1
4477 abort: decoding near * (glob)
4484 abort: decoding near * (glob)
4478 [255]
4485 [255]
4479 $ hg log -T "invalid type: {rev|utf8}\n" -r0
4486 $ hg log -T "invalid type: {rev|utf8}\n" -r0
4480 abort: template filter 'utf8' is not compatible with keyword 'rev'
4487 abort: template filter 'utf8' is not compatible with keyword 'rev'
4481 [255]
4488 [255]
4482
4489
4483 pad width:
4490 pad width:
4484
4491
4485 $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
4492 $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
4486 \xc3\xa9- (esc)
4493 \xc3\xa9- (esc)
4487
4494
4488 $ cd ..
4495 $ cd ..
4489
4496
4490 Test that template function in extension is registered as expected
4497 Test that template function in extension is registered as expected
4491
4498
4492 $ cd a
4499 $ cd a
4493
4500
4494 $ cat <<EOF > $TESTTMP/customfunc.py
4501 $ cat <<EOF > $TESTTMP/customfunc.py
4495 > from mercurial import registrar
4502 > from mercurial import registrar
4496 >
4503 >
4497 > templatefunc = registrar.templatefunc()
4504 > templatefunc = registrar.templatefunc()
4498 >
4505 >
4499 > @templatefunc('custom()')
4506 > @templatefunc('custom()')
4500 > def custom(context, mapping, args):
4507 > def custom(context, mapping, args):
4501 > return 'custom'
4508 > return 'custom'
4502 > EOF
4509 > EOF
4503 $ cat <<EOF > .hg/hgrc
4510 $ cat <<EOF > .hg/hgrc
4504 > [extensions]
4511 > [extensions]
4505 > customfunc = $TESTTMP/customfunc.py
4512 > customfunc = $TESTTMP/customfunc.py
4506 > EOF
4513 > EOF
4507
4514
4508 $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true
4515 $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true
4509 custom
4516 custom
4510
4517
4511 $ cd ..
4518 $ cd ..
4512
4519
4513 Test 'graphwidth' in 'hg log' on various topologies. The key here is that the
4520 Test 'graphwidth' in 'hg log' on various topologies. The key here is that the
4514 printed graphwidths 3, 5, 7, etc. should all line up in their respective
4521 printed graphwidths 3, 5, 7, etc. should all line up in their respective
4515 columns. We don't care about other aspects of the graph rendering here.
4522 columns. We don't care about other aspects of the graph rendering here.
4516
4523
4517 $ hg init graphwidth
4524 $ hg init graphwidth
4518 $ cd graphwidth
4525 $ cd graphwidth
4519
4526
4520 $ wrappabletext="a a a a a a a a a a a a"
4527 $ wrappabletext="a a a a a a a a a a a a"
4521
4528
4522 $ printf "first\n" > file
4529 $ printf "first\n" > file
4523 $ hg add file
4530 $ hg add file
4524 $ hg commit -m "$wrappabletext"
4531 $ hg commit -m "$wrappabletext"
4525
4532
4526 $ printf "first\nsecond\n" > file
4533 $ printf "first\nsecond\n" > file
4527 $ hg commit -m "$wrappabletext"
4534 $ hg commit -m "$wrappabletext"
4528
4535
4529 $ hg checkout 0
4536 $ hg checkout 0
4530 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4537 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4531 $ printf "third\nfirst\n" > file
4538 $ printf "third\nfirst\n" > file
4532 $ hg commit -m "$wrappabletext"
4539 $ hg commit -m "$wrappabletext"
4533 created new head
4540 created new head
4534
4541
4535 $ hg merge
4542 $ hg merge
4536 merging file
4543 merging file
4537 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
4544 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
4538 (branch merge, don't forget to commit)
4545 (branch merge, don't forget to commit)
4539
4546
4540 $ hg log --graph -T "{graphwidth}"
4547 $ hg log --graph -T "{graphwidth}"
4541 @ 3
4548 @ 3
4542 |
4549 |
4543 | @ 5
4550 | @ 5
4544 |/
4551 |/
4545 o 3
4552 o 3
4546
4553
4547 $ hg commit -m "$wrappabletext"
4554 $ hg commit -m "$wrappabletext"
4548
4555
4549 $ hg log --graph -T "{graphwidth}"
4556 $ hg log --graph -T "{graphwidth}"
4550 @ 5
4557 @ 5
4551 |\
4558 |\
4552 | o 5
4559 | o 5
4553 | |
4560 | |
4554 o | 5
4561 o | 5
4555 |/
4562 |/
4556 o 3
4563 o 3
4557
4564
4558
4565
4559 $ hg checkout 0
4566 $ hg checkout 0
4560 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4567 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4561 $ printf "third\nfirst\nsecond\n" > file
4568 $ printf "third\nfirst\nsecond\n" > file
4562 $ hg commit -m "$wrappabletext"
4569 $ hg commit -m "$wrappabletext"
4563 created new head
4570 created new head
4564
4571
4565 $ hg log --graph -T "{graphwidth}"
4572 $ hg log --graph -T "{graphwidth}"
4566 @ 3
4573 @ 3
4567 |
4574 |
4568 | o 7
4575 | o 7
4569 | |\
4576 | |\
4570 +---o 7
4577 +---o 7
4571 | |
4578 | |
4572 | o 5
4579 | o 5
4573 |/
4580 |/
4574 o 3
4581 o 3
4575
4582
4576
4583
4577 $ hg log --graph -T "{graphwidth}" -r 3
4584 $ hg log --graph -T "{graphwidth}" -r 3
4578 o 5
4585 o 5
4579 |\
4586 |\
4580 ~ ~
4587 ~ ~
4581
4588
4582 $ hg log --graph -T "{graphwidth}" -r 1
4589 $ hg log --graph -T "{graphwidth}" -r 1
4583 o 3
4590 o 3
4584 |
4591 |
4585 ~
4592 ~
4586
4593
4587 $ hg merge
4594 $ hg merge
4588 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4595 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4589 (branch merge, don't forget to commit)
4596 (branch merge, don't forget to commit)
4590 $ hg commit -m "$wrappabletext"
4597 $ hg commit -m "$wrappabletext"
4591
4598
4592 $ printf "seventh\n" >> file
4599 $ printf "seventh\n" >> file
4593 $ hg commit -m "$wrappabletext"
4600 $ hg commit -m "$wrappabletext"
4594
4601
4595 $ hg log --graph -T "{graphwidth}"
4602 $ hg log --graph -T "{graphwidth}"
4596 @ 3
4603 @ 3
4597 |
4604 |
4598 o 5
4605 o 5
4599 |\
4606 |\
4600 | o 5
4607 | o 5
4601 | |
4608 | |
4602 o | 7
4609 o | 7
4603 |\ \
4610 |\ \
4604 | o | 7
4611 | o | 7
4605 | |/
4612 | |/
4606 o / 5
4613 o / 5
4607 |/
4614 |/
4608 o 3
4615 o 3
4609
4616
4610
4617
4611 The point of graphwidth is to allow wrapping that accounts for the space taken
4618 The point of graphwidth is to allow wrapping that accounts for the space taken
4612 by the graph.
4619 by the graph.
4613
4620
4614 $ COLUMNS=10 hg log --graph -T "{fill(desc, termwidth - graphwidth)}"
4621 $ COLUMNS=10 hg log --graph -T "{fill(desc, termwidth - graphwidth)}"
4615 @ a a a a
4622 @ a a a a
4616 | a a a a
4623 | a a a a
4617 | a a a a
4624 | a a a a
4618 o a a a
4625 o a a a
4619 |\ a a a
4626 |\ a a a
4620 | | a a a
4627 | | a a a
4621 | | a a a
4628 | | a a a
4622 | o a a a
4629 | o a a a
4623 | | a a a
4630 | | a a a
4624 | | a a a
4631 | | a a a
4625 | | a a a
4632 | | a a a
4626 o | a a
4633 o | a a
4627 |\ \ a a
4634 |\ \ a a
4628 | | | a a
4635 | | | a a
4629 | | | a a
4636 | | | a a
4630 | | | a a
4637 | | | a a
4631 | | | a a
4638 | | | a a
4632 | o | a a
4639 | o | a a
4633 | |/ a a
4640 | |/ a a
4634 | | a a
4641 | | a a
4635 | | a a
4642 | | a a
4636 | | a a
4643 | | a a
4637 | | a a
4644 | | a a
4638 o | a a a
4645 o | a a a
4639 |/ a a a
4646 |/ a a a
4640 | a a a
4647 | a a a
4641 | a a a
4648 | a a a
4642 o a a a a
4649 o a a a a
4643 a a a a
4650 a a a a
4644 a a a a
4651 a a a a
4645
4652
4646 Something tricky happens when there are elided nodes; the next drawn row of
4653 Something tricky happens when there are elided nodes; the next drawn row of
4647 edges can be more than one column wider, but the graph width only increases by
4654 edges can be more than one column wider, but the graph width only increases by
4648 one column. The remaining columns are added in between the nodes.
4655 one column. The remaining columns are added in between the nodes.
4649
4656
4650 $ hg log --graph -T "{graphwidth}" -r "0|2|4|5"
4657 $ hg log --graph -T "{graphwidth}" -r "0|2|4|5"
4651 o 5
4658 o 5
4652 |\
4659 |\
4653 | \
4660 | \
4654 | :\
4661 | :\
4655 o : : 7
4662 o : : 7
4656 :/ /
4663 :/ /
4657 : o 5
4664 : o 5
4658 :/
4665 :/
4659 o 3
4666 o 3
4660
4667
4661
4668
4662 $ cd ..
4669 $ cd ..
4663
4670
General Comments 0
You need to be logged in to leave comments. Login now