##// END OF EJS Templates
logcmdutil: rewrite jsonchangeset printer to be backed by jsonformatter...
Yuya Nishihara -
r38026:814151cd default
parent child Browse files
Show More
@@ -1,940 +1,913 b''
1 1 # logcmdutil.py - utility for log-like commands
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import itertools
11 11 import os
12 12
13 13 from .i18n import _
14 14 from .node import (
15 hex,
16 15 nullid,
17 16 )
18 17
19 18 from . import (
20 19 dagop,
21 encoding,
22 20 error,
23 21 formatter,
24 22 graphmod,
25 23 match as matchmod,
26 24 mdiff,
27 25 patch,
28 26 pathutil,
29 27 pycompat,
30 28 revset,
31 29 revsetlang,
32 30 scmutil,
33 31 smartset,
34 32 templatekw,
35 33 templater,
36 34 util,
37 35 )
38 36 from .utils import (
39 37 dateutil,
40 38 stringutil,
41 39 )
42 40
43 41 def getlimit(opts):
44 42 """get the log limit according to option -l/--limit"""
45 43 limit = opts.get('limit')
46 44 if limit:
47 45 try:
48 46 limit = int(limit)
49 47 except ValueError:
50 48 raise error.Abort(_('limit must be a positive integer'))
51 49 if limit <= 0:
52 50 raise error.Abort(_('limit must be positive'))
53 51 else:
54 52 limit = None
55 53 return limit
56 54
57 55 def diffordiffstat(ui, repo, diffopts, node1, node2, match,
58 56 changes=None, stat=False, fp=None, prefix='',
59 57 root='', listsubrepos=False, hunksfilterfn=None):
60 58 '''show diff or diffstat.'''
61 59 if root:
62 60 relroot = pathutil.canonpath(repo.root, repo.getcwd(), root)
63 61 else:
64 62 relroot = ''
65 63 if relroot != '':
66 64 # XXX relative roots currently don't work if the root is within a
67 65 # subrepo
68 66 uirelroot = match.uipath(relroot)
69 67 relroot += '/'
70 68 for matchroot in match.files():
71 69 if not matchroot.startswith(relroot):
72 70 ui.warn(_('warning: %s not inside relative root %s\n') % (
73 71 match.uipath(matchroot), uirelroot))
74 72
75 73 if stat:
76 74 diffopts = diffopts.copy(context=0, noprefix=False)
77 75 width = 80
78 76 if not ui.plain():
79 77 width = ui.termwidth()
80 78
81 79 chunks = patch.diff(repo, node1, node2, match, changes, opts=diffopts,
82 80 prefix=prefix, relroot=relroot,
83 81 hunksfilterfn=hunksfilterfn)
84 82
85 83 if fp is not None or ui.canwritewithoutlabels():
86 84 out = fp or ui
87 85 if stat:
88 86 chunks = [patch.diffstat(util.iterlines(chunks), width=width)]
89 87 for chunk in util.filechunkiter(util.chunkbuffer(chunks)):
90 88 out.write(chunk)
91 89 else:
92 90 if stat:
93 91 chunks = patch.diffstatui(util.iterlines(chunks), width=width)
94 92 else:
95 93 chunks = patch.difflabel(lambda chunks, **kwargs: chunks, chunks,
96 94 opts=diffopts)
97 95 if ui.canbatchlabeledwrites():
98 96 def gen():
99 97 for chunk, label in chunks:
100 98 yield ui.label(chunk, label=label)
101 99 for chunk in util.filechunkiter(util.chunkbuffer(gen())):
102 100 ui.write(chunk)
103 101 else:
104 102 for chunk, label in chunks:
105 103 ui.write(chunk, label=label)
106 104
107 105 if listsubrepos:
108 106 ctx1 = repo[node1]
109 107 ctx2 = repo[node2]
110 108 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
111 109 tempnode2 = node2
112 110 try:
113 111 if node2 is not None:
114 112 tempnode2 = ctx2.substate[subpath][1]
115 113 except KeyError:
116 114 # A subrepo that existed in node1 was deleted between node1 and
117 115 # node2 (inclusive). Thus, ctx2's substate won't contain that
118 116 # subpath. The best we can do is to ignore it.
119 117 tempnode2 = None
120 118 submatch = matchmod.subdirmatcher(subpath, match)
121 119 sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
122 120 stat=stat, fp=fp, prefix=prefix)
123 121
124 122 class changesetdiffer(object):
125 123 """Generate diff of changeset with pre-configured filtering functions"""
126 124
127 125 def _makefilematcher(self, ctx):
128 126 return scmutil.matchall(ctx.repo())
129 127
130 128 def _makehunksfilter(self, ctx):
131 129 return None
132 130
133 131 def showdiff(self, ui, ctx, diffopts, stat=False):
134 132 repo = ctx.repo()
135 133 node = ctx.node()
136 134 prev = ctx.p1().node()
137 135 diffordiffstat(ui, repo, diffopts, prev, node,
138 136 match=self._makefilematcher(ctx), stat=stat,
139 137 hunksfilterfn=self._makehunksfilter(ctx))
140 138
141 139 def changesetlabels(ctx):
142 140 labels = ['log.changeset', 'changeset.%s' % ctx.phasestr()]
143 141 if ctx.obsolete():
144 142 labels.append('changeset.obsolete')
145 143 if ctx.isunstable():
146 144 labels.append('changeset.unstable')
147 145 for instability in ctx.instabilities():
148 146 labels.append('instability.%s' % instability)
149 147 return ' '.join(labels)
150 148
151 149 class changesetprinter(object):
152 150 '''show changeset information when templating not requested.'''
153 151
154 152 def __init__(self, ui, repo, differ=None, diffopts=None, buffered=False):
155 153 self.ui = ui
156 154 self.repo = repo
157 155 self.buffered = buffered
158 156 self._differ = differ or changesetdiffer()
159 157 self.diffopts = diffopts or {}
160 158 self.header = {}
161 159 self.hunk = {}
162 160 self.lastheader = None
163 161 self.footer = None
164 162 self._columns = templatekw.getlogcolumns()
165 163
166 164 def flush(self, ctx):
167 165 rev = ctx.rev()
168 166 if rev in self.header:
169 167 h = self.header[rev]
170 168 if h != self.lastheader:
171 169 self.lastheader = h
172 170 self.ui.write(h)
173 171 del self.header[rev]
174 172 if rev in self.hunk:
175 173 self.ui.write(self.hunk[rev])
176 174 del self.hunk[rev]
177 175
178 176 def close(self):
179 177 if self.footer:
180 178 self.ui.write(self.footer)
181 179
182 180 def show(self, ctx, copies=None, **props):
183 181 props = pycompat.byteskwargs(props)
184 182 if self.buffered:
185 183 self.ui.pushbuffer(labeled=True)
186 184 self._show(ctx, copies, props)
187 185 self.hunk[ctx.rev()] = self.ui.popbuffer()
188 186 else:
189 187 self._show(ctx, copies, props)
190 188
191 189 def _show(self, ctx, copies, props):
192 190 '''show a single changeset or file revision'''
193 191 changenode = ctx.node()
194 192 rev = ctx.rev()
195 193
196 194 if self.ui.quiet:
197 195 self.ui.write("%s\n" % scmutil.formatchangeid(ctx),
198 196 label='log.node')
199 197 return
200 198
201 199 columns = self._columns
202 200 self.ui.write(columns['changeset'] % scmutil.formatchangeid(ctx),
203 201 label=changesetlabels(ctx))
204 202
205 203 # branches are shown first before any other names due to backwards
206 204 # compatibility
207 205 branch = ctx.branch()
208 206 # don't show the default branch name
209 207 if branch != 'default':
210 208 self.ui.write(columns['branch'] % branch, label='log.branch')
211 209
212 210 for nsname, ns in self.repo.names.iteritems():
213 211 # branches has special logic already handled above, so here we just
214 212 # skip it
215 213 if nsname == 'branches':
216 214 continue
217 215 # we will use the templatename as the color name since those two
218 216 # should be the same
219 217 for name in ns.names(self.repo, changenode):
220 218 self.ui.write(ns.logfmt % name,
221 219 label='log.%s' % ns.colorname)
222 220 if self.ui.debugflag:
223 221 self.ui.write(columns['phase'] % ctx.phasestr(), label='log.phase')
224 222 for pctx in scmutil.meaningfulparents(self.repo, ctx):
225 223 label = 'log.parent changeset.%s' % pctx.phasestr()
226 224 self.ui.write(columns['parent'] % scmutil.formatchangeid(pctx),
227 225 label=label)
228 226
229 227 if self.ui.debugflag and rev is not None:
230 228 mnode = ctx.manifestnode()
231 229 mrev = self.repo.manifestlog._revlog.rev(mnode)
232 230 self.ui.write(columns['manifest']
233 231 % scmutil.formatrevnode(self.ui, mrev, mnode),
234 232 label='ui.debug log.manifest')
235 233 self.ui.write(columns['user'] % ctx.user(), label='log.user')
236 234 self.ui.write(columns['date'] % dateutil.datestr(ctx.date()),
237 235 label='log.date')
238 236
239 237 if ctx.isunstable():
240 238 instabilities = ctx.instabilities()
241 239 self.ui.write(columns['instability'] % ', '.join(instabilities),
242 240 label='log.instability')
243 241
244 242 elif ctx.obsolete():
245 243 self._showobsfate(ctx)
246 244
247 245 self._exthook(ctx)
248 246
249 247 if self.ui.debugflag:
250 248 files = ctx.p1().status(ctx)[:3]
251 249 for key, value in zip(['files', 'files+', 'files-'], files):
252 250 if value:
253 251 self.ui.write(columns[key] % " ".join(value),
254 252 label='ui.debug log.files')
255 253 elif ctx.files() and self.ui.verbose:
256 254 self.ui.write(columns['files'] % " ".join(ctx.files()),
257 255 label='ui.note log.files')
258 256 if copies and self.ui.verbose:
259 257 copies = ['%s (%s)' % c for c in copies]
260 258 self.ui.write(columns['copies'] % ' '.join(copies),
261 259 label='ui.note log.copies')
262 260
263 261 extra = ctx.extra()
264 262 if extra and self.ui.debugflag:
265 263 for key, value in sorted(extra.items()):
266 264 self.ui.write(columns['extra']
267 265 % (key, stringutil.escapestr(value)),
268 266 label='ui.debug log.extra')
269 267
270 268 description = ctx.description().strip()
271 269 if description:
272 270 if self.ui.verbose:
273 271 self.ui.write(_("description:\n"),
274 272 label='ui.note log.description')
275 273 self.ui.write(description,
276 274 label='ui.note log.description')
277 275 self.ui.write("\n\n")
278 276 else:
279 277 self.ui.write(columns['summary'] % description.splitlines()[0],
280 278 label='log.summary')
281 279 self.ui.write("\n")
282 280
283 281 self._showpatch(ctx)
284 282
285 283 def _showobsfate(self, ctx):
286 284 # TODO: do not depend on templater
287 285 tres = formatter.templateresources(self.repo.ui, self.repo)
288 286 t = formatter.maketemplater(self.repo.ui, '{join(obsfate, "\n")}',
289 287 defaults=templatekw.keywords,
290 288 resources=tres)
291 289 obsfate = t.renderdefault({'ctx': ctx}).splitlines()
292 290
293 291 if obsfate:
294 292 for obsfateline in obsfate:
295 293 self.ui.write(self._columns['obsolete'] % obsfateline,
296 294 label='log.obsfate')
297 295
298 296 def _exthook(self, ctx):
299 297 '''empty method used by extension as a hook point
300 298 '''
301 299
302 300 def _showpatch(self, ctx):
303 301 stat = self.diffopts.get('stat')
304 302 diff = self.diffopts.get('patch')
305 303 diffopts = patch.diffallopts(self.ui, self.diffopts)
306 304 if stat:
307 305 self._differ.showdiff(self.ui, ctx, diffopts, stat=True)
308 306 if stat and diff:
309 307 self.ui.write("\n")
310 308 if diff:
311 309 self._differ.showdiff(self.ui, ctx, diffopts, stat=False)
312 310 if stat or diff:
313 311 self.ui.write("\n")
314 312
315 313 class jsonchangeset(changesetprinter):
316 314 '''format changeset information.'''
317 315
318 316 def __init__(self, ui, repo, differ=None, diffopts=None, buffered=False):
319 317 changesetprinter.__init__(self, ui, repo, differ, diffopts, buffered)
320 self._first = True
318 self._fm = formatter.jsonformatter(ui, ui, 'log', {})
321 319
322 320 def close(self):
323 if not self._first:
324 self.ui.write("\n]\n")
325 else:
326 self.ui.write("[]\n")
321 self._fm.end()
327 322
328 323 def _show(self, ctx, copies, props):
329 324 '''show a single changeset or file revision'''
325 fm = self._fm
326 fm.startitem()
327
328 # TODO: maybe this should be wdirrev/wdirnode?
330 329 rev = ctx.rev()
331 330 if rev is None:
332 jrev = jnode = 'null'
331 hexnode = None
333 332 else:
334 jrev = '%d' % rev
335 jnode = '"%s"' % hex(ctx.node())
336 j = encoding.jsonescape
337
338 if self._first:
339 self.ui.write("[\n {")
340 self._first = False
341 else:
342 self.ui.write(",\n {")
333 hexnode = fm.hexfunc(ctx.node())
334 fm.data(rev=rev,
335 node=hexnode)
343 336
344 337 if self.ui.quiet:
345 self.ui.write(('\n "rev": %s') % jrev)
346 self.ui.write((',\n "node": %s') % jnode)
347 self.ui.write('\n }')
348 338 return
349 339
350 self.ui.write(('\n "rev": %s') % jrev)
351 self.ui.write((',\n "node": %s') % jnode)
352 self.ui.write((',\n "branch": "%s"') % j(ctx.branch()))
353 self.ui.write((',\n "phase": "%s"') % ctx.phasestr())
354 self.ui.write((',\n "user": "%s"') % j(ctx.user()))
355 self.ui.write((',\n "date": [%d, %d]') % ctx.date())
356 self.ui.write((',\n "desc": "%s"') % j(ctx.description()))
357
358 self.ui.write((',\n "bookmarks": [%s]') %
359 ", ".join('"%s"' % j(b) for b in ctx.bookmarks()))
360 self.ui.write((',\n "tags": [%s]') %
361 ", ".join('"%s"' % j(t) for t in ctx.tags()))
362 self.ui.write((',\n "parents": [%s]') %
363 ", ".join('"%s"' % c.hex() for c in ctx.parents()))
340 fm.data(branch=ctx.branch(),
341 phase=ctx.phasestr(),
342 user=ctx.user(),
343 date=fm.formatdate(ctx.date()),
344 desc=ctx.description(),
345 bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark'),
346 tags=fm.formatlist(ctx.tags(), name='tag'),
347 parents=fm.formatlist([fm.hexfunc(c.node())
348 for c in ctx.parents()], name='node'))
364 349
365 350 if self.ui.debugflag:
366 351 if rev is None:
367 jmanifestnode = 'null'
352 hexnode = None
368 353 else:
369 jmanifestnode = '"%s"' % hex(ctx.manifestnode())
370 self.ui.write((',\n "manifest": %s') % jmanifestnode)
371
372 self.ui.write((',\n "extra": {%s}') %
373 ", ".join('"%s": "%s"' % (j(k), j(v))
374 for k, v in ctx.extra().items()))
354 hexnode = fm.hexfunc(ctx.manifestnode())
355 fm.data(manifest=hexnode,
356 extra=fm.formatdict(ctx.extra()))
375 357
376 358 files = ctx.p1().status(ctx)
377 self.ui.write((',\n "modified": [%s]') %
378 ", ".join('"%s"' % j(f) for f in files[0]))
379 self.ui.write((',\n "added": [%s]') %
380 ", ".join('"%s"' % j(f) for f in files[1]))
381 self.ui.write((',\n "removed": [%s]') %
382 ", ".join('"%s"' % j(f) for f in files[2]))
359 fm.data(modified=fm.formatlist(files[0], name='file'),
360 added=fm.formatlist(files[1], name='file'),
361 removed=fm.formatlist(files[2], name='file'))
383 362
384 363 elif self.ui.verbose:
385 self.ui.write((',\n "files": [%s]') %
386 ", ".join('"%s"' % j(f) for f in ctx.files()))
387
364 fm.data(files=fm.formatlist(ctx.files(), name='file'))
388 365 if copies:
389 self.ui.write((',\n "copies": {%s}') %
390 ", ".join('"%s": "%s"' % (j(k), j(v))
391 for k, v in copies))
366 fm.data(copies=fm.formatdict(copies,
367 key='name', value='source'))
392 368
393 369 stat = self.diffopts.get('stat')
394 370 diff = self.diffopts.get('patch')
395 371 diffopts = patch.difffeatureopts(self.ui, self.diffopts, git=True)
396 372 if stat:
397 373 self.ui.pushbuffer()
398 374 self._differ.showdiff(self.ui, ctx, diffopts, stat=True)
399 self.ui.write((',\n "diffstat": "%s"')
400 % j(self.ui.popbuffer()))
375 fm.data(diffstat=self.ui.popbuffer())
401 376 if diff:
402 377 self.ui.pushbuffer()
403 378 self._differ.showdiff(self.ui, ctx, diffopts, stat=False)
404 self.ui.write((',\n "diff": "%s"') % j(self.ui.popbuffer()))
405
406 self.ui.write("\n }")
379 fm.data(diff=self.ui.popbuffer())
407 380
408 381 class changesettemplater(changesetprinter):
409 382 '''format changeset information.
410 383
411 384 Note: there are a variety of convenience functions to build a
412 385 changesettemplater for common cases. See functions such as:
413 386 maketemplater, changesetdisplayer, buildcommittemplate, or other
414 387 functions that use changesest_templater.
415 388 '''
416 389
417 390 # Arguments before "buffered" used to be positional. Consider not
418 391 # adding/removing arguments before "buffered" to not break callers.
419 392 def __init__(self, ui, repo, tmplspec, differ=None, diffopts=None,
420 393 buffered=False):
421 394 changesetprinter.__init__(self, ui, repo, differ, diffopts, buffered)
422 395 # tres is shared with _graphnodeformatter()
423 396 self._tresources = tres = formatter.templateresources(ui, repo)
424 397 self.t = formatter.loadtemplater(ui, tmplspec,
425 398 defaults=templatekw.keywords,
426 399 resources=tres,
427 400 cache=templatekw.defaulttempl)
428 401 self._counter = itertools.count()
429 402
430 403 self._tref = tmplspec.ref
431 404 self._parts = {'header': '', 'footer': '',
432 405 tmplspec.ref: tmplspec.ref,
433 406 'docheader': '', 'docfooter': '',
434 407 'separator': ''}
435 408 if tmplspec.mapfile:
436 409 # find correct templates for current mode, for backward
437 410 # compatibility with 'log -v/-q/--debug' using a mapfile
438 411 tmplmodes = [
439 412 (True, ''),
440 413 (self.ui.verbose, '_verbose'),
441 414 (self.ui.quiet, '_quiet'),
442 415 (self.ui.debugflag, '_debug'),
443 416 ]
444 417 for mode, postfix in tmplmodes:
445 418 for t in self._parts:
446 419 cur = t + postfix
447 420 if mode and cur in self.t:
448 421 self._parts[t] = cur
449 422 else:
450 423 partnames = [p for p in self._parts.keys() if p != tmplspec.ref]
451 424 m = formatter.templatepartsmap(tmplspec, self.t, partnames)
452 425 self._parts.update(m)
453 426
454 427 if self._parts['docheader']:
455 428 self.ui.write(self.t.render(self._parts['docheader'], {}))
456 429
457 430 def close(self):
458 431 if self._parts['docfooter']:
459 432 if not self.footer:
460 433 self.footer = ""
461 434 self.footer += self.t.render(self._parts['docfooter'], {})
462 435 return super(changesettemplater, self).close()
463 436
464 437 def _show(self, ctx, copies, props):
465 438 '''show a single changeset or file revision'''
466 439 props = props.copy()
467 440 props['ctx'] = ctx
468 441 props['index'] = index = next(self._counter)
469 442 props['revcache'] = {'copies': copies}
470 443
471 444 # write separator, which wouldn't work well with the header part below
472 445 # since there's inherently a conflict between header (across items) and
473 446 # separator (per item)
474 447 if self._parts['separator'] and index > 0:
475 448 self.ui.write(self.t.render(self._parts['separator'], {}))
476 449
477 450 # write header
478 451 if self._parts['header']:
479 452 h = self.t.render(self._parts['header'], props)
480 453 if self.buffered:
481 454 self.header[ctx.rev()] = h
482 455 else:
483 456 if self.lastheader != h:
484 457 self.lastheader = h
485 458 self.ui.write(h)
486 459
487 460 # write changeset metadata, then patch if requested
488 461 key = self._parts[self._tref]
489 462 self.ui.write(self.t.render(key, props))
490 463 self._showpatch(ctx)
491 464
492 465 if self._parts['footer']:
493 466 if not self.footer:
494 467 self.footer = self.t.render(self._parts['footer'], props)
495 468
496 469 def templatespec(tmpl, mapfile):
497 470 if mapfile:
498 471 return formatter.templatespec('changeset', tmpl, mapfile)
499 472 else:
500 473 return formatter.templatespec('', tmpl, None)
501 474
502 475 def _lookuptemplate(ui, tmpl, style):
503 476 """Find the template matching the given template spec or style
504 477
505 478 See formatter.lookuptemplate() for details.
506 479 """
507 480
508 481 # ui settings
509 482 if not tmpl and not style: # template are stronger than style
510 483 tmpl = ui.config('ui', 'logtemplate')
511 484 if tmpl:
512 485 return templatespec(templater.unquotestring(tmpl), None)
513 486 else:
514 487 style = util.expandpath(ui.config('ui', 'style'))
515 488
516 489 if not tmpl and style:
517 490 mapfile = style
518 491 if not os.path.split(mapfile)[0]:
519 492 mapname = (templater.templatepath('map-cmdline.' + mapfile)
520 493 or templater.templatepath(mapfile))
521 494 if mapname:
522 495 mapfile = mapname
523 496 return templatespec(None, mapfile)
524 497
525 498 if not tmpl:
526 499 return templatespec(None, None)
527 500
528 501 return formatter.lookuptemplate(ui, 'changeset', tmpl)
529 502
530 503 def maketemplater(ui, repo, tmpl, buffered=False):
531 504 """Create a changesettemplater from a literal template 'tmpl'
532 505 byte-string."""
533 506 spec = templatespec(tmpl, None)
534 507 return changesettemplater(ui, repo, spec, buffered=buffered)
535 508
536 509 def changesetdisplayer(ui, repo, opts, differ=None, buffered=False):
537 510 """show one changeset using template or regular display.
538 511
539 512 Display format will be the first non-empty hit of:
540 513 1. option 'template'
541 514 2. option 'style'
542 515 3. [ui] setting 'logtemplate'
543 516 4. [ui] setting 'style'
544 517 If all of these values are either the unset or the empty string,
545 518 regular display via changesetprinter() is done.
546 519 """
547 520 postargs = (differ, opts, buffered)
548 521 if opts.get('template') == 'json':
549 522 return jsonchangeset(ui, repo, *postargs)
550 523
551 524 spec = _lookuptemplate(ui, opts.get('template'), opts.get('style'))
552 525
553 526 if not spec.ref and not spec.tmpl and not spec.mapfile:
554 527 return changesetprinter(ui, repo, *postargs)
555 528
556 529 return changesettemplater(ui, repo, spec, *postargs)
557 530
558 531 def _makematcher(repo, revs, pats, opts):
559 532 """Build matcher and expanded patterns from log options
560 533
561 534 If --follow, revs are the revisions to follow from.
562 535
563 536 Returns (match, pats, slowpath) where
564 537 - match: a matcher built from the given pats and -I/-X opts
565 538 - pats: patterns used (globs are expanded on Windows)
566 539 - slowpath: True if patterns aren't as simple as scanning filelogs
567 540 """
568 541 # pats/include/exclude are passed to match.match() directly in
569 542 # _matchfiles() revset but walkchangerevs() builds its matcher with
570 543 # scmutil.match(). The difference is input pats are globbed on
571 544 # platforms without shell expansion (windows).
572 545 wctx = repo[None]
573 546 match, pats = scmutil.matchandpats(wctx, pats, opts)
574 547 slowpath = match.anypats() or (not match.always() and opts.get('removed'))
575 548 if not slowpath:
576 549 follow = opts.get('follow') or opts.get('follow_first')
577 550 startctxs = []
578 551 if follow and opts.get('rev'):
579 552 startctxs = [repo[r] for r in revs]
580 553 for f in match.files():
581 554 if follow and startctxs:
582 555 # No idea if the path was a directory at that revision, so
583 556 # take the slow path.
584 557 if any(f not in c for c in startctxs):
585 558 slowpath = True
586 559 continue
587 560 elif follow and f not in wctx:
588 561 # If the file exists, it may be a directory, so let it
589 562 # take the slow path.
590 563 if os.path.exists(repo.wjoin(f)):
591 564 slowpath = True
592 565 continue
593 566 else:
594 567 raise error.Abort(_('cannot follow file not in parent '
595 568 'revision: "%s"') % f)
596 569 filelog = repo.file(f)
597 570 if not filelog:
598 571 # A zero count may be a directory or deleted file, so
599 572 # try to find matching entries on the slow path.
600 573 if follow:
601 574 raise error.Abort(
602 575 _('cannot follow nonexistent file: "%s"') % f)
603 576 slowpath = True
604 577
605 578 # We decided to fall back to the slowpath because at least one
606 579 # of the paths was not a file. Check to see if at least one of them
607 580 # existed in history - in that case, we'll continue down the
608 581 # slowpath; otherwise, we can turn off the slowpath
609 582 if slowpath:
610 583 for path in match.files():
611 584 if path == '.' or path in repo.store:
612 585 break
613 586 else:
614 587 slowpath = False
615 588
616 589 return match, pats, slowpath
617 590
618 591 def _fileancestors(repo, revs, match, followfirst):
619 592 fctxs = []
620 593 for r in revs:
621 594 ctx = repo[r]
622 595 fctxs.extend(ctx[f].introfilectx() for f in ctx.walk(match))
623 596
624 597 # When displaying a revision with --patch --follow FILE, we have
625 598 # to know which file of the revision must be diffed. With
626 599 # --follow, we want the names of the ancestors of FILE in the
627 600 # revision, stored in "fcache". "fcache" is populated as a side effect
628 601 # of the graph traversal.
629 602 fcache = {}
630 603 def filematcher(ctx):
631 604 return scmutil.matchfiles(repo, fcache.get(ctx.rev(), []))
632 605
633 606 def revgen():
634 607 for rev, cs in dagop.filectxancestors(fctxs, followfirst=followfirst):
635 608 fcache[rev] = [c.path() for c in cs]
636 609 yield rev
637 610 return smartset.generatorset(revgen(), iterasc=False), filematcher
638 611
639 612 def _makenofollowfilematcher(repo, pats, opts):
640 613 '''hook for extensions to override the filematcher for non-follow cases'''
641 614 return None
642 615
643 616 _opt2logrevset = {
644 617 'no_merges': ('not merge()', None),
645 618 'only_merges': ('merge()', None),
646 619 '_matchfiles': (None, '_matchfiles(%ps)'),
647 620 'date': ('date(%s)', None),
648 621 'branch': ('branch(%s)', '%lr'),
649 622 '_patslog': ('filelog(%s)', '%lr'),
650 623 'keyword': ('keyword(%s)', '%lr'),
651 624 'prune': ('ancestors(%s)', 'not %lr'),
652 625 'user': ('user(%s)', '%lr'),
653 626 }
654 627
655 628 def _makerevset(repo, match, pats, slowpath, opts):
656 629 """Return a revset string built from log options and file patterns"""
657 630 opts = dict(opts)
658 631 # follow or not follow?
659 632 follow = opts.get('follow') or opts.get('follow_first')
660 633
661 634 # branch and only_branch are really aliases and must be handled at
662 635 # the same time
663 636 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
664 637 opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']]
665 638
666 639 if slowpath:
667 640 # See walkchangerevs() slow path.
668 641 #
669 642 # pats/include/exclude cannot be represented as separate
670 643 # revset expressions as their filtering logic applies at file
671 644 # level. For instance "-I a -X b" matches a revision touching
672 645 # "a" and "b" while "file(a) and not file(b)" does
673 646 # not. Besides, filesets are evaluated against the working
674 647 # directory.
675 648 matchargs = ['r:', 'd:relpath']
676 649 for p in pats:
677 650 matchargs.append('p:' + p)
678 651 for p in opts.get('include', []):
679 652 matchargs.append('i:' + p)
680 653 for p in opts.get('exclude', []):
681 654 matchargs.append('x:' + p)
682 655 opts['_matchfiles'] = matchargs
683 656 elif not follow:
684 657 opts['_patslog'] = list(pats)
685 658
686 659 expr = []
687 660 for op, val in sorted(opts.iteritems()):
688 661 if not val:
689 662 continue
690 663 if op not in _opt2logrevset:
691 664 continue
692 665 revop, listop = _opt2logrevset[op]
693 666 if revop and '%' not in revop:
694 667 expr.append(revop)
695 668 elif not listop:
696 669 expr.append(revsetlang.formatspec(revop, val))
697 670 else:
698 671 if revop:
699 672 val = [revsetlang.formatspec(revop, v) for v in val]
700 673 expr.append(revsetlang.formatspec(listop, val))
701 674
702 675 if expr:
703 676 expr = '(' + ' and '.join(expr) + ')'
704 677 else:
705 678 expr = None
706 679 return expr
707 680
708 681 def _initialrevs(repo, opts):
709 682 """Return the initial set of revisions to be filtered or followed"""
710 683 follow = opts.get('follow') or opts.get('follow_first')
711 684 if opts.get('rev'):
712 685 revs = scmutil.revrange(repo, opts['rev'])
713 686 elif follow and repo.dirstate.p1() == nullid:
714 687 revs = smartset.baseset()
715 688 elif follow:
716 689 revs = repo.revs('.')
717 690 else:
718 691 revs = smartset.spanset(repo)
719 692 revs.reverse()
720 693 return revs
721 694
722 695 def getrevs(repo, pats, opts):
723 696 """Return (revs, differ) where revs is a smartset
724 697
725 698 differ is a changesetdiffer with pre-configured file matcher.
726 699 """
727 700 follow = opts.get('follow') or opts.get('follow_first')
728 701 followfirst = opts.get('follow_first')
729 702 limit = getlimit(opts)
730 703 revs = _initialrevs(repo, opts)
731 704 if not revs:
732 705 return smartset.baseset(), None
733 706 match, pats, slowpath = _makematcher(repo, revs, pats, opts)
734 707 filematcher = None
735 708 if follow:
736 709 if slowpath or match.always():
737 710 revs = dagop.revancestors(repo, revs, followfirst=followfirst)
738 711 else:
739 712 revs, filematcher = _fileancestors(repo, revs, match, followfirst)
740 713 revs.reverse()
741 714 if filematcher is None:
742 715 filematcher = _makenofollowfilematcher(repo, pats, opts)
743 716 if filematcher is None:
744 717 def filematcher(ctx):
745 718 return match
746 719
747 720 expr = _makerevset(repo, match, pats, slowpath, opts)
748 721 if opts.get('graph') and opts.get('rev'):
749 722 # User-specified revs might be unsorted, but don't sort before
750 723 # _makerevset because it might depend on the order of revs
751 724 if not (revs.isdescending() or revs.istopo()):
752 725 revs.sort(reverse=True)
753 726 if expr:
754 727 matcher = revset.match(None, expr)
755 728 revs = matcher(repo, revs)
756 729 if limit is not None:
757 730 revs = revs.slice(0, limit)
758 731
759 732 differ = changesetdiffer()
760 733 differ._makefilematcher = filematcher
761 734 return revs, differ
762 735
763 736 def _parselinerangeopt(repo, opts):
764 737 """Parse --line-range log option and return a list of tuples (filename,
765 738 (fromline, toline)).
766 739 """
767 740 linerangebyfname = []
768 741 for pat in opts.get('line_range', []):
769 742 try:
770 743 pat, linerange = pat.rsplit(',', 1)
771 744 except ValueError:
772 745 raise error.Abort(_('malformatted line-range pattern %s') % pat)
773 746 try:
774 747 fromline, toline = map(int, linerange.split(':'))
775 748 except ValueError:
776 749 raise error.Abort(_("invalid line range for %s") % pat)
777 750 msg = _("line range pattern '%s' must match exactly one file") % pat
778 751 fname = scmutil.parsefollowlinespattern(repo, None, pat, msg)
779 752 linerangebyfname.append(
780 753 (fname, util.processlinerange(fromline, toline)))
781 754 return linerangebyfname
782 755
783 756 def getlinerangerevs(repo, userrevs, opts):
784 757 """Return (revs, differ).
785 758
786 759 "revs" are revisions obtained by processing "line-range" log options and
787 760 walking block ancestors of each specified file/line-range.
788 761
789 762 "differ" is a changesetdiffer with pre-configured file matcher and hunks
790 763 filter.
791 764 """
792 765 wctx = repo[None]
793 766
794 767 # Two-levels map of "rev -> file ctx -> [line range]".
795 768 linerangesbyrev = {}
796 769 for fname, (fromline, toline) in _parselinerangeopt(repo, opts):
797 770 if fname not in wctx:
798 771 raise error.Abort(_('cannot follow file not in parent '
799 772 'revision: "%s"') % fname)
800 773 fctx = wctx.filectx(fname)
801 774 for fctx, linerange in dagop.blockancestors(fctx, fromline, toline):
802 775 rev = fctx.introrev()
803 776 if rev not in userrevs:
804 777 continue
805 778 linerangesbyrev.setdefault(
806 779 rev, {}).setdefault(
807 780 fctx.path(), []).append(linerange)
808 781
809 782 def nofilterhunksfn(fctx, hunks):
810 783 return hunks
811 784
812 785 def hunksfilter(ctx):
813 786 fctxlineranges = linerangesbyrev.get(ctx.rev())
814 787 if fctxlineranges is None:
815 788 return nofilterhunksfn
816 789
817 790 def filterfn(fctx, hunks):
818 791 lineranges = fctxlineranges.get(fctx.path())
819 792 if lineranges is not None:
820 793 for hr, lines in hunks:
821 794 if hr is None: # binary
822 795 yield hr, lines
823 796 continue
824 797 if any(mdiff.hunkinrange(hr[2:], lr)
825 798 for lr in lineranges):
826 799 yield hr, lines
827 800 else:
828 801 for hunk in hunks:
829 802 yield hunk
830 803
831 804 return filterfn
832 805
833 806 def filematcher(ctx):
834 807 files = list(linerangesbyrev.get(ctx.rev(), []))
835 808 return scmutil.matchfiles(repo, files)
836 809
837 810 revs = sorted(linerangesbyrev, reverse=True)
838 811
839 812 differ = changesetdiffer()
840 813 differ._makefilematcher = filematcher
841 814 differ._makehunksfilter = hunksfilter
842 815 return revs, differ
843 816
844 817 def _graphnodeformatter(ui, displayer):
845 818 spec = ui.config('ui', 'graphnodetemplate')
846 819 if not spec:
847 820 return templatekw.getgraphnode # fast path for "{graphnode}"
848 821
849 822 spec = templater.unquotestring(spec)
850 823 if isinstance(displayer, changesettemplater):
851 824 # reuse cache of slow templates
852 825 tres = displayer._tresources
853 826 else:
854 827 tres = formatter.templateresources(ui)
855 828 templ = formatter.maketemplater(ui, spec, defaults=templatekw.keywords,
856 829 resources=tres)
857 830 def formatnode(repo, ctx):
858 831 props = {'ctx': ctx, 'repo': repo}
859 832 return templ.renderdefault(props)
860 833 return formatnode
861 834
862 835 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, props=None):
863 836 props = props or {}
864 837 formatnode = _graphnodeformatter(ui, displayer)
865 838 state = graphmod.asciistate()
866 839 styles = state['styles']
867 840
868 841 # only set graph styling if HGPLAIN is not set.
869 842 if ui.plain('graph'):
870 843 # set all edge styles to |, the default pre-3.8 behaviour
871 844 styles.update(dict.fromkeys(styles, '|'))
872 845 else:
873 846 edgetypes = {
874 847 'parent': graphmod.PARENT,
875 848 'grandparent': graphmod.GRANDPARENT,
876 849 'missing': graphmod.MISSINGPARENT
877 850 }
878 851 for name, key in edgetypes.items():
879 852 # experimental config: experimental.graphstyle.*
880 853 styles[key] = ui.config('experimental', 'graphstyle.%s' % name,
881 854 styles[key])
882 855 if not styles[key]:
883 856 styles[key] = None
884 857
885 858 # experimental config: experimental.graphshorten
886 859 state['graphshorten'] = ui.configbool('experimental', 'graphshorten')
887 860
888 861 for rev, type, ctx, parents in dag:
889 862 char = formatnode(repo, ctx)
890 863 copies = None
891 864 if getrenamed and ctx.rev():
892 865 copies = []
893 866 for fn in ctx.files():
894 867 rename = getrenamed(fn, ctx.rev())
895 868 if rename:
896 869 copies.append((fn, rename[0]))
897 870 edges = edgefn(type, char, state, rev, parents)
898 871 firstedge = next(edges)
899 872 width = firstedge[2]
900 873 displayer.show(ctx, copies=copies,
901 874 graphwidth=width, **pycompat.strkwargs(props))
902 875 lines = displayer.hunk.pop(rev).split('\n')
903 876 if not lines[-1]:
904 877 del lines[-1]
905 878 displayer.flush(ctx)
906 879 for type, char, width, coldata in itertools.chain([firstedge], edges):
907 880 graphmod.ascii(ui, state, type, char, lines, coldata)
908 881 lines = []
909 882 displayer.close()
910 883
911 884 def displaygraphrevs(ui, repo, revs, displayer, getrenamed):
912 885 revdag = graphmod.dagwalker(repo, revs)
913 886 displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges, getrenamed)
914 887
915 888 def displayrevs(ui, repo, revs, displayer, getrenamed):
916 889 for rev in revs:
917 890 ctx = repo[rev]
918 891 copies = None
919 892 if getrenamed is not None and rev:
920 893 copies = []
921 894 for fn in ctx.files():
922 895 rename = getrenamed(fn, rev)
923 896 if rename:
924 897 copies.append((fn, rename[0]))
925 898 displayer.show(ctx, copies=copies)
926 899 displayer.flush(ctx)
927 900 displayer.close()
928 901
929 902 def checkunsupportedgraphflags(pats, opts):
930 903 for op in ["newest_first"]:
931 904 if op in opts and opts[op]:
932 905 raise error.Abort(_("-G/--graph option is incompatible with --%s")
933 906 % op.replace("_", "-"))
934 907
935 908 def graphrevs(repo, nodes, opts):
936 909 limit = getlimit(opts)
937 910 nodes.reverse()
938 911 if limit is not None:
939 912 nodes = nodes[:limit]
940 913 return graphmod.nodes(repo, nodes)
@@ -1,4883 +1,4884 b''
1 1 $ hg init a
2 2 $ cd a
3 3 $ echo a > a
4 4 $ hg add a
5 5 $ echo line 1 > b
6 6 $ echo line 2 >> b
7 7 $ hg commit -l b -d '1000000 0' -u 'User Name <user@hostname>'
8 8
9 9 $ hg add b
10 10 $ echo other 1 > c
11 11 $ echo other 2 >> c
12 12 $ echo >> c
13 13 $ echo other 3 >> c
14 14 $ hg commit -l c -d '1100000 0' -u 'A. N. Other <other@place>'
15 15
16 16 $ hg add c
17 17 $ hg commit -m 'no person' -d '1200000 0' -u 'other@place'
18 18 $ echo c >> c
19 19 $ hg commit -m 'no user, no domain' -d '1300000 0' -u 'person'
20 20
21 21 $ echo foo > .hg/branch
22 22 $ hg commit -m 'new branch' -d '1400000 0' -u 'person'
23 23
24 24 $ hg co -q 3
25 25 $ echo other 4 >> d
26 26 $ hg add d
27 27 $ hg commit -m 'new head' -d '1500000 0' -u 'person'
28 28
29 29 $ hg merge -q foo
30 30 $ hg commit -m 'merge' -d '1500001 0' -u 'person'
31 31
32 32 Test arithmetic operators have the right precedence:
33 33
34 34 $ hg log -l 1 -T '{date(date, "%Y") + 5 * 10} {date(date, "%Y") - 2 * 3}\n'
35 35 2020 1964
36 36 $ hg log -l 1 -T '{date(date, "%Y") * 5 + 10} {date(date, "%Y") * 3 - 2}\n'
37 37 9860 5908
38 38
39 39 Test division:
40 40
41 41 $ hg debugtemplate -r0 -v '{5 / 2} {mod(5, 2)}\n'
42 42 (template
43 43 (/
44 44 (integer '5')
45 45 (integer '2'))
46 46 (string ' ')
47 47 (func
48 48 (symbol 'mod')
49 49 (list
50 50 (integer '5')
51 51 (integer '2')))
52 52 (string '\n'))
53 53 2 1
54 54 $ hg debugtemplate -r0 -v '{5 / -2} {mod(5, -2)}\n'
55 55 (template
56 56 (/
57 57 (integer '5')
58 58 (negate
59 59 (integer '2')))
60 60 (string ' ')
61 61 (func
62 62 (symbol 'mod')
63 63 (list
64 64 (integer '5')
65 65 (negate
66 66 (integer '2'))))
67 67 (string '\n'))
68 68 -3 -1
69 69 $ hg debugtemplate -r0 -v '{-5 / 2} {mod(-5, 2)}\n'
70 70 (template
71 71 (/
72 72 (negate
73 73 (integer '5'))
74 74 (integer '2'))
75 75 (string ' ')
76 76 (func
77 77 (symbol 'mod')
78 78 (list
79 79 (negate
80 80 (integer '5'))
81 81 (integer '2')))
82 82 (string '\n'))
83 83 -3 1
84 84 $ hg debugtemplate -r0 -v '{-5 / -2} {mod(-5, -2)}\n'
85 85 (template
86 86 (/
87 87 (negate
88 88 (integer '5'))
89 89 (negate
90 90 (integer '2')))
91 91 (string ' ')
92 92 (func
93 93 (symbol 'mod')
94 94 (list
95 95 (negate
96 96 (integer '5'))
97 97 (negate
98 98 (integer '2'))))
99 99 (string '\n'))
100 100 2 -1
101 101
102 102 Filters bind closer than arithmetic:
103 103
104 104 $ hg debugtemplate -r0 -v '{revset(".")|count - 1}\n'
105 105 (template
106 106 (-
107 107 (|
108 108 (func
109 109 (symbol 'revset')
110 110 (string '.'))
111 111 (symbol 'count'))
112 112 (integer '1'))
113 113 (string '\n'))
114 114 0
115 115
116 116 But negate binds closer still:
117 117
118 118 $ hg debugtemplate -r0 -v '{1-3|stringify}\n'
119 119 (template
120 120 (-
121 121 (integer '1')
122 122 (|
123 123 (integer '3')
124 124 (symbol 'stringify')))
125 125 (string '\n'))
126 126 hg: parse error: arithmetic only defined on integers
127 127 [255]
128 128 $ hg debugtemplate -r0 -v '{-3|stringify}\n'
129 129 (template
130 130 (|
131 131 (negate
132 132 (integer '3'))
133 133 (symbol 'stringify'))
134 134 (string '\n'))
135 135 -3
136 136
137 137 Filters bind as close as map operator:
138 138
139 139 $ hg debugtemplate -r0 -v '{desc|splitlines % "{line}\n"}'
140 140 (template
141 141 (%
142 142 (|
143 143 (symbol 'desc')
144 144 (symbol 'splitlines'))
145 145 (template
146 146 (symbol 'line')
147 147 (string '\n'))))
148 148 line 1
149 149 line 2
150 150
151 151 Keyword arguments:
152 152
153 153 $ hg debugtemplate -r0 -v '{foo=bar|baz}'
154 154 (template
155 155 (keyvalue
156 156 (symbol 'foo')
157 157 (|
158 158 (symbol 'bar')
159 159 (symbol 'baz'))))
160 160 hg: parse error: can't use a key-value pair in this context
161 161 [255]
162 162
163 163 $ hg debugtemplate '{pad("foo", width=10, left=true)}\n'
164 164 foo
165 165
166 166 Call function which takes named arguments by filter syntax:
167 167
168 168 $ hg debugtemplate '{" "|separate}'
169 169 $ hg debugtemplate '{("not", "an", "argument", "list")|separate}'
170 170 hg: parse error: unknown method 'list'
171 171 [255]
172 172
173 173 Second branch starting at nullrev:
174 174
175 175 $ hg update null
176 176 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
177 177 $ echo second > second
178 178 $ hg add second
179 179 $ hg commit -m second -d '1000000 0' -u 'User Name <user@hostname>'
180 180 created new head
181 181
182 182 $ echo third > third
183 183 $ hg add third
184 184 $ hg mv second fourth
185 185 $ hg commit -m third -d "2020-01-01 10:01"
186 186
187 187 $ hg log --template '{join(file_copies, ",\n")}\n' -r .
188 188 fourth (second)
189 189 $ hg log -T '{file_copies % "{source} -> {name}\n"}' -r .
190 190 second -> fourth
191 191 $ hg log -T '{rev} {ifcontains("fourth", file_copies, "t", "f")}\n' -r .:7
192 192 8 t
193 193 7 f
194 194
195 195 Working-directory revision has special identifiers, though they are still
196 196 experimental:
197 197
198 198 $ hg log -r 'wdir()' -T '{rev}:{node}\n'
199 199 2147483647:ffffffffffffffffffffffffffffffffffffffff
200 200
201 201 Some keywords are invalid for working-directory revision, but they should
202 202 never cause crash:
203 203
204 204 $ hg log -r 'wdir()' -T '{manifest}\n'
205 205
206 206
207 207 Internal resources shouldn't be exposed (issue5699):
208 208
209 209 $ hg log -r. -T '{cache}{ctx}{repo}{revcache}{templ}{ui}'
210 210
211 211 Never crash on internal resource not available:
212 212
213 213 $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n'
214 214 abort: template resource not available: ctx
215 215 [255]
216 216
217 217 $ hg config -T '{author}'
218 218
219 219 Quoting for ui.logtemplate
220 220
221 221 $ hg tip --config "ui.logtemplate={rev}\n"
222 222 8
223 223 $ hg tip --config "ui.logtemplate='{rev}\n'"
224 224 8
225 225 $ hg tip --config 'ui.logtemplate="{rev}\n"'
226 226 8
227 227 $ hg tip --config 'ui.logtemplate=n{rev}\n'
228 228 n8
229 229
230 230 Make sure user/global hgrc does not affect tests
231 231
232 232 $ echo '[ui]' > .hg/hgrc
233 233 $ echo 'logtemplate =' >> .hg/hgrc
234 234 $ echo 'style =' >> .hg/hgrc
235 235
236 236 Add some simple styles to settings
237 237
238 238 $ cat <<'EOF' >> .hg/hgrc
239 239 > [templates]
240 240 > simple = "{rev}\n"
241 241 > simple2 = {rev}\n
242 242 > rev = "should not precede {rev} keyword\n"
243 243 > EOF
244 244
245 245 $ hg log -l1 -Tsimple
246 246 8
247 247 $ hg log -l1 -Tsimple2
248 248 8
249 249 $ hg log -l1 -Trev
250 250 should not precede 8 keyword
251 251 $ hg log -l1 -T '{simple}'
252 252 8
253 253
254 254 Map file shouldn't see user templates:
255 255
256 256 $ cat <<EOF > tmpl
257 257 > changeset = 'nothing expanded:{simple}\n'
258 258 > EOF
259 259 $ hg log -l1 --style ./tmpl
260 260 nothing expanded:
261 261
262 262 Test templates and style maps in files:
263 263
264 264 $ echo "{rev}" > tmpl
265 265 $ hg log -l1 -T./tmpl
266 266 8
267 267 $ hg log -l1 -Tblah/blah
268 268 blah/blah (no-eol)
269 269
270 270 $ printf 'changeset = "{rev}\\n"\n' > map-simple
271 271 $ hg log -l1 -T./map-simple
272 272 8
273 273
274 274 a map file may have [templates] and [templatealias] sections:
275 275
276 276 $ cat <<'EOF' > map-simple
277 277 > [templates]
278 278 > changeset = "{a}\n"
279 279 > [templatealias]
280 280 > a = rev
281 281 > EOF
282 282 $ hg log -l1 -T./map-simple
283 283 8
284 284
285 285 so it can be included in hgrc
286 286
287 287 $ cat <<EOF > myhgrc
288 288 > %include $HGRCPATH
289 289 > %include map-simple
290 290 > [templates]
291 291 > foo = "{changeset}"
292 292 > EOF
293 293 $ HGRCPATH=./myhgrc hg log -l1 -Tfoo
294 294 8
295 295 $ HGRCPATH=./myhgrc hg log -l1 -T'{a}\n'
296 296 8
297 297
298 298 Test template map inheritance
299 299
300 300 $ echo "__base__ = map-cmdline.default" > map-simple
301 301 $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple
302 302 $ hg log -l1 -T./map-simple
303 303 changeset: ***8***
304 304 tag: tip
305 305 user: test
306 306 date: Wed Jan 01 10:01:00 2020 +0000
307 307 summary: third
308 308
309 309
310 310 Test docheader, docfooter and separator in template map
311 311
312 312 $ cat <<'EOF' > map-myjson
313 313 > docheader = '\{\n'
314 314 > docfooter = '\n}\n'
315 315 > separator = ',\n'
316 316 > changeset = ' {dict(rev, node|short)|json}'
317 317 > EOF
318 318 $ hg log -l2 -T./map-myjson
319 319 {
320 320 {"node": "95c24699272e", "rev": 8},
321 321 {"node": "29114dbae42b", "rev": 7}
322 322 }
323 323
324 324 Test docheader, docfooter and separator in [templates] section
325 325
326 326 $ cat <<'EOF' >> .hg/hgrc
327 327 > [templates]
328 328 > myjson = ' {dict(rev, node|short)|json}'
329 329 > myjson:docheader = '\{\n'
330 330 > myjson:docfooter = '\n}\n'
331 331 > myjson:separator = ',\n'
332 332 > :docheader = 'should not be selected as a docheader for literal templates\n'
333 333 > EOF
334 334 $ hg log -l2 -Tmyjson
335 335 {
336 336 {"node": "95c24699272e", "rev": 8},
337 337 {"node": "29114dbae42b", "rev": 7}
338 338 }
339 339 $ hg log -l1 -T'{rev}\n'
340 340 8
341 341
342 342 Template should precede style option
343 343
344 344 $ hg log -l1 --style default -T '{rev}\n'
345 345 8
346 346
347 347 Add a commit with empty description, to ensure that the templates
348 348 below will omit the description line.
349 349
350 350 $ echo c >> c
351 351 $ hg add c
352 352 $ hg commit -qm ' '
353 353
354 354 Default style is like normal output. Phases style should be the same
355 355 as default style, except for extra phase lines.
356 356
357 357 $ hg log > log.out
358 358 $ hg log --style default > style.out
359 359 $ cmp log.out style.out || diff -u log.out style.out
360 360 $ hg log -T phases > phases.out
361 361 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
362 362 +phase: draft
363 363 +phase: draft
364 364 +phase: draft
365 365 +phase: draft
366 366 +phase: draft
367 367 +phase: draft
368 368 +phase: draft
369 369 +phase: draft
370 370 +phase: draft
371 371 +phase: draft
372 372
373 373 $ hg log -v > log.out
374 374 $ hg log -v --style default > style.out
375 375 $ cmp log.out style.out || diff -u log.out style.out
376 376 $ hg log -v -T phases > phases.out
377 377 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
378 378 +phase: draft
379 379 +phase: draft
380 380 +phase: draft
381 381 +phase: draft
382 382 +phase: draft
383 383 +phase: draft
384 384 +phase: draft
385 385 +phase: draft
386 386 +phase: draft
387 387 +phase: draft
388 388
389 389 $ hg log -q > log.out
390 390 $ hg log -q --style default > style.out
391 391 $ cmp log.out style.out || diff -u log.out style.out
392 392 $ hg log -q -T phases > phases.out
393 393 $ cmp log.out phases.out || diff -u log.out phases.out
394 394
395 395 $ hg log --debug > log.out
396 396 $ hg log --debug --style default > style.out
397 397 $ cmp log.out style.out || diff -u log.out style.out
398 398 $ hg log --debug -T phases > phases.out
399 399 $ cmp log.out phases.out || diff -u log.out phases.out
400 400
401 401 Default style of working-directory revision should also be the same (but
402 402 date may change while running tests):
403 403
404 404 $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out
405 405 $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out
406 406 $ cmp log.out style.out || diff -u log.out style.out
407 407
408 408 $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out
409 409 $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out
410 410 $ cmp log.out style.out || diff -u log.out style.out
411 411
412 412 $ hg log -r 'wdir()' -q > log.out
413 413 $ hg log -r 'wdir()' -q --style default > style.out
414 414 $ cmp log.out style.out || diff -u log.out style.out
415 415
416 416 $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out
417 417 $ hg log -r 'wdir()' --debug --style default \
418 418 > | sed 's|^date:.*|date:|' > style.out
419 419 $ cmp log.out style.out || diff -u log.out style.out
420 420
421 421 Default style should also preserve color information (issue2866):
422 422
423 423 $ cp $HGRCPATH $HGRCPATH-bak
424 424 $ cat <<EOF >> $HGRCPATH
425 425 > [extensions]
426 426 > color=
427 427 > EOF
428 428
429 429 $ hg --color=debug log > log.out
430 430 $ hg --color=debug log --style default > style.out
431 431 $ cmp log.out style.out || diff -u log.out style.out
432 432 $ hg --color=debug log -T phases > phases.out
433 433 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
434 434 +[log.phase|phase: draft]
435 435 +[log.phase|phase: draft]
436 436 +[log.phase|phase: draft]
437 437 +[log.phase|phase: draft]
438 438 +[log.phase|phase: draft]
439 439 +[log.phase|phase: draft]
440 440 +[log.phase|phase: draft]
441 441 +[log.phase|phase: draft]
442 442 +[log.phase|phase: draft]
443 443 +[log.phase|phase: draft]
444 444
445 445 $ hg --color=debug -v log > log.out
446 446 $ hg --color=debug -v log --style default > style.out
447 447 $ cmp log.out style.out || diff -u log.out style.out
448 448 $ hg --color=debug -v log -T phases > phases.out
449 449 $ diff -U 0 log.out phases.out | egrep -v '^---|^\+\+\+|^@@'
450 450 +[log.phase|phase: draft]
451 451 +[log.phase|phase: draft]
452 452 +[log.phase|phase: draft]
453 453 +[log.phase|phase: draft]
454 454 +[log.phase|phase: draft]
455 455 +[log.phase|phase: draft]
456 456 +[log.phase|phase: draft]
457 457 +[log.phase|phase: draft]
458 458 +[log.phase|phase: draft]
459 459 +[log.phase|phase: draft]
460 460
461 461 $ hg --color=debug -q log > log.out
462 462 $ hg --color=debug -q log --style default > style.out
463 463 $ cmp log.out style.out || diff -u log.out style.out
464 464 $ hg --color=debug -q log -T phases > phases.out
465 465 $ cmp log.out phases.out || diff -u log.out phases.out
466 466
467 467 $ hg --color=debug --debug log > log.out
468 468 $ hg --color=debug --debug log --style default > style.out
469 469 $ cmp log.out style.out || diff -u log.out style.out
470 470 $ hg --color=debug --debug log -T phases > phases.out
471 471 $ cmp log.out phases.out || diff -u log.out phases.out
472 472
473 473 $ mv $HGRCPATH-bak $HGRCPATH
474 474
475 475 Remove commit with empty commit message, so as to not pollute further
476 476 tests.
477 477
478 478 $ hg --config extensions.strip= strip -q .
479 479
480 480 Revision with no copies (used to print a traceback):
481 481
482 482 $ hg tip -v --template '\n'
483 483
484 484
485 485 Compact style works:
486 486
487 487 $ hg log -Tcompact
488 488 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
489 489 third
490 490
491 491 7:-1 29114dbae42b 1970-01-12 13:46 +0000 user
492 492 second
493 493
494 494 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
495 495 merge
496 496
497 497 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
498 498 new head
499 499
500 500 4 bbe44766e73d 1970-01-17 04:53 +0000 person
501 501 new branch
502 502
503 503 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
504 504 no user, no domain
505 505
506 506 2 97054abb4ab8 1970-01-14 21:20 +0000 other
507 507 no person
508 508
509 509 1 b608e9d1a3f0 1970-01-13 17:33 +0000 other
510 510 other 1
511 511
512 512 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 user
513 513 line 1
514 514
515 515
516 516 $ hg log -v --style compact
517 517 8[tip] 95c24699272e 2020-01-01 10:01 +0000 test
518 518 third
519 519
520 520 7:-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
521 521 second
522 522
523 523 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
524 524 merge
525 525
526 526 5:3 13207e5a10d9 1970-01-18 08:40 +0000 person
527 527 new head
528 528
529 529 4 bbe44766e73d 1970-01-17 04:53 +0000 person
530 530 new branch
531 531
532 532 3 10e46f2dcbf4 1970-01-16 01:06 +0000 person
533 533 no user, no domain
534 534
535 535 2 97054abb4ab8 1970-01-14 21:20 +0000 other@place
536 536 no person
537 537
538 538 1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
539 539 other 1
540 540 other 2
541 541
542 542 other 3
543 543
544 544 0 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
545 545 line 1
546 546 line 2
547 547
548 548
549 549 $ hg log --debug --style compact
550 550 8[tip]:7,-1 95c24699272e 2020-01-01 10:01 +0000 test
551 551 third
552 552
553 553 7:-1,-1 29114dbae42b 1970-01-12 13:46 +0000 User Name <user@hostname>
554 554 second
555 555
556 556 6:5,4 d41e714fe50d 1970-01-18 08:40 +0000 person
557 557 merge
558 558
559 559 5:3,-1 13207e5a10d9 1970-01-18 08:40 +0000 person
560 560 new head
561 561
562 562 4:3,-1 bbe44766e73d 1970-01-17 04:53 +0000 person
563 563 new branch
564 564
565 565 3:2,-1 10e46f2dcbf4 1970-01-16 01:06 +0000 person
566 566 no user, no domain
567 567
568 568 2:1,-1 97054abb4ab8 1970-01-14 21:20 +0000 other@place
569 569 no person
570 570
571 571 1:0,-1 b608e9d1a3f0 1970-01-13 17:33 +0000 A. N. Other <other@place>
572 572 other 1
573 573 other 2
574 574
575 575 other 3
576 576
577 577 0:-1,-1 1e4e1b8f71e0 1970-01-12 13:46 +0000 User Name <user@hostname>
578 578 line 1
579 579 line 2
580 580
581 581
582 582 Test xml styles:
583 583
584 584 $ hg log --style xml -r 'not all()'
585 585 <?xml version="1.0"?>
586 586 <log>
587 587 </log>
588 588
589 589 $ hg log --style xml
590 590 <?xml version="1.0"?>
591 591 <log>
592 592 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
593 593 <tag>tip</tag>
594 594 <author email="test">test</author>
595 595 <date>2020-01-01T10:01:00+00:00</date>
596 596 <msg xml:space="preserve">third</msg>
597 597 </logentry>
598 598 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
599 599 <parent revision="-1" node="0000000000000000000000000000000000000000" />
600 600 <author email="user@hostname">User Name</author>
601 601 <date>1970-01-12T13:46:40+00:00</date>
602 602 <msg xml:space="preserve">second</msg>
603 603 </logentry>
604 604 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
605 605 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
606 606 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
607 607 <author email="person">person</author>
608 608 <date>1970-01-18T08:40:01+00:00</date>
609 609 <msg xml:space="preserve">merge</msg>
610 610 </logentry>
611 611 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
612 612 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
613 613 <author email="person">person</author>
614 614 <date>1970-01-18T08:40:00+00:00</date>
615 615 <msg xml:space="preserve">new head</msg>
616 616 </logentry>
617 617 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
618 618 <branch>foo</branch>
619 619 <author email="person">person</author>
620 620 <date>1970-01-17T04:53:20+00:00</date>
621 621 <msg xml:space="preserve">new branch</msg>
622 622 </logentry>
623 623 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
624 624 <author email="person">person</author>
625 625 <date>1970-01-16T01:06:40+00:00</date>
626 626 <msg xml:space="preserve">no user, no domain</msg>
627 627 </logentry>
628 628 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
629 629 <author email="other@place">other</author>
630 630 <date>1970-01-14T21:20:00+00:00</date>
631 631 <msg xml:space="preserve">no person</msg>
632 632 </logentry>
633 633 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
634 634 <author email="other@place">A. N. Other</author>
635 635 <date>1970-01-13T17:33:20+00:00</date>
636 636 <msg xml:space="preserve">other 1
637 637 other 2
638 638
639 639 other 3</msg>
640 640 </logentry>
641 641 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
642 642 <author email="user@hostname">User Name</author>
643 643 <date>1970-01-12T13:46:40+00:00</date>
644 644 <msg xml:space="preserve">line 1
645 645 line 2</msg>
646 646 </logentry>
647 647 </log>
648 648
649 649 $ hg log -v --style xml
650 650 <?xml version="1.0"?>
651 651 <log>
652 652 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
653 653 <tag>tip</tag>
654 654 <author email="test">test</author>
655 655 <date>2020-01-01T10:01:00+00:00</date>
656 656 <msg xml:space="preserve">third</msg>
657 657 <paths>
658 658 <path action="A">fourth</path>
659 659 <path action="A">third</path>
660 660 <path action="R">second</path>
661 661 </paths>
662 662 <copies>
663 663 <copy source="second">fourth</copy>
664 664 </copies>
665 665 </logentry>
666 666 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
667 667 <parent revision="-1" node="0000000000000000000000000000000000000000" />
668 668 <author email="user@hostname">User Name</author>
669 669 <date>1970-01-12T13:46:40+00:00</date>
670 670 <msg xml:space="preserve">second</msg>
671 671 <paths>
672 672 <path action="A">second</path>
673 673 </paths>
674 674 </logentry>
675 675 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
676 676 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
677 677 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
678 678 <author email="person">person</author>
679 679 <date>1970-01-18T08:40:01+00:00</date>
680 680 <msg xml:space="preserve">merge</msg>
681 681 <paths>
682 682 </paths>
683 683 </logentry>
684 684 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
685 685 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
686 686 <author email="person">person</author>
687 687 <date>1970-01-18T08:40:00+00:00</date>
688 688 <msg xml:space="preserve">new head</msg>
689 689 <paths>
690 690 <path action="A">d</path>
691 691 </paths>
692 692 </logentry>
693 693 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
694 694 <branch>foo</branch>
695 695 <author email="person">person</author>
696 696 <date>1970-01-17T04:53:20+00:00</date>
697 697 <msg xml:space="preserve">new branch</msg>
698 698 <paths>
699 699 </paths>
700 700 </logentry>
701 701 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
702 702 <author email="person">person</author>
703 703 <date>1970-01-16T01:06:40+00:00</date>
704 704 <msg xml:space="preserve">no user, no domain</msg>
705 705 <paths>
706 706 <path action="M">c</path>
707 707 </paths>
708 708 </logentry>
709 709 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
710 710 <author email="other@place">other</author>
711 711 <date>1970-01-14T21:20:00+00:00</date>
712 712 <msg xml:space="preserve">no person</msg>
713 713 <paths>
714 714 <path action="A">c</path>
715 715 </paths>
716 716 </logentry>
717 717 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
718 718 <author email="other@place">A. N. Other</author>
719 719 <date>1970-01-13T17:33:20+00:00</date>
720 720 <msg xml:space="preserve">other 1
721 721 other 2
722 722
723 723 other 3</msg>
724 724 <paths>
725 725 <path action="A">b</path>
726 726 </paths>
727 727 </logentry>
728 728 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
729 729 <author email="user@hostname">User Name</author>
730 730 <date>1970-01-12T13:46:40+00:00</date>
731 731 <msg xml:space="preserve">line 1
732 732 line 2</msg>
733 733 <paths>
734 734 <path action="A">a</path>
735 735 </paths>
736 736 </logentry>
737 737 </log>
738 738
739 739 $ hg log --debug --style xml
740 740 <?xml version="1.0"?>
741 741 <log>
742 742 <logentry revision="8" node="95c24699272ef57d062b8bccc32c878bf841784a">
743 743 <tag>tip</tag>
744 744 <parent revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453" />
745 745 <parent revision="-1" node="0000000000000000000000000000000000000000" />
746 746 <author email="test">test</author>
747 747 <date>2020-01-01T10:01:00+00:00</date>
748 748 <msg xml:space="preserve">third</msg>
749 749 <paths>
750 750 <path action="A">fourth</path>
751 751 <path action="A">third</path>
752 752 <path action="R">second</path>
753 753 </paths>
754 754 <copies>
755 755 <copy source="second">fourth</copy>
756 756 </copies>
757 757 <extra key="branch">default</extra>
758 758 </logentry>
759 759 <logentry revision="7" node="29114dbae42b9f078cf2714dbe3a86bba8ec7453">
760 760 <parent revision="-1" node="0000000000000000000000000000000000000000" />
761 761 <parent revision="-1" node="0000000000000000000000000000000000000000" />
762 762 <author email="user@hostname">User Name</author>
763 763 <date>1970-01-12T13:46:40+00:00</date>
764 764 <msg xml:space="preserve">second</msg>
765 765 <paths>
766 766 <path action="A">second</path>
767 767 </paths>
768 768 <extra key="branch">default</extra>
769 769 </logentry>
770 770 <logentry revision="6" node="d41e714fe50d9e4a5f11b4d595d543481b5f980b">
771 771 <parent revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f" />
772 772 <parent revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74" />
773 773 <author email="person">person</author>
774 774 <date>1970-01-18T08:40:01+00:00</date>
775 775 <msg xml:space="preserve">merge</msg>
776 776 <paths>
777 777 </paths>
778 778 <extra key="branch">default</extra>
779 779 </logentry>
780 780 <logentry revision="5" node="13207e5a10d9fd28ec424934298e176197f2c67f">
781 781 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
782 782 <parent revision="-1" node="0000000000000000000000000000000000000000" />
783 783 <author email="person">person</author>
784 784 <date>1970-01-18T08:40:00+00:00</date>
785 785 <msg xml:space="preserve">new head</msg>
786 786 <paths>
787 787 <path action="A">d</path>
788 788 </paths>
789 789 <extra key="branch">default</extra>
790 790 </logentry>
791 791 <logentry revision="4" node="bbe44766e73d5f11ed2177f1838de10c53ef3e74">
792 792 <branch>foo</branch>
793 793 <parent revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47" />
794 794 <parent revision="-1" node="0000000000000000000000000000000000000000" />
795 795 <author email="person">person</author>
796 796 <date>1970-01-17T04:53:20+00:00</date>
797 797 <msg xml:space="preserve">new branch</msg>
798 798 <paths>
799 799 </paths>
800 800 <extra key="branch">foo</extra>
801 801 </logentry>
802 802 <logentry revision="3" node="10e46f2dcbf4823578cf180f33ecf0b957964c47">
803 803 <parent revision="2" node="97054abb4ab824450e9164180baf491ae0078465" />
804 804 <parent revision="-1" node="0000000000000000000000000000000000000000" />
805 805 <author email="person">person</author>
806 806 <date>1970-01-16T01:06:40+00:00</date>
807 807 <msg xml:space="preserve">no user, no domain</msg>
808 808 <paths>
809 809 <path action="M">c</path>
810 810 </paths>
811 811 <extra key="branch">default</extra>
812 812 </logentry>
813 813 <logentry revision="2" node="97054abb4ab824450e9164180baf491ae0078465">
814 814 <parent revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965" />
815 815 <parent revision="-1" node="0000000000000000000000000000000000000000" />
816 816 <author email="other@place">other</author>
817 817 <date>1970-01-14T21:20:00+00:00</date>
818 818 <msg xml:space="preserve">no person</msg>
819 819 <paths>
820 820 <path action="A">c</path>
821 821 </paths>
822 822 <extra key="branch">default</extra>
823 823 </logentry>
824 824 <logentry revision="1" node="b608e9d1a3f0273ccf70fb85fd6866b3482bf965">
825 825 <parent revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f" />
826 826 <parent revision="-1" node="0000000000000000000000000000000000000000" />
827 827 <author email="other@place">A. N. Other</author>
828 828 <date>1970-01-13T17:33:20+00:00</date>
829 829 <msg xml:space="preserve">other 1
830 830 other 2
831 831
832 832 other 3</msg>
833 833 <paths>
834 834 <path action="A">b</path>
835 835 </paths>
836 836 <extra key="branch">default</extra>
837 837 </logentry>
838 838 <logentry revision="0" node="1e4e1b8f71e05681d422154f5421e385fec3454f">
839 839 <parent revision="-1" node="0000000000000000000000000000000000000000" />
840 840 <parent revision="-1" node="0000000000000000000000000000000000000000" />
841 841 <author email="user@hostname">User Name</author>
842 842 <date>1970-01-12T13:46:40+00:00</date>
843 843 <msg xml:space="preserve">line 1
844 844 line 2</msg>
845 845 <paths>
846 846 <path action="A">a</path>
847 847 </paths>
848 848 <extra key="branch">default</extra>
849 849 </logentry>
850 850 </log>
851 851
852 852
853 853 Test JSON style:
854 854
855 855 $ hg log -k nosuch -Tjson
856 []
856 [
857 ]
857 858
858 859 $ hg log -qr . -Tjson
859 860 [
860 861 {
861 "rev": 8,
862 "node": "95c24699272ef57d062b8bccc32c878bf841784a"
862 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
863 "rev": 8
863 864 }
864 865 ]
865 866
866 867 $ hg log -vpr . -Tjson --stat
867 868 [
868 869 {
869 "rev": 8,
870 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
870 "bookmarks": [],
871 871 "branch": "default",
872 "phase": "draft",
873 "user": "test",
874 872 "date": [1577872860, 0],
875 873 "desc": "third",
876 "bookmarks": [],
877 "tags": ["tip"],
874 "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",
875 "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n",
876 "files": ["fourth", "second", "third"],
877 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
878 878 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
879 "files": ["fourth", "second", "third"],
880 "diffstat": " fourth | 1 +\n second | 1 -\n third | 1 +\n 3 files changed, 2 insertions(+), 1 deletions(-)\n",
881 "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"
879 "phase": "draft",
880 "rev": 8,
881 "tags": ["tip"],
882 "user": "test"
882 883 }
883 884 ]
884 885
885 886 honor --git but not format-breaking diffopts
886 887 $ hg --config diff.noprefix=True log --git -vpr . -Tjson
887 888 [
888 889 {
889 "rev": 8,
890 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
890 "bookmarks": [],
891 891 "branch": "default",
892 "phase": "draft",
893 "user": "test",
894 892 "date": [1577872860, 0],
895 893 "desc": "third",
896 "bookmarks": [],
897 "tags": ["tip"],
894 "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",
895 "files": ["fourth", "second", "third"],
896 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
898 897 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
899 "files": ["fourth", "second", "third"],
900 "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"
898 "phase": "draft",
899 "rev": 8,
900 "tags": ["tip"],
901 "user": "test"
901 902 }
902 903 ]
903 904
904 905 $ hg log -T json
905 906 [
906 907 {
907 "rev": 8,
908 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
908 "bookmarks": [],
909 909 "branch": "default",
910 "phase": "draft",
911 "user": "test",
912 910 "date": [1577872860, 0],
913 911 "desc": "third",
914 "bookmarks": [],
912 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
913 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
914 "phase": "draft",
915 "rev": 8,
915 916 "tags": ["tip"],
916 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"]
917 "user": "test"
917 918 },
918 919 {
919 "rev": 7,
920 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
920 "bookmarks": [],
921 921 "branch": "default",
922 "phase": "draft",
923 "user": "User Name <user@hostname>",
924 922 "date": [1000000, 0],
925 923 "desc": "second",
926 "bookmarks": [],
924 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
925 "parents": ["0000000000000000000000000000000000000000"],
926 "phase": "draft",
927 "rev": 7,
927 928 "tags": [],
928 "parents": ["0000000000000000000000000000000000000000"]
929 "user": "User Name <user@hostname>"
929 930 },
930 931 {
931 "rev": 6,
932 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
932 "bookmarks": [],
933 933 "branch": "default",
934 "phase": "draft",
935 "user": "person",
936 934 "date": [1500001, 0],
937 935 "desc": "merge",
938 "bookmarks": [],
936 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
937 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
938 "phase": "draft",
939 "rev": 6,
939 940 "tags": [],
940 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"]
941 "user": "person"
941 942 },
942 943 {
943 "rev": 5,
944 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
944 "bookmarks": [],
945 945 "branch": "default",
946 "phase": "draft",
947 "user": "person",
948 946 "date": [1500000, 0],
949 947 "desc": "new head",
950 "bookmarks": [],
948 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
949 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
950 "phase": "draft",
951 "rev": 5,
951 952 "tags": [],
952 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
953 "user": "person"
953 954 },
954 955 {
955 "rev": 4,
956 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
956 "bookmarks": [],
957 957 "branch": "foo",
958 "phase": "draft",
959 "user": "person",
960 958 "date": [1400000, 0],
961 959 "desc": "new branch",
962 "bookmarks": [],
960 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
961 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
962 "phase": "draft",
963 "rev": 4,
963 964 "tags": [],
964 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"]
965 "user": "person"
965 966 },
966 967 {
967 "rev": 3,
968 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
968 "bookmarks": [],
969 969 "branch": "default",
970 "phase": "draft",
971 "user": "person",
972 970 "date": [1300000, 0],
973 971 "desc": "no user, no domain",
974 "bookmarks": [],
972 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
973 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
974 "phase": "draft",
975 "rev": 3,
975 976 "tags": [],
976 "parents": ["97054abb4ab824450e9164180baf491ae0078465"]
977 "user": "person"
977 978 },
978 979 {
979 "rev": 2,
980 "node": "97054abb4ab824450e9164180baf491ae0078465",
980 "bookmarks": [],
981 981 "branch": "default",
982 "phase": "draft",
983 "user": "other@place",
984 982 "date": [1200000, 0],
985 983 "desc": "no person",
986 "bookmarks": [],
984 "node": "97054abb4ab824450e9164180baf491ae0078465",
985 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
986 "phase": "draft",
987 "rev": 2,
987 988 "tags": [],
988 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"]
989 "user": "other@place"
989 990 },
990 991 {
991 "rev": 1,
992 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
992 "bookmarks": [],
993 993 "branch": "default",
994 "phase": "draft",
995 "user": "A. N. Other <other@place>",
996 994 "date": [1100000, 0],
997 995 "desc": "other 1\nother 2\n\nother 3",
998 "bookmarks": [],
996 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
997 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
998 "phase": "draft",
999 "rev": 1,
999 1000 "tags": [],
1000 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"]
1001 "user": "A. N. Other <other@place>"
1001 1002 },
1002 1003 {
1003 "rev": 0,
1004 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1004 "bookmarks": [],
1005 1005 "branch": "default",
1006 "phase": "draft",
1007 "user": "User Name <user@hostname>",
1008 1006 "date": [1000000, 0],
1009 1007 "desc": "line 1\nline 2",
1010 "bookmarks": [],
1008 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1009 "parents": ["0000000000000000000000000000000000000000"],
1010 "phase": "draft",
1011 "rev": 0,
1011 1012 "tags": [],
1012 "parents": ["0000000000000000000000000000000000000000"]
1013 "user": "User Name <user@hostname>"
1013 1014 }
1014 1015 ]
1015 1016
1016 1017 $ hg heads -v -Tjson
1017 1018 [
1018 1019 {
1019 "rev": 8,
1020 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
1020 "bookmarks": [],
1021 1021 "branch": "default",
1022 "phase": "draft",
1023 "user": "test",
1024 1022 "date": [1577872860, 0],
1025 1023 "desc": "third",
1026 "bookmarks": [],
1024 "files": ["fourth", "second", "third"],
1025 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
1026 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
1027 "phase": "draft",
1028 "rev": 8,
1027 1029 "tags": ["tip"],
1028 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
1029 "files": ["fourth", "second", "third"]
1030 "user": "test"
1030 1031 },
1031 1032 {
1032 "rev": 6,
1033 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
1033 "bookmarks": [],
1034 1034 "branch": "default",
1035 "phase": "draft",
1036 "user": "person",
1037 1035 "date": [1500001, 0],
1038 1036 "desc": "merge",
1039 "bookmarks": [],
1037 "files": [],
1038 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
1039 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1040 "phase": "draft",
1041 "rev": 6,
1040 1042 "tags": [],
1041 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1042 "files": []
1043 "user": "person"
1043 1044 },
1044 1045 {
1045 "rev": 4,
1046 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1046 "bookmarks": [],
1047 1047 "branch": "foo",
1048 "phase": "draft",
1049 "user": "person",
1050 1048 "date": [1400000, 0],
1051 1049 "desc": "new branch",
1052 "bookmarks": [],
1050 "files": [],
1051 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1052 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1053 "phase": "draft",
1054 "rev": 4,
1053 1055 "tags": [],
1054 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1055 "files": []
1056 "user": "person"
1056 1057 }
1057 1058 ]
1058 1059
1059 1060 $ hg log --debug -Tjson
1060 1061 [
1061 1062 {
1062 "rev": 8,
1063 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
1063 "added": ["fourth", "third"],
1064 "bookmarks": [],
1064 1065 "branch": "default",
1065 "phase": "draft",
1066 "user": "test",
1067 1066 "date": [1577872860, 0],
1068 1067 "desc": "third",
1069 "bookmarks": [],
1070 "tags": ["tip"],
1071 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
1068 "extra": {"branch": "default"},
1072 1069 "manifest": "94961b75a2da554b4df6fb599e5bfc7d48de0c64",
1073 "extra": {"branch": "default"},
1074 1070 "modified": [],
1075 "added": ["fourth", "third"],
1076 "removed": ["second"]
1071 "node": "95c24699272ef57d062b8bccc32c878bf841784a",
1072 "parents": ["29114dbae42b9f078cf2714dbe3a86bba8ec7453"],
1073 "phase": "draft",
1074 "removed": ["second"],
1075 "rev": 8,
1076 "tags": ["tip"],
1077 "user": "test"
1077 1078 },
1078 1079 {
1079 "rev": 7,
1080 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
1080 "added": ["second"],
1081 "bookmarks": [],
1081 1082 "branch": "default",
1082 "phase": "draft",
1083 "user": "User Name <user@hostname>",
1084 1083 "date": [1000000, 0],
1085 1084 "desc": "second",
1086 "bookmarks": [],
1087 "tags": [],
1088 "parents": ["0000000000000000000000000000000000000000"],
1085 "extra": {"branch": "default"},
1089 1086 "manifest": "f2dbc354b94e5ec0b4f10680ee0cee816101d0bf",
1090 "extra": {"branch": "default"},
1091 1087 "modified": [],
1092 "added": ["second"],
1093 "removed": []
1088 "node": "29114dbae42b9f078cf2714dbe3a86bba8ec7453",
1089 "parents": ["0000000000000000000000000000000000000000"],
1090 "phase": "draft",
1091 "removed": [],
1092 "rev": 7,
1093 "tags": [],
1094 "user": "User Name <user@hostname>"
1094 1095 },
1095 1096 {
1096 "rev": 6,
1097 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
1097 "added": [],
1098 "bookmarks": [],
1098 1099 "branch": "default",
1099 "phase": "draft",
1100 "user": "person",
1101 1100 "date": [1500001, 0],
1102 1101 "desc": "merge",
1103 "bookmarks": [],
1104 "tags": [],
1105 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1102 "extra": {"branch": "default"},
1106 1103 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1107 "extra": {"branch": "default"},
1108 1104 "modified": [],
1109 "added": [],
1110 "removed": []
1105 "node": "d41e714fe50d9e4a5f11b4d595d543481b5f980b",
1106 "parents": ["13207e5a10d9fd28ec424934298e176197f2c67f", "bbe44766e73d5f11ed2177f1838de10c53ef3e74"],
1107 "phase": "draft",
1108 "removed": [],
1109 "rev": 6,
1110 "tags": [],
1111 "user": "person"
1111 1112 },
1112 1113 {
1113 "rev": 5,
1114 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
1114 "added": ["d"],
1115 "bookmarks": [],
1115 1116 "branch": "default",
1116 "phase": "draft",
1117 "user": "person",
1118 1117 "date": [1500000, 0],
1119 1118 "desc": "new head",
1120 "bookmarks": [],
1121 "tags": [],
1122 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1119 "extra": {"branch": "default"},
1123 1120 "manifest": "4dc3def4f9b4c6e8de820f6ee74737f91e96a216",
1124 "extra": {"branch": "default"},
1125 1121 "modified": [],
1126 "added": ["d"],
1127 "removed": []
1122 "node": "13207e5a10d9fd28ec424934298e176197f2c67f",
1123 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1124 "phase": "draft",
1125 "removed": [],
1126 "rev": 5,
1127 "tags": [],
1128 "user": "person"
1128 1129 },
1129 1130 {
1130 "rev": 4,
1131 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1131 "added": [],
1132 "bookmarks": [],
1132 1133 "branch": "foo",
1133 "phase": "draft",
1134 "user": "person",
1135 1134 "date": [1400000, 0],
1136 1135 "desc": "new branch",
1137 "bookmarks": [],
1138 "tags": [],
1139 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1136 "extra": {"branch": "foo"},
1140 1137 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1141 "extra": {"branch": "foo"},
1142 1138 "modified": [],
1143 "added": [],
1144 "removed": []
1139 "node": "bbe44766e73d5f11ed2177f1838de10c53ef3e74",
1140 "parents": ["10e46f2dcbf4823578cf180f33ecf0b957964c47"],
1141 "phase": "draft",
1142 "removed": [],
1143 "rev": 4,
1144 "tags": [],
1145 "user": "person"
1145 1146 },
1146 1147 {
1147 "rev": 3,
1148 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
1148 "added": [],
1149 "bookmarks": [],
1149 1150 "branch": "default",
1150 "phase": "draft",
1151 "user": "person",
1152 1151 "date": [1300000, 0],
1153 1152 "desc": "no user, no domain",
1154 "bookmarks": [],
1155 "tags": [],
1156 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
1153 "extra": {"branch": "default"},
1157 1154 "manifest": "cb5a1327723bada42f117e4c55a303246eaf9ccc",
1158 "extra": {"branch": "default"},
1159 1155 "modified": ["c"],
1160 "added": [],
1161 "removed": []
1156 "node": "10e46f2dcbf4823578cf180f33ecf0b957964c47",
1157 "parents": ["97054abb4ab824450e9164180baf491ae0078465"],
1158 "phase": "draft",
1159 "removed": [],
1160 "rev": 3,
1161 "tags": [],
1162 "user": "person"
1162 1163 },
1163 1164 {
1164 "rev": 2,
1165 "node": "97054abb4ab824450e9164180baf491ae0078465",
1165 "added": ["c"],
1166 "bookmarks": [],
1166 1167 "branch": "default",
1167 "phase": "draft",
1168 "user": "other@place",
1169 1168 "date": [1200000, 0],
1170 1169 "desc": "no person",
1171 "bookmarks": [],
1172 "tags": [],
1173 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
1170 "extra": {"branch": "default"},
1174 1171 "manifest": "6e0e82995c35d0d57a52aca8da4e56139e06b4b1",
1175 "extra": {"branch": "default"},
1176 1172 "modified": [],
1177 "added": ["c"],
1178 "removed": []
1173 "node": "97054abb4ab824450e9164180baf491ae0078465",
1174 "parents": ["b608e9d1a3f0273ccf70fb85fd6866b3482bf965"],
1175 "phase": "draft",
1176 "removed": [],
1177 "rev": 2,
1178 "tags": [],
1179 "user": "other@place"
1179 1180 },
1180 1181 {
1181 "rev": 1,
1182 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
1182 "added": ["b"],
1183 "bookmarks": [],
1183 1184 "branch": "default",
1184 "phase": "draft",
1185 "user": "A. N. Other <other@place>",
1186 1185 "date": [1100000, 0],
1187 1186 "desc": "other 1\nother 2\n\nother 3",
1188 "bookmarks": [],
1189 "tags": [],
1190 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
1187 "extra": {"branch": "default"},
1191 1188 "manifest": "4e8d705b1e53e3f9375e0e60dc7b525d8211fe55",
1192 "extra": {"branch": "default"},
1193 1189 "modified": [],
1194 "added": ["b"],
1195 "removed": []
1190 "node": "b608e9d1a3f0273ccf70fb85fd6866b3482bf965",
1191 "parents": ["1e4e1b8f71e05681d422154f5421e385fec3454f"],
1192 "phase": "draft",
1193 "removed": [],
1194 "rev": 1,
1195 "tags": [],
1196 "user": "A. N. Other <other@place>"
1196 1197 },
1197 1198 {
1198 "rev": 0,
1199 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1199 "added": ["a"],
1200 "bookmarks": [],
1200 1201 "branch": "default",
1201 "phase": "draft",
1202 "user": "User Name <user@hostname>",
1203 1202 "date": [1000000, 0],
1204 1203 "desc": "line 1\nline 2",
1205 "bookmarks": [],
1206 "tags": [],
1207 "parents": ["0000000000000000000000000000000000000000"],
1204 "extra": {"branch": "default"},
1208 1205 "manifest": "a0c8bcbbb45c63b90b70ad007bf38961f64f2af0",
1209 "extra": {"branch": "default"},
1210 1206 "modified": [],
1211 "added": ["a"],
1212 "removed": []
1207 "node": "1e4e1b8f71e05681d422154f5421e385fec3454f",
1208 "parents": ["0000000000000000000000000000000000000000"],
1209 "phase": "draft",
1210 "removed": [],
1211 "rev": 0,
1212 "tags": [],
1213 "user": "User Name <user@hostname>"
1213 1214 }
1214 1215 ]
1215 1216
1216 1217 Error if style not readable:
1217 1218
1218 1219 #if unix-permissions no-root
1219 1220 $ touch q
1220 1221 $ chmod 0 q
1221 1222 $ hg log --style ./q
1222 1223 abort: Permission denied: ./q
1223 1224 [255]
1224 1225 #endif
1225 1226
1226 1227 Error if no style:
1227 1228
1228 1229 $ hg log --style notexist
1229 1230 abort: style 'notexist' not found
1230 1231 (available styles: bisect, changelog, compact, default, phases, show, status, xml)
1231 1232 [255]
1232 1233
1233 1234 $ hg log -T list
1234 1235 available styles: bisect, changelog, compact, default, phases, show, status, xml
1235 1236 abort: specify a template
1236 1237 [255]
1237 1238
1238 1239 Error if style missing key:
1239 1240
1240 1241 $ echo 'q = q' > t
1241 1242 $ hg log --style ./t
1242 1243 abort: "changeset" not in template map
1243 1244 [255]
1244 1245
1245 1246 Error if style missing value:
1246 1247
1247 1248 $ echo 'changeset =' > t
1248 1249 $ hg log --style t
1249 1250 hg: parse error at t:1: missing value
1250 1251 [255]
1251 1252
1252 1253 Error if include fails:
1253 1254
1254 1255 $ echo 'changeset = q' >> t
1255 1256 #if unix-permissions no-root
1256 1257 $ hg log --style ./t
1257 1258 abort: template file ./q: Permission denied
1258 1259 [255]
1259 1260 $ rm -f q
1260 1261 #endif
1261 1262
1262 1263 Include works:
1263 1264
1264 1265 $ echo '{rev}' > q
1265 1266 $ hg log --style ./t
1266 1267 8
1267 1268 7
1268 1269 6
1269 1270 5
1270 1271 4
1271 1272 3
1272 1273 2
1273 1274 1
1274 1275 0
1275 1276
1276 1277 Check that recursive reference does not fall into RuntimeError (issue4758):
1277 1278
1278 1279 common mistake:
1279 1280
1280 1281 $ cat << EOF > issue4758
1281 1282 > changeset = '{changeset}\n'
1282 1283 > EOF
1283 1284 $ hg log --style ./issue4758
1284 1285 abort: recursive reference 'changeset' in template
1285 1286 [255]
1286 1287
1287 1288 circular reference:
1288 1289
1289 1290 $ cat << EOF > issue4758
1290 1291 > changeset = '{foo}'
1291 1292 > foo = '{changeset}'
1292 1293 > EOF
1293 1294 $ hg log --style ./issue4758
1294 1295 abort: recursive reference 'foo' in template
1295 1296 [255]
1296 1297
1297 1298 buildmap() -> gettemplate(), where no thunk was made:
1298 1299
1299 1300 $ cat << EOF > issue4758
1300 1301 > changeset = '{files % changeset}\n'
1301 1302 > EOF
1302 1303 $ hg log --style ./issue4758
1303 1304 abort: recursive reference 'changeset' in template
1304 1305 [255]
1305 1306
1306 1307 not a recursion if a keyword of the same name exists:
1307 1308
1308 1309 $ cat << EOF > issue4758
1309 1310 > changeset = '{tags % rev}'
1310 1311 > rev = '{rev} {tag}\n'
1311 1312 > EOF
1312 1313 $ hg log --style ./issue4758 -r tip
1313 1314 8 tip
1314 1315
1315 1316 Check that {phase} works correctly on parents:
1316 1317
1317 1318 $ cat << EOF > parentphase
1318 1319 > changeset_debug = '{rev} ({phase}):{parents}\n'
1319 1320 > parent = ' {rev} ({phase})'
1320 1321 > EOF
1321 1322 $ hg phase -r 5 --public
1322 1323 $ hg phase -r 7 --secret --force
1323 1324 $ hg log --debug -G --style ./parentphase
1324 1325 @ 8 (secret): 7 (secret) -1 (public)
1325 1326 |
1326 1327 o 7 (secret): -1 (public) -1 (public)
1327 1328
1328 1329 o 6 (draft): 5 (public) 4 (draft)
1329 1330 |\
1330 1331 | o 5 (public): 3 (public) -1 (public)
1331 1332 | |
1332 1333 o | 4 (draft): 3 (public) -1 (public)
1333 1334 |/
1334 1335 o 3 (public): 2 (public) -1 (public)
1335 1336 |
1336 1337 o 2 (public): 1 (public) -1 (public)
1337 1338 |
1338 1339 o 1 (public): 0 (public) -1 (public)
1339 1340 |
1340 1341 o 0 (public): -1 (public) -1 (public)
1341 1342
1342 1343
1343 1344 Missing non-standard names give no error (backward compatibility):
1344 1345
1345 1346 $ echo "changeset = '{c}'" > t
1346 1347 $ hg log --style ./t
1347 1348
1348 1349 Defining non-standard name works:
1349 1350
1350 1351 $ cat <<EOF > t
1351 1352 > changeset = '{c}'
1352 1353 > c = q
1353 1354 > EOF
1354 1355 $ hg log --style ./t
1355 1356 8
1356 1357 7
1357 1358 6
1358 1359 5
1359 1360 4
1360 1361 3
1361 1362 2
1362 1363 1
1363 1364 0
1364 1365
1365 1366 ui.style works:
1366 1367
1367 1368 $ echo '[ui]' > .hg/hgrc
1368 1369 $ echo 'style = t' >> .hg/hgrc
1369 1370 $ hg log
1370 1371 8
1371 1372 7
1372 1373 6
1373 1374 5
1374 1375 4
1375 1376 3
1376 1377 2
1377 1378 1
1378 1379 0
1379 1380
1380 1381
1381 1382 Issue338:
1382 1383
1383 1384 $ hg log --style=changelog > changelog
1384 1385
1385 1386 $ cat changelog
1386 1387 2020-01-01 test <test>
1387 1388
1388 1389 * fourth, second, third:
1389 1390 third
1390 1391 [95c24699272e] [tip]
1391 1392
1392 1393 1970-01-12 User Name <user@hostname>
1393 1394
1394 1395 * second:
1395 1396 second
1396 1397 [29114dbae42b]
1397 1398
1398 1399 1970-01-18 person <person>
1399 1400
1400 1401 * merge
1401 1402 [d41e714fe50d]
1402 1403
1403 1404 * d:
1404 1405 new head
1405 1406 [13207e5a10d9]
1406 1407
1407 1408 1970-01-17 person <person>
1408 1409
1409 1410 * new branch
1410 1411 [bbe44766e73d] <foo>
1411 1412
1412 1413 1970-01-16 person <person>
1413 1414
1414 1415 * c:
1415 1416 no user, no domain
1416 1417 [10e46f2dcbf4]
1417 1418
1418 1419 1970-01-14 other <other@place>
1419 1420
1420 1421 * c:
1421 1422 no person
1422 1423 [97054abb4ab8]
1423 1424
1424 1425 1970-01-13 A. N. Other <other@place>
1425 1426
1426 1427 * b:
1427 1428 other 1 other 2
1428 1429
1429 1430 other 3
1430 1431 [b608e9d1a3f0]
1431 1432
1432 1433 1970-01-12 User Name <user@hostname>
1433 1434
1434 1435 * a:
1435 1436 line 1 line 2
1436 1437 [1e4e1b8f71e0]
1437 1438
1438 1439
1439 1440 Issue2130: xml output for 'hg heads' is malformed
1440 1441
1441 1442 $ hg heads --style changelog
1442 1443 2020-01-01 test <test>
1443 1444
1444 1445 * fourth, second, third:
1445 1446 third
1446 1447 [95c24699272e] [tip]
1447 1448
1448 1449 1970-01-18 person <person>
1449 1450
1450 1451 * merge
1451 1452 [d41e714fe50d]
1452 1453
1453 1454 1970-01-17 person <person>
1454 1455
1455 1456 * new branch
1456 1457 [bbe44766e73d] <foo>
1457 1458
1458 1459
1459 1460 Keys work:
1460 1461
1461 1462 $ for key in author branch branches date desc file_adds file_dels file_mods \
1462 1463 > file_copies file_copies_switch files \
1463 1464 > manifest node parents rev tags diffstat extras \
1464 1465 > p1rev p2rev p1node p2node; do
1465 1466 > for mode in '' --verbose --debug; do
1466 1467 > hg log $mode --template "$key$mode: {$key}\n"
1467 1468 > done
1468 1469 > done
1469 1470 author: test
1470 1471 author: User Name <user@hostname>
1471 1472 author: person
1472 1473 author: person
1473 1474 author: person
1474 1475 author: person
1475 1476 author: other@place
1476 1477 author: A. N. Other <other@place>
1477 1478 author: User Name <user@hostname>
1478 1479 author--verbose: test
1479 1480 author--verbose: User Name <user@hostname>
1480 1481 author--verbose: person
1481 1482 author--verbose: person
1482 1483 author--verbose: person
1483 1484 author--verbose: person
1484 1485 author--verbose: other@place
1485 1486 author--verbose: A. N. Other <other@place>
1486 1487 author--verbose: User Name <user@hostname>
1487 1488 author--debug: test
1488 1489 author--debug: User Name <user@hostname>
1489 1490 author--debug: person
1490 1491 author--debug: person
1491 1492 author--debug: person
1492 1493 author--debug: person
1493 1494 author--debug: other@place
1494 1495 author--debug: A. N. Other <other@place>
1495 1496 author--debug: User Name <user@hostname>
1496 1497 branch: default
1497 1498 branch: default
1498 1499 branch: default
1499 1500 branch: default
1500 1501 branch: foo
1501 1502 branch: default
1502 1503 branch: default
1503 1504 branch: default
1504 1505 branch: default
1505 1506 branch--verbose: default
1506 1507 branch--verbose: default
1507 1508 branch--verbose: default
1508 1509 branch--verbose: default
1509 1510 branch--verbose: foo
1510 1511 branch--verbose: default
1511 1512 branch--verbose: default
1512 1513 branch--verbose: default
1513 1514 branch--verbose: default
1514 1515 branch--debug: default
1515 1516 branch--debug: default
1516 1517 branch--debug: default
1517 1518 branch--debug: default
1518 1519 branch--debug: foo
1519 1520 branch--debug: default
1520 1521 branch--debug: default
1521 1522 branch--debug: default
1522 1523 branch--debug: default
1523 1524 branches:
1524 1525 branches:
1525 1526 branches:
1526 1527 branches:
1527 1528 branches: foo
1528 1529 branches:
1529 1530 branches:
1530 1531 branches:
1531 1532 branches:
1532 1533 branches--verbose:
1533 1534 branches--verbose:
1534 1535 branches--verbose:
1535 1536 branches--verbose:
1536 1537 branches--verbose: foo
1537 1538 branches--verbose:
1538 1539 branches--verbose:
1539 1540 branches--verbose:
1540 1541 branches--verbose:
1541 1542 branches--debug:
1542 1543 branches--debug:
1543 1544 branches--debug:
1544 1545 branches--debug:
1545 1546 branches--debug: foo
1546 1547 branches--debug:
1547 1548 branches--debug:
1548 1549 branches--debug:
1549 1550 branches--debug:
1550 1551 date: 1577872860.00
1551 1552 date: 1000000.00
1552 1553 date: 1500001.00
1553 1554 date: 1500000.00
1554 1555 date: 1400000.00
1555 1556 date: 1300000.00
1556 1557 date: 1200000.00
1557 1558 date: 1100000.00
1558 1559 date: 1000000.00
1559 1560 date--verbose: 1577872860.00
1560 1561 date--verbose: 1000000.00
1561 1562 date--verbose: 1500001.00
1562 1563 date--verbose: 1500000.00
1563 1564 date--verbose: 1400000.00
1564 1565 date--verbose: 1300000.00
1565 1566 date--verbose: 1200000.00
1566 1567 date--verbose: 1100000.00
1567 1568 date--verbose: 1000000.00
1568 1569 date--debug: 1577872860.00
1569 1570 date--debug: 1000000.00
1570 1571 date--debug: 1500001.00
1571 1572 date--debug: 1500000.00
1572 1573 date--debug: 1400000.00
1573 1574 date--debug: 1300000.00
1574 1575 date--debug: 1200000.00
1575 1576 date--debug: 1100000.00
1576 1577 date--debug: 1000000.00
1577 1578 desc: third
1578 1579 desc: second
1579 1580 desc: merge
1580 1581 desc: new head
1581 1582 desc: new branch
1582 1583 desc: no user, no domain
1583 1584 desc: no person
1584 1585 desc: other 1
1585 1586 other 2
1586 1587
1587 1588 other 3
1588 1589 desc: line 1
1589 1590 line 2
1590 1591 desc--verbose: third
1591 1592 desc--verbose: second
1592 1593 desc--verbose: merge
1593 1594 desc--verbose: new head
1594 1595 desc--verbose: new branch
1595 1596 desc--verbose: no user, no domain
1596 1597 desc--verbose: no person
1597 1598 desc--verbose: other 1
1598 1599 other 2
1599 1600
1600 1601 other 3
1601 1602 desc--verbose: line 1
1602 1603 line 2
1603 1604 desc--debug: third
1604 1605 desc--debug: second
1605 1606 desc--debug: merge
1606 1607 desc--debug: new head
1607 1608 desc--debug: new branch
1608 1609 desc--debug: no user, no domain
1609 1610 desc--debug: no person
1610 1611 desc--debug: other 1
1611 1612 other 2
1612 1613
1613 1614 other 3
1614 1615 desc--debug: line 1
1615 1616 line 2
1616 1617 file_adds: fourth third
1617 1618 file_adds: second
1618 1619 file_adds:
1619 1620 file_adds: d
1620 1621 file_adds:
1621 1622 file_adds:
1622 1623 file_adds: c
1623 1624 file_adds: b
1624 1625 file_adds: a
1625 1626 file_adds--verbose: fourth third
1626 1627 file_adds--verbose: second
1627 1628 file_adds--verbose:
1628 1629 file_adds--verbose: d
1629 1630 file_adds--verbose:
1630 1631 file_adds--verbose:
1631 1632 file_adds--verbose: c
1632 1633 file_adds--verbose: b
1633 1634 file_adds--verbose: a
1634 1635 file_adds--debug: fourth third
1635 1636 file_adds--debug: second
1636 1637 file_adds--debug:
1637 1638 file_adds--debug: d
1638 1639 file_adds--debug:
1639 1640 file_adds--debug:
1640 1641 file_adds--debug: c
1641 1642 file_adds--debug: b
1642 1643 file_adds--debug: a
1643 1644 file_dels: second
1644 1645 file_dels:
1645 1646 file_dels:
1646 1647 file_dels:
1647 1648 file_dels:
1648 1649 file_dels:
1649 1650 file_dels:
1650 1651 file_dels:
1651 1652 file_dels:
1652 1653 file_dels--verbose: second
1653 1654 file_dels--verbose:
1654 1655 file_dels--verbose:
1655 1656 file_dels--verbose:
1656 1657 file_dels--verbose:
1657 1658 file_dels--verbose:
1658 1659 file_dels--verbose:
1659 1660 file_dels--verbose:
1660 1661 file_dels--verbose:
1661 1662 file_dels--debug: second
1662 1663 file_dels--debug:
1663 1664 file_dels--debug:
1664 1665 file_dels--debug:
1665 1666 file_dels--debug:
1666 1667 file_dels--debug:
1667 1668 file_dels--debug:
1668 1669 file_dels--debug:
1669 1670 file_dels--debug:
1670 1671 file_mods:
1671 1672 file_mods:
1672 1673 file_mods:
1673 1674 file_mods:
1674 1675 file_mods:
1675 1676 file_mods: c
1676 1677 file_mods:
1677 1678 file_mods:
1678 1679 file_mods:
1679 1680 file_mods--verbose:
1680 1681 file_mods--verbose:
1681 1682 file_mods--verbose:
1682 1683 file_mods--verbose:
1683 1684 file_mods--verbose:
1684 1685 file_mods--verbose: c
1685 1686 file_mods--verbose:
1686 1687 file_mods--verbose:
1687 1688 file_mods--verbose:
1688 1689 file_mods--debug:
1689 1690 file_mods--debug:
1690 1691 file_mods--debug:
1691 1692 file_mods--debug:
1692 1693 file_mods--debug:
1693 1694 file_mods--debug: c
1694 1695 file_mods--debug:
1695 1696 file_mods--debug:
1696 1697 file_mods--debug:
1697 1698 file_copies: fourth (second)
1698 1699 file_copies:
1699 1700 file_copies:
1700 1701 file_copies:
1701 1702 file_copies:
1702 1703 file_copies:
1703 1704 file_copies:
1704 1705 file_copies:
1705 1706 file_copies:
1706 1707 file_copies--verbose: fourth (second)
1707 1708 file_copies--verbose:
1708 1709 file_copies--verbose:
1709 1710 file_copies--verbose:
1710 1711 file_copies--verbose:
1711 1712 file_copies--verbose:
1712 1713 file_copies--verbose:
1713 1714 file_copies--verbose:
1714 1715 file_copies--verbose:
1715 1716 file_copies--debug: fourth (second)
1716 1717 file_copies--debug:
1717 1718 file_copies--debug:
1718 1719 file_copies--debug:
1719 1720 file_copies--debug:
1720 1721 file_copies--debug:
1721 1722 file_copies--debug:
1722 1723 file_copies--debug:
1723 1724 file_copies--debug:
1724 1725 file_copies_switch:
1725 1726 file_copies_switch:
1726 1727 file_copies_switch:
1727 1728 file_copies_switch:
1728 1729 file_copies_switch:
1729 1730 file_copies_switch:
1730 1731 file_copies_switch:
1731 1732 file_copies_switch:
1732 1733 file_copies_switch:
1733 1734 file_copies_switch--verbose:
1734 1735 file_copies_switch--verbose:
1735 1736 file_copies_switch--verbose:
1736 1737 file_copies_switch--verbose:
1737 1738 file_copies_switch--verbose:
1738 1739 file_copies_switch--verbose:
1739 1740 file_copies_switch--verbose:
1740 1741 file_copies_switch--verbose:
1741 1742 file_copies_switch--verbose:
1742 1743 file_copies_switch--debug:
1743 1744 file_copies_switch--debug:
1744 1745 file_copies_switch--debug:
1745 1746 file_copies_switch--debug:
1746 1747 file_copies_switch--debug:
1747 1748 file_copies_switch--debug:
1748 1749 file_copies_switch--debug:
1749 1750 file_copies_switch--debug:
1750 1751 file_copies_switch--debug:
1751 1752 files: fourth second third
1752 1753 files: second
1753 1754 files:
1754 1755 files: d
1755 1756 files:
1756 1757 files: c
1757 1758 files: c
1758 1759 files: b
1759 1760 files: a
1760 1761 files--verbose: fourth second third
1761 1762 files--verbose: second
1762 1763 files--verbose:
1763 1764 files--verbose: d
1764 1765 files--verbose:
1765 1766 files--verbose: c
1766 1767 files--verbose: c
1767 1768 files--verbose: b
1768 1769 files--verbose: a
1769 1770 files--debug: fourth second third
1770 1771 files--debug: second
1771 1772 files--debug:
1772 1773 files--debug: d
1773 1774 files--debug:
1774 1775 files--debug: c
1775 1776 files--debug: c
1776 1777 files--debug: b
1777 1778 files--debug: a
1778 1779 manifest: 6:94961b75a2da
1779 1780 manifest: 5:f2dbc354b94e
1780 1781 manifest: 4:4dc3def4f9b4
1781 1782 manifest: 4:4dc3def4f9b4
1782 1783 manifest: 3:cb5a1327723b
1783 1784 manifest: 3:cb5a1327723b
1784 1785 manifest: 2:6e0e82995c35
1785 1786 manifest: 1:4e8d705b1e53
1786 1787 manifest: 0:a0c8bcbbb45c
1787 1788 manifest--verbose: 6:94961b75a2da
1788 1789 manifest--verbose: 5:f2dbc354b94e
1789 1790 manifest--verbose: 4:4dc3def4f9b4
1790 1791 manifest--verbose: 4:4dc3def4f9b4
1791 1792 manifest--verbose: 3:cb5a1327723b
1792 1793 manifest--verbose: 3:cb5a1327723b
1793 1794 manifest--verbose: 2:6e0e82995c35
1794 1795 manifest--verbose: 1:4e8d705b1e53
1795 1796 manifest--verbose: 0:a0c8bcbbb45c
1796 1797 manifest--debug: 6:94961b75a2da554b4df6fb599e5bfc7d48de0c64
1797 1798 manifest--debug: 5:f2dbc354b94e5ec0b4f10680ee0cee816101d0bf
1798 1799 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1799 1800 manifest--debug: 4:4dc3def4f9b4c6e8de820f6ee74737f91e96a216
1800 1801 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1801 1802 manifest--debug: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
1802 1803 manifest--debug: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
1803 1804 manifest--debug: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
1804 1805 manifest--debug: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
1805 1806 node: 95c24699272ef57d062b8bccc32c878bf841784a
1806 1807 node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1807 1808 node: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1808 1809 node: 13207e5a10d9fd28ec424934298e176197f2c67f
1809 1810 node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1810 1811 node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1811 1812 node: 97054abb4ab824450e9164180baf491ae0078465
1812 1813 node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1813 1814 node: 1e4e1b8f71e05681d422154f5421e385fec3454f
1814 1815 node--verbose: 95c24699272ef57d062b8bccc32c878bf841784a
1815 1816 node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1816 1817 node--verbose: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1817 1818 node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
1818 1819 node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1819 1820 node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1820 1821 node--verbose: 97054abb4ab824450e9164180baf491ae0078465
1821 1822 node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1822 1823 node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
1823 1824 node--debug: 95c24699272ef57d062b8bccc32c878bf841784a
1824 1825 node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
1825 1826 node--debug: d41e714fe50d9e4a5f11b4d595d543481b5f980b
1826 1827 node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
1827 1828 node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
1828 1829 node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
1829 1830 node--debug: 97054abb4ab824450e9164180baf491ae0078465
1830 1831 node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
1831 1832 node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
1832 1833 parents:
1833 1834 parents: -1:000000000000
1834 1835 parents: 5:13207e5a10d9 4:bbe44766e73d
1835 1836 parents: 3:10e46f2dcbf4
1836 1837 parents:
1837 1838 parents:
1838 1839 parents:
1839 1840 parents:
1840 1841 parents:
1841 1842 parents--verbose:
1842 1843 parents--verbose: -1:000000000000
1843 1844 parents--verbose: 5:13207e5a10d9 4:bbe44766e73d
1844 1845 parents--verbose: 3:10e46f2dcbf4
1845 1846 parents--verbose:
1846 1847 parents--verbose:
1847 1848 parents--verbose:
1848 1849 parents--verbose:
1849 1850 parents--verbose:
1850 1851 parents--debug: 7:29114dbae42b9f078cf2714dbe3a86bba8ec7453 -1:0000000000000000000000000000000000000000
1851 1852 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1852 1853 parents--debug: 5:13207e5a10d9fd28ec424934298e176197f2c67f 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
1853 1854 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1854 1855 parents--debug: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47 -1:0000000000000000000000000000000000000000
1855 1856 parents--debug: 2:97054abb4ab824450e9164180baf491ae0078465 -1:0000000000000000000000000000000000000000
1856 1857 parents--debug: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965 -1:0000000000000000000000000000000000000000
1857 1858 parents--debug: 0:1e4e1b8f71e05681d422154f5421e385fec3454f -1:0000000000000000000000000000000000000000
1858 1859 parents--debug: -1:0000000000000000000000000000000000000000 -1:0000000000000000000000000000000000000000
1859 1860 rev: 8
1860 1861 rev: 7
1861 1862 rev: 6
1862 1863 rev: 5
1863 1864 rev: 4
1864 1865 rev: 3
1865 1866 rev: 2
1866 1867 rev: 1
1867 1868 rev: 0
1868 1869 rev--verbose: 8
1869 1870 rev--verbose: 7
1870 1871 rev--verbose: 6
1871 1872 rev--verbose: 5
1872 1873 rev--verbose: 4
1873 1874 rev--verbose: 3
1874 1875 rev--verbose: 2
1875 1876 rev--verbose: 1
1876 1877 rev--verbose: 0
1877 1878 rev--debug: 8
1878 1879 rev--debug: 7
1879 1880 rev--debug: 6
1880 1881 rev--debug: 5
1881 1882 rev--debug: 4
1882 1883 rev--debug: 3
1883 1884 rev--debug: 2
1884 1885 rev--debug: 1
1885 1886 rev--debug: 0
1886 1887 tags: tip
1887 1888 tags:
1888 1889 tags:
1889 1890 tags:
1890 1891 tags:
1891 1892 tags:
1892 1893 tags:
1893 1894 tags:
1894 1895 tags:
1895 1896 tags--verbose: tip
1896 1897 tags--verbose:
1897 1898 tags--verbose:
1898 1899 tags--verbose:
1899 1900 tags--verbose:
1900 1901 tags--verbose:
1901 1902 tags--verbose:
1902 1903 tags--verbose:
1903 1904 tags--verbose:
1904 1905 tags--debug: tip
1905 1906 tags--debug:
1906 1907 tags--debug:
1907 1908 tags--debug:
1908 1909 tags--debug:
1909 1910 tags--debug:
1910 1911 tags--debug:
1911 1912 tags--debug:
1912 1913 tags--debug:
1913 1914 diffstat: 3: +2/-1
1914 1915 diffstat: 1: +1/-0
1915 1916 diffstat: 0: +0/-0
1916 1917 diffstat: 1: +1/-0
1917 1918 diffstat: 0: +0/-0
1918 1919 diffstat: 1: +1/-0
1919 1920 diffstat: 1: +4/-0
1920 1921 diffstat: 1: +2/-0
1921 1922 diffstat: 1: +1/-0
1922 1923 diffstat--verbose: 3: +2/-1
1923 1924 diffstat--verbose: 1: +1/-0
1924 1925 diffstat--verbose: 0: +0/-0
1925 1926 diffstat--verbose: 1: +1/-0
1926 1927 diffstat--verbose: 0: +0/-0
1927 1928 diffstat--verbose: 1: +1/-0
1928 1929 diffstat--verbose: 1: +4/-0
1929 1930 diffstat--verbose: 1: +2/-0
1930 1931 diffstat--verbose: 1: +1/-0
1931 1932 diffstat--debug: 3: +2/-1
1932 1933 diffstat--debug: 1: +1/-0
1933 1934 diffstat--debug: 0: +0/-0
1934 1935 diffstat--debug: 1: +1/-0
1935 1936 diffstat--debug: 0: +0/-0
1936 1937 diffstat--debug: 1: +1/-0
1937 1938 diffstat--debug: 1: +4/-0
1938 1939 diffstat--debug: 1: +2/-0
1939 1940 diffstat--debug: 1: +1/-0
1940 1941 extras: branch=default
1941 1942 extras: branch=default
1942 1943 extras: branch=default
1943 1944 extras: branch=default
1944 1945 extras: branch=foo
1945 1946 extras: branch=default
1946 1947 extras: branch=default
1947 1948 extras: branch=default
1948 1949 extras: branch=default
1949 1950 extras--verbose: branch=default
1950 1951 extras--verbose: branch=default
1951 1952 extras--verbose: branch=default
1952 1953 extras--verbose: branch=default
1953 1954 extras--verbose: branch=foo
1954 1955 extras--verbose: branch=default
1955 1956 extras--verbose: branch=default
1956 1957 extras--verbose: branch=default
1957 1958 extras--verbose: branch=default
1958 1959 extras--debug: branch=default
1959 1960 extras--debug: branch=default
1960 1961 extras--debug: branch=default
1961 1962 extras--debug: branch=default
1962 1963 extras--debug: branch=foo
1963 1964 extras--debug: branch=default
1964 1965 extras--debug: branch=default
1965 1966 extras--debug: branch=default
1966 1967 extras--debug: branch=default
1967 1968 p1rev: 7
1968 1969 p1rev: -1
1969 1970 p1rev: 5
1970 1971 p1rev: 3
1971 1972 p1rev: 3
1972 1973 p1rev: 2
1973 1974 p1rev: 1
1974 1975 p1rev: 0
1975 1976 p1rev: -1
1976 1977 p1rev--verbose: 7
1977 1978 p1rev--verbose: -1
1978 1979 p1rev--verbose: 5
1979 1980 p1rev--verbose: 3
1980 1981 p1rev--verbose: 3
1981 1982 p1rev--verbose: 2
1982 1983 p1rev--verbose: 1
1983 1984 p1rev--verbose: 0
1984 1985 p1rev--verbose: -1
1985 1986 p1rev--debug: 7
1986 1987 p1rev--debug: -1
1987 1988 p1rev--debug: 5
1988 1989 p1rev--debug: 3
1989 1990 p1rev--debug: 3
1990 1991 p1rev--debug: 2
1991 1992 p1rev--debug: 1
1992 1993 p1rev--debug: 0
1993 1994 p1rev--debug: -1
1994 1995 p2rev: -1
1995 1996 p2rev: -1
1996 1997 p2rev: 4
1997 1998 p2rev: -1
1998 1999 p2rev: -1
1999 2000 p2rev: -1
2000 2001 p2rev: -1
2001 2002 p2rev: -1
2002 2003 p2rev: -1
2003 2004 p2rev--verbose: -1
2004 2005 p2rev--verbose: -1
2005 2006 p2rev--verbose: 4
2006 2007 p2rev--verbose: -1
2007 2008 p2rev--verbose: -1
2008 2009 p2rev--verbose: -1
2009 2010 p2rev--verbose: -1
2010 2011 p2rev--verbose: -1
2011 2012 p2rev--verbose: -1
2012 2013 p2rev--debug: -1
2013 2014 p2rev--debug: -1
2014 2015 p2rev--debug: 4
2015 2016 p2rev--debug: -1
2016 2017 p2rev--debug: -1
2017 2018 p2rev--debug: -1
2018 2019 p2rev--debug: -1
2019 2020 p2rev--debug: -1
2020 2021 p2rev--debug: -1
2021 2022 p1node: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
2022 2023 p1node: 0000000000000000000000000000000000000000
2023 2024 p1node: 13207e5a10d9fd28ec424934298e176197f2c67f
2024 2025 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2025 2026 p1node: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2026 2027 p1node: 97054abb4ab824450e9164180baf491ae0078465
2027 2028 p1node: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2028 2029 p1node: 1e4e1b8f71e05681d422154f5421e385fec3454f
2029 2030 p1node: 0000000000000000000000000000000000000000
2030 2031 p1node--verbose: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
2031 2032 p1node--verbose: 0000000000000000000000000000000000000000
2032 2033 p1node--verbose: 13207e5a10d9fd28ec424934298e176197f2c67f
2033 2034 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2034 2035 p1node--verbose: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2035 2036 p1node--verbose: 97054abb4ab824450e9164180baf491ae0078465
2036 2037 p1node--verbose: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2037 2038 p1node--verbose: 1e4e1b8f71e05681d422154f5421e385fec3454f
2038 2039 p1node--verbose: 0000000000000000000000000000000000000000
2039 2040 p1node--debug: 29114dbae42b9f078cf2714dbe3a86bba8ec7453
2040 2041 p1node--debug: 0000000000000000000000000000000000000000
2041 2042 p1node--debug: 13207e5a10d9fd28ec424934298e176197f2c67f
2042 2043 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2043 2044 p1node--debug: 10e46f2dcbf4823578cf180f33ecf0b957964c47
2044 2045 p1node--debug: 97054abb4ab824450e9164180baf491ae0078465
2045 2046 p1node--debug: b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2046 2047 p1node--debug: 1e4e1b8f71e05681d422154f5421e385fec3454f
2047 2048 p1node--debug: 0000000000000000000000000000000000000000
2048 2049 p2node: 0000000000000000000000000000000000000000
2049 2050 p2node: 0000000000000000000000000000000000000000
2050 2051 p2node: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2051 2052 p2node: 0000000000000000000000000000000000000000
2052 2053 p2node: 0000000000000000000000000000000000000000
2053 2054 p2node: 0000000000000000000000000000000000000000
2054 2055 p2node: 0000000000000000000000000000000000000000
2055 2056 p2node: 0000000000000000000000000000000000000000
2056 2057 p2node: 0000000000000000000000000000000000000000
2057 2058 p2node--verbose: 0000000000000000000000000000000000000000
2058 2059 p2node--verbose: 0000000000000000000000000000000000000000
2059 2060 p2node--verbose: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2060 2061 p2node--verbose: 0000000000000000000000000000000000000000
2061 2062 p2node--verbose: 0000000000000000000000000000000000000000
2062 2063 p2node--verbose: 0000000000000000000000000000000000000000
2063 2064 p2node--verbose: 0000000000000000000000000000000000000000
2064 2065 p2node--verbose: 0000000000000000000000000000000000000000
2065 2066 p2node--verbose: 0000000000000000000000000000000000000000
2066 2067 p2node--debug: 0000000000000000000000000000000000000000
2067 2068 p2node--debug: 0000000000000000000000000000000000000000
2068 2069 p2node--debug: bbe44766e73d5f11ed2177f1838de10c53ef3e74
2069 2070 p2node--debug: 0000000000000000000000000000000000000000
2070 2071 p2node--debug: 0000000000000000000000000000000000000000
2071 2072 p2node--debug: 0000000000000000000000000000000000000000
2072 2073 p2node--debug: 0000000000000000000000000000000000000000
2073 2074 p2node--debug: 0000000000000000000000000000000000000000
2074 2075 p2node--debug: 0000000000000000000000000000000000000000
2075 2076
2076 2077 Filters work:
2077 2078
2078 2079 $ hg log --template '{author|domain}\n'
2079 2080
2080 2081 hostname
2081 2082
2082 2083
2083 2084
2084 2085
2085 2086 place
2086 2087 place
2087 2088 hostname
2088 2089
2089 2090 $ hg log --template '{author|person}\n'
2090 2091 test
2091 2092 User Name
2092 2093 person
2093 2094 person
2094 2095 person
2095 2096 person
2096 2097 other
2097 2098 A. N. Other
2098 2099 User Name
2099 2100
2100 2101 $ hg log --template '{author|user}\n'
2101 2102 test
2102 2103 user
2103 2104 person
2104 2105 person
2105 2106 person
2106 2107 person
2107 2108 other
2108 2109 other
2109 2110 user
2110 2111
2111 2112 $ hg log --template '{date|date}\n'
2112 2113 Wed Jan 01 10:01:00 2020 +0000
2113 2114 Mon Jan 12 13:46:40 1970 +0000
2114 2115 Sun Jan 18 08:40:01 1970 +0000
2115 2116 Sun Jan 18 08:40:00 1970 +0000
2116 2117 Sat Jan 17 04:53:20 1970 +0000
2117 2118 Fri Jan 16 01:06:40 1970 +0000
2118 2119 Wed Jan 14 21:20:00 1970 +0000
2119 2120 Tue Jan 13 17:33:20 1970 +0000
2120 2121 Mon Jan 12 13:46:40 1970 +0000
2121 2122
2122 2123 $ hg log --template '{date|isodate}\n'
2123 2124 2020-01-01 10:01 +0000
2124 2125 1970-01-12 13:46 +0000
2125 2126 1970-01-18 08:40 +0000
2126 2127 1970-01-18 08:40 +0000
2127 2128 1970-01-17 04:53 +0000
2128 2129 1970-01-16 01:06 +0000
2129 2130 1970-01-14 21:20 +0000
2130 2131 1970-01-13 17:33 +0000
2131 2132 1970-01-12 13:46 +0000
2132 2133
2133 2134 $ hg log --template '{date|isodatesec}\n'
2134 2135 2020-01-01 10:01:00 +0000
2135 2136 1970-01-12 13:46:40 +0000
2136 2137 1970-01-18 08:40:01 +0000
2137 2138 1970-01-18 08:40:00 +0000
2138 2139 1970-01-17 04:53:20 +0000
2139 2140 1970-01-16 01:06:40 +0000
2140 2141 1970-01-14 21:20:00 +0000
2141 2142 1970-01-13 17:33:20 +0000
2142 2143 1970-01-12 13:46:40 +0000
2143 2144
2144 2145 $ hg log --template '{date|rfc822date}\n'
2145 2146 Wed, 01 Jan 2020 10:01:00 +0000
2146 2147 Mon, 12 Jan 1970 13:46:40 +0000
2147 2148 Sun, 18 Jan 1970 08:40:01 +0000
2148 2149 Sun, 18 Jan 1970 08:40:00 +0000
2149 2150 Sat, 17 Jan 1970 04:53:20 +0000
2150 2151 Fri, 16 Jan 1970 01:06:40 +0000
2151 2152 Wed, 14 Jan 1970 21:20:00 +0000
2152 2153 Tue, 13 Jan 1970 17:33:20 +0000
2153 2154 Mon, 12 Jan 1970 13:46:40 +0000
2154 2155
2155 2156 $ hg log --template '{desc|firstline}\n'
2156 2157 third
2157 2158 second
2158 2159 merge
2159 2160 new head
2160 2161 new branch
2161 2162 no user, no domain
2162 2163 no person
2163 2164 other 1
2164 2165 line 1
2165 2166
2166 2167 $ hg log --template '{node|short}\n'
2167 2168 95c24699272e
2168 2169 29114dbae42b
2169 2170 d41e714fe50d
2170 2171 13207e5a10d9
2171 2172 bbe44766e73d
2172 2173 10e46f2dcbf4
2173 2174 97054abb4ab8
2174 2175 b608e9d1a3f0
2175 2176 1e4e1b8f71e0
2176 2177
2177 2178 $ hg log --template '<changeset author="{author|xmlescape}"/>\n'
2178 2179 <changeset author="test"/>
2179 2180 <changeset author="User Name &lt;user@hostname&gt;"/>
2180 2181 <changeset author="person"/>
2181 2182 <changeset author="person"/>
2182 2183 <changeset author="person"/>
2183 2184 <changeset author="person"/>
2184 2185 <changeset author="other@place"/>
2185 2186 <changeset author="A. N. Other &lt;other@place&gt;"/>
2186 2187 <changeset author="User Name &lt;user@hostname&gt;"/>
2187 2188
2188 2189 $ hg log --template '{rev}: {children}\n'
2189 2190 8:
2190 2191 7: 8:95c24699272e
2191 2192 6:
2192 2193 5: 6:d41e714fe50d
2193 2194 4: 6:d41e714fe50d
2194 2195 3: 4:bbe44766e73d 5:13207e5a10d9
2195 2196 2: 3:10e46f2dcbf4
2196 2197 1: 2:97054abb4ab8
2197 2198 0: 1:b608e9d1a3f0
2198 2199
2199 2200 Formatnode filter works:
2200 2201
2201 2202 $ hg -q log -r 0 --template '{node|formatnode}\n'
2202 2203 1e4e1b8f71e0
2203 2204
2204 2205 $ hg log -r 0 --template '{node|formatnode}\n'
2205 2206 1e4e1b8f71e0
2206 2207
2207 2208 $ hg -v log -r 0 --template '{node|formatnode}\n'
2208 2209 1e4e1b8f71e0
2209 2210
2210 2211 $ hg --debug log -r 0 --template '{node|formatnode}\n'
2211 2212 1e4e1b8f71e05681d422154f5421e385fec3454f
2212 2213
2213 2214 Age filter:
2214 2215
2215 2216 $ hg init unstable-hash
2216 2217 $ cd unstable-hash
2217 2218 $ hg log --template '{date|age}\n' > /dev/null || exit 1
2218 2219
2219 2220 >>> from __future__ import absolute_import
2220 2221 >>> import datetime
2221 2222 >>> fp = open('a', 'wb')
2222 2223 >>> n = datetime.datetime.now() + datetime.timedelta(366 * 7)
2223 2224 >>> fp.write(b'%d-%d-%d 00:00' % (n.year, n.month, n.day)) and None
2224 2225 >>> fp.close()
2225 2226 $ hg add a
2226 2227 $ hg commit -m future -d "`cat a`"
2227 2228
2228 2229 $ hg log -l1 --template '{date|age}\n'
2229 2230 7 years from now
2230 2231
2231 2232 $ cd ..
2232 2233 $ rm -rf unstable-hash
2233 2234
2234 2235 Filename filters:
2235 2236
2236 2237 $ hg debugtemplate '{"foo/bar"|basename}|{"foo/"|basename}|{"foo"|basename}|\n'
2237 2238 bar||foo|
2238 2239 $ hg debugtemplate '{"foo/bar"|dirname}|{"foo/"|dirname}|{"foo"|dirname}|\n'
2239 2240 foo|foo||
2240 2241 $ hg debugtemplate '{"foo/bar"|stripdir}|{"foo/"|stripdir}|{"foo"|stripdir}|\n'
2241 2242 foo|foo|foo|
2242 2243
2243 2244 Add a dummy commit to make up for the instability of the above:
2244 2245
2245 2246 $ echo a > a
2246 2247 $ hg add a
2247 2248 $ hg ci -m future
2248 2249
2249 2250 Count filter:
2250 2251
2251 2252 $ hg log -l1 --template '{node|count} {node|short|count}\n'
2252 2253 40 12
2253 2254
2254 2255 $ hg log -l1 --template '{revset("null^")|count} {revset(".")|count} {revset("0::3")|count}\n'
2255 2256 0 1 4
2256 2257
2257 2258 $ hg log -G --template '{rev}: children: {children|count}, \
2258 2259 > tags: {tags|count}, file_adds: {file_adds|count}, \
2259 2260 > ancestors: {revset("ancestors(%s)", rev)|count}'
2260 2261 @ 9: children: 0, tags: 1, file_adds: 1, ancestors: 3
2261 2262 |
2262 2263 o 8: children: 1, tags: 0, file_adds: 2, ancestors: 2
2263 2264 |
2264 2265 o 7: children: 1, tags: 0, file_adds: 1, ancestors: 1
2265 2266
2266 2267 o 6: children: 0, tags: 0, file_adds: 0, ancestors: 7
2267 2268 |\
2268 2269 | o 5: children: 1, tags: 0, file_adds: 1, ancestors: 5
2269 2270 | |
2270 2271 o | 4: children: 1, tags: 0, file_adds: 0, ancestors: 5
2271 2272 |/
2272 2273 o 3: children: 2, tags: 0, file_adds: 0, ancestors: 4
2273 2274 |
2274 2275 o 2: children: 1, tags: 0, file_adds: 1, ancestors: 3
2275 2276 |
2276 2277 o 1: children: 1, tags: 0, file_adds: 1, ancestors: 2
2277 2278 |
2278 2279 o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1
2279 2280
2280 2281
2281 2282 $ hg log -l1 -T '{termwidth|count}\n'
2282 2283 hg: parse error: not countable
2283 2284 (template filter 'count' is not compatible with keyword 'termwidth')
2284 2285 [255]
2285 2286
2286 2287 Upper/lower filters:
2287 2288
2288 2289 $ hg log -r0 --template '{branch|upper}\n'
2289 2290 DEFAULT
2290 2291 $ hg log -r0 --template '{author|lower}\n'
2291 2292 user name <user@hostname>
2292 2293 $ hg log -r0 --template '{date|upper}\n'
2293 2294 1000000.00
2294 2295
2295 2296 Add a commit that does all possible modifications at once
2296 2297
2297 2298 $ echo modify >> third
2298 2299 $ touch b
2299 2300 $ hg add b
2300 2301 $ hg mv fourth fifth
2301 2302 $ hg rm a
2302 2303 $ hg ci -m "Modify, add, remove, rename"
2303 2304
2304 2305 Check the status template
2305 2306
2306 2307 $ cat <<EOF >> $HGRCPATH
2307 2308 > [extensions]
2308 2309 > color=
2309 2310 > EOF
2310 2311
2311 2312 $ hg log -T status -r 10
2312 2313 changeset: 10:0f9759ec227a
2313 2314 tag: tip
2314 2315 user: test
2315 2316 date: Thu Jan 01 00:00:00 1970 +0000
2316 2317 summary: Modify, add, remove, rename
2317 2318 files:
2318 2319 M third
2319 2320 A b
2320 2321 A fifth
2321 2322 R a
2322 2323 R fourth
2323 2324
2324 2325 $ hg log -T status -C -r 10
2325 2326 changeset: 10:0f9759ec227a
2326 2327 tag: tip
2327 2328 user: test
2328 2329 date: Thu Jan 01 00:00:00 1970 +0000
2329 2330 summary: Modify, add, remove, rename
2330 2331 files:
2331 2332 M third
2332 2333 A b
2333 2334 A fifth
2334 2335 fourth
2335 2336 R a
2336 2337 R fourth
2337 2338
2338 2339 $ hg log -T status -C -r 10 -v
2339 2340 changeset: 10:0f9759ec227a
2340 2341 tag: tip
2341 2342 user: test
2342 2343 date: Thu Jan 01 00:00:00 1970 +0000
2343 2344 description:
2344 2345 Modify, add, remove, rename
2345 2346
2346 2347 files:
2347 2348 M third
2348 2349 A b
2349 2350 A fifth
2350 2351 fourth
2351 2352 R a
2352 2353 R fourth
2353 2354
2354 2355 $ hg log -T status -C -r 10 --debug
2355 2356 changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c
2356 2357 tag: tip
2357 2358 phase: secret
2358 2359 parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066
2359 2360 parent: -1:0000000000000000000000000000000000000000
2360 2361 manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567
2361 2362 user: test
2362 2363 date: Thu Jan 01 00:00:00 1970 +0000
2363 2364 extra: branch=default
2364 2365 description:
2365 2366 Modify, add, remove, rename
2366 2367
2367 2368 files:
2368 2369 M third
2369 2370 A b
2370 2371 A fifth
2371 2372 fourth
2372 2373 R a
2373 2374 R fourth
2374 2375
2375 2376 $ hg log -T status -C -r 10 --quiet
2376 2377 10:0f9759ec227a
2377 2378 $ hg --color=debug log -T status -r 10
2378 2379 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2379 2380 [log.tag|tag: tip]
2380 2381 [log.user|user: test]
2381 2382 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2382 2383 [log.summary|summary: Modify, add, remove, rename]
2383 2384 [ui.note log.files|files:]
2384 2385 [status.modified|M third]
2385 2386 [status.added|A b]
2386 2387 [status.added|A fifth]
2387 2388 [status.removed|R a]
2388 2389 [status.removed|R fourth]
2389 2390
2390 2391 $ hg --color=debug log -T status -C -r 10
2391 2392 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2392 2393 [log.tag|tag: tip]
2393 2394 [log.user|user: test]
2394 2395 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2395 2396 [log.summary|summary: Modify, add, remove, rename]
2396 2397 [ui.note log.files|files:]
2397 2398 [status.modified|M third]
2398 2399 [status.added|A b]
2399 2400 [status.added|A fifth]
2400 2401 [status.copied| fourth]
2401 2402 [status.removed|R a]
2402 2403 [status.removed|R fourth]
2403 2404
2404 2405 $ hg --color=debug log -T status -C -r 10 -v
2405 2406 [log.changeset changeset.secret|changeset: 10:0f9759ec227a]
2406 2407 [log.tag|tag: tip]
2407 2408 [log.user|user: test]
2408 2409 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2409 2410 [ui.note log.description|description:]
2410 2411 [ui.note log.description|Modify, add, remove, rename]
2411 2412
2412 2413 [ui.note log.files|files:]
2413 2414 [status.modified|M third]
2414 2415 [status.added|A b]
2415 2416 [status.added|A fifth]
2416 2417 [status.copied| fourth]
2417 2418 [status.removed|R a]
2418 2419 [status.removed|R fourth]
2419 2420
2420 2421 $ hg --color=debug log -T status -C -r 10 --debug
2421 2422 [log.changeset changeset.secret|changeset: 10:0f9759ec227a4859c2014a345cd8a859022b7c6c]
2422 2423 [log.tag|tag: tip]
2423 2424 [log.phase|phase: secret]
2424 2425 [log.parent changeset.secret|parent: 9:bf9dfba36635106d6a73ccc01e28b762da60e066]
2425 2426 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2426 2427 [ui.debug log.manifest|manifest: 8:89dd546f2de0a9d6d664f58d86097eb97baba567]
2427 2428 [log.user|user: test]
2428 2429 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
2429 2430 [ui.debug log.extra|extra: branch=default]
2430 2431 [ui.note log.description|description:]
2431 2432 [ui.note log.description|Modify, add, remove, rename]
2432 2433
2433 2434 [ui.note log.files|files:]
2434 2435 [status.modified|M third]
2435 2436 [status.added|A b]
2436 2437 [status.added|A fifth]
2437 2438 [status.copied| fourth]
2438 2439 [status.removed|R a]
2439 2440 [status.removed|R fourth]
2440 2441
2441 2442 $ hg --color=debug log -T status -C -r 10 --quiet
2442 2443 [log.node|10:0f9759ec227a]
2443 2444
2444 2445 Check the bisect template
2445 2446
2446 2447 $ hg bisect -g 1
2447 2448 $ hg bisect -b 3 --noupdate
2448 2449 Testing changeset 2:97054abb4ab8 (2 changesets remaining, ~1 tests)
2449 2450 $ hg log -T bisect -r 0:4
2450 2451 changeset: 0:1e4e1b8f71e0
2451 2452 bisect: good (implicit)
2452 2453 user: User Name <user@hostname>
2453 2454 date: Mon Jan 12 13:46:40 1970 +0000
2454 2455 summary: line 1
2455 2456
2456 2457 changeset: 1:b608e9d1a3f0
2457 2458 bisect: good
2458 2459 user: A. N. Other <other@place>
2459 2460 date: Tue Jan 13 17:33:20 1970 +0000
2460 2461 summary: other 1
2461 2462
2462 2463 changeset: 2:97054abb4ab8
2463 2464 bisect: untested
2464 2465 user: other@place
2465 2466 date: Wed Jan 14 21:20:00 1970 +0000
2466 2467 summary: no person
2467 2468
2468 2469 changeset: 3:10e46f2dcbf4
2469 2470 bisect: bad
2470 2471 user: person
2471 2472 date: Fri Jan 16 01:06:40 1970 +0000
2472 2473 summary: no user, no domain
2473 2474
2474 2475 changeset: 4:bbe44766e73d
2475 2476 bisect: bad (implicit)
2476 2477 branch: foo
2477 2478 user: person
2478 2479 date: Sat Jan 17 04:53:20 1970 +0000
2479 2480 summary: new branch
2480 2481
2481 2482 $ hg log --debug -T bisect -r 0:4
2482 2483 changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2483 2484 bisect: good (implicit)
2484 2485 phase: public
2485 2486 parent: -1:0000000000000000000000000000000000000000
2486 2487 parent: -1:0000000000000000000000000000000000000000
2487 2488 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
2488 2489 user: User Name <user@hostname>
2489 2490 date: Mon Jan 12 13:46:40 1970 +0000
2490 2491 files+: a
2491 2492 extra: branch=default
2492 2493 description:
2493 2494 line 1
2494 2495 line 2
2495 2496
2496 2497
2497 2498 changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2498 2499 bisect: good
2499 2500 phase: public
2500 2501 parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f
2501 2502 parent: -1:0000000000000000000000000000000000000000
2502 2503 manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55
2503 2504 user: A. N. Other <other@place>
2504 2505 date: Tue Jan 13 17:33:20 1970 +0000
2505 2506 files+: b
2506 2507 extra: branch=default
2507 2508 description:
2508 2509 other 1
2509 2510 other 2
2510 2511
2511 2512 other 3
2512 2513
2513 2514
2514 2515 changeset: 2:97054abb4ab824450e9164180baf491ae0078465
2515 2516 bisect: untested
2516 2517 phase: public
2517 2518 parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965
2518 2519 parent: -1:0000000000000000000000000000000000000000
2519 2520 manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1
2520 2521 user: other@place
2521 2522 date: Wed Jan 14 21:20:00 1970 +0000
2522 2523 files+: c
2523 2524 extra: branch=default
2524 2525 description:
2525 2526 no person
2526 2527
2527 2528
2528 2529 changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2529 2530 bisect: bad
2530 2531 phase: public
2531 2532 parent: 2:97054abb4ab824450e9164180baf491ae0078465
2532 2533 parent: -1:0000000000000000000000000000000000000000
2533 2534 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2534 2535 user: person
2535 2536 date: Fri Jan 16 01:06:40 1970 +0000
2536 2537 files: c
2537 2538 extra: branch=default
2538 2539 description:
2539 2540 no user, no domain
2540 2541
2541 2542
2542 2543 changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
2543 2544 bisect: bad (implicit)
2544 2545 branch: foo
2545 2546 phase: draft
2546 2547 parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47
2547 2548 parent: -1:0000000000000000000000000000000000000000
2548 2549 manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc
2549 2550 user: person
2550 2551 date: Sat Jan 17 04:53:20 1970 +0000
2551 2552 extra: branch=foo
2552 2553 description:
2553 2554 new branch
2554 2555
2555 2556
2556 2557 $ hg log -v -T bisect -r 0:4
2557 2558 changeset: 0:1e4e1b8f71e0
2558 2559 bisect: good (implicit)
2559 2560 user: User Name <user@hostname>
2560 2561 date: Mon Jan 12 13:46:40 1970 +0000
2561 2562 files: a
2562 2563 description:
2563 2564 line 1
2564 2565 line 2
2565 2566
2566 2567
2567 2568 changeset: 1:b608e9d1a3f0
2568 2569 bisect: good
2569 2570 user: A. N. Other <other@place>
2570 2571 date: Tue Jan 13 17:33:20 1970 +0000
2571 2572 files: b
2572 2573 description:
2573 2574 other 1
2574 2575 other 2
2575 2576
2576 2577 other 3
2577 2578
2578 2579
2579 2580 changeset: 2:97054abb4ab8
2580 2581 bisect: untested
2581 2582 user: other@place
2582 2583 date: Wed Jan 14 21:20:00 1970 +0000
2583 2584 files: c
2584 2585 description:
2585 2586 no person
2586 2587
2587 2588
2588 2589 changeset: 3:10e46f2dcbf4
2589 2590 bisect: bad
2590 2591 user: person
2591 2592 date: Fri Jan 16 01:06:40 1970 +0000
2592 2593 files: c
2593 2594 description:
2594 2595 no user, no domain
2595 2596
2596 2597
2597 2598 changeset: 4:bbe44766e73d
2598 2599 bisect: bad (implicit)
2599 2600 branch: foo
2600 2601 user: person
2601 2602 date: Sat Jan 17 04:53:20 1970 +0000
2602 2603 description:
2603 2604 new branch
2604 2605
2605 2606
2606 2607 $ hg --color=debug log -T bisect -r 0:4
2607 2608 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2608 2609 [log.bisect bisect.good|bisect: good (implicit)]
2609 2610 [log.user|user: User Name <user@hostname>]
2610 2611 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2611 2612 [log.summary|summary: line 1]
2612 2613
2613 2614 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2614 2615 [log.bisect bisect.good|bisect: good]
2615 2616 [log.user|user: A. N. Other <other@place>]
2616 2617 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2617 2618 [log.summary|summary: other 1]
2618 2619
2619 2620 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2620 2621 [log.bisect bisect.untested|bisect: untested]
2621 2622 [log.user|user: other@place]
2622 2623 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2623 2624 [log.summary|summary: no person]
2624 2625
2625 2626 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2626 2627 [log.bisect bisect.bad|bisect: bad]
2627 2628 [log.user|user: person]
2628 2629 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2629 2630 [log.summary|summary: no user, no domain]
2630 2631
2631 2632 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2632 2633 [log.bisect bisect.bad|bisect: bad (implicit)]
2633 2634 [log.branch|branch: foo]
2634 2635 [log.user|user: person]
2635 2636 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2636 2637 [log.summary|summary: new branch]
2637 2638
2638 2639 $ hg --color=debug log --debug -T bisect -r 0:4
2639 2640 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2640 2641 [log.bisect bisect.good|bisect: good (implicit)]
2641 2642 [log.phase|phase: public]
2642 2643 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2643 2644 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2644 2645 [ui.debug log.manifest|manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0]
2645 2646 [log.user|user: User Name <user@hostname>]
2646 2647 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2647 2648 [ui.debug log.files|files+: a]
2648 2649 [ui.debug log.extra|extra: branch=default]
2649 2650 [ui.note log.description|description:]
2650 2651 [ui.note log.description|line 1
2651 2652 line 2]
2652 2653
2653 2654
2654 2655 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2655 2656 [log.bisect bisect.good|bisect: good]
2656 2657 [log.phase|phase: public]
2657 2658 [log.parent changeset.public|parent: 0:1e4e1b8f71e05681d422154f5421e385fec3454f]
2658 2659 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2659 2660 [ui.debug log.manifest|manifest: 1:4e8d705b1e53e3f9375e0e60dc7b525d8211fe55]
2660 2661 [log.user|user: A. N. Other <other@place>]
2661 2662 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2662 2663 [ui.debug log.files|files+: b]
2663 2664 [ui.debug log.extra|extra: branch=default]
2664 2665 [ui.note log.description|description:]
2665 2666 [ui.note log.description|other 1
2666 2667 other 2
2667 2668
2668 2669 other 3]
2669 2670
2670 2671
2671 2672 [log.changeset changeset.public|changeset: 2:97054abb4ab824450e9164180baf491ae0078465]
2672 2673 [log.bisect bisect.untested|bisect: untested]
2673 2674 [log.phase|phase: public]
2674 2675 [log.parent changeset.public|parent: 1:b608e9d1a3f0273ccf70fb85fd6866b3482bf965]
2675 2676 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2676 2677 [ui.debug log.manifest|manifest: 2:6e0e82995c35d0d57a52aca8da4e56139e06b4b1]
2677 2678 [log.user|user: other@place]
2678 2679 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2679 2680 [ui.debug log.files|files+: c]
2680 2681 [ui.debug log.extra|extra: branch=default]
2681 2682 [ui.note log.description|description:]
2682 2683 [ui.note log.description|no person]
2683 2684
2684 2685
2685 2686 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2686 2687 [log.bisect bisect.bad|bisect: bad]
2687 2688 [log.phase|phase: public]
2688 2689 [log.parent changeset.public|parent: 2:97054abb4ab824450e9164180baf491ae0078465]
2689 2690 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2690 2691 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2691 2692 [log.user|user: person]
2692 2693 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2693 2694 [ui.debug log.files|files: c]
2694 2695 [ui.debug log.extra|extra: branch=default]
2695 2696 [ui.note log.description|description:]
2696 2697 [ui.note log.description|no user, no domain]
2697 2698
2698 2699
2699 2700 [log.changeset changeset.draft|changeset: 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74]
2700 2701 [log.bisect bisect.bad|bisect: bad (implicit)]
2701 2702 [log.branch|branch: foo]
2702 2703 [log.phase|phase: draft]
2703 2704 [log.parent changeset.public|parent: 3:10e46f2dcbf4823578cf180f33ecf0b957964c47]
2704 2705 [log.parent changeset.public|parent: -1:0000000000000000000000000000000000000000]
2705 2706 [ui.debug log.manifest|manifest: 3:cb5a1327723bada42f117e4c55a303246eaf9ccc]
2706 2707 [log.user|user: person]
2707 2708 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2708 2709 [ui.debug log.extra|extra: branch=foo]
2709 2710 [ui.note log.description|description:]
2710 2711 [ui.note log.description|new branch]
2711 2712
2712 2713
2713 2714 $ hg --color=debug log -v -T bisect -r 0:4
2714 2715 [log.changeset changeset.public|changeset: 0:1e4e1b8f71e0]
2715 2716 [log.bisect bisect.good|bisect: good (implicit)]
2716 2717 [log.user|user: User Name <user@hostname>]
2717 2718 [log.date|date: Mon Jan 12 13:46:40 1970 +0000]
2718 2719 [ui.note log.files|files: a]
2719 2720 [ui.note log.description|description:]
2720 2721 [ui.note log.description|line 1
2721 2722 line 2]
2722 2723
2723 2724
2724 2725 [log.changeset changeset.public|changeset: 1:b608e9d1a3f0]
2725 2726 [log.bisect bisect.good|bisect: good]
2726 2727 [log.user|user: A. N. Other <other@place>]
2727 2728 [log.date|date: Tue Jan 13 17:33:20 1970 +0000]
2728 2729 [ui.note log.files|files: b]
2729 2730 [ui.note log.description|description:]
2730 2731 [ui.note log.description|other 1
2731 2732 other 2
2732 2733
2733 2734 other 3]
2734 2735
2735 2736
2736 2737 [log.changeset changeset.public|changeset: 2:97054abb4ab8]
2737 2738 [log.bisect bisect.untested|bisect: untested]
2738 2739 [log.user|user: other@place]
2739 2740 [log.date|date: Wed Jan 14 21:20:00 1970 +0000]
2740 2741 [ui.note log.files|files: c]
2741 2742 [ui.note log.description|description:]
2742 2743 [ui.note log.description|no person]
2743 2744
2744 2745
2745 2746 [log.changeset changeset.public|changeset: 3:10e46f2dcbf4]
2746 2747 [log.bisect bisect.bad|bisect: bad]
2747 2748 [log.user|user: person]
2748 2749 [log.date|date: Fri Jan 16 01:06:40 1970 +0000]
2749 2750 [ui.note log.files|files: c]
2750 2751 [ui.note log.description|description:]
2751 2752 [ui.note log.description|no user, no domain]
2752 2753
2753 2754
2754 2755 [log.changeset changeset.draft|changeset: 4:bbe44766e73d]
2755 2756 [log.bisect bisect.bad|bisect: bad (implicit)]
2756 2757 [log.branch|branch: foo]
2757 2758 [log.user|user: person]
2758 2759 [log.date|date: Sat Jan 17 04:53:20 1970 +0000]
2759 2760 [ui.note log.description|description:]
2760 2761 [ui.note log.description|new branch]
2761 2762
2762 2763
2763 2764 $ hg bisect --reset
2764 2765
2765 2766 Error on syntax:
2766 2767
2767 2768 $ echo 'x = "f' >> t
2768 2769 $ hg log
2769 2770 hg: parse error at t:3: unmatched quotes
2770 2771 [255]
2771 2772
2772 2773 $ hg log -T '{date'
2773 2774 hg: parse error at 1: unterminated template expansion
2774 2775 ({date
2775 2776 ^ here)
2776 2777 [255]
2777 2778 $ hg log -T '{date(}'
2778 2779 hg: parse error at 6: not a prefix: end
2779 2780 ({date(}
2780 2781 ^ here)
2781 2782 [255]
2782 2783 $ hg log -T '{date)}'
2783 2784 hg: parse error at 5: invalid token
2784 2785 ({date)}
2785 2786 ^ here)
2786 2787 [255]
2787 2788 $ hg log -T '{date date}'
2788 2789 hg: parse error at 6: invalid token
2789 2790 ({date date}
2790 2791 ^ here)
2791 2792 [255]
2792 2793
2793 2794 $ hg log -T '{}'
2794 2795 hg: parse error at 1: not a prefix: end
2795 2796 ({}
2796 2797 ^ here)
2797 2798 [255]
2798 2799 $ hg debugtemplate -v '{()}'
2799 2800 (template
2800 2801 (group
2801 2802 None))
2802 2803 hg: parse error: missing argument
2803 2804 [255]
2804 2805
2805 2806 Behind the scenes, this would throw TypeError without intype=bytes
2806 2807
2807 2808 $ hg log -l 3 --template '{date|obfuscate}\n'
2808 2809 &#48;&#46;&#48;&#48;
2809 2810 &#48;&#46;&#48;&#48;
2810 2811 &#49;&#53;&#55;&#55;&#56;&#55;&#50;&#56;&#54;&#48;&#46;&#48;&#48;
2811 2812
2812 2813 Behind the scenes, this will throw a ValueError
2813 2814
2814 2815 $ hg log -l 3 --template 'line: {desc|shortdate}\n'
2815 2816 hg: parse error: invalid date: 'Modify, add, remove, rename'
2816 2817 (template filter 'shortdate' is not compatible with keyword 'desc')
2817 2818 [255]
2818 2819
2819 2820 Behind the scenes, this would throw AttributeError without intype=bytes
2820 2821
2821 2822 $ hg log -l 3 --template 'line: {date|escape}\n'
2822 2823 line: 0.00
2823 2824 line: 0.00
2824 2825 line: 1577872860.00
2825 2826
2826 2827 $ hg log -l 3 --template 'line: {extras|localdate}\n'
2827 2828 hg: parse error: localdate expects a date information
2828 2829 [255]
2829 2830
2830 2831 Behind the scenes, this will throw ValueError
2831 2832
2832 2833 $ hg tip --template '{author|email|date}\n'
2833 2834 hg: parse error: date expects a date information
2834 2835 [255]
2835 2836
2836 2837 $ hg tip -T '{author|email|shortdate}\n'
2837 2838 hg: parse error: invalid date: 'test'
2838 2839 (template filter 'shortdate' is not compatible with keyword 'author')
2839 2840 [255]
2840 2841
2841 2842 $ hg tip -T '{get(extras, "branch")|shortdate}\n'
2842 2843 hg: parse error: invalid date: 'default'
2843 2844 (incompatible use of template filter 'shortdate')
2844 2845 [255]
2845 2846
2846 2847 Error in nested template:
2847 2848
2848 2849 $ hg log -T '{"date'
2849 2850 hg: parse error at 2: unterminated string
2850 2851 ({"date
2851 2852 ^ here)
2852 2853 [255]
2853 2854
2854 2855 $ hg log -T '{"foo{date|?}"}'
2855 2856 hg: parse error at 11: syntax error
2856 2857 ({"foo{date|?}"}
2857 2858 ^ here)
2858 2859 [255]
2859 2860
2860 2861 Thrown an error if a template function doesn't exist
2861 2862
2862 2863 $ hg tip --template '{foo()}\n'
2863 2864 hg: parse error: unknown function 'foo'
2864 2865 [255]
2865 2866
2866 2867 Pass generator object created by template function to filter
2867 2868
2868 2869 $ hg log -l 1 --template '{if(author, author)|user}\n'
2869 2870 test
2870 2871
2871 2872 Test index keyword:
2872 2873
2873 2874 $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n'
2874 2875 10 0:a 1:b 2:fifth 3:fourth 4:third
2875 2876 11 0:a
2876 2877
2877 2878 $ hg branches -T '{index} {branch}\n'
2878 2879 0 default
2879 2880 1 foo
2880 2881
2881 2882 Test diff function:
2882 2883
2883 2884 $ hg diff -c 8
2884 2885 diff -r 29114dbae42b -r 95c24699272e fourth
2885 2886 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2886 2887 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2887 2888 @@ -0,0 +1,1 @@
2888 2889 +second
2889 2890 diff -r 29114dbae42b -r 95c24699272e second
2890 2891 --- a/second Mon Jan 12 13:46:40 1970 +0000
2891 2892 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2892 2893 @@ -1,1 +0,0 @@
2893 2894 -second
2894 2895 diff -r 29114dbae42b -r 95c24699272e third
2895 2896 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2896 2897 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2897 2898 @@ -0,0 +1,1 @@
2898 2899 +third
2899 2900
2900 2901 $ hg log -r 8 -T "{diff()}"
2901 2902 diff -r 29114dbae42b -r 95c24699272e fourth
2902 2903 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2903 2904 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2904 2905 @@ -0,0 +1,1 @@
2905 2906 +second
2906 2907 diff -r 29114dbae42b -r 95c24699272e second
2907 2908 --- a/second Mon Jan 12 13:46:40 1970 +0000
2908 2909 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2909 2910 @@ -1,1 +0,0 @@
2910 2911 -second
2911 2912 diff -r 29114dbae42b -r 95c24699272e third
2912 2913 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2913 2914 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2914 2915 @@ -0,0 +1,1 @@
2915 2916 +third
2916 2917
2917 2918 $ hg log -r 8 -T "{diff('glob:f*')}"
2918 2919 diff -r 29114dbae42b -r 95c24699272e fourth
2919 2920 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2920 2921 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2921 2922 @@ -0,0 +1,1 @@
2922 2923 +second
2923 2924
2924 2925 $ hg log -r 8 -T "{diff('', 'glob:f*')}"
2925 2926 diff -r 29114dbae42b -r 95c24699272e second
2926 2927 --- a/second Mon Jan 12 13:46:40 1970 +0000
2927 2928 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2928 2929 @@ -1,1 +0,0 @@
2929 2930 -second
2930 2931 diff -r 29114dbae42b -r 95c24699272e third
2931 2932 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2932 2933 +++ b/third Wed Jan 01 10:01:00 2020 +0000
2933 2934 @@ -0,0 +1,1 @@
2934 2935 +third
2935 2936
2936 2937 $ hg log -r 8 -T "{diff('FOURTH'|lower)}"
2937 2938 diff -r 29114dbae42b -r 95c24699272e fourth
2938 2939 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2939 2940 +++ b/fourth Wed Jan 01 10:01:00 2020 +0000
2940 2941 @@ -0,0 +1,1 @@
2941 2942 +second
2942 2943
2943 2944 ui verbosity:
2944 2945
2945 2946 $ hg log -l1 -T '{verbosity}\n'
2946 2947
2947 2948 $ hg log -l1 -T '{verbosity}\n' --debug
2948 2949 debug
2949 2950 $ hg log -l1 -T '{verbosity}\n' --quiet
2950 2951 quiet
2951 2952 $ hg log -l1 -T '{verbosity}\n' --verbose
2952 2953 verbose
2953 2954
2954 2955 $ cd ..
2955 2956
2956 2957
2957 2958 latesttag:
2958 2959
2959 2960 $ hg init latesttag
2960 2961 $ cd latesttag
2961 2962
2962 2963 $ echo a > file
2963 2964 $ hg ci -Am a -d '0 0'
2964 2965 adding file
2965 2966
2966 2967 $ echo b >> file
2967 2968 $ hg ci -m b -d '1 0'
2968 2969
2969 2970 $ echo c >> head1
2970 2971 $ hg ci -Am h1c -d '2 0'
2971 2972 adding head1
2972 2973
2973 2974 $ hg update -q 1
2974 2975 $ echo d >> head2
2975 2976 $ hg ci -Am h2d -d '3 0'
2976 2977 adding head2
2977 2978 created new head
2978 2979
2979 2980 $ echo e >> head2
2980 2981 $ hg ci -m h2e -d '4 0'
2981 2982
2982 2983 $ hg merge -q
2983 2984 $ hg ci -m merge -d '5 -3600'
2984 2985
2985 2986 No tag set:
2986 2987
2987 2988 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2988 2989 @ 5: null+5
2989 2990 |\
2990 2991 | o 4: null+4
2991 2992 | |
2992 2993 | o 3: null+3
2993 2994 | |
2994 2995 o | 2: null+3
2995 2996 |/
2996 2997 o 1: null+2
2997 2998 |
2998 2999 o 0: null+1
2999 3000
3000 3001
3001 3002 One common tag: longest path wins for {latesttagdistance}:
3002 3003
3003 3004 $ hg tag -r 1 -m t1 -d '6 0' t1
3004 3005 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
3005 3006 @ 6: t1+4
3006 3007 |
3007 3008 o 5: t1+3
3008 3009 |\
3009 3010 | o 4: t1+2
3010 3011 | |
3011 3012 | o 3: t1+1
3012 3013 | |
3013 3014 o | 2: t1+1
3014 3015 |/
3015 3016 o 1: t1+0
3016 3017 |
3017 3018 o 0: null+1
3018 3019
3019 3020
3020 3021 One ancestor tag: closest wins:
3021 3022
3022 3023 $ hg tag -r 2 -m t2 -d '7 0' t2
3023 3024 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
3024 3025 @ 7: t2+3
3025 3026 |
3026 3027 o 6: t2+2
3027 3028 |
3028 3029 o 5: t2+1
3029 3030 |\
3030 3031 | o 4: t1+2
3031 3032 | |
3032 3033 | o 3: t1+1
3033 3034 | |
3034 3035 o | 2: t2+0
3035 3036 |/
3036 3037 o 1: t1+0
3037 3038 |
3038 3039 o 0: null+1
3039 3040
3040 3041
3041 3042 Two branch tags: more recent wins if same number of changes:
3042 3043
3043 3044 $ hg tag -r 3 -m t3 -d '8 0' t3
3044 3045 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
3045 3046 @ 8: t3+5
3046 3047 |
3047 3048 o 7: t3+4
3048 3049 |
3049 3050 o 6: t3+3
3050 3051 |
3051 3052 o 5: t3+2
3052 3053 |\
3053 3054 | o 4: t3+1
3054 3055 | |
3055 3056 | o 3: t3+0
3056 3057 | |
3057 3058 o | 2: t2+0
3058 3059 |/
3059 3060 o 1: t1+0
3060 3061 |
3061 3062 o 0: null+1
3062 3063
3063 3064
3064 3065 Two branch tags: fewest changes wins:
3065 3066
3066 3067 $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
3067 3068 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
3068 3069 @ 9: t4+5,6
3069 3070 |
3070 3071 o 8: t4+4,5
3071 3072 |
3072 3073 o 7: t4+3,4
3073 3074 |
3074 3075 o 6: t4+2,3
3075 3076 |
3076 3077 o 5: t4+1,2
3077 3078 |\
3078 3079 | o 4: t4+0,0
3079 3080 | |
3080 3081 | o 3: t3+0,0
3081 3082 | |
3082 3083 o | 2: t2+0,0
3083 3084 |/
3084 3085 o 1: t1+0,0
3085 3086 |
3086 3087 o 0: null+1,1
3087 3088
3088 3089
3089 3090 Merged tag overrides:
3090 3091
3091 3092 $ hg tag -r 5 -m t5 -d '9 0' t5
3092 3093 $ hg tag -r 3 -m at3 -d '10 0' at3
3093 3094 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
3094 3095 @ 11: t5+6
3095 3096 |
3096 3097 o 10: t5+5
3097 3098 |
3098 3099 o 9: t5+4
3099 3100 |
3100 3101 o 8: t5+3
3101 3102 |
3102 3103 o 7: t5+2
3103 3104 |
3104 3105 o 6: t5+1
3105 3106 |
3106 3107 o 5: t5+0
3107 3108 |\
3108 3109 | o 4: t4+0
3109 3110 | |
3110 3111 | o 3: at3:t3+0
3111 3112 | |
3112 3113 o | 2: t2+0
3113 3114 |/
3114 3115 o 1: t1+0
3115 3116 |
3116 3117 o 0: null+1
3117 3118
3118 3119
3119 3120 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
3120 3121 @ 11: t5+6,6
3121 3122 |
3122 3123 o 10: t5+5,5
3123 3124 |
3124 3125 o 9: t5+4,4
3125 3126 |
3126 3127 o 8: t5+3,3
3127 3128 |
3128 3129 o 7: t5+2,2
3129 3130 |
3130 3131 o 6: t5+1,1
3131 3132 |
3132 3133 o 5: t5+0,0
3133 3134 |\
3134 3135 | o 4: t4+0,0
3135 3136 | |
3136 3137 | o 3: at3+0,0 t3+0,0
3137 3138 | |
3138 3139 o | 2: t2+0,0
3139 3140 |/
3140 3141 o 1: t1+0,0
3141 3142 |
3142 3143 o 0: null+1,1
3143 3144
3144 3145
3145 3146 $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n"
3146 3147 @ 11: t3, C: 9, D: 8
3147 3148 |
3148 3149 o 10: t3, C: 8, D: 7
3149 3150 |
3150 3151 o 9: t3, C: 7, D: 6
3151 3152 |
3152 3153 o 8: t3, C: 6, D: 5
3153 3154 |
3154 3155 o 7: t3, C: 5, D: 4
3155 3156 |
3156 3157 o 6: t3, C: 4, D: 3
3157 3158 |
3158 3159 o 5: t3, C: 3, D: 2
3159 3160 |\
3160 3161 | o 4: t3, C: 1, D: 1
3161 3162 | |
3162 3163 | o 3: t3, C: 0, D: 0
3163 3164 | |
3164 3165 o | 2: t1, C: 1, D: 1
3165 3166 |/
3166 3167 o 1: t1, C: 0, D: 0
3167 3168 |
3168 3169 o 0: null, C: 1, D: 1
3169 3170
3170 3171
3171 3172 $ cd ..
3172 3173
3173 3174
3174 3175 Style path expansion: issue1948 - ui.style option doesn't work on OSX
3175 3176 if it is a relative path
3176 3177
3177 3178 $ mkdir -p home/styles
3178 3179
3179 3180 $ cat > home/styles/teststyle <<EOF
3180 3181 > changeset = 'test {rev}:{node|short}\n'
3181 3182 > EOF
3182 3183
3183 3184 $ HOME=`pwd`/home; export HOME
3184 3185
3185 3186 $ cat > latesttag/.hg/hgrc <<EOF
3186 3187 > [ui]
3187 3188 > style = ~/styles/teststyle
3188 3189 > EOF
3189 3190
3190 3191 $ hg -R latesttag tip
3191 3192 test 11:97e5943b523a
3192 3193
3193 3194 Test recursive showlist template (issue1989):
3194 3195
3195 3196 $ cat > style1989 <<EOF
3196 3197 > changeset = '{file_mods}{manifest}{extras}'
3197 3198 > file_mod = 'M|{author|person}\n'
3198 3199 > manifest = '{rev},{author}\n'
3199 3200 > extra = '{key}: {author}\n'
3200 3201 > EOF
3201 3202
3202 3203 $ hg -R latesttag log -r tip --style=style1989
3203 3204 M|test
3204 3205 11,test
3205 3206 branch: test
3206 3207
3207 3208 Test new-style inline templating:
3208 3209
3209 3210 $ hg log -R latesttag -r tip --template 'modified files: {file_mods % " {file}\n"}\n'
3210 3211 modified files: .hgtags
3211 3212
3212 3213
3213 3214 $ hg log -R latesttag -r tip -T '{rev % "a"}\n'
3214 3215 hg: parse error: keyword 'rev' is not iterable of mappings
3215 3216 [255]
3216 3217 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "a"}\n'
3217 3218 hg: parse error: None is not iterable of mappings
3218 3219 [255]
3219 3220 $ hg log -R latesttag -r tip -T '{extras % "{key}\n" % "{key}\n"}'
3220 3221 hg: parse error: list of strings is not mappable
3221 3222 [255]
3222 3223
3223 3224 Test new-style inline templating of non-list/dict type:
3224 3225
3225 3226 $ hg log -R latesttag -r tip -T '{manifest}\n'
3226 3227 11:2bc6e9006ce2
3227 3228 $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n'
3228 3229 string length: 15
3229 3230 $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n'
3230 3231 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc
3231 3232
3232 3233 $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}'
3233 3234 branch: default
3234 3235 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}'
3235 3236 hg: parse error: None is not iterable of mappings
3236 3237 [255]
3237 3238 $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}'
3238 3239 branch: default
3239 3240 $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}'
3240 3241 0:ce3cec86e6c2
3241 3242 $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}'
3242 3243 9:fbc7cd862e9c
3243 3244
3244 3245 Test manifest/get() can be join()-ed as before, though it's silly:
3245 3246
3246 3247 $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n'
3247 3248 11:2bc6e9006ce2
3248 3249 $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n'
3249 3250 default
3250 3251
3251 3252 Test min/max of integers
3252 3253
3253 3254 $ hg log -R latesttag -l1 -T '{min(revset("9:10"))}\n'
3254 3255 9
3255 3256 $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n'
3256 3257 10
3257 3258
3258 3259 Test min/max over map operation:
3259 3260
3260 3261 $ hg log -R latesttag -r3 -T '{min(tags % "{tag}")}\n'
3261 3262 at3
3262 3263 $ hg log -R latesttag -r3 -T '{max(tags % "{tag}")}\n'
3263 3264 t3
3264 3265
3265 3266 Test min/max of if() result
3266 3267
3267 3268 $ cd latesttag
3268 3269 $ hg log -l1 -T '{min(if(true, revset("9:10"), ""))}\n'
3269 3270 9
3270 3271 $ hg log -l1 -T '{max(if(false, "", revset("9:10")))}\n'
3271 3272 10
3272 3273 $ hg log -l1 -T '{min(ifcontains("a", "aa", revset("9:10"), ""))}\n'
3273 3274 9
3274 3275 $ hg log -l1 -T '{max(ifcontains("a", "bb", "", revset("9:10")))}\n'
3275 3276 10
3276 3277 $ hg log -l1 -T '{min(ifeq(0, 0, revset("9:10"), ""))}\n'
3277 3278 9
3278 3279 $ hg log -l1 -T '{max(ifeq(0, 1, "", revset("9:10")))}\n'
3279 3280 10
3280 3281 $ cd ..
3281 3282
3282 3283 Test laziness of if() then/else clause
3283 3284
3284 3285 $ hg debugtemplate '{count(0)}'
3285 3286 hg: parse error: not countable
3286 3287 (incompatible use of template filter 'count')
3287 3288 [255]
3288 3289 $ hg debugtemplate '{if(true, "", count(0))}'
3289 3290 $ hg debugtemplate '{if(false, count(0), "")}'
3290 3291 $ hg debugtemplate '{ifcontains("a", "aa", "", count(0))}'
3291 3292 $ hg debugtemplate '{ifcontains("a", "bb", count(0), "")}'
3292 3293 $ hg debugtemplate '{ifeq(0, 0, "", count(0))}'
3293 3294 $ hg debugtemplate '{ifeq(0, 1, count(0), "")}'
3294 3295
3295 3296 Test dot operator precedence:
3296 3297
3297 3298 $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n'
3298 3299 (template
3299 3300 (|
3300 3301 (.
3301 3302 (symbol 'manifest')
3302 3303 (symbol 'node'))
3303 3304 (symbol 'short'))
3304 3305 (string '\n'))
3305 3306 89f4071fec70
3306 3307
3307 3308 (the following examples are invalid, but seem natural in parsing POV)
3308 3309
3309 3310 $ hg debugtemplate -R latesttag -r0 -v '{foo|bar.baz}\n' 2> /dev/null
3310 3311 (template
3311 3312 (|
3312 3313 (symbol 'foo')
3313 3314 (.
3314 3315 (symbol 'bar')
3315 3316 (symbol 'baz')))
3316 3317 (string '\n'))
3317 3318 [255]
3318 3319 $ hg debugtemplate -R latesttag -r0 -v '{foo.bar()}\n' 2> /dev/null
3319 3320 (template
3320 3321 (.
3321 3322 (symbol 'foo')
3322 3323 (func
3323 3324 (symbol 'bar')
3324 3325 None))
3325 3326 (string '\n'))
3326 3327 [255]
3327 3328
3328 3329 Test evaluation of dot operator:
3329 3330
3330 3331 $ hg log -R latesttag -l1 -T '{min(revset("0:9")).node}\n'
3331 3332 ce3cec86e6c26bd9bdfc590a6b92abc9680f1796
3332 3333 $ hg log -R latesttag -r0 -T '{extras.branch}\n'
3333 3334 default
3334 3335
3335 3336 $ hg log -R latesttag -l1 -T '{author.invalid}\n'
3336 3337 hg: parse error: keyword 'author' has no member
3337 3338 [255]
3338 3339 $ hg log -R latesttag -l1 -T '{min("abc").invalid}\n'
3339 3340 hg: parse error: 'a' has no member
3340 3341 [255]
3341 3342
3342 3343 Test the sub function of templating for expansion:
3343 3344
3344 3345 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
3345 3346 xx
3346 3347
3347 3348 $ hg log -R latesttag -r 10 -T '{sub("[", "x", rev)}\n'
3348 3349 hg: parse error: sub got an invalid pattern: [
3349 3350 [255]
3350 3351 $ hg log -R latesttag -r 10 -T '{sub("[0-9]", r"\1", rev)}\n'
3351 3352 hg: parse error: sub got an invalid replacement: \1
3352 3353 [255]
3353 3354
3354 3355 Test the strip function with chars specified:
3355 3356
3356 3357 $ hg log -R latesttag --template '{desc}\n'
3357 3358 at3
3358 3359 t5
3359 3360 t4
3360 3361 t3
3361 3362 t2
3362 3363 t1
3363 3364 merge
3364 3365 h2e
3365 3366 h2d
3366 3367 h1c
3367 3368 b
3368 3369 a
3369 3370
3370 3371 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
3371 3372 at3
3372 3373 5
3373 3374 4
3374 3375 3
3375 3376 2
3376 3377 1
3377 3378 merg
3378 3379 h2
3379 3380 h2d
3380 3381 h1c
3381 3382 b
3382 3383 a
3383 3384
3384 3385 Test date format:
3385 3386
3386 3387 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
3387 3388 date: 70 01 01 10 +0000
3388 3389 date: 70 01 01 09 +0000
3389 3390 date: 70 01 01 04 +0000
3390 3391 date: 70 01 01 08 +0000
3391 3392 date: 70 01 01 07 +0000
3392 3393 date: 70 01 01 06 +0000
3393 3394 date: 70 01 01 05 +0100
3394 3395 date: 70 01 01 04 +0000
3395 3396 date: 70 01 01 03 +0000
3396 3397 date: 70 01 01 02 +0000
3397 3398 date: 70 01 01 01 +0000
3398 3399 date: 70 01 01 00 +0000
3399 3400
3400 3401 Test invalid date:
3401 3402
3402 3403 $ hg log -R latesttag -T '{date(rev)}\n'
3403 3404 hg: parse error: date expects a date information
3404 3405 [255]
3405 3406
3406 3407 Test integer literal:
3407 3408
3408 3409 $ hg debugtemplate -v '{(0)}\n'
3409 3410 (template
3410 3411 (group
3411 3412 (integer '0'))
3412 3413 (string '\n'))
3413 3414 0
3414 3415 $ hg debugtemplate -v '{(123)}\n'
3415 3416 (template
3416 3417 (group
3417 3418 (integer '123'))
3418 3419 (string '\n'))
3419 3420 123
3420 3421 $ hg debugtemplate -v '{(-4)}\n'
3421 3422 (template
3422 3423 (group
3423 3424 (negate
3424 3425 (integer '4')))
3425 3426 (string '\n'))
3426 3427 -4
3427 3428 $ hg debugtemplate '{(-)}\n'
3428 3429 hg: parse error at 3: not a prefix: )
3429 3430 ({(-)}\n
3430 3431 ^ here)
3431 3432 [255]
3432 3433 $ hg debugtemplate '{(-a)}\n'
3433 3434 hg: parse error: negation needs an integer argument
3434 3435 [255]
3435 3436
3436 3437 top-level integer literal is interpreted as symbol (i.e. variable name):
3437 3438
3438 3439 $ hg debugtemplate -D 1=one -v '{1}\n'
3439 3440 (template
3440 3441 (integer '1')
3441 3442 (string '\n'))
3442 3443 one
3443 3444 $ hg debugtemplate -D 1=one -v '{if("t", "{1}")}\n'
3444 3445 (template
3445 3446 (func
3446 3447 (symbol 'if')
3447 3448 (list
3448 3449 (string 't')
3449 3450 (template
3450 3451 (integer '1'))))
3451 3452 (string '\n'))
3452 3453 one
3453 3454 $ hg debugtemplate -D 1=one -v '{1|stringify}\n'
3454 3455 (template
3455 3456 (|
3456 3457 (integer '1')
3457 3458 (symbol 'stringify'))
3458 3459 (string '\n'))
3459 3460 one
3460 3461
3461 3462 unless explicit symbol is expected:
3462 3463
3463 3464 $ hg log -Ra -r0 -T '{desc|1}\n'
3464 3465 hg: parse error: expected a symbol, got 'integer'
3465 3466 [255]
3466 3467 $ hg log -Ra -r0 -T '{1()}\n'
3467 3468 hg: parse error: expected a symbol, got 'integer'
3468 3469 [255]
3469 3470
3470 3471 Test string literal:
3471 3472
3472 3473 $ hg debugtemplate -Ra -r0 -v '{"string with no template fragment"}\n'
3473 3474 (template
3474 3475 (string 'string with no template fragment')
3475 3476 (string '\n'))
3476 3477 string with no template fragment
3477 3478 $ hg debugtemplate -Ra -r0 -v '{"template: {rev}"}\n'
3478 3479 (template
3479 3480 (template
3480 3481 (string 'template: ')
3481 3482 (symbol 'rev'))
3482 3483 (string '\n'))
3483 3484 template: 0
3484 3485 $ hg debugtemplate -Ra -r0 -v '{r"rawstring: {rev}"}\n'
3485 3486 (template
3486 3487 (string 'rawstring: {rev}')
3487 3488 (string '\n'))
3488 3489 rawstring: {rev}
3489 3490 $ hg debugtemplate -Ra -r0 -v '{files % r"rawstring: {file}"}\n'
3490 3491 (template
3491 3492 (%
3492 3493 (symbol 'files')
3493 3494 (string 'rawstring: {file}'))
3494 3495 (string '\n'))
3495 3496 rawstring: {file}
3496 3497
3497 3498 Test string escaping:
3498 3499
3499 3500 $ hg log -R latesttag -r 0 --template '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3500 3501 >
3501 3502 <>\n<[>
3502 3503 <>\n<]>
3503 3504 <>\n<
3504 3505
3505 3506 $ hg log -R latesttag -r 0 \
3506 3507 > --config ui.logtemplate='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3507 3508 >
3508 3509 <>\n<[>
3509 3510 <>\n<]>
3510 3511 <>\n<
3511 3512
3512 3513 $ hg log -R latesttag -r 0 -T esc \
3513 3514 > --config templates.esc='>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3514 3515 >
3515 3516 <>\n<[>
3516 3517 <>\n<]>
3517 3518 <>\n<
3518 3519
3519 3520 $ cat <<'EOF' > esctmpl
3520 3521 > changeset = '>\n<>\\n<{if(rev, "[>\n<>\\n<]")}>\n<>\\n<\n'
3521 3522 > EOF
3522 3523 $ hg log -R latesttag -r 0 --style ./esctmpl
3523 3524 >
3524 3525 <>\n<[>
3525 3526 <>\n<]>
3526 3527 <>\n<
3527 3528
3528 3529 Test string escaping of quotes:
3529 3530
3530 3531 $ hg log -Ra -r0 -T '{"\""}\n'
3531 3532 "
3532 3533 $ hg log -Ra -r0 -T '{"\\\""}\n'
3533 3534 \"
3534 3535 $ hg log -Ra -r0 -T '{r"\""}\n'
3535 3536 \"
3536 3537 $ hg log -Ra -r0 -T '{r"\\\""}\n'
3537 3538 \\\"
3538 3539
3539 3540
3540 3541 $ hg log -Ra -r0 -T '{"\""}\n'
3541 3542 "
3542 3543 $ hg log -Ra -r0 -T '{"\\\""}\n'
3543 3544 \"
3544 3545 $ hg log -Ra -r0 -T '{r"\""}\n'
3545 3546 \"
3546 3547 $ hg log -Ra -r0 -T '{r"\\\""}\n'
3547 3548 \\\"
3548 3549
3549 3550 Test exception in quoted template. single backslash before quotation mark is
3550 3551 stripped before parsing:
3551 3552
3552 3553 $ cat <<'EOF' > escquotetmpl
3553 3554 > changeset = "\" \\" \\\" \\\\" {files % \"{file}\"}\n"
3554 3555 > EOF
3555 3556 $ cd latesttag
3556 3557 $ hg log -r 2 --style ../escquotetmpl
3557 3558 " \" \" \\" head1
3558 3559
3559 3560 $ hg log -r 2 -T esc --config templates.esc='"{\"valid\"}\n"'
3560 3561 valid
3561 3562 $ hg log -r 2 -T esc --config templates.esc="'"'{\'"'"'valid\'"'"'}\n'"'"
3562 3563 valid
3563 3564
3564 3565 Test compatibility with 2.9.2-3.4 of escaped quoted strings in nested
3565 3566 _evalifliteral() templates (issue4733):
3566 3567
3567 3568 $ hg log -r 2 -T '{if(rev, "\"{rev}")}\n'
3568 3569 "2
3569 3570 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\"{rev}\")}")}\n'
3570 3571 "2
3571 3572 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\"{rev}\\\")}\")}")}\n'
3572 3573 "2
3573 3574
3574 3575 $ hg log -r 2 -T '{if(rev, "\\\"")}\n'
3575 3576 \"
3576 3577 $ hg log -r 2 -T '{if(rev, "{if(rev, \"\\\\\\\"\")}")}\n'
3577 3578 \"
3578 3579 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, \\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
3579 3580 \"
3580 3581
3581 3582 $ hg log -r 2 -T '{if(rev, r"\\\"")}\n'
3582 3583 \\\"
3583 3584 $ hg log -r 2 -T '{if(rev, "{if(rev, r\"\\\\\\\"\")}")}\n'
3584 3585 \\\"
3585 3586 $ hg log -r 2 -T '{if(rev, "{if(rev, \"{if(rev, r\\\"\\\\\\\\\\\\\\\"\\\")}\")}")}\n'
3586 3587 \\\"
3587 3588
3588 3589 escaped single quotes and errors:
3589 3590
3590 3591 $ hg log -r 2 -T "{if(rev, '{if(rev, \'foo\')}')}"'\n'
3591 3592 foo
3592 3593 $ hg log -r 2 -T "{if(rev, '{if(rev, r\'foo\')}')}"'\n'
3593 3594 foo
3594 3595 $ hg log -r 2 -T '{if(rev, "{if(rev, \")}")}\n'
3595 3596 hg: parse error at 21: unterminated string
3596 3597 ({if(rev, "{if(rev, \")}")}\n
3597 3598 ^ here)
3598 3599 [255]
3599 3600 $ hg log -r 2 -T '{if(rev, \"\\"")}\n'
3600 3601 hg: parse error: trailing \ in string
3601 3602 [255]
3602 3603 $ hg log -r 2 -T '{if(rev, r\"\\"")}\n'
3603 3604 hg: parse error: trailing \ in string
3604 3605 [255]
3605 3606
3606 3607 $ cd ..
3607 3608
3608 3609 Test leading backslashes:
3609 3610
3610 3611 $ cd latesttag
3611 3612 $ hg log -r 2 -T '\{rev} {files % "\{file}"}\n'
3612 3613 {rev} {file}
3613 3614 $ hg log -r 2 -T '\\{rev} {files % "\\{file}"}\n'
3614 3615 \2 \head1
3615 3616 $ hg log -r 2 -T '\\\{rev} {files % "\\\{file}"}\n'
3616 3617 \{rev} \{file}
3617 3618 $ cd ..
3618 3619
3619 3620 Test leading backslashes in "if" expression (issue4714):
3620 3621
3621 3622 $ cd latesttag
3622 3623 $ hg log -r 2 -T '{if("1", "\{rev}")} {if("1", r"\{rev}")}\n'
3623 3624 {rev} \{rev}
3624 3625 $ hg log -r 2 -T '{if("1", "\\{rev}")} {if("1", r"\\{rev}")}\n'
3625 3626 \2 \\{rev}
3626 3627 $ hg log -r 2 -T '{if("1", "\\\{rev}")} {if("1", r"\\\{rev}")}\n'
3627 3628 \{rev} \\\{rev}
3628 3629 $ cd ..
3629 3630
3630 3631 "string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
3631 3632
3632 3633 $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
3633 3634 \x6e
3634 3635 $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
3635 3636 \x5c\x786e
3636 3637 $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
3637 3638 \x6e
3638 3639 $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
3639 3640 \x5c\x786e
3640 3641
3641 3642 $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
3642 3643 \x6e
3643 3644 $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
3644 3645 \x5c\x786e
3645 3646 $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
3646 3647 \x6e
3647 3648 $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
3648 3649 \x5c\x786e
3649 3650
3650 3651 $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
3651 3652 fourth
3652 3653 second
3653 3654 third
3654 3655 $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
3655 3656 fourth\nsecond\nthird
3656 3657
3657 3658 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
3658 3659 <p>
3659 3660 1st
3660 3661 </p>
3661 3662 <p>
3662 3663 2nd
3663 3664 </p>
3664 3665 $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
3665 3666 <p>
3666 3667 1st\n\n2nd
3667 3668 </p>
3668 3669 $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
3669 3670 1st
3670 3671
3671 3672 2nd
3672 3673
3673 3674 $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
3674 3675 o perso
3675 3676 $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
3676 3677 no person
3677 3678 $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
3678 3679 o perso
3679 3680 $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
3680 3681 no perso
3681 3682
3682 3683 $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
3683 3684 -o perso-
3684 3685 $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
3685 3686 no person
3686 3687 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
3687 3688 \x2do perso\x2d
3688 3689 $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
3689 3690 -o perso-
3690 3691 $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
3691 3692 \x2do perso\x6e
3692 3693
3693 3694 $ hg log -R a -r 8 --template '{files % "{file}\n"}'
3694 3695 fourth
3695 3696 second
3696 3697 third
3697 3698
3698 3699 Test string escaping in nested expression:
3699 3700
3700 3701 $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
3701 3702 fourth\x6esecond\x6ethird
3702 3703 $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
3703 3704 fourth\x6esecond\x6ethird
3704 3705
3705 3706 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
3706 3707 fourth\x6esecond\x6ethird
3707 3708 $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
3708 3709 fourth\x5c\x786esecond\x5c\x786ethird
3709 3710
3710 3711 $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
3711 3712 3:\x6eo user, \x6eo domai\x6e
3712 3713 4:\x5c\x786eew bra\x5c\x786ech
3713 3714
3714 3715 Test quotes in nested expression are evaluated just like a $(command)
3715 3716 substitution in POSIX shells:
3716 3717
3717 3718 $ hg log -R a -r 8 -T '{"{"{rev}:{node|short}"}"}\n'
3718 3719 8:95c24699272e
3719 3720 $ hg log -R a -r 8 -T '{"{"\{{rev}} \"{node|short}\""}"}\n'
3720 3721 {8} "95c24699272e"
3721 3722
3722 3723 Test recursive evaluation:
3723 3724
3724 3725 $ hg init r
3725 3726 $ cd r
3726 3727 $ echo a > a
3727 3728 $ hg ci -Am '{rev}'
3728 3729 adding a
3729 3730 $ hg log -r 0 --template '{if(rev, desc)}\n'
3730 3731 {rev}
3731 3732 $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n'
3732 3733 test 0
3733 3734
3734 3735 $ hg branch -q 'text.{rev}'
3735 3736 $ echo aa >> aa
3736 3737 $ hg ci -u '{node|short}' -m 'desc to be wrapped desc to be wrapped'
3737 3738
3738 3739 $ hg log -l1 --template '{fill(desc, "20", author, branch)}'
3739 3740 {node|short}desc to
3740 3741 text.{rev}be wrapped
3741 3742 text.{rev}desc to be
3742 3743 text.{rev}wrapped (no-eol)
3743 3744 $ hg log -l1 --template '{fill(desc, "20", "{node|short}:", "text.{rev}:")}'
3744 3745 bcc7ff960b8e:desc to
3745 3746 text.1:be wrapped
3746 3747 text.1:desc to be
3747 3748 text.1:wrapped (no-eol)
3748 3749 $ hg log -l1 -T '{fill(desc, date, "", "")}\n'
3749 3750 hg: parse error: fill expects an integer width
3750 3751 [255]
3751 3752
3752 3753 $ COLUMNS=25 hg log -l1 --template '{fill(desc, termwidth, "{node|short}:", "termwidth.{rev}:")}'
3753 3754 bcc7ff960b8e:desc to be
3754 3755 termwidth.1:wrapped desc
3755 3756 termwidth.1:to be wrapped (no-eol)
3756 3757
3757 3758 $ hg log -l 1 --template '{sub(r"[0-9]", "-", author)}'
3758 3759 {node|short} (no-eol)
3759 3760 $ hg log -l 1 --template '{sub(r"[0-9]", "-", "{node|short}")}'
3760 3761 bcc-ff---b-e (no-eol)
3761 3762
3762 3763 $ cat >> .hg/hgrc <<EOF
3763 3764 > [extensions]
3764 3765 > color=
3765 3766 > [color]
3766 3767 > mode=ansi
3767 3768 > text.{rev} = red
3768 3769 > text.1 = green
3769 3770 > EOF
3770 3771 $ hg log --color=always -l 1 --template '{label(branch, "text\n")}'
3771 3772 \x1b[0;31mtext\x1b[0m (esc)
3772 3773 $ hg log --color=always -l 1 --template '{label("text.{rev}", "text\n")}'
3773 3774 \x1b[0;32mtext\x1b[0m (esc)
3774 3775
3775 3776 color effect can be specified without quoting:
3776 3777
3777 3778 $ hg log --color=always -l 1 --template '{label(red, "text\n")}'
3778 3779 \x1b[0;31mtext\x1b[0m (esc)
3779 3780
3780 3781 color effects can be nested (issue5413)
3781 3782
3782 3783 $ hg debugtemplate --color=always \
3783 3784 > '{label(red, "red{label(magenta, "ma{label(cyan, "cyan")}{label(yellow, "yellow")}genta")}")}\n'
3784 3785 \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)
3785 3786
3786 3787 pad() should interact well with color codes (issue5416)
3787 3788
3788 3789 $ hg debugtemplate --color=always \
3789 3790 > '{pad(label(red, "red"), 5, label(cyan, "-"))}\n'
3790 3791 \x1b[0;31mred\x1b[0m\x1b[0;36m-\x1b[0m\x1b[0;36m-\x1b[0m (esc)
3791 3792
3792 3793 label should be no-op if color is disabled:
3793 3794
3794 3795 $ hg log --color=never -l 1 --template '{label(red, "text\n")}'
3795 3796 text
3796 3797 $ hg log --config extensions.color=! -l 1 --template '{label(red, "text\n")}'
3797 3798 text
3798 3799
3799 3800 Test branches inside if statement:
3800 3801
3801 3802 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
3802 3803 no
3803 3804
3804 3805 Test dict constructor:
3805 3806
3806 3807 $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n'
3807 3808 y=f7769ec2ab97 x=0
3808 3809 $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}'
3809 3810 x=0
3810 3811 y=f7769ec2ab97
3811 3812 $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n'
3812 3813 {"x": 0, "y": "f7769ec2ab97"}
3813 3814 $ hg log -r 0 -T '{dict()|json}\n'
3814 3815 {}
3815 3816
3816 3817 $ hg log -r 0 -T '{dict(rev, node=node|short)}\n'
3817 3818 rev=0 node=f7769ec2ab97
3818 3819 $ hg log -r 0 -T '{dict(rev, node|short)}\n'
3819 3820 rev=0 node=f7769ec2ab97
3820 3821
3821 3822 $ hg log -r 0 -T '{dict(rev, rev=rev)}\n'
3822 3823 hg: parse error: duplicated dict key 'rev' inferred
3823 3824 [255]
3824 3825 $ hg log -r 0 -T '{dict(node, node|short)}\n'
3825 3826 hg: parse error: duplicated dict key 'node' inferred
3826 3827 [255]
3827 3828 $ hg log -r 0 -T '{dict(1 + 2)}'
3828 3829 hg: parse error: dict key cannot be inferred
3829 3830 [255]
3830 3831
3831 3832 $ hg log -r 0 -T '{dict(x=rev, x=node)}'
3832 3833 hg: parse error: dict got multiple values for keyword argument 'x'
3833 3834 [255]
3834 3835
3835 3836 Test get function:
3836 3837
3837 3838 $ hg log -r 0 --template '{get(extras, "branch")}\n'
3838 3839 default
3839 3840 $ hg log -r 0 --template '{get(extras, "br{"anch"}")}\n'
3840 3841 default
3841 3842 $ hg log -r 0 --template '{get(files, "should_fail")}\n'
3842 3843 hg: parse error: get() expects a dict as first argument
3843 3844 [255]
3844 3845
3845 3846 Test json filter applied to hybrid object:
3846 3847
3847 3848 $ hg log -r0 -T '{files|json}\n'
3848 3849 ["a"]
3849 3850 $ hg log -r0 -T '{extras|json}\n'
3850 3851 {"branch": "default"}
3851 3852
3852 3853 Test json filter applied to map result:
3853 3854
3854 3855 $ hg log -r0 -T '{json(extras % "{key}")}\n'
3855 3856 ["branch"]
3856 3857
3857 3858 Test localdate(date, tz) function:
3858 3859
3859 3860 $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n'
3860 3861 1970-01-01 09:00 +0900
3861 3862 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n'
3862 3863 1970-01-01 00:00 +0000
3863 3864 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "blahUTC")|isodate}\n'
3864 3865 hg: parse error: localdate expects a timezone
3865 3866 [255]
3866 3867 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n'
3867 3868 1970-01-01 02:00 +0200
3868 3869 $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n'
3869 3870 1970-01-01 00:00 +0000
3870 3871 $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n'
3871 3872 1970-01-01 00:00 +0000
3872 3873 $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n'
3873 3874 hg: parse error: localdate expects a timezone
3874 3875 [255]
3875 3876 $ hg log -r0 -T '{localdate(date, date)|isodate}\n'
3876 3877 hg: parse error: localdate expects a timezone
3877 3878 [255]
3878 3879
3879 3880 Test shortest(node) function:
3880 3881
3881 3882 $ echo b > b
3882 3883 $ hg ci -qAm b
3883 3884 $ hg log --template '{shortest(node)}\n'
3884 3885 e777
3885 3886 bcc7
3886 3887 f776
3887 3888 $ hg log --template '{shortest(node, 10)}\n'
3888 3889 e777603221
3889 3890 bcc7ff960b
3890 3891 f7769ec2ab
3891 3892 $ hg log --template '{node|shortest}\n' -l1
3892 3893 e777
3893 3894
3894 3895 $ hg log -r 0 -T '{shortest(node, "1{"0"}")}\n'
3895 3896 f7769ec2ab
3896 3897 $ hg log -r 0 -T '{shortest(node, "not an int")}\n'
3897 3898 hg: parse error: shortest() expects an integer minlength
3898 3899 [255]
3899 3900
3900 3901 $ hg log -r 'wdir()' -T '{node|shortest}\n'
3901 3902 ffff
3902 3903
3903 3904 $ hg log --template '{shortest("f")}\n' -l1
3904 3905 f
3905 3906
3906 3907 $ hg log --template '{shortest("0123456789012345678901234567890123456789")}\n' -l1
3907 3908 0123456789012345678901234567890123456789
3908 3909
3909 3910 $ hg log --template '{shortest("01234567890123456789012345678901234567890123456789")}\n' -l1
3910 3911 01234567890123456789012345678901234567890123456789
3911 3912
3912 3913 $ hg log --template '{shortest("not a hex string")}\n' -l1
3913 3914 not a hex string
3914 3915
3915 3916 $ hg log --template '{shortest("not a hex string, but it'\''s 40 bytes long")}\n' -l1
3916 3917 not a hex string, but it's 40 bytes long
3917 3918
3918 3919 $ cd ..
3919 3920
3920 3921 Test shortest(node) with the repo having short hash collision:
3921 3922
3922 3923 $ hg init hashcollision
3923 3924 $ cd hashcollision
3924 3925 $ cat <<EOF >> .hg/hgrc
3925 3926 > [experimental]
3926 3927 > evolution.createmarkers=True
3927 3928 > EOF
3928 3929 $ echo 0 > a
3929 3930 $ hg ci -qAm 0
3930 3931 $ for i in 17 129 248 242 480 580 617 1057 2857 4025; do
3931 3932 > hg up -q 0
3932 3933 > echo $i > a
3933 3934 > hg ci -qm $i
3934 3935 > done
3935 3936 $ hg up -q null
3936 3937 $ hg log -r0: -T '{rev}:{node}\n'
3937 3938 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a
3938 3939 1:11424df6dc1dd4ea255eae2b58eaca7831973bbc
3939 3940 2:11407b3f1b9c3e76a79c1ec5373924df096f0499
3940 3941 3:11dd92fe0f39dfdaacdaa5f3997edc533875cfc4
3941 3942 4:10776689e627b465361ad5c296a20a487e153ca4
3942 3943 5:a00be79088084cb3aff086ab799f8790e01a976b
3943 3944 6:a0b0acd79b4498d0052993d35a6a748dd51d13e6
3944 3945 7:a0457b3450b8e1b778f1163b31a435802987fe5d
3945 3946 8:c56256a09cd28e5764f32e8e2810d0f01e2e357a
3946 3947 9:c5623987d205cd6d9d8389bfc40fff9dbb670b48
3947 3948 10:c562ddd9c94164376c20b86b0b4991636a3bf84f
3948 3949 $ hg debugobsolete a00be79088084cb3aff086ab799f8790e01a976b
3949 3950 obsoleted 1 changesets
3950 3951 $ hg debugobsolete c5623987d205cd6d9d8389bfc40fff9dbb670b48
3951 3952 obsoleted 1 changesets
3952 3953 $ hg debugobsolete c562ddd9c94164376c20b86b0b4991636a3bf84f
3953 3954 obsoleted 1 changesets
3954 3955
3955 3956 nodes starting with '11' (we don't have the revision number '11' though)
3956 3957
3957 3958 $ hg log -r 1:3 -T '{rev}:{shortest(node, 0)}\n'
3958 3959 1:1142
3959 3960 2:1140
3960 3961 3:11d
3961 3962
3962 3963 '5:a00' is hidden, but still we have two nodes starting with 'a0'
3963 3964
3964 3965 $ hg log -r 6:7 -T '{rev}:{shortest(node, 0)}\n'
3965 3966 6:a0b
3966 3967 7:a04
3967 3968
3968 3969 node '10' conflicts with the revision number '10' even if it is hidden
3969 3970 (we could exclude hidden revision numbers, but currently we don't)
3970 3971
3971 3972 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n'
3972 3973 4:107
3973 3974 $ hg log -r 4 -T '{rev}:{shortest(node, 0)}\n' --hidden
3974 3975 4:107
3975 3976
3976 3977 node 'c562' should be unique if the other 'c562' nodes are hidden
3977 3978 (but we don't try the slow path to filter out hidden nodes for now)
3978 3979
3979 3980 $ hg log -r 8 -T '{rev}:{node|shortest}\n'
3980 3981 8:c5625
3981 3982 $ hg log -r 8:10 -T '{rev}:{node|shortest}\n' --hidden
3982 3983 8:c5625
3983 3984 9:c5623
3984 3985 10:c562d
3985 3986
3986 3987 $ cd ..
3987 3988
3988 3989 Test pad function
3989 3990
3990 3991 $ cd r
3991 3992
3992 3993 $ hg log --template '{pad(rev, 20)} {author|user}\n'
3993 3994 2 test
3994 3995 1 {node|short}
3995 3996 0 test
3996 3997
3997 3998 $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n'
3998 3999 2 test
3999 4000 1 {node|short}
4000 4001 0 test
4001 4002
4002 4003 $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n'
4003 4004 2------------------- test
4004 4005 1------------------- {node|short}
4005 4006 0------------------- test
4006 4007
4007 4008 Test template string in pad function
4008 4009
4009 4010 $ hg log -r 0 -T '{pad("\{{rev}}", 10)} {author|user}\n'
4010 4011 {0} test
4011 4012
4012 4013 $ hg log -r 0 -T '{pad(r"\{rev}", 10)} {author|user}\n'
4013 4014 \{rev} test
4014 4015
4015 4016 Test width argument passed to pad function
4016 4017
4017 4018 $ hg log -r 0 -T '{pad(rev, "1{"0"}")} {author|user}\n'
4018 4019 0 test
4019 4020 $ hg log -r 0 -T '{pad(rev, "not an int")}\n'
4020 4021 hg: parse error: pad() expects an integer width
4021 4022 [255]
4022 4023
4023 4024 Test invalid fillchar passed to pad function
4024 4025
4025 4026 $ hg log -r 0 -T '{pad(rev, 10, "")}\n'
4026 4027 hg: parse error: pad() expects a single fill character
4027 4028 [255]
4028 4029 $ hg log -r 0 -T '{pad(rev, 10, "--")}\n'
4029 4030 hg: parse error: pad() expects a single fill character
4030 4031 [255]
4031 4032
4032 4033 Test boolean argument passed to pad function
4033 4034
4034 4035 no crash
4035 4036
4036 4037 $ hg log -r 0 -T '{pad(rev, 10, "-", "f{"oo"}")}\n'
4037 4038 ---------0
4038 4039
4039 4040 string/literal
4040 4041
4041 4042 $ hg log -r 0 -T '{pad(rev, 10, "-", "false")}\n'
4042 4043 ---------0
4043 4044 $ hg log -r 0 -T '{pad(rev, 10, "-", false)}\n'
4044 4045 0---------
4045 4046 $ hg log -r 0 -T '{pad(rev, 10, "-", "")}\n'
4046 4047 0---------
4047 4048
4048 4049 unknown keyword is evaluated to ''
4049 4050
4050 4051 $ hg log -r 0 -T '{pad(rev, 10, "-", unknownkeyword)}\n'
4051 4052 0---------
4052 4053
4053 4054 Test separate function
4054 4055
4055 4056 $ hg log -r 0 -T '{separate("-", "", "a", "b", "", "", "c", "")}\n'
4056 4057 a-b-c
4057 4058 $ hg log -r 0 -T '{separate(" ", "{rev}:{node|short}", author|user, branch)}\n'
4058 4059 0:f7769ec2ab97 test default
4059 4060 $ hg log -r 0 --color=always -T '{separate(" ", "a", label(red, "b"), "c", label(red, ""), "d")}\n'
4060 4061 a \x1b[0;31mb\x1b[0m c d (esc)
4061 4062
4062 4063 Test boolean expression/literal passed to if function
4063 4064
4064 4065 $ hg log -r 0 -T '{if(rev, "rev 0 is True")}\n'
4065 4066 rev 0 is True
4066 4067 $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n'
4067 4068 literal 0 is True as well
4068 4069 $ hg log -r 0 -T '{if("", "", "empty string is False")}\n'
4069 4070 empty string is False
4070 4071 $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n'
4071 4072 empty list is False
4072 4073 $ hg log -r 0 -T '{if(true, "true is True")}\n'
4073 4074 true is True
4074 4075 $ hg log -r 0 -T '{if(false, "", "false is False")}\n'
4075 4076 false is False
4076 4077 $ hg log -r 0 -T '{if("false", "non-empty string is True")}\n'
4077 4078 non-empty string is True
4078 4079
4079 4080 Test ifcontains function
4080 4081
4081 4082 $ hg log --template '{rev} {ifcontains(rev, "2 two 0", "is in the string", "is not")}\n'
4082 4083 2 is in the string
4083 4084 1 is not
4084 4085 0 is in the string
4085 4086
4086 4087 $ hg log -T '{rev} {ifcontains(rev, "2 two{" 0"}", "is in the string", "is not")}\n'
4087 4088 2 is in the string
4088 4089 1 is not
4089 4090 0 is in the string
4090 4091
4091 4092 $ hg log --template '{rev} {ifcontains("a", file_adds, "added a", "did not add a")}\n'
4092 4093 2 did not add a
4093 4094 1 did not add a
4094 4095 0 added a
4095 4096
4096 4097 $ hg log --debug -T '{rev}{ifcontains(1, parents, " is parent of 1")}\n'
4097 4098 2 is parent of 1
4098 4099 1
4099 4100 0
4100 4101
4101 4102 Test revset function
4102 4103
4103 4104 $ hg log --template '{rev} {ifcontains(rev, revset("."), "current rev", "not current rev")}\n'
4104 4105 2 current rev
4105 4106 1 not current rev
4106 4107 0 not current rev
4107 4108
4108 4109 $ hg log --template '{rev} {ifcontains(rev, revset(". + .^"), "match rev", "not match rev")}\n'
4109 4110 2 match rev
4110 4111 1 match rev
4111 4112 0 not match rev
4112 4113
4113 4114 $ hg log -T '{ifcontains(desc, revset(":"), "", "type not match")}\n' -l1
4114 4115 type not match
4115 4116
4116 4117 $ hg log --template '{rev} Parents: {revset("parents(%s)", rev)}\n'
4117 4118 2 Parents: 1
4118 4119 1 Parents: 0
4119 4120 0 Parents:
4120 4121
4121 4122 $ cat >> .hg/hgrc <<EOF
4122 4123 > [revsetalias]
4123 4124 > myparents(\$1) = parents(\$1)
4124 4125 > EOF
4125 4126 $ hg log --template '{rev} Parents: {revset("myparents(%s)", rev)}\n'
4126 4127 2 Parents: 1
4127 4128 1 Parents: 0
4128 4129 0 Parents:
4129 4130
4130 4131 $ hg log --template 'Rev: {rev}\n{revset("::%s", rev) % "Ancestor: {revision}\n"}\n'
4131 4132 Rev: 2
4132 4133 Ancestor: 0
4133 4134 Ancestor: 1
4134 4135 Ancestor: 2
4135 4136
4136 4137 Rev: 1
4137 4138 Ancestor: 0
4138 4139 Ancestor: 1
4139 4140
4140 4141 Rev: 0
4141 4142 Ancestor: 0
4142 4143
4143 4144 $ hg log --template '{revset("TIP"|lower)}\n' -l1
4144 4145 2
4145 4146
4146 4147 $ hg log -T '{revset("%s", "t{"ip"}")}\n' -l1
4147 4148 2
4148 4149
4149 4150 a list template is evaluated for each item of revset/parents
4150 4151
4151 4152 $ hg log -T '{rev} p: {revset("p1(%s)", rev) % "{rev}:{node|short}"}\n'
4152 4153 2 p: 1:bcc7ff960b8e
4153 4154 1 p: 0:f7769ec2ab97
4154 4155 0 p:
4155 4156
4156 4157 $ hg log --debug -T '{rev} p:{parents % " {rev}:{node|short}"}\n'
4157 4158 2 p: 1:bcc7ff960b8e -1:000000000000
4158 4159 1 p: 0:f7769ec2ab97 -1:000000000000
4159 4160 0 p: -1:000000000000 -1:000000000000
4160 4161
4161 4162 therefore, 'revcache' should be recreated for each rev
4162 4163
4163 4164 $ hg log -T '{rev} {file_adds}\np {revset("p1(%s)", rev) % "{file_adds}"}\n'
4164 4165 2 aa b
4165 4166 p
4166 4167 1
4167 4168 p a
4168 4169 0 a
4169 4170 p
4170 4171
4171 4172 $ hg log --debug -T '{rev} {file_adds}\np {parents % "{file_adds}"}\n'
4172 4173 2 aa b
4173 4174 p
4174 4175 1
4175 4176 p a
4176 4177 0 a
4177 4178 p
4178 4179
4179 4180 a revset item must be evaluated as an integer revision, not an offset from tip
4180 4181
4181 4182 $ hg log -l 1 -T '{revset("null") % "{rev}:{node|short}"}\n'
4182 4183 -1:000000000000
4183 4184 $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n'
4184 4185 -1:000000000000
4185 4186
4186 4187 join() should pick '{rev}' from revset items:
4187 4188
4188 4189 $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6
4189 4190 4, 5
4190 4191
4191 4192 on the other hand, parents are formatted as '{rev}:{node|formatnode}' by
4192 4193 default. join() should agree with the default formatting:
4193 4194
4194 4195 $ hg log -R ../a -T '{join(parents, ", ")}\n' -r6
4195 4196 5:13207e5a10d9, 4:bbe44766e73d
4196 4197
4197 4198 $ hg log -R ../a -T '{join(parents, ",\n")}\n' -r6 --debug
4198 4199 5:13207e5a10d9fd28ec424934298e176197f2c67f,
4199 4200 4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
4200 4201
4201 4202 Invalid arguments passed to revset()
4202 4203
4203 4204 $ hg log -T '{revset("%whatever", 0)}\n'
4204 4205 hg: parse error: unexpected revspec format character w
4205 4206 [255]
4206 4207 $ hg log -T '{revset("%lwhatever", files)}\n'
4207 4208 hg: parse error: unexpected revspec format character w
4208 4209 [255]
4209 4210 $ hg log -T '{revset("%s %s", 0)}\n'
4210 4211 hg: parse error: missing argument for revspec
4211 4212 [255]
4212 4213 $ hg log -T '{revset("", 0)}\n'
4213 4214 hg: parse error: too many revspec arguments specified
4214 4215 [255]
4215 4216 $ hg log -T '{revset("%s", 0, 1)}\n'
4216 4217 hg: parse error: too many revspec arguments specified
4217 4218 [255]
4218 4219 $ hg log -T '{revset("%", 0)}\n'
4219 4220 hg: parse error: incomplete revspec format character
4220 4221 [255]
4221 4222 $ hg log -T '{revset("%l", 0)}\n'
4222 4223 hg: parse error: incomplete revspec format character
4223 4224 [255]
4224 4225 $ hg log -T '{revset("%d", 'foo')}\n'
4225 4226 hg: parse error: invalid argument for revspec
4226 4227 [255]
4227 4228 $ hg log -T '{revset("%ld", files)}\n'
4228 4229 hg: parse error: invalid argument for revspec
4229 4230 [255]
4230 4231 $ hg log -T '{revset("%ls", 0)}\n'
4231 4232 hg: parse error: invalid argument for revspec
4232 4233 [255]
4233 4234 $ hg log -T '{revset("%b", 'foo')}\n'
4234 4235 hg: parse error: invalid argument for revspec
4235 4236 [255]
4236 4237 $ hg log -T '{revset("%lb", files)}\n'
4237 4238 hg: parse error: invalid argument for revspec
4238 4239 [255]
4239 4240 $ hg log -T '{revset("%r", 0)}\n'
4240 4241 hg: parse error: invalid argument for revspec
4241 4242 [255]
4242 4243
4243 4244 Test 'originalnode'
4244 4245
4245 4246 $ hg log -r 1 -T '{revset("null") % "{node|short} {originalnode|short}"}\n'
4246 4247 000000000000 bcc7ff960b8e
4247 4248 $ hg log -r 0 -T '{manifest % "{node} {originalnode}"}\n'
4248 4249 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 f7769ec2ab975ad19684098ad1ffd9b81ecc71a1
4249 4250
4250 4251 Test files function
4251 4252
4252 4253 $ hg log -T "{rev}\n{join(files('*'), '\n')}\n"
4253 4254 2
4254 4255 a
4255 4256 aa
4256 4257 b
4257 4258 1
4258 4259 a
4259 4260 0
4260 4261 a
4261 4262
4262 4263 $ hg log -T "{rev}\n{join(files('aa'), '\n')}\n"
4263 4264 2
4264 4265 aa
4265 4266 1
4266 4267
4267 4268 0
4268 4269
4269 4270
4270 4271 Test relpath function
4271 4272
4272 4273 $ hg log -r0 -T '{files % "{file|relpath}\n"}'
4273 4274 a
4274 4275 $ cd ..
4275 4276 $ hg log -R r -r0 -T '{files % "{file|relpath}\n"}'
4276 4277 r/a
4277 4278 $ cd r
4278 4279
4279 4280 Test active bookmark templating
4280 4281
4281 4282 $ hg book foo
4282 4283 $ hg book bar
4283 4284 $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, active, \"*\")} '}\n"
4284 4285 2 bar* foo
4285 4286 1
4286 4287 0
4287 4288 $ hg log --template "{rev} {activebookmark}\n"
4288 4289 2 bar
4289 4290 1
4290 4291 0
4291 4292 $ hg bookmarks --inactive bar
4292 4293 $ hg log --template "{rev} {activebookmark}\n"
4293 4294 2
4294 4295 1
4295 4296 0
4296 4297 $ hg book -r1 baz
4297 4298 $ hg log --template "{rev} {join(bookmarks, ' ')}\n"
4298 4299 2 bar foo
4299 4300 1 baz
4300 4301 0
4301 4302 $ hg log --template "{rev} {ifcontains('foo', bookmarks, 't', 'f')}\n"
4302 4303 2 t
4303 4304 1 f
4304 4305 0 f
4305 4306
4306 4307 Test namespaces dict
4307 4308
4308 4309 $ hg --config extensions.revnamesext=$TESTDIR/revnamesext.py log -T '{rev}\n{namespaces % " {namespace} color={colorname} builtin={builtin}\n {join(names, ",")}\n"}\n'
4309 4310 2
4310 4311 bookmarks color=bookmark builtin=True
4311 4312 bar,foo
4312 4313 tags color=tag builtin=True
4313 4314 tip
4314 4315 branches color=branch builtin=True
4315 4316 text.{rev}
4316 4317 revnames color=revname builtin=False
4317 4318 r2
4318 4319
4319 4320 1
4320 4321 bookmarks color=bookmark builtin=True
4321 4322 baz
4322 4323 tags color=tag builtin=True
4323 4324
4324 4325 branches color=branch builtin=True
4325 4326 text.{rev}
4326 4327 revnames color=revname builtin=False
4327 4328 r1
4328 4329
4329 4330 0
4330 4331 bookmarks color=bookmark builtin=True
4331 4332
4332 4333 tags color=tag builtin=True
4333 4334
4334 4335 branches color=branch builtin=True
4335 4336 default
4336 4337 revnames color=revname builtin=False
4337 4338 r0
4338 4339
4339 4340 $ hg log -r2 -T '{namespaces % "{namespace}: {names}\n"}'
4340 4341 bookmarks: bar foo
4341 4342 tags: tip
4342 4343 branches: text.{rev}
4343 4344 $ hg log -r2 -T '{namespaces % "{namespace}:\n{names % " {name}\n"}"}'
4344 4345 bookmarks:
4345 4346 bar
4346 4347 foo
4347 4348 tags:
4348 4349 tip
4349 4350 branches:
4350 4351 text.{rev}
4351 4352 $ hg log -r2 -T '{get(namespaces, "bookmarks") % "{name}\n"}'
4352 4353 bar
4353 4354 foo
4354 4355 $ hg log -r2 -T '{namespaces.bookmarks % "{bookmark}\n"}'
4355 4356 bar
4356 4357 foo
4357 4358
4358 4359 Test stringify on sub expressions
4359 4360
4360 4361 $ cd ..
4361 4362 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
4362 4363 fourth, second, third
4363 4364 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
4364 4365 abc
4365 4366
4366 4367 Test splitlines
4367 4368
4368 4369 $ hg log -Gv -R a --template "{splitlines(desc) % 'foo {line}\n'}"
4369 4370 @ foo Modify, add, remove, rename
4370 4371 |
4371 4372 o foo future
4372 4373 |
4373 4374 o foo third
4374 4375 |
4375 4376 o foo second
4376 4377
4377 4378 o foo merge
4378 4379 |\
4379 4380 | o foo new head
4380 4381 | |
4381 4382 o | foo new branch
4382 4383 |/
4383 4384 o foo no user, no domain
4384 4385 |
4385 4386 o foo no person
4386 4387 |
4387 4388 o foo other 1
4388 4389 | foo other 2
4389 4390 | foo
4390 4391 | foo other 3
4391 4392 o foo line 1
4392 4393 foo line 2
4393 4394
4394 4395 $ hg log -R a -r0 -T '{desc|splitlines}\n'
4395 4396 line 1 line 2
4396 4397 $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n'
4397 4398 line 1|line 2
4398 4399
4399 4400 Test startswith
4400 4401 $ hg log -Gv -R a --template "{startswith(desc)}"
4401 4402 hg: parse error: startswith expects two arguments
4402 4403 [255]
4403 4404
4404 4405 $ hg log -Gv -R a --template "{startswith('line', desc)}"
4405 4406 @
4406 4407 |
4407 4408 o
4408 4409 |
4409 4410 o
4410 4411 |
4411 4412 o
4412 4413
4413 4414 o
4414 4415 |\
4415 4416 | o
4416 4417 | |
4417 4418 o |
4418 4419 |/
4419 4420 o
4420 4421 |
4421 4422 o
4422 4423 |
4423 4424 o
4424 4425 |
4425 4426 o line 1
4426 4427 line 2
4427 4428
4428 4429 Test bad template with better error message
4429 4430
4430 4431 $ hg log -Gv -R a --template '{desc|user()}'
4431 4432 hg: parse error: expected a symbol, got 'func'
4432 4433 [255]
4433 4434
4434 4435 Test word function (including index out of bounds graceful failure)
4435 4436
4436 4437 $ hg log -Gv -R a --template "{word('1', desc)}"
4437 4438 @ add,
4438 4439 |
4439 4440 o
4440 4441 |
4441 4442 o
4442 4443 |
4443 4444 o
4444 4445
4445 4446 o
4446 4447 |\
4447 4448 | o head
4448 4449 | |
4449 4450 o | branch
4450 4451 |/
4451 4452 o user,
4452 4453 |
4453 4454 o person
4454 4455 |
4455 4456 o 1
4456 4457 |
4457 4458 o 1
4458 4459
4459 4460
4460 4461 Test word third parameter used as splitter
4461 4462
4462 4463 $ hg log -Gv -R a --template "{word('0', desc, 'o')}"
4463 4464 @ M
4464 4465 |
4465 4466 o future
4466 4467 |
4467 4468 o third
4468 4469 |
4469 4470 o sec
4470 4471
4471 4472 o merge
4472 4473 |\
4473 4474 | o new head
4474 4475 | |
4475 4476 o | new branch
4476 4477 |/
4477 4478 o n
4478 4479 |
4479 4480 o n
4480 4481 |
4481 4482 o
4482 4483 |
4483 4484 o line 1
4484 4485 line 2
4485 4486
4486 4487 Test word error messages for not enough and too many arguments
4487 4488
4488 4489 $ hg log -Gv -R a --template "{word('0')}"
4489 4490 hg: parse error: word expects two or three arguments, got 1
4490 4491 [255]
4491 4492
4492 4493 $ hg log -Gv -R a --template "{word('0', desc, 'o', 'h', 'b', 'o', 'y')}"
4493 4494 hg: parse error: word expects two or three arguments, got 7
4494 4495 [255]
4495 4496
4496 4497 Test word for integer literal
4497 4498
4498 4499 $ hg log -R a --template "{word(2, desc)}\n" -r0
4499 4500 line
4500 4501
4501 4502 Test word for invalid numbers
4502 4503
4503 4504 $ hg log -Gv -R a --template "{word('a', desc)}"
4504 4505 hg: parse error: word expects an integer index
4505 4506 [255]
4506 4507
4507 4508 Test word for out of range
4508 4509
4509 4510 $ hg log -R a --template "{word(10000, desc)}"
4510 4511 $ hg log -R a --template "{word(-10000, desc)}"
4511 4512
4512 4513 Test indent and not adding to empty lines
4513 4514
4514 4515 $ hg log -T "-----\n{indent(desc, '>> ', ' > ')}\n" -r 0:1 -R a
4515 4516 -----
4516 4517 > line 1
4517 4518 >> line 2
4518 4519 -----
4519 4520 > other 1
4520 4521 >> other 2
4521 4522
4522 4523 >> other 3
4523 4524
4524 4525 Test with non-strings like dates
4525 4526
4526 4527 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a
4527 4528 1200000.00
4528 4529 1300000.00
4529 4530
4530 4531 Test broken string escapes:
4531 4532
4532 4533 $ hg log -T "bogus\\" -R a
4533 4534 hg: parse error: trailing \ in string
4534 4535 [255]
4535 4536 $ hg log -T "\\xy" -R a
4536 4537 hg: parse error: invalid \x escape* (glob)
4537 4538 [255]
4538 4539
4539 4540 json filter should escape HTML tags so that the output can be embedded in hgweb:
4540 4541
4541 4542 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
4542 4543 "\u003cfoo@example.org\u003e"
4543 4544
4544 4545 Templater supports aliases of symbol and func() styles:
4545 4546
4546 4547 $ hg clone -q a aliases
4547 4548 $ cd aliases
4548 4549 $ cat <<EOF >> .hg/hgrc
4549 4550 > [templatealias]
4550 4551 > r = rev
4551 4552 > rn = "{r}:{node|short}"
4552 4553 > status(c, files) = files % "{c} {file}\n"
4553 4554 > utcdate(d) = localdate(d, "UTC")
4554 4555 > EOF
4555 4556
4556 4557 $ hg debugtemplate -vr0 '{rn} {utcdate(date)|isodate}\n'
4557 4558 (template
4558 4559 (symbol 'rn')
4559 4560 (string ' ')
4560 4561 (|
4561 4562 (func
4562 4563 (symbol 'utcdate')
4563 4564 (symbol 'date'))
4564 4565 (symbol 'isodate'))
4565 4566 (string '\n'))
4566 4567 * expanded:
4567 4568 (template
4568 4569 (template
4569 4570 (symbol 'rev')
4570 4571 (string ':')
4571 4572 (|
4572 4573 (symbol 'node')
4573 4574 (symbol 'short')))
4574 4575 (string ' ')
4575 4576 (|
4576 4577 (func
4577 4578 (symbol 'localdate')
4578 4579 (list
4579 4580 (symbol 'date')
4580 4581 (string 'UTC')))
4581 4582 (symbol 'isodate'))
4582 4583 (string '\n'))
4583 4584 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4584 4585
4585 4586 $ hg debugtemplate -vr0 '{status("A", file_adds)}'
4586 4587 (template
4587 4588 (func
4588 4589 (symbol 'status')
4589 4590 (list
4590 4591 (string 'A')
4591 4592 (symbol 'file_adds'))))
4592 4593 * expanded:
4593 4594 (template
4594 4595 (%
4595 4596 (symbol 'file_adds')
4596 4597 (template
4597 4598 (string 'A')
4598 4599 (string ' ')
4599 4600 (symbol 'file')
4600 4601 (string '\n'))))
4601 4602 A a
4602 4603
4603 4604 A unary function alias can be called as a filter:
4604 4605
4605 4606 $ hg debugtemplate -vr0 '{date|utcdate|isodate}\n'
4606 4607 (template
4607 4608 (|
4608 4609 (|
4609 4610 (symbol 'date')
4610 4611 (symbol 'utcdate'))
4611 4612 (symbol 'isodate'))
4612 4613 (string '\n'))
4613 4614 * expanded:
4614 4615 (template
4615 4616 (|
4616 4617 (func
4617 4618 (symbol 'localdate')
4618 4619 (list
4619 4620 (symbol 'date')
4620 4621 (string 'UTC')))
4621 4622 (symbol 'isodate'))
4622 4623 (string '\n'))
4623 4624 1970-01-12 13:46 +0000
4624 4625
4625 4626 Aliases should be applied only to command arguments and templates in hgrc.
4626 4627 Otherwise, our stock styles and web templates could be corrupted:
4627 4628
4628 4629 $ hg log -r0 -T '{rn} {utcdate(date)|isodate}\n'
4629 4630 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4630 4631
4631 4632 $ hg log -r0 --config ui.logtemplate='"{rn} {utcdate(date)|isodate}\n"'
4632 4633 0:1e4e1b8f71e0 1970-01-12 13:46 +0000
4633 4634
4634 4635 $ cat <<EOF > tmpl
4635 4636 > changeset = 'nothing expanded:{rn}\n'
4636 4637 > EOF
4637 4638 $ hg log -r0 --style ./tmpl
4638 4639 nothing expanded:
4639 4640
4640 4641 Aliases in formatter:
4641 4642
4642 4643 $ hg branches -T '{pad(branch, 7)} {rn}\n'
4643 4644 default 6:d41e714fe50d
4644 4645 foo 4:bbe44766e73d
4645 4646
4646 4647 Aliases should honor HGPLAIN:
4647 4648
4648 4649 $ HGPLAIN= hg log -r0 -T 'nothing expanded:{rn}\n'
4649 4650 nothing expanded:
4650 4651 $ HGPLAINEXCEPT=templatealias hg log -r0 -T '{rn}\n'
4651 4652 0:1e4e1b8f71e0
4652 4653
4653 4654 Unparsable alias:
4654 4655
4655 4656 $ hg debugtemplate --config templatealias.bad='x(' -v '{bad}'
4656 4657 (template
4657 4658 (symbol 'bad'))
4658 4659 abort: bad definition of template alias "bad": at 2: not a prefix: end
4659 4660 [255]
4660 4661 $ hg log --config templatealias.bad='x(' -T '{bad}'
4661 4662 abort: bad definition of template alias "bad": at 2: not a prefix: end
4662 4663 [255]
4663 4664
4664 4665 $ cd ..
4665 4666
4666 4667 Set up repository for non-ascii encoding tests:
4667 4668
4668 4669 $ hg init nonascii
4669 4670 $ cd nonascii
4670 4671 $ $PYTHON <<EOF
4671 4672 > open('latin1', 'wb').write(b'\xe9')
4672 4673 > open('utf-8', 'wb').write(b'\xc3\xa9')
4673 4674 > EOF
4674 4675 $ HGENCODING=utf-8 hg branch -q `cat utf-8`
4675 4676 $ HGENCODING=utf-8 hg ci -qAm "non-ascii branch: `cat utf-8`" utf-8
4676 4677
4677 4678 json filter should try round-trip conversion to utf-8:
4678 4679
4679 4680 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
4680 4681 "\u00e9"
4681 4682 $ HGENCODING=ascii hg log -T "{desc|json}\n" -r0
4682 4683 "non-ascii branch: \u00e9"
4683 4684
4684 4685 json filter takes input as utf-8b:
4685 4686
4686 4687 $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1
4687 4688 "\u00e9"
4688 4689 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
4689 4690 "\udce9"
4690 4691
4691 4692 utf8 filter:
4692 4693
4693 4694 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
4694 4695 round-trip: c3a9
4695 4696 $ HGENCODING=latin1 hg log -T "decoded: {'`cat latin1`'|utf8|hex}\n" -l1
4696 4697 decoded: c3a9
4697 4698 $ HGENCODING=ascii hg log -T "replaced: {'`cat latin1`'|utf8|hex}\n" -l1
4698 4699 abort: decoding near * (glob)
4699 4700 [255]
4700 4701 $ hg log -T "coerced to string: {rev|utf8}\n" -r0
4701 4702 coerced to string: 0
4702 4703
4703 4704 pad width:
4704 4705
4705 4706 $ HGENCODING=utf-8 hg debugtemplate "{pad('`cat utf-8`', 2, '-')}\n"
4706 4707 \xc3\xa9- (esc)
4707 4708
4708 4709 $ cd ..
4709 4710
4710 4711 Test that template function in extension is registered as expected
4711 4712
4712 4713 $ cd a
4713 4714
4714 4715 $ cat <<EOF > $TESTTMP/customfunc.py
4715 4716 > from mercurial import registrar
4716 4717 >
4717 4718 > templatefunc = registrar.templatefunc()
4718 4719 >
4719 4720 > @templatefunc(b'custom()')
4720 4721 > def custom(context, mapping, args):
4721 4722 > return b'custom'
4722 4723 > EOF
4723 4724 $ cat <<EOF > .hg/hgrc
4724 4725 > [extensions]
4725 4726 > customfunc = $TESTTMP/customfunc.py
4726 4727 > EOF
4727 4728
4728 4729 $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true
4729 4730 custom
4730 4731
4731 4732 $ cd ..
4732 4733
4733 4734 Test 'graphwidth' in 'hg log' on various topologies. The key here is that the
4734 4735 printed graphwidths 3, 5, 7, etc. should all line up in their respective
4735 4736 columns. We don't care about other aspects of the graph rendering here.
4736 4737
4737 4738 $ hg init graphwidth
4738 4739 $ cd graphwidth
4739 4740
4740 4741 $ wrappabletext="a a a a a a a a a a a a"
4741 4742
4742 4743 $ printf "first\n" > file
4743 4744 $ hg add file
4744 4745 $ hg commit -m "$wrappabletext"
4745 4746
4746 4747 $ printf "first\nsecond\n" > file
4747 4748 $ hg commit -m "$wrappabletext"
4748 4749
4749 4750 $ hg checkout 0
4750 4751 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4751 4752 $ printf "third\nfirst\n" > file
4752 4753 $ hg commit -m "$wrappabletext"
4753 4754 created new head
4754 4755
4755 4756 $ hg merge
4756 4757 merging file
4757 4758 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
4758 4759 (branch merge, don't forget to commit)
4759 4760
4760 4761 $ hg log --graph -T "{graphwidth}"
4761 4762 @ 3
4762 4763 |
4763 4764 | @ 5
4764 4765 |/
4765 4766 o 3
4766 4767
4767 4768 $ hg commit -m "$wrappabletext"
4768 4769
4769 4770 $ hg log --graph -T "{graphwidth}"
4770 4771 @ 5
4771 4772 |\
4772 4773 | o 5
4773 4774 | |
4774 4775 o | 5
4775 4776 |/
4776 4777 o 3
4777 4778
4778 4779
4779 4780 $ hg checkout 0
4780 4781 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4781 4782 $ printf "third\nfirst\nsecond\n" > file
4782 4783 $ hg commit -m "$wrappabletext"
4783 4784 created new head
4784 4785
4785 4786 $ hg log --graph -T "{graphwidth}"
4786 4787 @ 3
4787 4788 |
4788 4789 | o 7
4789 4790 | |\
4790 4791 +---o 7
4791 4792 | |
4792 4793 | o 5
4793 4794 |/
4794 4795 o 3
4795 4796
4796 4797
4797 4798 $ hg log --graph -T "{graphwidth}" -r 3
4798 4799 o 5
4799 4800 |\
4800 4801 ~ ~
4801 4802
4802 4803 $ hg log --graph -T "{graphwidth}" -r 1
4803 4804 o 3
4804 4805 |
4805 4806 ~
4806 4807
4807 4808 $ hg merge
4808 4809 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4809 4810 (branch merge, don't forget to commit)
4810 4811 $ hg commit -m "$wrappabletext"
4811 4812
4812 4813 $ printf "seventh\n" >> file
4813 4814 $ hg commit -m "$wrappabletext"
4814 4815
4815 4816 $ hg log --graph -T "{graphwidth}"
4816 4817 @ 3
4817 4818 |
4818 4819 o 5
4819 4820 |\
4820 4821 | o 5
4821 4822 | |
4822 4823 o | 7
4823 4824 |\ \
4824 4825 | o | 7
4825 4826 | |/
4826 4827 o / 5
4827 4828 |/
4828 4829 o 3
4829 4830
4830 4831
4831 4832 The point of graphwidth is to allow wrapping that accounts for the space taken
4832 4833 by the graph.
4833 4834
4834 4835 $ COLUMNS=10 hg log --graph -T "{fill(desc, termwidth - graphwidth)}"
4835 4836 @ a a a a
4836 4837 | a a a a
4837 4838 | a a a a
4838 4839 o a a a
4839 4840 |\ a a a
4840 4841 | | a a a
4841 4842 | | a a a
4842 4843 | o a a a
4843 4844 | | a a a
4844 4845 | | a a a
4845 4846 | | a a a
4846 4847 o | a a
4847 4848 |\ \ a a
4848 4849 | | | a a
4849 4850 | | | a a
4850 4851 | | | a a
4851 4852 | | | a a
4852 4853 | o | a a
4853 4854 | |/ a a
4854 4855 | | a a
4855 4856 | | a a
4856 4857 | | a a
4857 4858 | | a a
4858 4859 o | a a a
4859 4860 |/ a a a
4860 4861 | a a a
4861 4862 | a a a
4862 4863 o a a a a
4863 4864 a a a a
4864 4865 a a a a
4865 4866
4866 4867 Something tricky happens when there are elided nodes; the next drawn row of
4867 4868 edges can be more than one column wider, but the graph width only increases by
4868 4869 one column. The remaining columns are added in between the nodes.
4869 4870
4870 4871 $ hg log --graph -T "{graphwidth}" -r "0|2|4|5"
4871 4872 o 5
4872 4873 |\
4873 4874 | \
4874 4875 | :\
4875 4876 o : : 7
4876 4877 :/ /
4877 4878 : o 5
4878 4879 :/
4879 4880 o 3
4880 4881
4881 4882
4882 4883 $ cd ..
4883 4884
@@ -1,922 +1,922 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [diff]
3 3 > git = true
4 4 > EOF
5 5
6 6 $ hg init
7 7 $ cat > foo << EOF
8 8 > 0
9 9 > 1
10 10 > 2
11 11 > 3
12 12 > 4
13 13 > EOF
14 14 $ hg ci -Am init
15 15 adding foo
16 16 $ cat > foo << EOF
17 17 > 0
18 18 > 0
19 19 > 0
20 20 > 0
21 21 > 1
22 22 > 2
23 23 > 3
24 24 > 4
25 25 > EOF
26 26 $ hg ci -m 'more 0'
27 27 $ sed 's/2/2+/' foo > foo.new
28 28 $ mv foo.new foo
29 29 $ cat > bar << EOF
30 30 > a
31 31 > b
32 32 > c
33 33 > d
34 34 > e
35 35 > EOF
36 36 $ hg add bar
37 37 $ hg ci -Am "2 -> 2+; added bar"
38 38 $ cat >> foo << EOF
39 39 > 5
40 40 > 6
41 41 > 7
42 42 > 8
43 43 > 9
44 44 > 10
45 45 > 11
46 46 > EOF
47 47 $ hg ci -m "to 11"
48 48
49 49 Add some changes with two diff hunks
50 50
51 51 $ sed 's/^1$/ 1/' foo > foo.new
52 52 $ mv foo.new foo
53 53 $ sed 's/^11$/11+/' foo > foo.new
54 54 $ mv foo.new foo
55 55 $ hg ci -m '11 -> 11+; leading space before "1"'
56 56 (make sure there are two hunks in "foo")
57 57 $ hg diff -c .
58 58 diff --git a/foo b/foo
59 59 --- a/foo
60 60 +++ b/foo
61 61 @@ -2,7 +2,7 @@
62 62 0
63 63 0
64 64 0
65 65 -1
66 66 + 1
67 67 2+
68 68 3
69 69 4
70 70 @@ -12,4 +12,4 @@
71 71 8
72 72 9
73 73 10
74 74 -11
75 75 +11+
76 76 $ sed 's/3/3+/' foo > foo.new
77 77 $ mv foo.new foo
78 78 $ sed 's/^11+$/11-/' foo > foo.new
79 79 $ mv foo.new foo
80 80 $ sed 's/a/a+/' bar > bar.new
81 81 $ mv bar.new bar
82 82 $ hg ci -m 'foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+'
83 83 (make sure there are two hunks in "foo")
84 84 $ hg diff -c . foo
85 85 diff --git a/foo b/foo
86 86 --- a/foo
87 87 +++ b/foo
88 88 @@ -4,7 +4,7 @@
89 89 0
90 90 1
91 91 2+
92 92 -3
93 93 +3+
94 94 4
95 95 5
96 96 6
97 97 @@ -12,4 +12,4 @@
98 98 8
99 99 9
100 100 10
101 101 -11+
102 102 +11-
103 103
104 104 $ hg log -f -L foo,5:7 -p
105 105 changeset: 5:cfdf972b3971
106 106 tag: tip
107 107 user: test
108 108 date: Thu Jan 01 00:00:00 1970 +0000
109 109 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
110 110
111 111 diff --git a/foo b/foo
112 112 --- a/foo
113 113 +++ b/foo
114 114 @@ -4,7 +4,7 @@
115 115 0
116 116 1
117 117 2+
118 118 -3
119 119 +3+
120 120 4
121 121 5
122 122 6
123 123
124 124 changeset: 4:eaec41c1a0c9
125 125 user: test
126 126 date: Thu Jan 01 00:00:00 1970 +0000
127 127 summary: 11 -> 11+; leading space before "1"
128 128
129 129 diff --git a/foo b/foo
130 130 --- a/foo
131 131 +++ b/foo
132 132 @@ -2,7 +2,7 @@
133 133 0
134 134 0
135 135 0
136 136 -1
137 137 + 1
138 138 2+
139 139 3
140 140 4
141 141
142 142 changeset: 2:63a884426fd0
143 143 user: test
144 144 date: Thu Jan 01 00:00:00 1970 +0000
145 145 summary: 2 -> 2+; added bar
146 146
147 147 diff --git a/foo b/foo
148 148 --- a/foo
149 149 +++ b/foo
150 150 @@ -3,6 +3,6 @@
151 151 0
152 152 0
153 153 1
154 154 -2
155 155 +2+
156 156 3
157 157 4
158 158
159 159 changeset: 0:5ae1f82b9a00
160 160 user: test
161 161 date: Thu Jan 01 00:00:00 1970 +0000
162 162 summary: init
163 163
164 164 diff --git a/foo b/foo
165 165 new file mode 100644
166 166 --- /dev/null
167 167 +++ b/foo
168 168 @@ -0,0 +1,5 @@
169 169 +0
170 170 +1
171 171 +2
172 172 +3
173 173 +4
174 174
175 175 $ hg log -f --graph -L foo,5:7 -p
176 176 @ changeset: 5:cfdf972b3971
177 177 | tag: tip
178 178 | user: test
179 179 | date: Thu Jan 01 00:00:00 1970 +0000
180 180 | summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
181 181 |
182 182 | diff --git a/foo b/foo
183 183 | --- a/foo
184 184 | +++ b/foo
185 185 | @@ -4,7 +4,7 @@
186 186 | 0
187 187 | 1
188 188 | 2+
189 189 | -3
190 190 | +3+
191 191 | 4
192 192 | 5
193 193 | 6
194 194 |
195 195 o changeset: 4:eaec41c1a0c9
196 196 : user: test
197 197 : date: Thu Jan 01 00:00:00 1970 +0000
198 198 : summary: 11 -> 11+; leading space before "1"
199 199 :
200 200 : diff --git a/foo b/foo
201 201 : --- a/foo
202 202 : +++ b/foo
203 203 : @@ -2,7 +2,7 @@
204 204 : 0
205 205 : 0
206 206 : 0
207 207 : -1
208 208 : + 1
209 209 : 2+
210 210 : 3
211 211 : 4
212 212 :
213 213 o changeset: 2:63a884426fd0
214 214 : user: test
215 215 : date: Thu Jan 01 00:00:00 1970 +0000
216 216 : summary: 2 -> 2+; added bar
217 217 :
218 218 : diff --git a/foo b/foo
219 219 : --- a/foo
220 220 : +++ b/foo
221 221 : @@ -3,6 +3,6 @@
222 222 : 0
223 223 : 0
224 224 : 1
225 225 : -2
226 226 : +2+
227 227 : 3
228 228 : 4
229 229 :
230 230 o changeset: 0:5ae1f82b9a00
231 231 user: test
232 232 date: Thu Jan 01 00:00:00 1970 +0000
233 233 summary: init
234 234
235 235 diff --git a/foo b/foo
236 236 new file mode 100644
237 237 --- /dev/null
238 238 +++ b/foo
239 239 @@ -0,0 +1,5 @@
240 240 +0
241 241 +1
242 242 +2
243 243 +3
244 244 +4
245 245
246 246
247 247 With --template.
248 248
249 249 $ hg log -f -L foo,5:7 -T '{rev}:{node|short} {desc|firstline}\n'
250 250 5:cfdf972b3971 foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
251 251 4:eaec41c1a0c9 11 -> 11+; leading space before "1"
252 252 2:63a884426fd0 2 -> 2+; added bar
253 253 0:5ae1f82b9a00 init
254 254 $ hg log -f -L foo,5:7 -T json
255 255 [
256 256 {
257 "rev": 5,
258 "node": "cfdf972b3971a2a59638bf9583c0debbffee5404",
257 "bookmarks": [],
259 258 "branch": "default",
260 "phase": "draft",
261 "user": "test",
262 259 "date": [0, 0],
263 260 "desc": "foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+",
264 "bookmarks": [],
261 "node": "cfdf972b3971a2a59638bf9583c0debbffee5404",
262 "parents": ["eaec41c1a0c9ad0a5e999611d0149d171beffb8c"],
263 "phase": "draft",
264 "rev": 5,
265 265 "tags": ["tip"],
266 "parents": ["eaec41c1a0c9ad0a5e999611d0149d171beffb8c"]
266 "user": "test"
267 267 },
268 268 {
269 "rev": 4,
270 "node": "eaec41c1a0c9ad0a5e999611d0149d171beffb8c",
269 "bookmarks": [],
271 270 "branch": "default",
272 "phase": "draft",
273 "user": "test",
274 271 "date": [0, 0],
275 272 "desc": "11 -> 11+; leading space before \"1\"",
276 "bookmarks": [],
273 "node": "eaec41c1a0c9ad0a5e999611d0149d171beffb8c",
274 "parents": ["730a61fbaecf426c17c2c66bc42d195b5d5b0ba8"],
275 "phase": "draft",
276 "rev": 4,
277 277 "tags": [],
278 "parents": ["730a61fbaecf426c17c2c66bc42d195b5d5b0ba8"]
278 "user": "test"
279 279 },
280 280 {
281 "rev": 2,
282 "node": "63a884426fd0b277fcd55895bbb2f230434576eb",
281 "bookmarks": [],
283 282 "branch": "default",
284 "phase": "draft",
285 "user": "test",
286 283 "date": [0, 0],
287 284 "desc": "2 -> 2+; added bar",
288 "bookmarks": [],
285 "node": "63a884426fd0b277fcd55895bbb2f230434576eb",
286 "parents": ["29a1e7c6b80024f63f310a2d71de979e9d2996d7"],
287 "phase": "draft",
288 "rev": 2,
289 289 "tags": [],
290 "parents": ["29a1e7c6b80024f63f310a2d71de979e9d2996d7"]
290 "user": "test"
291 291 },
292 292 {
293 "rev": 0,
294 "node": "5ae1f82b9a000ff1e0967d0dac1c58b9d796e1b4",
293 "bookmarks": [],
295 294 "branch": "default",
296 "phase": "draft",
297 "user": "test",
298 295 "date": [0, 0],
299 296 "desc": "init",
300 "bookmarks": [],
297 "node": "5ae1f82b9a000ff1e0967d0dac1c58b9d796e1b4",
298 "parents": ["0000000000000000000000000000000000000000"],
299 "phase": "draft",
300 "rev": 0,
301 301 "tags": [],
302 "parents": ["0000000000000000000000000000000000000000"]
302 "user": "test"
303 303 }
304 304 ]
305 305
306 306 With some white-space diff option, respective revisions are skipped.
307 307
308 308 $ hg log -f -L foo,5:7 -p --config diff.ignorews=true
309 309 changeset: 5:cfdf972b3971
310 310 tag: tip
311 311 user: test
312 312 date: Thu Jan 01 00:00:00 1970 +0000
313 313 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
314 314
315 315 diff --git a/foo b/foo
316 316 --- a/foo
317 317 +++ b/foo
318 318 @@ -4,7 +4,7 @@
319 319 0
320 320 1
321 321 2+
322 322 -3
323 323 +3+
324 324 4
325 325 5
326 326 6
327 327
328 328 changeset: 2:63a884426fd0
329 329 user: test
330 330 date: Thu Jan 01 00:00:00 1970 +0000
331 331 summary: 2 -> 2+; added bar
332 332
333 333 diff --git a/foo b/foo
334 334 --- a/foo
335 335 +++ b/foo
336 336 @@ -3,6 +3,6 @@
337 337 0
338 338 0
339 339 1
340 340 -2
341 341 +2+
342 342 3
343 343 4
344 344
345 345 changeset: 0:5ae1f82b9a00
346 346 user: test
347 347 date: Thu Jan 01 00:00:00 1970 +0000
348 348 summary: init
349 349
350 350 diff --git a/foo b/foo
351 351 new file mode 100644
352 352 --- /dev/null
353 353 +++ b/foo
354 354 @@ -0,0 +1,5 @@
355 355 +0
356 356 +1
357 357 +2
358 358 +3
359 359 +4
360 360
361 361
362 362 Regular file patterns are not allowed.
363 363
364 364 $ hg log -f -L foo,5:7 -p bar
365 365 abort: FILE arguments are not compatible with --line-range option
366 366 [255]
367 367
368 368 Option --rev acts as a restriction.
369 369
370 370 $ hg log -f -L foo,5:7 -p -r 'desc(2)'
371 371 changeset: 2:63a884426fd0
372 372 user: test
373 373 date: Thu Jan 01 00:00:00 1970 +0000
374 374 summary: 2 -> 2+; added bar
375 375
376 376 diff --git a/foo b/foo
377 377 --- a/foo
378 378 +++ b/foo
379 379 @@ -3,6 +3,6 @@
380 380 0
381 381 0
382 382 1
383 383 -2
384 384 +2+
385 385 3
386 386 4
387 387
388 388 changeset: 0:5ae1f82b9a00
389 389 user: test
390 390 date: Thu Jan 01 00:00:00 1970 +0000
391 391 summary: init
392 392
393 393 diff --git a/foo b/foo
394 394 new file mode 100644
395 395 --- /dev/null
396 396 +++ b/foo
397 397 @@ -0,0 +1,5 @@
398 398 +0
399 399 +1
400 400 +2
401 401 +3
402 402 +4
403 403
404 404
405 405 With several -L patterns, changes touching any files in their respective line
406 406 range are show.
407 407
408 408 $ hg log -f -L foo,5:7 -L bar,1:2 -p
409 409 changeset: 5:cfdf972b3971
410 410 tag: tip
411 411 user: test
412 412 date: Thu Jan 01 00:00:00 1970 +0000
413 413 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
414 414
415 415 diff --git a/bar b/bar
416 416 --- a/bar
417 417 +++ b/bar
418 418 @@ -1,4 +1,4 @@
419 419 -a
420 420 +a+
421 421 b
422 422 c
423 423 d
424 424 diff --git a/foo b/foo
425 425 --- a/foo
426 426 +++ b/foo
427 427 @@ -4,7 +4,7 @@
428 428 0
429 429 1
430 430 2+
431 431 -3
432 432 +3+
433 433 4
434 434 5
435 435 6
436 436
437 437 changeset: 4:eaec41c1a0c9
438 438 user: test
439 439 date: Thu Jan 01 00:00:00 1970 +0000
440 440 summary: 11 -> 11+; leading space before "1"
441 441
442 442 diff --git a/foo b/foo
443 443 --- a/foo
444 444 +++ b/foo
445 445 @@ -2,7 +2,7 @@
446 446 0
447 447 0
448 448 0
449 449 -1
450 450 + 1
451 451 2+
452 452 3
453 453 4
454 454
455 455 changeset: 2:63a884426fd0
456 456 user: test
457 457 date: Thu Jan 01 00:00:00 1970 +0000
458 458 summary: 2 -> 2+; added bar
459 459
460 460 diff --git a/bar b/bar
461 461 new file mode 100644
462 462 --- /dev/null
463 463 +++ b/bar
464 464 @@ -0,0 +1,5 @@
465 465 +a
466 466 +b
467 467 +c
468 468 +d
469 469 +e
470 470 diff --git a/foo b/foo
471 471 --- a/foo
472 472 +++ b/foo
473 473 @@ -3,6 +3,6 @@
474 474 0
475 475 0
476 476 1
477 477 -2
478 478 +2+
479 479 3
480 480 4
481 481
482 482 changeset: 0:5ae1f82b9a00
483 483 user: test
484 484 date: Thu Jan 01 00:00:00 1970 +0000
485 485 summary: init
486 486
487 487 diff --git a/foo b/foo
488 488 new file mode 100644
489 489 --- /dev/null
490 490 +++ b/foo
491 491 @@ -0,0 +1,5 @@
492 492 +0
493 493 +1
494 494 +2
495 495 +3
496 496 +4
497 497
498 498
499 499 Multiple -L options with the same file yields changes touching any of
500 500 specified line ranges.
501 501
502 502 $ hg log -f -L foo,5:7 -L foo,14:15 -p
503 503 changeset: 5:cfdf972b3971
504 504 tag: tip
505 505 user: test
506 506 date: Thu Jan 01 00:00:00 1970 +0000
507 507 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
508 508
509 509 diff --git a/foo b/foo
510 510 --- a/foo
511 511 +++ b/foo
512 512 @@ -4,7 +4,7 @@
513 513 0
514 514 1
515 515 2+
516 516 -3
517 517 +3+
518 518 4
519 519 5
520 520 6
521 521 @@ -12,4 +12,4 @@
522 522 8
523 523 9
524 524 10
525 525 -11+
526 526 +11-
527 527
528 528 changeset: 4:eaec41c1a0c9
529 529 user: test
530 530 date: Thu Jan 01 00:00:00 1970 +0000
531 531 summary: 11 -> 11+; leading space before "1"
532 532
533 533 diff --git a/foo b/foo
534 534 --- a/foo
535 535 +++ b/foo
536 536 @@ -2,7 +2,7 @@
537 537 0
538 538 0
539 539 0
540 540 -1
541 541 + 1
542 542 2+
543 543 3
544 544 4
545 545 @@ -12,4 +12,4 @@
546 546 8
547 547 9
548 548 10
549 549 -11
550 550 +11+
551 551
552 552 changeset: 3:730a61fbaecf
553 553 user: test
554 554 date: Thu Jan 01 00:00:00 1970 +0000
555 555 summary: to 11
556 556
557 557 diff --git a/foo b/foo
558 558 --- a/foo
559 559 +++ b/foo
560 560 @@ -6,3 +6,10 @@
561 561 2+
562 562 3
563 563 4
564 564 +5
565 565 +6
566 566 +7
567 567 +8
568 568 +9
569 569 +10
570 570 +11
571 571
572 572 changeset: 2:63a884426fd0
573 573 user: test
574 574 date: Thu Jan 01 00:00:00 1970 +0000
575 575 summary: 2 -> 2+; added bar
576 576
577 577 diff --git a/foo b/foo
578 578 --- a/foo
579 579 +++ b/foo
580 580 @@ -3,6 +3,6 @@
581 581 0
582 582 0
583 583 1
584 584 -2
585 585 +2+
586 586 3
587 587 4
588 588
589 589 changeset: 0:5ae1f82b9a00
590 590 user: test
591 591 date: Thu Jan 01 00:00:00 1970 +0000
592 592 summary: init
593 593
594 594 diff --git a/foo b/foo
595 595 new file mode 100644
596 596 --- /dev/null
597 597 +++ b/foo
598 598 @@ -0,0 +1,5 @@
599 599 +0
600 600 +1
601 601 +2
602 602 +3
603 603 +4
604 604
605 605
606 606 A file with a comma in its name.
607 607
608 608 $ cat > ba,z << EOF
609 609 > q
610 610 > w
611 611 > e
612 612 > r
613 613 > t
614 614 > y
615 615 > EOF
616 616 $ hg ci -Am 'querty'
617 617 adding ba,z
618 618 $ cat >> ba,z << EOF
619 619 > u
620 620 > i
621 621 > o
622 622 > p
623 623 > EOF
624 624 $ hg ci -m 'more keys'
625 625 $ cat > ba,z << EOF
626 626 > a
627 627 > z
628 628 > e
629 629 > r
630 630 > t
631 631 > y
632 632 > u
633 633 > i
634 634 > o
635 635 > p
636 636 > EOF
637 637 $ hg ci -m 'azerty'
638 638 $ hg log -f -L ba,z,1:2 -p
639 639 changeset: 8:52373265138b
640 640 tag: tip
641 641 user: test
642 642 date: Thu Jan 01 00:00:00 1970 +0000
643 643 summary: azerty
644 644
645 645 diff --git a/ba,z b/ba,z
646 646 --- a/ba,z
647 647 +++ b/ba,z
648 648 @@ -1,5 +1,5 @@
649 649 -q
650 650 -w
651 651 +a
652 652 +z
653 653 e
654 654 r
655 655 t
656 656
657 657 changeset: 6:96ba8850f316
658 658 user: test
659 659 date: Thu Jan 01 00:00:00 1970 +0000
660 660 summary: querty
661 661
662 662 diff --git a/ba,z b/ba,z
663 663 new file mode 100644
664 664 --- /dev/null
665 665 +++ b/ba,z
666 666 @@ -0,0 +1,6 @@
667 667 +q
668 668 +w
669 669 +e
670 670 +r
671 671 +t
672 672 +y
673 673
674 674
675 675 Exact prefix kinds work in -L options.
676 676
677 677 $ mkdir dir
678 678 $ cd dir
679 679 $ hg log -f -L path:foo,5:7 -p
680 680 changeset: 5:cfdf972b3971
681 681 user: test
682 682 date: Thu Jan 01 00:00:00 1970 +0000
683 683 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
684 684
685 685 diff --git a/foo b/foo
686 686 --- a/foo
687 687 +++ b/foo
688 688 @@ -4,7 +4,7 @@
689 689 0
690 690 1
691 691 2+
692 692 -3
693 693 +3+
694 694 4
695 695 5
696 696 6
697 697
698 698 changeset: 4:eaec41c1a0c9
699 699 user: test
700 700 date: Thu Jan 01 00:00:00 1970 +0000
701 701 summary: 11 -> 11+; leading space before "1"
702 702
703 703 diff --git a/foo b/foo
704 704 --- a/foo
705 705 +++ b/foo
706 706 @@ -2,7 +2,7 @@
707 707 0
708 708 0
709 709 0
710 710 -1
711 711 + 1
712 712 2+
713 713 3
714 714 4
715 715
716 716 changeset: 2:63a884426fd0
717 717 user: test
718 718 date: Thu Jan 01 00:00:00 1970 +0000
719 719 summary: 2 -> 2+; added bar
720 720
721 721 diff --git a/foo b/foo
722 722 --- a/foo
723 723 +++ b/foo
724 724 @@ -3,6 +3,6 @@
725 725 0
726 726 0
727 727 1
728 728 -2
729 729 +2+
730 730 3
731 731 4
732 732
733 733 changeset: 0:5ae1f82b9a00
734 734 user: test
735 735 date: Thu Jan 01 00:00:00 1970 +0000
736 736 summary: init
737 737
738 738 diff --git a/foo b/foo
739 739 new file mode 100644
740 740 --- /dev/null
741 741 +++ b/foo
742 742 @@ -0,0 +1,5 @@
743 743 +0
744 744 +1
745 745 +2
746 746 +3
747 747 +4
748 748
749 749
750 750 Renames are followed.
751 751
752 752 $ hg mv ../foo baz
753 753 $ sed 's/1/1+/' baz > baz.new
754 754 $ mv baz.new baz
755 755 $ hg ci -m 'foo -> dir/baz; 1-1+'
756 756 $ hg diff -c .
757 757 diff --git a/foo b/dir/baz
758 758 rename from foo
759 759 rename to dir/baz
760 760 --- a/foo
761 761 +++ b/dir/baz
762 762 @@ -2,7 +2,7 @@
763 763 0
764 764 0
765 765 0
766 766 - 1
767 767 + 1+
768 768 2+
769 769 3+
770 770 4
771 771 @@ -11,5 +11,5 @@
772 772 7
773 773 8
774 774 9
775 775 -10
776 776 -11-
777 777 +1+0
778 778 +1+1-
779 779 $ hg log -f -L relpath:baz,5:7 -p
780 780 changeset: 9:6af29c3a778f
781 781 tag: tip
782 782 user: test
783 783 date: Thu Jan 01 00:00:00 1970 +0000
784 784 summary: foo -> dir/baz; 1-1+
785 785
786 786 diff --git a/foo b/dir/baz
787 787 copy from foo
788 788 copy to dir/baz
789 789 --- a/foo
790 790 +++ b/dir/baz
791 791 @@ -2,7 +2,7 @@
792 792 0
793 793 0
794 794 0
795 795 - 1
796 796 + 1+
797 797 2+
798 798 3+
799 799 4
800 800
801 801 changeset: 5:cfdf972b3971
802 802 user: test
803 803 date: Thu Jan 01 00:00:00 1970 +0000
804 804 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
805 805
806 806 diff --git a/foo b/foo
807 807 --- a/foo
808 808 +++ b/foo
809 809 @@ -4,7 +4,7 @@
810 810 0
811 811 1
812 812 2+
813 813 -3
814 814 +3+
815 815 4
816 816 5
817 817 6
818 818
819 819 changeset: 4:eaec41c1a0c9
820 820 user: test
821 821 date: Thu Jan 01 00:00:00 1970 +0000
822 822 summary: 11 -> 11+; leading space before "1"
823 823
824 824 diff --git a/foo b/foo
825 825 --- a/foo
826 826 +++ b/foo
827 827 @@ -2,7 +2,7 @@
828 828 0
829 829 0
830 830 0
831 831 -1
832 832 + 1
833 833 2+
834 834 3
835 835 4
836 836
837 837 changeset: 2:63a884426fd0
838 838 user: test
839 839 date: Thu Jan 01 00:00:00 1970 +0000
840 840 summary: 2 -> 2+; added bar
841 841
842 842 diff --git a/foo b/foo
843 843 --- a/foo
844 844 +++ b/foo
845 845 @@ -3,6 +3,6 @@
846 846 0
847 847 0
848 848 1
849 849 -2
850 850 +2+
851 851 3
852 852 4
853 853
854 854 changeset: 0:5ae1f82b9a00
855 855 user: test
856 856 date: Thu Jan 01 00:00:00 1970 +0000
857 857 summary: init
858 858
859 859 diff --git a/foo b/foo
860 860 new file mode 100644
861 861 --- /dev/null
862 862 +++ b/foo
863 863 @@ -0,0 +1,5 @@
864 864 +0
865 865 +1
866 866 +2
867 867 +3
868 868 +4
869 869
870 870
871 871 Binary files work but without diff hunks filtering.
872 872 (Checking w/ and w/o diff.git option.)
873 873
874 874 >>> open('binary', 'wb').write(b'this\nis\na\nbinary\0') and None
875 875 $ hg add binary
876 876 $ hg ci -m 'add a binary file' --quiet
877 877 $ hg log -f -L binary,1:2 -p
878 878 changeset: 10:c96381c229df
879 879 tag: tip
880 880 user: test
881 881 date: Thu Jan 01 00:00:00 1970 +0000
882 882 summary: add a binary file
883 883
884 884 diff --git a/dir/binary b/dir/binary
885 885 new file mode 100644
886 886 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c2e1fbed209fe919b3f189a6a31950e9adf61e45
887 887 GIT binary patch
888 888 literal 17
889 889 Wc$_QA$SmdpqC~Ew%)G>+N(KNlNClYy
890 890
891 891
892 892 $ hg log -f -L binary,1:2 -p --config diff.git=false
893 893 changeset: 10:c96381c229df
894 894 tag: tip
895 895 user: test
896 896 date: Thu Jan 01 00:00:00 1970 +0000
897 897 summary: add a binary file
898 898
899 899 diff -r 6af29c3a778f -r c96381c229df dir/binary
900 900 Binary file dir/binary has changed
901 901
902 902
903 903 Option --follow is required.
904 904
905 905 $ hg log -L foo,5:7
906 906 abort: --line-range requires --follow
907 907 [255]
908 908
909 909 Non-exact pattern kinds are not allowed.
910 910
911 911 $ cd ..
912 912 $ hg log -f -L glob:*a*,1:2
913 913 hg: parse error: line range pattern 'glob:*a*' must match exactly one file
914 914 [255]
915 915
916 916 We get an error for removed files.
917 917
918 918 $ hg rm dir/baz
919 919 $ hg ci -m 'remove baz' --quiet
920 920 $ hg log -f -L dir/baz,5:7 -p
921 921 abort: cannot follow file not in parent revision: "dir/baz"
922 922 [255]
@@ -1,2634 +1,2634 b''
1 1 Log on empty repository: checking consistency
2 2
3 3 $ hg init empty
4 4 $ cd empty
5 5 $ hg log
6 6 $ hg log -r 1
7 7 abort: unknown revision '1'!
8 8 [255]
9 9 $ hg log -r -1:0
10 10 abort: unknown revision '-1'!
11 11 [255]
12 12 $ hg log -r 'branch(name)'
13 13 abort: unknown revision 'name'!
14 14 [255]
15 15 $ hg log -r null -q
16 16 -1:000000000000
17 17
18 18 $ cd ..
19 19
20 20 The g is crafted to have 2 filelog topological heads in a linear
21 21 changeset graph
22 22
23 23 $ hg init a
24 24 $ cd a
25 25 $ echo a > a
26 26 $ echo f > f
27 27 $ hg ci -Ama -d '1 0'
28 28 adding a
29 29 adding f
30 30
31 31 $ hg cp a b
32 32 $ hg cp f g
33 33 $ hg ci -mb -d '2 0'
34 34
35 35 $ mkdir dir
36 36 $ hg mv b dir
37 37 $ echo g >> g
38 38 $ echo f >> f
39 39 $ hg ci -mc -d '3 0'
40 40
41 41 $ hg mv a b
42 42 $ hg cp -f f g
43 43 $ echo a > d
44 44 $ hg add d
45 45 $ hg ci -md -d '4 0'
46 46
47 47 $ hg mv dir/b e
48 48 $ hg ci -me -d '5 0'
49 49
50 50 Make sure largefiles doesn't interfere with logging a regular file
51 51 $ hg --debug log a -T '{rev}: {desc}\n' --config extensions.largefiles=
52 52 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
53 53 updated patterns: .hglf/a, a
54 54 0: a
55 55 $ hg log a
56 56 changeset: 0:9161b9aeaf16
57 57 user: test
58 58 date: Thu Jan 01 00:00:01 1970 +0000
59 59 summary: a
60 60
61 61 $ hg log glob:a*
62 62 changeset: 3:2ca5ba701980
63 63 user: test
64 64 date: Thu Jan 01 00:00:04 1970 +0000
65 65 summary: d
66 66
67 67 changeset: 0:9161b9aeaf16
68 68 user: test
69 69 date: Thu Jan 01 00:00:01 1970 +0000
70 70 summary: a
71 71
72 72 $ hg --debug log glob:a* -T '{rev}: {desc}\n' --config extensions.largefiles=
73 73 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
74 74 updated patterns: glob:.hglf/a*, glob:a*
75 75 3: d
76 76 0: a
77 77
78 78 log on directory
79 79
80 80 $ hg log dir
81 81 changeset: 4:7e4639b4691b
82 82 tag: tip
83 83 user: test
84 84 date: Thu Jan 01 00:00:05 1970 +0000
85 85 summary: e
86 86
87 87 changeset: 2:f8954cd4dc1f
88 88 user: test
89 89 date: Thu Jan 01 00:00:03 1970 +0000
90 90 summary: c
91 91
92 92 $ hg log somethingthatdoesntexist dir
93 93 changeset: 4:7e4639b4691b
94 94 tag: tip
95 95 user: test
96 96 date: Thu Jan 01 00:00:05 1970 +0000
97 97 summary: e
98 98
99 99 changeset: 2:f8954cd4dc1f
100 100 user: test
101 101 date: Thu Jan 01 00:00:03 1970 +0000
102 102 summary: c
103 103
104 104
105 105 -X, with explicit path
106 106
107 107 $ hg log a -X a
108 108
109 109 -f, non-existent directory
110 110
111 111 $ hg log -f dir
112 112 abort: cannot follow file not in parent revision: "dir"
113 113 [255]
114 114
115 115 -f, directory
116 116
117 117 $ hg up -q 3
118 118 $ hg log -f dir
119 119 changeset: 2:f8954cd4dc1f
120 120 user: test
121 121 date: Thu Jan 01 00:00:03 1970 +0000
122 122 summary: c
123 123
124 124 -f, directory with --patch
125 125
126 126 $ hg log -f dir -p
127 127 changeset: 2:f8954cd4dc1f
128 128 user: test
129 129 date: Thu Jan 01 00:00:03 1970 +0000
130 130 summary: c
131 131
132 132 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
133 133 --- /dev/null* (glob)
134 134 +++ b/dir/b* (glob)
135 135 @@ -0,0 +1,1 @@
136 136 +a
137 137
138 138
139 139 -f, pattern
140 140
141 141 $ hg log -f -I 'dir**' -p
142 142 changeset: 2:f8954cd4dc1f
143 143 user: test
144 144 date: Thu Jan 01 00:00:03 1970 +0000
145 145 summary: c
146 146
147 147 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
148 148 --- /dev/null* (glob)
149 149 +++ b/dir/b* (glob)
150 150 @@ -0,0 +1,1 @@
151 151 +a
152 152
153 153 $ hg up -q 4
154 154
155 155 -f, a wrong style
156 156
157 157 $ hg log -f -l1 --style something
158 158 abort: style 'something' not found
159 159 (available styles: bisect, changelog, compact, default, phases, show, status, xml)
160 160 [255]
161 161
162 162 -f, phases style
163 163
164 164
165 165 $ hg log -f -l1 --style phases
166 166 changeset: 4:7e4639b4691b
167 167 tag: tip
168 168 phase: draft
169 169 user: test
170 170 date: Thu Jan 01 00:00:05 1970 +0000
171 171 summary: e
172 172
173 173
174 174 $ hg log -f -l1 --style phases -q
175 175 4:7e4639b4691b
176 176
177 177 -f, but no args
178 178
179 179 $ hg log -f
180 180 changeset: 4:7e4639b4691b
181 181 tag: tip
182 182 user: test
183 183 date: Thu Jan 01 00:00:05 1970 +0000
184 184 summary: e
185 185
186 186 changeset: 3:2ca5ba701980
187 187 user: test
188 188 date: Thu Jan 01 00:00:04 1970 +0000
189 189 summary: d
190 190
191 191 changeset: 2:f8954cd4dc1f
192 192 user: test
193 193 date: Thu Jan 01 00:00:03 1970 +0000
194 194 summary: c
195 195
196 196 changeset: 1:d89b0a12d229
197 197 user: test
198 198 date: Thu Jan 01 00:00:02 1970 +0000
199 199 summary: b
200 200
201 201 changeset: 0:9161b9aeaf16
202 202 user: test
203 203 date: Thu Jan 01 00:00:01 1970 +0000
204 204 summary: a
205 205
206 206
207 207 one rename
208 208
209 209 $ hg up -q 2
210 210 $ hg log -vf a
211 211 changeset: 0:9161b9aeaf16
212 212 user: test
213 213 date: Thu Jan 01 00:00:01 1970 +0000
214 214 files: a f
215 215 description:
216 216 a
217 217
218 218
219 219
220 220 many renames
221 221
222 222 $ hg up -q tip
223 223 $ hg log -vf e
224 224 changeset: 4:7e4639b4691b
225 225 tag: tip
226 226 user: test
227 227 date: Thu Jan 01 00:00:05 1970 +0000
228 228 files: dir/b e
229 229 description:
230 230 e
231 231
232 232
233 233 changeset: 2:f8954cd4dc1f
234 234 user: test
235 235 date: Thu Jan 01 00:00:03 1970 +0000
236 236 files: b dir/b f g
237 237 description:
238 238 c
239 239
240 240
241 241 changeset: 1:d89b0a12d229
242 242 user: test
243 243 date: Thu Jan 01 00:00:02 1970 +0000
244 244 files: b g
245 245 description:
246 246 b
247 247
248 248
249 249 changeset: 0:9161b9aeaf16
250 250 user: test
251 251 date: Thu Jan 01 00:00:01 1970 +0000
252 252 files: a f
253 253 description:
254 254 a
255 255
256 256
257 257
258 258
259 259 log -pf dir/b
260 260
261 261 $ hg up -q 3
262 262 $ hg log -pf dir/b
263 263 changeset: 2:f8954cd4dc1f
264 264 user: test
265 265 date: Thu Jan 01 00:00:03 1970 +0000
266 266 summary: c
267 267
268 268 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
269 269 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
270 270 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
271 271 @@ -0,0 +1,1 @@
272 272 +a
273 273
274 274 changeset: 1:d89b0a12d229
275 275 user: test
276 276 date: Thu Jan 01 00:00:02 1970 +0000
277 277 summary: b
278 278
279 279 diff -r 9161b9aeaf16 -r d89b0a12d229 b
280 280 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
281 281 +++ b/b Thu Jan 01 00:00:02 1970 +0000
282 282 @@ -0,0 +1,1 @@
283 283 +a
284 284
285 285 changeset: 0:9161b9aeaf16
286 286 user: test
287 287 date: Thu Jan 01 00:00:01 1970 +0000
288 288 summary: a
289 289
290 290 diff -r 000000000000 -r 9161b9aeaf16 a
291 291 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
292 292 +++ b/a Thu Jan 01 00:00:01 1970 +0000
293 293 @@ -0,0 +1,1 @@
294 294 +a
295 295
296 296
297 297 log -pf b inside dir
298 298
299 299 $ hg --cwd=dir log -pf b
300 300 changeset: 2:f8954cd4dc1f
301 301 user: test
302 302 date: Thu Jan 01 00:00:03 1970 +0000
303 303 summary: c
304 304
305 305 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
306 306 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
307 307 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
308 308 @@ -0,0 +1,1 @@
309 309 +a
310 310
311 311 changeset: 1:d89b0a12d229
312 312 user: test
313 313 date: Thu Jan 01 00:00:02 1970 +0000
314 314 summary: b
315 315
316 316 diff -r 9161b9aeaf16 -r d89b0a12d229 b
317 317 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
318 318 +++ b/b Thu Jan 01 00:00:02 1970 +0000
319 319 @@ -0,0 +1,1 @@
320 320 +a
321 321
322 322 changeset: 0:9161b9aeaf16
323 323 user: test
324 324 date: Thu Jan 01 00:00:01 1970 +0000
325 325 summary: a
326 326
327 327 diff -r 000000000000 -r 9161b9aeaf16 a
328 328 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
329 329 +++ b/a Thu Jan 01 00:00:01 1970 +0000
330 330 @@ -0,0 +1,1 @@
331 331 +a
332 332
333 333
334 334 log -pf, but no args
335 335
336 336 $ hg log -pf
337 337 changeset: 3:2ca5ba701980
338 338 user: test
339 339 date: Thu Jan 01 00:00:04 1970 +0000
340 340 summary: d
341 341
342 342 diff -r f8954cd4dc1f -r 2ca5ba701980 a
343 343 --- a/a Thu Jan 01 00:00:03 1970 +0000
344 344 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
345 345 @@ -1,1 +0,0 @@
346 346 -a
347 347 diff -r f8954cd4dc1f -r 2ca5ba701980 b
348 348 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
349 349 +++ b/b Thu Jan 01 00:00:04 1970 +0000
350 350 @@ -0,0 +1,1 @@
351 351 +a
352 352 diff -r f8954cd4dc1f -r 2ca5ba701980 d
353 353 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
354 354 +++ b/d Thu Jan 01 00:00:04 1970 +0000
355 355 @@ -0,0 +1,1 @@
356 356 +a
357 357 diff -r f8954cd4dc1f -r 2ca5ba701980 g
358 358 --- a/g Thu Jan 01 00:00:03 1970 +0000
359 359 +++ b/g Thu Jan 01 00:00:04 1970 +0000
360 360 @@ -1,2 +1,2 @@
361 361 f
362 362 -g
363 363 +f
364 364
365 365 changeset: 2:f8954cd4dc1f
366 366 user: test
367 367 date: Thu Jan 01 00:00:03 1970 +0000
368 368 summary: c
369 369
370 370 diff -r d89b0a12d229 -r f8954cd4dc1f b
371 371 --- a/b Thu Jan 01 00:00:02 1970 +0000
372 372 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
373 373 @@ -1,1 +0,0 @@
374 374 -a
375 375 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
376 376 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
377 377 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
378 378 @@ -0,0 +1,1 @@
379 379 +a
380 380 diff -r d89b0a12d229 -r f8954cd4dc1f f
381 381 --- a/f Thu Jan 01 00:00:02 1970 +0000
382 382 +++ b/f Thu Jan 01 00:00:03 1970 +0000
383 383 @@ -1,1 +1,2 @@
384 384 f
385 385 +f
386 386 diff -r d89b0a12d229 -r f8954cd4dc1f g
387 387 --- a/g Thu Jan 01 00:00:02 1970 +0000
388 388 +++ b/g Thu Jan 01 00:00:03 1970 +0000
389 389 @@ -1,1 +1,2 @@
390 390 f
391 391 +g
392 392
393 393 changeset: 1:d89b0a12d229
394 394 user: test
395 395 date: Thu Jan 01 00:00:02 1970 +0000
396 396 summary: b
397 397
398 398 diff -r 9161b9aeaf16 -r d89b0a12d229 b
399 399 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
400 400 +++ b/b Thu Jan 01 00:00:02 1970 +0000
401 401 @@ -0,0 +1,1 @@
402 402 +a
403 403 diff -r 9161b9aeaf16 -r d89b0a12d229 g
404 404 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
405 405 +++ b/g Thu Jan 01 00:00:02 1970 +0000
406 406 @@ -0,0 +1,1 @@
407 407 +f
408 408
409 409 changeset: 0:9161b9aeaf16
410 410 user: test
411 411 date: Thu Jan 01 00:00:01 1970 +0000
412 412 summary: a
413 413
414 414 diff -r 000000000000 -r 9161b9aeaf16 a
415 415 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
416 416 +++ b/a Thu Jan 01 00:00:01 1970 +0000
417 417 @@ -0,0 +1,1 @@
418 418 +a
419 419 diff -r 000000000000 -r 9161b9aeaf16 f
420 420 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
421 421 +++ b/f Thu Jan 01 00:00:01 1970 +0000
422 422 @@ -0,0 +1,1 @@
423 423 +f
424 424
425 425
426 426 log -vf dir/b
427 427
428 428 $ hg log -vf dir/b
429 429 changeset: 2:f8954cd4dc1f
430 430 user: test
431 431 date: Thu Jan 01 00:00:03 1970 +0000
432 432 files: b dir/b f g
433 433 description:
434 434 c
435 435
436 436
437 437 changeset: 1:d89b0a12d229
438 438 user: test
439 439 date: Thu Jan 01 00:00:02 1970 +0000
440 440 files: b g
441 441 description:
442 442 b
443 443
444 444
445 445 changeset: 0:9161b9aeaf16
446 446 user: test
447 447 date: Thu Jan 01 00:00:01 1970 +0000
448 448 files: a f
449 449 description:
450 450 a
451 451
452 452
453 453
454 454
455 455 -f and multiple filelog heads
456 456
457 457 $ hg up -q 2
458 458 $ hg log -f g --template '{rev}\n'
459 459 2
460 460 1
461 461 0
462 462 $ hg up -q tip
463 463 $ hg log -f g --template '{rev}\n'
464 464 3
465 465 2
466 466 0
467 467
468 468 follow files from the specified revisions (issue4959)
469 469
470 470 $ hg log -G -T '{rev} {files},{file_copies % " {source}->{name}"}\n'
471 471 @ 4 dir/b e, dir/b->e
472 472 |
473 473 o 3 a b d g, a->b f->g
474 474 |
475 475 o 2 b dir/b f g, b->dir/b
476 476 |
477 477 o 1 b g, a->b f->g
478 478 |
479 479 o 0 a f,
480 480
481 481
482 482 $ hg log -T '{rev}\n' -fr 4 e
483 483 4
484 484 2
485 485 1
486 486 0
487 487 $ hg log -T '{rev}\n' -fr 2 g
488 488 2
489 489 1
490 490 0
491 491 $ hg log -T '{rev}\n' -fr '2+3' g
492 492 3
493 493 2
494 494 1
495 495 0
496 496
497 497 follow files from the specified revisions with glob patterns (issue5053)
498 498 (BROKEN: should follow copies from e@4)
499 499
500 500 $ hg log -T '{rev}\n' -fr4 e -X '[abcdfg]'
501 501 4
502 502 2 (false !)
503 503 1 (false !)
504 504 0 (false !)
505 505
506 506 follow files from the specified revisions with missing patterns
507 507 (BROKEN: should follow copies from e@4)
508 508
509 509 $ hg log -T '{rev}\n' -fr4 e x
510 510 4
511 511 2 (false !)
512 512 1 (false !)
513 513 0 (false !)
514 514
515 515 follow files from the specified revisions across copies with -p/--patch
516 516
517 517 $ hg log -T '== rev: {rev},{file_copies % " {source}->{name}"} ==\n' -fpr 4 e g
518 518 == rev: 4, dir/b->e ==
519 519 diff -r 2ca5ba701980 -r 7e4639b4691b e
520 520 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
521 521 +++ b/e Thu Jan 01 00:00:05 1970 +0000
522 522 @@ -0,0 +1,1 @@
523 523 +a
524 524
525 525 == rev: 3, a->b f->g ==
526 526 diff -r f8954cd4dc1f -r 2ca5ba701980 g
527 527 --- a/g Thu Jan 01 00:00:03 1970 +0000
528 528 +++ b/g Thu Jan 01 00:00:04 1970 +0000
529 529 @@ -1,2 +1,2 @@
530 530 f
531 531 -g
532 532 +f
533 533
534 534 == rev: 2, b->dir/b ==
535 535 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
536 536 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
537 537 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
538 538 @@ -0,0 +1,1 @@
539 539 +a
540 540 diff -r d89b0a12d229 -r f8954cd4dc1f f
541 541 --- a/f Thu Jan 01 00:00:02 1970 +0000
542 542 +++ b/f Thu Jan 01 00:00:03 1970 +0000
543 543 @@ -1,1 +1,2 @@
544 544 f
545 545 +f
546 546
547 547 == rev: 1, a->b f->g ==
548 548 diff -r 9161b9aeaf16 -r d89b0a12d229 b
549 549 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
550 550 +++ b/b Thu Jan 01 00:00:02 1970 +0000
551 551 @@ -0,0 +1,1 @@
552 552 +a
553 553
554 554 == rev: 0, ==
555 555 diff -r 000000000000 -r 9161b9aeaf16 a
556 556 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
557 557 +++ b/a Thu Jan 01 00:00:01 1970 +0000
558 558 @@ -0,0 +1,1 @@
559 559 +a
560 560 diff -r 000000000000 -r 9161b9aeaf16 f
561 561 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
562 562 +++ b/f Thu Jan 01 00:00:01 1970 +0000
563 563 @@ -0,0 +1,1 @@
564 564 +f
565 565
566 566
567 567 log copies with --copies
568 568
569 569 $ hg log -vC --template '{rev} {file_copies}\n'
570 570 4 e (dir/b)
571 571 3 b (a)g (f)
572 572 2 dir/b (b)
573 573 1 b (a)g (f)
574 574 0
575 575
576 576 log copies switch without --copies, with old filecopy template
577 577
578 578 $ hg log -v --template '{rev} {file_copies_switch%filecopy}\n'
579 579 4
580 580 3
581 581 2
582 582 1
583 583 0
584 584
585 585 log copies switch with --copies
586 586
587 587 $ hg log -vC --template '{rev} {file_copies_switch}\n'
588 588 4 e (dir/b)
589 589 3 b (a)g (f)
590 590 2 dir/b (b)
591 591 1 b (a)g (f)
592 592 0
593 593
594 594
595 595 log copies with hardcoded style and with --style=default
596 596
597 597 $ hg log -vC -r4
598 598 changeset: 4:7e4639b4691b
599 599 tag: tip
600 600 user: test
601 601 date: Thu Jan 01 00:00:05 1970 +0000
602 602 files: dir/b e
603 603 copies: e (dir/b)
604 604 description:
605 605 e
606 606
607 607
608 608 $ hg log -vC -r4 --style=default
609 609 changeset: 4:7e4639b4691b
610 610 tag: tip
611 611 user: test
612 612 date: Thu Jan 01 00:00:05 1970 +0000
613 613 files: dir/b e
614 614 copies: e (dir/b)
615 615 description:
616 616 e
617 617
618 618
619 619 $ hg log -vC -r4 -Tjson
620 620 [
621 621 {
622 "rev": 4,
623 "node": "7e4639b4691b9f84b81036a8d4fb218ce3c5e3a3",
622 "bookmarks": [],
624 623 "branch": "default",
625 "phase": "draft",
626 "user": "test",
624 "copies": {"e": "dir/b"},
627 625 "date": [5, 0],
628 626 "desc": "e",
629 "bookmarks": [],
630 "tags": ["tip"],
627 "files": ["dir/b", "e"],
628 "node": "7e4639b4691b9f84b81036a8d4fb218ce3c5e3a3",
631 629 "parents": ["2ca5ba7019804f1f597249caddf22a64d34df0ba"],
632 "files": ["dir/b", "e"],
633 "copies": {"e": "dir/b"}
630 "phase": "draft",
631 "rev": 4,
632 "tags": ["tip"],
633 "user": "test"
634 634 }
635 635 ]
636 636
637 637 log copies, non-linear manifest
638 638
639 639 $ hg up -C 3
640 640 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
641 641 $ hg mv dir/b e
642 642 $ echo foo > foo
643 643 $ hg ci -Ame2 -d '6 0'
644 644 adding foo
645 645 created new head
646 646 $ hg log -v --template '{rev} {file_copies}\n' -r 5
647 647 5 e (dir/b)
648 648
649 649
650 650 log copies, execute bit set
651 651
652 652 #if execbit
653 653 $ chmod +x e
654 654 $ hg ci -me3 -d '7 0'
655 655 $ hg log -v --template '{rev} {file_copies}\n' -r 6
656 656 6
657 657 #endif
658 658
659 659
660 660 log -p d
661 661
662 662 $ hg log -pv d
663 663 changeset: 3:2ca5ba701980
664 664 user: test
665 665 date: Thu Jan 01 00:00:04 1970 +0000
666 666 files: a b d g
667 667 description:
668 668 d
669 669
670 670
671 671 diff -r f8954cd4dc1f -r 2ca5ba701980 d
672 672 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
673 673 +++ b/d Thu Jan 01 00:00:04 1970 +0000
674 674 @@ -0,0 +1,1 @@
675 675 +a
676 676
677 677
678 678
679 679 log --removed file
680 680
681 681 $ hg log --removed -v a
682 682 changeset: 3:2ca5ba701980
683 683 user: test
684 684 date: Thu Jan 01 00:00:04 1970 +0000
685 685 files: a b d g
686 686 description:
687 687 d
688 688
689 689
690 690 changeset: 0:9161b9aeaf16
691 691 user: test
692 692 date: Thu Jan 01 00:00:01 1970 +0000
693 693 files: a f
694 694 description:
695 695 a
696 696
697 697
698 698
699 699 log --removed revrange file
700 700
701 701 $ hg log --removed -v -r0:2 a
702 702 changeset: 0:9161b9aeaf16
703 703 user: test
704 704 date: Thu Jan 01 00:00:01 1970 +0000
705 705 files: a f
706 706 description:
707 707 a
708 708
709 709
710 710 $ cd ..
711 711
712 712 log --follow tests
713 713
714 714 $ hg init follow
715 715 $ cd follow
716 716
717 717 $ echo base > base
718 718 $ hg ci -Ambase -d '1 0'
719 719 adding base
720 720
721 721 $ echo r1 >> base
722 722 $ hg ci -Amr1 -d '1 0'
723 723 $ echo r2 >> base
724 724 $ hg ci -Amr2 -d '1 0'
725 725
726 726 $ hg up -C 1
727 727 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
728 728 $ echo b1 > b1
729 729
730 730 log -r "follow('set:clean()')"
731 731
732 732 $ hg log -r "follow('set:clean()')"
733 733 changeset: 0:67e992f2c4f3
734 734 user: test
735 735 date: Thu Jan 01 00:00:01 1970 +0000
736 736 summary: base
737 737
738 738 changeset: 1:3d5bf5654eda
739 739 user: test
740 740 date: Thu Jan 01 00:00:01 1970 +0000
741 741 summary: r1
742 742
743 743
744 744 $ hg ci -Amb1 -d '1 0'
745 745 adding b1
746 746 created new head
747 747
748 748
749 749 log -f
750 750
751 751 $ hg log -f
752 752 changeset: 3:e62f78d544b4
753 753 tag: tip
754 754 parent: 1:3d5bf5654eda
755 755 user: test
756 756 date: Thu Jan 01 00:00:01 1970 +0000
757 757 summary: b1
758 758
759 759 changeset: 1:3d5bf5654eda
760 760 user: test
761 761 date: Thu Jan 01 00:00:01 1970 +0000
762 762 summary: r1
763 763
764 764 changeset: 0:67e992f2c4f3
765 765 user: test
766 766 date: Thu Jan 01 00:00:01 1970 +0000
767 767 summary: base
768 768
769 769
770 770 log -r follow('glob:b*')
771 771
772 772 $ hg log -r "follow('glob:b*')"
773 773 changeset: 0:67e992f2c4f3
774 774 user: test
775 775 date: Thu Jan 01 00:00:01 1970 +0000
776 776 summary: base
777 777
778 778 changeset: 1:3d5bf5654eda
779 779 user: test
780 780 date: Thu Jan 01 00:00:01 1970 +0000
781 781 summary: r1
782 782
783 783 changeset: 3:e62f78d544b4
784 784 tag: tip
785 785 parent: 1:3d5bf5654eda
786 786 user: test
787 787 date: Thu Jan 01 00:00:01 1970 +0000
788 788 summary: b1
789 789
790 790 log -f -r '1 + 4'
791 791
792 792 $ hg up -C 0
793 793 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
794 794 $ echo b2 > b2
795 795 $ hg ci -Amb2 -d '1 0'
796 796 adding b2
797 797 created new head
798 798 $ hg log -f -r '1 + 4'
799 799 changeset: 4:ddb82e70d1a1
800 800 tag: tip
801 801 parent: 0:67e992f2c4f3
802 802 user: test
803 803 date: Thu Jan 01 00:00:01 1970 +0000
804 804 summary: b2
805 805
806 806 changeset: 1:3d5bf5654eda
807 807 user: test
808 808 date: Thu Jan 01 00:00:01 1970 +0000
809 809 summary: r1
810 810
811 811 changeset: 0:67e992f2c4f3
812 812 user: test
813 813 date: Thu Jan 01 00:00:01 1970 +0000
814 814 summary: base
815 815
816 816
817 817 log -fr with aliases: 'A' should be expanded, but 'reverse()' should have no
818 818 effect
819 819
820 820 $ hg log --config 'revsetalias.reverse(x)=x' --config 'revsetalias.A=1+4' -qfrA
821 821 4:ddb82e70d1a1
822 822 1:3d5bf5654eda
823 823 0:67e992f2c4f3
824 824
825 825 log -r "follow('set:grep(b2)')"
826 826
827 827 $ hg log -r "follow('set:grep(b2)')"
828 828 changeset: 4:ddb82e70d1a1
829 829 tag: tip
830 830 parent: 0:67e992f2c4f3
831 831 user: test
832 832 date: Thu Jan 01 00:00:01 1970 +0000
833 833 summary: b2
834 834
835 835 log -r "follow('set:grep(b2)', 4)"
836 836
837 837 $ hg up -qC 0
838 838 $ hg log -r "follow('set:grep(b2)', 4)"
839 839 changeset: 4:ddb82e70d1a1
840 840 tag: tip
841 841 parent: 0:67e992f2c4f3
842 842 user: test
843 843 date: Thu Jan 01 00:00:01 1970 +0000
844 844 summary: b2
845 845
846 846
847 847 follow files starting from multiple revisions:
848 848
849 849 $ hg log -T '{rev}: {files}\n' -r "follow('glob:b?', startrev=2+3+4)"
850 850 3: b1
851 851 4: b2
852 852
853 853 follow files starting from empty revision:
854 854
855 855 $ hg log -T '{rev}: {files}\n' -r "follow('glob:*', startrev=.-.)"
856 856
857 857 follow starting from revisions:
858 858
859 859 $ hg log -Gq -r "follow(startrev=2+4)"
860 860 o 4:ddb82e70d1a1
861 861 |
862 862 | o 2:60c670bf5b30
863 863 | |
864 864 | o 1:3d5bf5654eda
865 865 |/
866 866 @ 0:67e992f2c4f3
867 867
868 868
869 869 follow the current revision:
870 870
871 871 $ hg log -Gq -r "follow()"
872 872 @ 0:67e992f2c4f3
873 873
874 874
875 875 $ hg up -qC 4
876 876
877 877 log -f -r null
878 878
879 879 $ hg log -f -r null
880 880 changeset: -1:000000000000
881 881 user:
882 882 date: Thu Jan 01 00:00:00 1970 +0000
883 883
884 884 $ hg log -f -r null -G
885 885 o changeset: -1:000000000000
886 886 user:
887 887 date: Thu Jan 01 00:00:00 1970 +0000
888 888
889 889
890 890
891 891 log -f with null parent
892 892
893 893 $ hg up -C null
894 894 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
895 895 $ hg log -f
896 896
897 897
898 898 log -r . with two parents
899 899
900 900 $ hg up -C 3
901 901 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
902 902 $ hg merge tip
903 903 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
904 904 (branch merge, don't forget to commit)
905 905 $ hg log -r .
906 906 changeset: 3:e62f78d544b4
907 907 parent: 1:3d5bf5654eda
908 908 user: test
909 909 date: Thu Jan 01 00:00:01 1970 +0000
910 910 summary: b1
911 911
912 912
913 913
914 914 log -r . with one parent
915 915
916 916 $ hg ci -mm12 -d '1 0'
917 917 $ hg log -r .
918 918 changeset: 5:302e9dd6890d
919 919 tag: tip
920 920 parent: 3:e62f78d544b4
921 921 parent: 4:ddb82e70d1a1
922 922 user: test
923 923 date: Thu Jan 01 00:00:01 1970 +0000
924 924 summary: m12
925 925
926 926
927 927 $ echo postm >> b1
928 928 $ hg ci -Amb1.1 -d'1 0'
929 929
930 930
931 931 log --follow-first
932 932
933 933 $ hg log --follow-first
934 934 changeset: 6:2404bbcab562
935 935 tag: tip
936 936 user: test
937 937 date: Thu Jan 01 00:00:01 1970 +0000
938 938 summary: b1.1
939 939
940 940 changeset: 5:302e9dd6890d
941 941 parent: 3:e62f78d544b4
942 942 parent: 4:ddb82e70d1a1
943 943 user: test
944 944 date: Thu Jan 01 00:00:01 1970 +0000
945 945 summary: m12
946 946
947 947 changeset: 3:e62f78d544b4
948 948 parent: 1:3d5bf5654eda
949 949 user: test
950 950 date: Thu Jan 01 00:00:01 1970 +0000
951 951 summary: b1
952 952
953 953 changeset: 1:3d5bf5654eda
954 954 user: test
955 955 date: Thu Jan 01 00:00:01 1970 +0000
956 956 summary: r1
957 957
958 958 changeset: 0:67e992f2c4f3
959 959 user: test
960 960 date: Thu Jan 01 00:00:01 1970 +0000
961 961 summary: base
962 962
963 963
964 964
965 965 log -P 2
966 966
967 967 $ hg log -P 2
968 968 changeset: 6:2404bbcab562
969 969 tag: tip
970 970 user: test
971 971 date: Thu Jan 01 00:00:01 1970 +0000
972 972 summary: b1.1
973 973
974 974 changeset: 5:302e9dd6890d
975 975 parent: 3:e62f78d544b4
976 976 parent: 4:ddb82e70d1a1
977 977 user: test
978 978 date: Thu Jan 01 00:00:01 1970 +0000
979 979 summary: m12
980 980
981 981 changeset: 4:ddb82e70d1a1
982 982 parent: 0:67e992f2c4f3
983 983 user: test
984 984 date: Thu Jan 01 00:00:01 1970 +0000
985 985 summary: b2
986 986
987 987 changeset: 3:e62f78d544b4
988 988 parent: 1:3d5bf5654eda
989 989 user: test
990 990 date: Thu Jan 01 00:00:01 1970 +0000
991 991 summary: b1
992 992
993 993
994 994
995 995 log -r tip -p --git
996 996
997 997 $ hg log -r tip -p --git
998 998 changeset: 6:2404bbcab562
999 999 tag: tip
1000 1000 user: test
1001 1001 date: Thu Jan 01 00:00:01 1970 +0000
1002 1002 summary: b1.1
1003 1003
1004 1004 diff --git a/b1 b/b1
1005 1005 --- a/b1
1006 1006 +++ b/b1
1007 1007 @@ -1,1 +1,2 @@
1008 1008 b1
1009 1009 +postm
1010 1010
1011 1011
1012 1012
1013 1013 log -r ""
1014 1014
1015 1015 $ hg log -r ''
1016 1016 hg: parse error: empty query
1017 1017 [255]
1018 1018
1019 1019 log -r <some unknown node id>
1020 1020
1021 1021 $ hg log -r 1000000000000000000000000000000000000000
1022 1022 abort: unknown revision '1000000000000000000000000000000000000000'!
1023 1023 [255]
1024 1024
1025 1025 log -k r1
1026 1026
1027 1027 $ hg log -k r1
1028 1028 changeset: 1:3d5bf5654eda
1029 1029 user: test
1030 1030 date: Thu Jan 01 00:00:01 1970 +0000
1031 1031 summary: r1
1032 1032
1033 1033 log -p -l2 --color=always
1034 1034
1035 1035 $ hg --config extensions.color= --config color.mode=ansi \
1036 1036 > log -p -l2 --color=always
1037 1037 \x1b[0;33mchangeset: 6:2404bbcab562\x1b[0m (esc)
1038 1038 tag: tip
1039 1039 user: test
1040 1040 date: Thu Jan 01 00:00:01 1970 +0000
1041 1041 summary: b1.1
1042 1042
1043 1043 \x1b[0;1mdiff -r 302e9dd6890d -r 2404bbcab562 b1\x1b[0m (esc)
1044 1044 \x1b[0;31;1m--- a/b1 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
1045 1045 \x1b[0;32;1m+++ b/b1 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
1046 1046 \x1b[0;35m@@ -1,1 +1,2 @@\x1b[0m (esc)
1047 1047 b1
1048 1048 \x1b[0;32m+postm\x1b[0m (esc)
1049 1049
1050 1050 \x1b[0;33mchangeset: 5:302e9dd6890d\x1b[0m (esc)
1051 1051 parent: 3:e62f78d544b4
1052 1052 parent: 4:ddb82e70d1a1
1053 1053 user: test
1054 1054 date: Thu Jan 01 00:00:01 1970 +0000
1055 1055 summary: m12
1056 1056
1057 1057 \x1b[0;1mdiff -r e62f78d544b4 -r 302e9dd6890d b2\x1b[0m (esc)
1058 1058 \x1b[0;31;1m--- /dev/null Thu Jan 01 00:00:00 1970 +0000\x1b[0m (esc)
1059 1059 \x1b[0;32;1m+++ b/b2 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
1060 1060 \x1b[0;35m@@ -0,0 +1,1 @@\x1b[0m (esc)
1061 1061 \x1b[0;32m+b2\x1b[0m (esc)
1062 1062
1063 1063
1064 1064
1065 1065 log -r tip --stat
1066 1066
1067 1067 $ hg log -r tip --stat
1068 1068 changeset: 6:2404bbcab562
1069 1069 tag: tip
1070 1070 user: test
1071 1071 date: Thu Jan 01 00:00:01 1970 +0000
1072 1072 summary: b1.1
1073 1073
1074 1074 b1 | 1 +
1075 1075 1 files changed, 1 insertions(+), 0 deletions(-)
1076 1076
1077 1077
1078 1078 $ cd ..
1079 1079
1080 1080 log --follow --patch FILE in repository where linkrev isn't trustworthy
1081 1081 (issue5376)
1082 1082
1083 1083 $ hg init follow-dup
1084 1084 $ cd follow-dup
1085 1085 $ cat <<EOF >> .hg/hgrc
1086 1086 > [ui]
1087 1087 > logtemplate = '=== {rev}: {desc}\n'
1088 1088 > [diff]
1089 1089 > nodates = True
1090 1090 > EOF
1091 1091 $ echo 0 >> a
1092 1092 $ hg ci -qAm 'a0'
1093 1093 $ echo 1 >> a
1094 1094 $ hg ci -m 'a1'
1095 1095 $ hg up -q 0
1096 1096 $ echo 1 >> a
1097 1097 $ touch b
1098 1098 $ hg ci -qAm 'a1 with b'
1099 1099 $ echo 3 >> a
1100 1100 $ hg ci -m 'a3'
1101 1101
1102 1102 fctx.rev() == 2, but fctx.linkrev() == 1
1103 1103
1104 1104 $ hg log -pf a
1105 1105 === 3: a3
1106 1106 diff -r 4ea02ba94d66 -r e7a6331a34f0 a
1107 1107 --- a/a
1108 1108 +++ b/a
1109 1109 @@ -1,2 +1,3 @@
1110 1110 0
1111 1111 1
1112 1112 +3
1113 1113
1114 1114 === 2: a1 with b
1115 1115 diff -r 49b5e81287e2 -r 4ea02ba94d66 a
1116 1116 --- a/a
1117 1117 +++ b/a
1118 1118 @@ -1,1 +1,2 @@
1119 1119 0
1120 1120 +1
1121 1121
1122 1122 === 0: a0
1123 1123 diff -r 000000000000 -r 49b5e81287e2 a
1124 1124 --- /dev/null
1125 1125 +++ b/a
1126 1126 @@ -0,0 +1,1 @@
1127 1127 +0
1128 1128
1129 1129
1130 1130 fctx.introrev() == 2, but fctx.linkrev() == 1
1131 1131
1132 1132 $ hg up -q 2
1133 1133 $ hg log -pf a
1134 1134 === 2: a1 with b
1135 1135 diff -r 49b5e81287e2 -r 4ea02ba94d66 a
1136 1136 --- a/a
1137 1137 +++ b/a
1138 1138 @@ -1,1 +1,2 @@
1139 1139 0
1140 1140 +1
1141 1141
1142 1142 === 0: a0
1143 1143 diff -r 000000000000 -r 49b5e81287e2 a
1144 1144 --- /dev/null
1145 1145 +++ b/a
1146 1146 @@ -0,0 +1,1 @@
1147 1147 +0
1148 1148
1149 1149
1150 1150 $ cd ..
1151 1151
1152 1152 Multiple copy sources of a file:
1153 1153
1154 1154 $ hg init follow-multi
1155 1155 $ cd follow-multi
1156 1156 $ echo 0 >> a
1157 1157 $ hg ci -qAm 'a'
1158 1158 $ hg cp a b
1159 1159 $ hg ci -m 'a->b'
1160 1160 $ echo 2 >> a
1161 1161 $ hg ci -m 'a'
1162 1162 $ echo 3 >> b
1163 1163 $ hg ci -m 'b'
1164 1164 $ echo 4 >> a
1165 1165 $ echo 4 >> b
1166 1166 $ hg ci -m 'a,b'
1167 1167 $ echo 5 >> a
1168 1168 $ hg ci -m 'a0'
1169 1169 $ echo 6 >> b
1170 1170 $ hg ci -m 'b0'
1171 1171 $ hg up -q 4
1172 1172 $ echo 7 >> b
1173 1173 $ hg ci -m 'b1'
1174 1174 created new head
1175 1175 $ echo 8 >> a
1176 1176 $ hg ci -m 'a1'
1177 1177 $ hg rm a
1178 1178 $ hg mv b a
1179 1179 $ hg ci -m 'b1->a1'
1180 1180 $ hg merge -qt :local
1181 1181 $ hg ci -m '(a0,b1->a1)->a'
1182 1182
1183 1183 $ hg log -GT '{rev}: {desc}\n'
1184 1184 @ 10: (a0,b1->a1)->a
1185 1185 |\
1186 1186 | o 9: b1->a1
1187 1187 | |
1188 1188 | o 8: a1
1189 1189 | |
1190 1190 | o 7: b1
1191 1191 | |
1192 1192 o | 6: b0
1193 1193 | |
1194 1194 o | 5: a0
1195 1195 |/
1196 1196 o 4: a,b
1197 1197 |
1198 1198 o 3: b
1199 1199 |
1200 1200 o 2: a
1201 1201 |
1202 1202 o 1: a->b
1203 1203 |
1204 1204 o 0: a
1205 1205
1206 1206
1207 1207 since file 'a' has multiple copy sources at the revision 4, ancestors can't
1208 1208 be indexed solely by fctx.linkrev().
1209 1209
1210 1210 $ hg log -T '{rev}: {desc}\n' -f a
1211 1211 10: (a0,b1->a1)->a
1212 1212 9: b1->a1
1213 1213 7: b1
1214 1214 5: a0
1215 1215 4: a,b
1216 1216 3: b
1217 1217 2: a
1218 1218 1: a->b
1219 1219 0: a
1220 1220
1221 1221 $ cd ..
1222 1222
1223 1223 Test that log should respect the order of -rREV even if multiple OR conditions
1224 1224 are specified (issue5100):
1225 1225
1226 1226 $ hg init revorder
1227 1227 $ cd revorder
1228 1228
1229 1229 $ hg branch -q b0
1230 1230 $ echo 0 >> f0
1231 1231 $ hg ci -qAm k0 -u u0
1232 1232 $ hg branch -q b1
1233 1233 $ echo 1 >> f1
1234 1234 $ hg ci -qAm k1 -u u1
1235 1235 $ hg branch -q b2
1236 1236 $ echo 2 >> f2
1237 1237 $ hg ci -qAm k2 -u u2
1238 1238
1239 1239 $ hg update -q b2
1240 1240 $ echo 3 >> f2
1241 1241 $ hg ci -qAm k2 -u u2
1242 1242 $ hg update -q b1
1243 1243 $ echo 4 >> f1
1244 1244 $ hg ci -qAm k1 -u u1
1245 1245 $ hg update -q b0
1246 1246 $ echo 5 >> f0
1247 1247 $ hg ci -qAm k0 -u u0
1248 1248
1249 1249 summary of revisions:
1250 1250
1251 1251 $ hg log -G -T '{rev} {branch} {author} {desc} {files}\n'
1252 1252 @ 5 b0 u0 k0 f0
1253 1253 |
1254 1254 | o 4 b1 u1 k1 f1
1255 1255 | |
1256 1256 | | o 3 b2 u2 k2 f2
1257 1257 | | |
1258 1258 | | o 2 b2 u2 k2 f2
1259 1259 | |/
1260 1260 | o 1 b1 u1 k1 f1
1261 1261 |/
1262 1262 o 0 b0 u0 k0 f0
1263 1263
1264 1264
1265 1265 log -b BRANCH in ascending order:
1266 1266
1267 1267 $ hg log -r0:tip -T '{rev} {branch}\n' -b b0 -b b1
1268 1268 0 b0
1269 1269 1 b1
1270 1270 4 b1
1271 1271 5 b0
1272 1272 $ hg log -r0:tip -T '{rev} {branch}\n' -b b1 -b b0
1273 1273 0 b0
1274 1274 1 b1
1275 1275 4 b1
1276 1276 5 b0
1277 1277
1278 1278 log --only-branch BRANCH in descending order:
1279 1279
1280 1280 $ hg log -rtip:0 -T '{rev} {branch}\n' --only-branch b1 --only-branch b2
1281 1281 4 b1
1282 1282 3 b2
1283 1283 2 b2
1284 1284 1 b1
1285 1285 $ hg log -rtip:0 -T '{rev} {branch}\n' --only-branch b2 --only-branch b1
1286 1286 4 b1
1287 1287 3 b2
1288 1288 2 b2
1289 1289 1 b1
1290 1290
1291 1291 log -u USER in ascending order, against compound set:
1292 1292
1293 1293 $ hg log -r'::head()' -T '{rev} {author}\n' -u u0 -u u2
1294 1294 0 u0
1295 1295 2 u2
1296 1296 3 u2
1297 1297 5 u0
1298 1298 $ hg log -r'::head()' -T '{rev} {author}\n' -u u2 -u u0
1299 1299 0 u0
1300 1300 2 u2
1301 1301 3 u2
1302 1302 5 u0
1303 1303
1304 1304 log -k TEXT in descending order, against compound set:
1305 1305
1306 1306 $ hg log -r'5 + reverse(::3)' -T '{rev} {desc}\n' -k k0 -k k1 -k k2
1307 1307 5 k0
1308 1308 3 k2
1309 1309 2 k2
1310 1310 1 k1
1311 1311 0 k0
1312 1312 $ hg log -r'5 + reverse(::3)' -T '{rev} {desc}\n' -k k2 -k k1 -k k0
1313 1313 5 k0
1314 1314 3 k2
1315 1315 2 k2
1316 1316 1 k1
1317 1317 0 k0
1318 1318
1319 1319 log FILE in ascending order, against dagrange:
1320 1320
1321 1321 $ hg log -r1:: -T '{rev} {files}\n' f1 f2
1322 1322 1 f1
1323 1323 2 f2
1324 1324 3 f2
1325 1325 4 f1
1326 1326 $ hg log -r1:: -T '{rev} {files}\n' f2 f1
1327 1327 1 f1
1328 1328 2 f2
1329 1329 3 f2
1330 1330 4 f1
1331 1331
1332 1332 $ cd ..
1333 1333
1334 1334 User
1335 1335
1336 1336 $ hg init usertest
1337 1337 $ cd usertest
1338 1338
1339 1339 $ echo a > a
1340 1340 $ hg ci -A -m "a" -u "User One <user1@example.org>"
1341 1341 adding a
1342 1342 $ echo b > b
1343 1343 $ hg ci -A -m "b" -u "User Two <user2@example.org>"
1344 1344 adding b
1345 1345
1346 1346 $ hg log -u "User One <user1@example.org>"
1347 1347 changeset: 0:29a4c94f1924
1348 1348 user: User One <user1@example.org>
1349 1349 date: Thu Jan 01 00:00:00 1970 +0000
1350 1350 summary: a
1351 1351
1352 1352 $ hg log -u "user1" -u "user2"
1353 1353 changeset: 1:e834b5e69c0e
1354 1354 tag: tip
1355 1355 user: User Two <user2@example.org>
1356 1356 date: Thu Jan 01 00:00:00 1970 +0000
1357 1357 summary: b
1358 1358
1359 1359 changeset: 0:29a4c94f1924
1360 1360 user: User One <user1@example.org>
1361 1361 date: Thu Jan 01 00:00:00 1970 +0000
1362 1362 summary: a
1363 1363
1364 1364 $ hg log -u "user3"
1365 1365
1366 1366 "-u USER" shouldn't be overridden by "user(USER)" alias
1367 1367
1368 1368 $ hg log --config 'revsetalias.user(x)=branch(x)' -u default
1369 1369 $ hg log --config 'revsetalias.user(x)=branch(x)' -u user1
1370 1370 changeset: 0:29a4c94f1924
1371 1371 user: User One <user1@example.org>
1372 1372 date: Thu Jan 01 00:00:00 1970 +0000
1373 1373 summary: a
1374 1374
1375 1375
1376 1376 $ cd ..
1377 1377
1378 1378 $ hg init branches
1379 1379 $ cd branches
1380 1380
1381 1381 $ echo a > a
1382 1382 $ hg ci -A -m "commit on default"
1383 1383 adding a
1384 1384 $ hg branch test
1385 1385 marked working directory as branch test
1386 1386 (branches are permanent and global, did you want a bookmark?)
1387 1387 $ echo b > b
1388 1388 $ hg ci -A -m "commit on test"
1389 1389 adding b
1390 1390
1391 1391 $ hg up default
1392 1392 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1393 1393 $ echo c > c
1394 1394 $ hg ci -A -m "commit on default"
1395 1395 adding c
1396 1396 $ hg up test
1397 1397 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1398 1398 $ echo c > c
1399 1399 $ hg ci -A -m "commit on test"
1400 1400 adding c
1401 1401
1402 1402
1403 1403 log -b default
1404 1404
1405 1405 $ hg log -b default
1406 1406 changeset: 2:c3a4f03cc9a7
1407 1407 parent: 0:24427303d56f
1408 1408 user: test
1409 1409 date: Thu Jan 01 00:00:00 1970 +0000
1410 1410 summary: commit on default
1411 1411
1412 1412 changeset: 0:24427303d56f
1413 1413 user: test
1414 1414 date: Thu Jan 01 00:00:00 1970 +0000
1415 1415 summary: commit on default
1416 1416
1417 1417
1418 1418
1419 1419 log -b test
1420 1420
1421 1421 $ hg log -b test
1422 1422 changeset: 3:f5d8de11c2e2
1423 1423 branch: test
1424 1424 tag: tip
1425 1425 parent: 1:d32277701ccb
1426 1426 user: test
1427 1427 date: Thu Jan 01 00:00:00 1970 +0000
1428 1428 summary: commit on test
1429 1429
1430 1430 changeset: 1:d32277701ccb
1431 1431 branch: test
1432 1432 user: test
1433 1433 date: Thu Jan 01 00:00:00 1970 +0000
1434 1434 summary: commit on test
1435 1435
1436 1436
1437 1437
1438 1438 log -b dummy
1439 1439
1440 1440 $ hg log -b dummy
1441 1441 abort: unknown revision 'dummy'!
1442 1442 [255]
1443 1443
1444 1444
1445 1445 log -b .
1446 1446
1447 1447 $ hg log -b .
1448 1448 changeset: 3:f5d8de11c2e2
1449 1449 branch: test
1450 1450 tag: tip
1451 1451 parent: 1:d32277701ccb
1452 1452 user: test
1453 1453 date: Thu Jan 01 00:00:00 1970 +0000
1454 1454 summary: commit on test
1455 1455
1456 1456 changeset: 1:d32277701ccb
1457 1457 branch: test
1458 1458 user: test
1459 1459 date: Thu Jan 01 00:00:00 1970 +0000
1460 1460 summary: commit on test
1461 1461
1462 1462
1463 1463
1464 1464 log -b default -b test
1465 1465
1466 1466 $ hg log -b default -b test
1467 1467 changeset: 3:f5d8de11c2e2
1468 1468 branch: test
1469 1469 tag: tip
1470 1470 parent: 1:d32277701ccb
1471 1471 user: test
1472 1472 date: Thu Jan 01 00:00:00 1970 +0000
1473 1473 summary: commit on test
1474 1474
1475 1475 changeset: 2:c3a4f03cc9a7
1476 1476 parent: 0:24427303d56f
1477 1477 user: test
1478 1478 date: Thu Jan 01 00:00:00 1970 +0000
1479 1479 summary: commit on default
1480 1480
1481 1481 changeset: 1:d32277701ccb
1482 1482 branch: test
1483 1483 user: test
1484 1484 date: Thu Jan 01 00:00:00 1970 +0000
1485 1485 summary: commit on test
1486 1486
1487 1487 changeset: 0:24427303d56f
1488 1488 user: test
1489 1489 date: Thu Jan 01 00:00:00 1970 +0000
1490 1490 summary: commit on default
1491 1491
1492 1492
1493 1493
1494 1494 log -b default -b .
1495 1495
1496 1496 $ hg log -b default -b .
1497 1497 changeset: 3:f5d8de11c2e2
1498 1498 branch: test
1499 1499 tag: tip
1500 1500 parent: 1:d32277701ccb
1501 1501 user: test
1502 1502 date: Thu Jan 01 00:00:00 1970 +0000
1503 1503 summary: commit on test
1504 1504
1505 1505 changeset: 2:c3a4f03cc9a7
1506 1506 parent: 0:24427303d56f
1507 1507 user: test
1508 1508 date: Thu Jan 01 00:00:00 1970 +0000
1509 1509 summary: commit on default
1510 1510
1511 1511 changeset: 1:d32277701ccb
1512 1512 branch: test
1513 1513 user: test
1514 1514 date: Thu Jan 01 00:00:00 1970 +0000
1515 1515 summary: commit on test
1516 1516
1517 1517 changeset: 0:24427303d56f
1518 1518 user: test
1519 1519 date: Thu Jan 01 00:00:00 1970 +0000
1520 1520 summary: commit on default
1521 1521
1522 1522
1523 1523
1524 1524 log -b . -b test
1525 1525
1526 1526 $ hg log -b . -b test
1527 1527 changeset: 3:f5d8de11c2e2
1528 1528 branch: test
1529 1529 tag: tip
1530 1530 parent: 1:d32277701ccb
1531 1531 user: test
1532 1532 date: Thu Jan 01 00:00:00 1970 +0000
1533 1533 summary: commit on test
1534 1534
1535 1535 changeset: 1:d32277701ccb
1536 1536 branch: test
1537 1537 user: test
1538 1538 date: Thu Jan 01 00:00:00 1970 +0000
1539 1539 summary: commit on test
1540 1540
1541 1541
1542 1542
1543 1543 log -b 2
1544 1544
1545 1545 $ hg log -b 2
1546 1546 changeset: 2:c3a4f03cc9a7
1547 1547 parent: 0:24427303d56f
1548 1548 user: test
1549 1549 date: Thu Jan 01 00:00:00 1970 +0000
1550 1550 summary: commit on default
1551 1551
1552 1552 changeset: 0:24427303d56f
1553 1553 user: test
1554 1554 date: Thu Jan 01 00:00:00 1970 +0000
1555 1555 summary: commit on default
1556 1556
1557 1557 #if gettext
1558 1558
1559 1559 Test that all log names are translated (e.g. branches, bookmarks, tags):
1560 1560
1561 1561 $ hg bookmark babar -r tip
1562 1562
1563 1563 $ HGENCODING=UTF-8 LANGUAGE=de hg log -r tip
1564 1564 \xc3\x84nderung: 3:f5d8de11c2e2 (esc)
1565 1565 Zweig: test
1566 1566 Lesezeichen: babar
1567 1567 Marke: tip
1568 1568 Vorg\xc3\xa4nger: 1:d32277701ccb (esc)
1569 1569 Nutzer: test
1570 1570 Datum: Thu Jan 01 00:00:00 1970 +0000
1571 1571 Zusammenfassung: commit on test
1572 1572
1573 1573 $ hg bookmark -d babar
1574 1574
1575 1575 #endif
1576 1576
1577 1577 log -p --cwd dir (in subdir)
1578 1578
1579 1579 $ mkdir dir
1580 1580 $ hg log -p --cwd dir
1581 1581 changeset: 3:f5d8de11c2e2
1582 1582 branch: test
1583 1583 tag: tip
1584 1584 parent: 1:d32277701ccb
1585 1585 user: test
1586 1586 date: Thu Jan 01 00:00:00 1970 +0000
1587 1587 summary: commit on test
1588 1588
1589 1589 diff -r d32277701ccb -r f5d8de11c2e2 c
1590 1590 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1591 1591 +++ b/c Thu Jan 01 00:00:00 1970 +0000
1592 1592 @@ -0,0 +1,1 @@
1593 1593 +c
1594 1594
1595 1595 changeset: 2:c3a4f03cc9a7
1596 1596 parent: 0:24427303d56f
1597 1597 user: test
1598 1598 date: Thu Jan 01 00:00:00 1970 +0000
1599 1599 summary: commit on default
1600 1600
1601 1601 diff -r 24427303d56f -r c3a4f03cc9a7 c
1602 1602 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1603 1603 +++ b/c Thu Jan 01 00:00:00 1970 +0000
1604 1604 @@ -0,0 +1,1 @@
1605 1605 +c
1606 1606
1607 1607 changeset: 1:d32277701ccb
1608 1608 branch: test
1609 1609 user: test
1610 1610 date: Thu Jan 01 00:00:00 1970 +0000
1611 1611 summary: commit on test
1612 1612
1613 1613 diff -r 24427303d56f -r d32277701ccb b
1614 1614 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1615 1615 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1616 1616 @@ -0,0 +1,1 @@
1617 1617 +b
1618 1618
1619 1619 changeset: 0:24427303d56f
1620 1620 user: test
1621 1621 date: Thu Jan 01 00:00:00 1970 +0000
1622 1622 summary: commit on default
1623 1623
1624 1624 diff -r 000000000000 -r 24427303d56f a
1625 1625 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1626 1626 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1627 1627 @@ -0,0 +1,1 @@
1628 1628 +a
1629 1629
1630 1630
1631 1631
1632 1632 log -p -R repo
1633 1633
1634 1634 $ cd dir
1635 1635 $ hg log -p -R .. ../a
1636 1636 changeset: 0:24427303d56f
1637 1637 user: test
1638 1638 date: Thu Jan 01 00:00:00 1970 +0000
1639 1639 summary: commit on default
1640 1640
1641 1641 diff -r 000000000000 -r 24427303d56f a
1642 1642 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1643 1643 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1644 1644 @@ -0,0 +1,1 @@
1645 1645 +a
1646 1646
1647 1647
1648 1648 $ cd ../..
1649 1649
1650 1650 $ hg init follow2
1651 1651 $ cd follow2
1652 1652
1653 1653 # Build the following history:
1654 1654 # tip - o - x - o - x - x
1655 1655 # \ /
1656 1656 # o - o - o - x
1657 1657 # \ /
1658 1658 # o
1659 1659 #
1660 1660 # Where "o" is a revision containing "foo" and
1661 1661 # "x" is a revision without "foo"
1662 1662
1663 1663 $ touch init
1664 1664 $ hg ci -A -m "init, unrelated"
1665 1665 adding init
1666 1666 $ echo 'foo' > init
1667 1667 $ hg ci -m "change, unrelated"
1668 1668 $ echo 'foo' > foo
1669 1669 $ hg ci -A -m "add unrelated old foo"
1670 1670 adding foo
1671 1671 $ hg rm foo
1672 1672 $ hg ci -m "delete foo, unrelated"
1673 1673 $ echo 'related' > foo
1674 1674 $ hg ci -A -m "add foo, related"
1675 1675 adding foo
1676 1676
1677 1677 $ hg up 0
1678 1678 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1679 1679 $ touch branch
1680 1680 $ hg ci -A -m "first branch, unrelated"
1681 1681 adding branch
1682 1682 created new head
1683 1683 $ touch foo
1684 1684 $ hg ci -A -m "create foo, related"
1685 1685 adding foo
1686 1686 $ echo 'change' > foo
1687 1687 $ hg ci -m "change foo, related"
1688 1688
1689 1689 $ hg up 6
1690 1690 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1691 1691 $ echo 'change foo in branch' > foo
1692 1692 $ hg ci -m "change foo in branch, related"
1693 1693 created new head
1694 1694 $ hg merge 7
1695 1695 merging foo
1696 1696 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
1697 1697 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1698 1698 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1699 1699 [1]
1700 1700 $ echo 'merge 1' > foo
1701 1701 $ hg resolve -m foo
1702 1702 (no more unresolved files)
1703 1703 $ hg ci -m "First merge, related"
1704 1704
1705 1705 $ hg merge 4
1706 1706 merging foo
1707 1707 warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
1708 1708 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
1709 1709 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1710 1710 [1]
1711 1711 $ echo 'merge 2' > foo
1712 1712 $ hg resolve -m foo
1713 1713 (no more unresolved files)
1714 1714 $ hg ci -m "Last merge, related"
1715 1715
1716 1716 $ hg log --graph
1717 1717 @ changeset: 10:4dae8563d2c5
1718 1718 |\ tag: tip
1719 1719 | | parent: 9:7b35701b003e
1720 1720 | | parent: 4:88176d361b69
1721 1721 | | user: test
1722 1722 | | date: Thu Jan 01 00:00:00 1970 +0000
1723 1723 | | summary: Last merge, related
1724 1724 | |
1725 1725 | o changeset: 9:7b35701b003e
1726 1726 | |\ parent: 8:e5416ad8a855
1727 1727 | | | parent: 7:87fe3144dcfa
1728 1728 | | | user: test
1729 1729 | | | date: Thu Jan 01 00:00:00 1970 +0000
1730 1730 | | | summary: First merge, related
1731 1731 | | |
1732 1732 | | o changeset: 8:e5416ad8a855
1733 1733 | | | parent: 6:dc6c325fe5ee
1734 1734 | | | user: test
1735 1735 | | | date: Thu Jan 01 00:00:00 1970 +0000
1736 1736 | | | summary: change foo in branch, related
1737 1737 | | |
1738 1738 | o | changeset: 7:87fe3144dcfa
1739 1739 | |/ user: test
1740 1740 | | date: Thu Jan 01 00:00:00 1970 +0000
1741 1741 | | summary: change foo, related
1742 1742 | |
1743 1743 | o changeset: 6:dc6c325fe5ee
1744 1744 | | user: test
1745 1745 | | date: Thu Jan 01 00:00:00 1970 +0000
1746 1746 | | summary: create foo, related
1747 1747 | |
1748 1748 | o changeset: 5:73db34516eb9
1749 1749 | | parent: 0:e87515fd044a
1750 1750 | | user: test
1751 1751 | | date: Thu Jan 01 00:00:00 1970 +0000
1752 1752 | | summary: first branch, unrelated
1753 1753 | |
1754 1754 o | changeset: 4:88176d361b69
1755 1755 | | user: test
1756 1756 | | date: Thu Jan 01 00:00:00 1970 +0000
1757 1757 | | summary: add foo, related
1758 1758 | |
1759 1759 o | changeset: 3:dd78ae4afb56
1760 1760 | | user: test
1761 1761 | | date: Thu Jan 01 00:00:00 1970 +0000
1762 1762 | | summary: delete foo, unrelated
1763 1763 | |
1764 1764 o | changeset: 2:c4c64aedf0f7
1765 1765 | | user: test
1766 1766 | | date: Thu Jan 01 00:00:00 1970 +0000
1767 1767 | | summary: add unrelated old foo
1768 1768 | |
1769 1769 o | changeset: 1:e5faa7440653
1770 1770 |/ user: test
1771 1771 | date: Thu Jan 01 00:00:00 1970 +0000
1772 1772 | summary: change, unrelated
1773 1773 |
1774 1774 o changeset: 0:e87515fd044a
1775 1775 user: test
1776 1776 date: Thu Jan 01 00:00:00 1970 +0000
1777 1777 summary: init, unrelated
1778 1778
1779 1779
1780 1780 $ hg --traceback log -f foo
1781 1781 changeset: 10:4dae8563d2c5
1782 1782 tag: tip
1783 1783 parent: 9:7b35701b003e
1784 1784 parent: 4:88176d361b69
1785 1785 user: test
1786 1786 date: Thu Jan 01 00:00:00 1970 +0000
1787 1787 summary: Last merge, related
1788 1788
1789 1789 changeset: 9:7b35701b003e
1790 1790 parent: 8:e5416ad8a855
1791 1791 parent: 7:87fe3144dcfa
1792 1792 user: test
1793 1793 date: Thu Jan 01 00:00:00 1970 +0000
1794 1794 summary: First merge, related
1795 1795
1796 1796 changeset: 8:e5416ad8a855
1797 1797 parent: 6:dc6c325fe5ee
1798 1798 user: test
1799 1799 date: Thu Jan 01 00:00:00 1970 +0000
1800 1800 summary: change foo in branch, related
1801 1801
1802 1802 changeset: 7:87fe3144dcfa
1803 1803 user: test
1804 1804 date: Thu Jan 01 00:00:00 1970 +0000
1805 1805 summary: change foo, related
1806 1806
1807 1807 changeset: 6:dc6c325fe5ee
1808 1808 user: test
1809 1809 date: Thu Jan 01 00:00:00 1970 +0000
1810 1810 summary: create foo, related
1811 1811
1812 1812 changeset: 4:88176d361b69
1813 1813 user: test
1814 1814 date: Thu Jan 01 00:00:00 1970 +0000
1815 1815 summary: add foo, related
1816 1816
1817 1817
1818 1818 Also check when maxrev < lastrevfilelog
1819 1819
1820 1820 $ hg --traceback log -f -r4 foo
1821 1821 changeset: 4:88176d361b69
1822 1822 user: test
1823 1823 date: Thu Jan 01 00:00:00 1970 +0000
1824 1824 summary: add foo, related
1825 1825
1826 1826 $ cd ..
1827 1827
1828 1828 Issue2383: hg log showing _less_ differences than hg diff
1829 1829
1830 1830 $ hg init issue2383
1831 1831 $ cd issue2383
1832 1832
1833 1833 Create a test repo:
1834 1834
1835 1835 $ echo a > a
1836 1836 $ hg ci -Am0
1837 1837 adding a
1838 1838 $ echo b > b
1839 1839 $ hg ci -Am1
1840 1840 adding b
1841 1841 $ hg co 0
1842 1842 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1843 1843 $ echo b > a
1844 1844 $ hg ci -m2
1845 1845 created new head
1846 1846
1847 1847 Merge:
1848 1848
1849 1849 $ hg merge
1850 1850 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1851 1851 (branch merge, don't forget to commit)
1852 1852
1853 1853 Make sure there's a file listed in the merge to trigger the bug:
1854 1854
1855 1855 $ echo c > a
1856 1856 $ hg ci -m3
1857 1857
1858 1858 Two files shown here in diff:
1859 1859
1860 1860 $ hg diff --rev 2:3
1861 1861 diff -r b09be438c43a -r 8e07aafe1edc a
1862 1862 --- a/a Thu Jan 01 00:00:00 1970 +0000
1863 1863 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1864 1864 @@ -1,1 +1,1 @@
1865 1865 -b
1866 1866 +c
1867 1867 diff -r b09be438c43a -r 8e07aafe1edc b
1868 1868 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1869 1869 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1870 1870 @@ -0,0 +1,1 @@
1871 1871 +b
1872 1872
1873 1873 Diff here should be the same:
1874 1874
1875 1875 $ hg log -vpr 3
1876 1876 changeset: 3:8e07aafe1edc
1877 1877 tag: tip
1878 1878 parent: 2:b09be438c43a
1879 1879 parent: 1:925d80f479bb
1880 1880 user: test
1881 1881 date: Thu Jan 01 00:00:00 1970 +0000
1882 1882 files: a
1883 1883 description:
1884 1884 3
1885 1885
1886 1886
1887 1887 diff -r b09be438c43a -r 8e07aafe1edc a
1888 1888 --- a/a Thu Jan 01 00:00:00 1970 +0000
1889 1889 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1890 1890 @@ -1,1 +1,1 @@
1891 1891 -b
1892 1892 +c
1893 1893 diff -r b09be438c43a -r 8e07aafe1edc b
1894 1894 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1895 1895 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1896 1896 @@ -0,0 +1,1 @@
1897 1897 +b
1898 1898
1899 1899 $ cd ..
1900 1900
1901 1901 'hg log -r rev fn' when last(filelog(fn)) != rev
1902 1902
1903 1903 $ hg init simplelog
1904 1904 $ cd simplelog
1905 1905 $ echo f > a
1906 1906 $ hg ci -Am'a' -d '0 0'
1907 1907 adding a
1908 1908 $ echo f >> a
1909 1909 $ hg ci -Am'a bis' -d '1 0'
1910 1910
1911 1911 $ hg log -r0 a
1912 1912 changeset: 0:9f758d63dcde
1913 1913 user: test
1914 1914 date: Thu Jan 01 00:00:00 1970 +0000
1915 1915 summary: a
1916 1916
1917 1917 enable obsolete to test hidden feature
1918 1918
1919 1919 $ cat >> $HGRCPATH << EOF
1920 1920 > [experimental]
1921 1921 > evolution.createmarkers=True
1922 1922 > EOF
1923 1923
1924 1924 $ hg log --template='{rev}:{node}\n'
1925 1925 1:a765632148dc55d38c35c4f247c618701886cb2f
1926 1926 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1927 1927 $ hg debugobsolete a765632148dc55d38c35c4f247c618701886cb2f
1928 1928 obsoleted 1 changesets
1929 1929 $ hg up null -q
1930 1930 $ hg log --template='{rev}:{node}\n'
1931 1931 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1932 1932 $ hg log --template='{rev}:{node}\n' --hidden
1933 1933 1:a765632148dc55d38c35c4f247c618701886cb2f
1934 1934 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1935 1935 $ hg log -r a
1936 1936 abort: hidden revision 'a' is pruned!
1937 1937 (use --hidden to access hidden revisions)
1938 1938 [255]
1939 1939
1940 1940 test that parent prevent a changeset to be hidden
1941 1941
1942 1942 $ hg up 1 -q --hidden
1943 1943 updating to a hidden changeset a765632148dc
1944 1944 (hidden revision 'a765632148dc' is pruned)
1945 1945 $ hg log --template='{rev}:{node}\n'
1946 1946 1:a765632148dc55d38c35c4f247c618701886cb2f
1947 1947 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1948 1948
1949 1949 test that second parent prevent a changeset to be hidden too
1950 1950
1951 1951 $ hg debugsetparents 0 1 # nothing suitable to merge here
1952 1952 $ hg log --template='{rev}:{node}\n'
1953 1953 1:a765632148dc55d38c35c4f247c618701886cb2f
1954 1954 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1955 1955 $ hg debugsetparents 1
1956 1956 $ hg up -q null
1957 1957
1958 1958 bookmarks prevent a changeset being hidden
1959 1959
1960 1960 $ hg bookmark --hidden -r 1 X
1961 1961 bookmarking hidden changeset a765632148dc
1962 1962 (hidden revision 'a765632148dc' is pruned)
1963 1963 $ hg log --template '{rev}:{node}\n'
1964 1964 1:a765632148dc55d38c35c4f247c618701886cb2f
1965 1965 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1966 1966 $ hg bookmark -d X
1967 1967
1968 1968 divergent bookmarks are not hidden
1969 1969
1970 1970 $ hg bookmark --hidden -r 1 X@foo
1971 1971 bookmarking hidden changeset a765632148dc
1972 1972 (hidden revision 'a765632148dc' is pruned)
1973 1973 $ hg log --template '{rev}:{node}\n'
1974 1974 1:a765632148dc55d38c35c4f247c618701886cb2f
1975 1975 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1976 1976
1977 1977 test hidden revision 0 (issue5385)
1978 1978
1979 1979 $ hg bookmark -d X@foo
1980 1980 $ hg up null -q
1981 1981 $ hg debugobsolete 9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1982 1982 obsoleted 1 changesets
1983 1983 $ echo f > b
1984 1984 $ hg ci -Am'b' -d '2 0'
1985 1985 adding b
1986 1986 $ echo f >> b
1987 1987 $ hg ci -m'b bis' -d '3 0'
1988 1988 $ hg log -T'{rev}:{node}\n'
1989 1989 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1990 1990 2:94375ec45bddd2a824535fc04855bd058c926ec0
1991 1991
1992 1992 $ hg log -T'{rev}:{node}\n' -r:
1993 1993 2:94375ec45bddd2a824535fc04855bd058c926ec0
1994 1994 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1995 1995 $ hg log -T'{rev}:{node}\n' -r:tip
1996 1996 2:94375ec45bddd2a824535fc04855bd058c926ec0
1997 1997 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
1998 1998 $ hg log -T'{rev}:{node}\n' -r:0
1999 1999 abort: hidden revision '0' is pruned!
2000 2000 (use --hidden to access hidden revisions)
2001 2001 [255]
2002 2002 $ hg log -T'{rev}:{node}\n' -f
2003 2003 3:d7d28b288a6b83d5d2cf49f10c5974deed3a1d2e
2004 2004 2:94375ec45bddd2a824535fc04855bd058c926ec0
2005 2005
2006 2006 clear extensions configuration
2007 2007 $ echo '[extensions]' >> $HGRCPATH
2008 2008 $ echo "obs=!" >> $HGRCPATH
2009 2009 $ cd ..
2010 2010
2011 2011 test -u/-k for problematic encoding
2012 2012 # unicode: cp932:
2013 2013 # u30A2 0x83 0x41(= 'A')
2014 2014 # u30C2 0x83 0x61(= 'a')
2015 2015
2016 2016 $ hg init problematicencoding
2017 2017 $ cd problematicencoding
2018 2018
2019 2019 >>> with open('setup.sh', 'wb') as f:
2020 2020 ... f.write(u'''
2021 2021 ... echo a > text
2022 2022 ... hg add text
2023 2023 ... hg --encoding utf-8 commit -u '\u30A2' -m none
2024 2024 ... echo b > text
2025 2025 ... hg --encoding utf-8 commit -u '\u30C2' -m none
2026 2026 ... echo c > text
2027 2027 ... hg --encoding utf-8 commit -u none -m '\u30A2'
2028 2028 ... echo d > text
2029 2029 ... hg --encoding utf-8 commit -u none -m '\u30C2'
2030 2030 ... '''.encode('utf-8')) and None
2031 2031 $ sh < setup.sh
2032 2032
2033 2033 test in problematic encoding
2034 2034 >>> with open('test.sh', 'wb') as f:
2035 2035 ... f.write(u'''
2036 2036 ... hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2'
2037 2037 ... echo ====
2038 2038 ... hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2'
2039 2039 ... echo ====
2040 2040 ... hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2'
2041 2041 ... echo ====
2042 2042 ... hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2'
2043 2043 ... '''.encode('cp932')) and None
2044 2044 $ sh < test.sh
2045 2045 0
2046 2046 ====
2047 2047 1
2048 2048 ====
2049 2049 2
2050 2050 0
2051 2051 ====
2052 2052 3
2053 2053 1
2054 2054
2055 2055 $ cd ..
2056 2056
2057 2057 test hg log on non-existent files and on directories
2058 2058 $ hg init issue1340
2059 2059 $ cd issue1340
2060 2060 $ mkdir d1; mkdir D2; mkdir D3.i; mkdir d4.hg; mkdir d5.d; mkdir .d6
2061 2061 $ echo 1 > d1/f1
2062 2062 $ echo 1 > D2/f1
2063 2063 $ echo 1 > D3.i/f1
2064 2064 $ echo 1 > d4.hg/f1
2065 2065 $ echo 1 > d5.d/f1
2066 2066 $ echo 1 > .d6/f1
2067 2067 $ hg -q add .
2068 2068 $ hg commit -m "a bunch of weird directories"
2069 2069 $ hg log -l1 d1/f1 | grep changeset
2070 2070 changeset: 0:65624cd9070a
2071 2071 $ hg log -l1 f1
2072 2072 $ hg log -l1 . | grep changeset
2073 2073 changeset: 0:65624cd9070a
2074 2074 $ hg log -l1 ./ | grep changeset
2075 2075 changeset: 0:65624cd9070a
2076 2076 $ hg log -l1 d1 | grep changeset
2077 2077 changeset: 0:65624cd9070a
2078 2078 $ hg log -l1 D2 | grep changeset
2079 2079 changeset: 0:65624cd9070a
2080 2080 $ hg log -l1 D2/f1 | grep changeset
2081 2081 changeset: 0:65624cd9070a
2082 2082 $ hg log -l1 D3.i | grep changeset
2083 2083 changeset: 0:65624cd9070a
2084 2084 $ hg log -l1 D3.i/f1 | grep changeset
2085 2085 changeset: 0:65624cd9070a
2086 2086 $ hg log -l1 d4.hg | grep changeset
2087 2087 changeset: 0:65624cd9070a
2088 2088 $ hg log -l1 d4.hg/f1 | grep changeset
2089 2089 changeset: 0:65624cd9070a
2090 2090 $ hg log -l1 d5.d | grep changeset
2091 2091 changeset: 0:65624cd9070a
2092 2092 $ hg log -l1 d5.d/f1 | grep changeset
2093 2093 changeset: 0:65624cd9070a
2094 2094 $ hg log -l1 .d6 | grep changeset
2095 2095 changeset: 0:65624cd9070a
2096 2096 $ hg log -l1 .d6/f1 | grep changeset
2097 2097 changeset: 0:65624cd9070a
2098 2098
2099 2099 issue3772: hg log -r :null showing revision 0 as well
2100 2100
2101 2101 $ hg log -r :null
2102 2102 changeset: 0:65624cd9070a
2103 2103 tag: tip
2104 2104 user: test
2105 2105 date: Thu Jan 01 00:00:00 1970 +0000
2106 2106 summary: a bunch of weird directories
2107 2107
2108 2108 changeset: -1:000000000000
2109 2109 user:
2110 2110 date: Thu Jan 01 00:00:00 1970 +0000
2111 2111
2112 2112 $ hg log -r null:null
2113 2113 changeset: -1:000000000000
2114 2114 user:
2115 2115 date: Thu Jan 01 00:00:00 1970 +0000
2116 2116
2117 2117 working-directory revision requires special treatment
2118 2118
2119 2119 clean:
2120 2120
2121 2121 $ hg log -r 'wdir()' --debug
2122 2122 changeset: 2147483647:ffffffffffffffffffffffffffffffffffffffff
2123 2123 phase: draft
2124 2124 parent: 0:65624cd9070a035fa7191a54f2b8af39f16b0c08
2125 2125 parent: -1:0000000000000000000000000000000000000000
2126 2126 user: test
2127 2127 date: [A-Za-z0-9:+ ]+ (re)
2128 2128 extra: branch=default
2129 2129
2130 2130 $ hg log -r 'wdir()' -p --stat
2131 2131 changeset: 2147483647:ffffffffffff
2132 2132 parent: 0:65624cd9070a
2133 2133 user: test
2134 2134 date: [A-Za-z0-9:+ ]+ (re)
2135 2135
2136 2136
2137 2137
2138 2138
2139 2139 dirty:
2140 2140
2141 2141 $ echo 2 >> d1/f1
2142 2142 $ echo 2 > d1/f2
2143 2143 $ hg add d1/f2
2144 2144 $ hg remove .d6/f1
2145 2145 $ hg status
2146 2146 M d1/f1
2147 2147 A d1/f2
2148 2148 R .d6/f1
2149 2149
2150 2150 $ hg log -r 'wdir()'
2151 2151 changeset: 2147483647:ffffffffffff
2152 2152 parent: 0:65624cd9070a
2153 2153 user: test
2154 2154 date: [A-Za-z0-9:+ ]+ (re)
2155 2155
2156 2156 $ hg log -r 'wdir()' -q
2157 2157 2147483647:ffffffffffff
2158 2158
2159 2159 $ hg log -r 'wdir()' --debug
2160 2160 changeset: 2147483647:ffffffffffffffffffffffffffffffffffffffff
2161 2161 phase: draft
2162 2162 parent: 0:65624cd9070a035fa7191a54f2b8af39f16b0c08
2163 2163 parent: -1:0000000000000000000000000000000000000000
2164 2164 user: test
2165 2165 date: [A-Za-z0-9:+ ]+ (re)
2166 2166 files: d1/f1
2167 2167 files+: d1/f2
2168 2168 files-: .d6/f1
2169 2169 extra: branch=default
2170 2170
2171 2171 $ hg log -r 'wdir()' -p --stat --git
2172 2172 changeset: 2147483647:ffffffffffff
2173 2173 parent: 0:65624cd9070a
2174 2174 user: test
2175 2175 date: [A-Za-z0-9:+ ]+ (re)
2176 2176
2177 2177 .d6/f1 | 1 -
2178 2178 d1/f1 | 1 +
2179 2179 d1/f2 | 1 +
2180 2180 3 files changed, 2 insertions(+), 1 deletions(-)
2181 2181
2182 2182 diff --git a/.d6/f1 b/.d6/f1
2183 2183 deleted file mode 100644
2184 2184 --- a/.d6/f1
2185 2185 +++ /dev/null
2186 2186 @@ -1,1 +0,0 @@
2187 2187 -1
2188 2188 diff --git a/d1/f1 b/d1/f1
2189 2189 --- a/d1/f1
2190 2190 +++ b/d1/f1
2191 2191 @@ -1,1 +1,2 @@
2192 2192 1
2193 2193 +2
2194 2194 diff --git a/d1/f2 b/d1/f2
2195 2195 new file mode 100644
2196 2196 --- /dev/null
2197 2197 +++ b/d1/f2
2198 2198 @@ -0,0 +1,1 @@
2199 2199 +2
2200 2200
2201 2201 $ hg log -r 'wdir()' -Tjson
2202 2202 [
2203 2203 {
2204 "rev": null,
2205 "node": null,
2204 "bookmarks": [],
2206 2205 "branch": "default",
2207 "phase": "draft",
2208 "user": "test",
2209 2206 "date": [*, 0], (glob)
2210 2207 "desc": "",
2211 "bookmarks": [],
2208 "node": null,
2209 "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"],
2210 "phase": "draft",
2211 "rev": null,
2212 2212 "tags": [],
2213 "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"]
2213 "user": "test"
2214 2214 }
2215 2215 ]
2216 2216
2217 2217 $ hg log -r 'wdir()' -Tjson -q
2218 2218 [
2219 2219 {
2220 "rev": null,
2221 "node": null
2220 "node": null,
2221 "rev": null
2222 2222 }
2223 2223 ]
2224 2224
2225 2225 $ hg log -r 'wdir()' -Tjson --debug
2226 2226 [
2227 2227 {
2228 "rev": null,
2229 "node": null,
2228 "added": ["d1/f2"],
2229 "bookmarks": [],
2230 2230 "branch": "default",
2231 "phase": "draft",
2232 "user": "test",
2233 2231 "date": [*, 0], (glob)
2234 2232 "desc": "",
2235 "bookmarks": [],
2236 "tags": [],
2237 "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"],
2233 "extra": {"branch": "default"},
2238 2234 "manifest": null,
2239 "extra": {"branch": "default"},
2240 2235 "modified": ["d1/f1"],
2241 "added": ["d1/f2"],
2242 "removed": [".d6/f1"]
2236 "node": null,
2237 "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"],
2238 "phase": "draft",
2239 "removed": [".d6/f1"],
2240 "rev": null,
2241 "tags": [],
2242 "user": "test"
2243 2243 }
2244 2244 ]
2245 2245
2246 2246 $ hg revert -aqC
2247 2247
2248 2248 Check that adding an arbitrary name shows up in log automatically
2249 2249
2250 2250 $ cat > ../names.py <<EOF
2251 2251 > """A small extension to test adding arbitrary names to a repo"""
2252 2252 > from __future__ import absolute_import
2253 2253 > from mercurial import namespaces
2254 2254 >
2255 2255 > def reposetup(ui, repo):
2256 2256 > foo = {b'foo': repo[0].node()}
2257 2257 > names = lambda r: foo.keys()
2258 2258 > namemap = lambda r, name: foo.get(name)
2259 2259 > nodemap = lambda r, node: [name for name, n in foo.items()
2260 2260 > if n == node]
2261 2261 > ns = namespaces.namespace(
2262 2262 > b"bars", templatename=b"bar", logname=b"barlog",
2263 2263 > colorname=b"barcolor", listnames=names, namemap=namemap,
2264 2264 > nodemap=nodemap)
2265 2265 >
2266 2266 > repo.names.addnamespace(ns)
2267 2267 > EOF
2268 2268
2269 2269 $ hg --config extensions.names=../names.py log -r 0
2270 2270 changeset: 0:65624cd9070a
2271 2271 tag: tip
2272 2272 barlog: foo
2273 2273 user: test
2274 2274 date: Thu Jan 01 00:00:00 1970 +0000
2275 2275 summary: a bunch of weird directories
2276 2276
2277 2277 $ hg --config extensions.names=../names.py \
2278 2278 > --config extensions.color= --config color.log.barcolor=red \
2279 2279 > --color=always log -r 0
2280 2280 \x1b[0;33mchangeset: 0:65624cd9070a\x1b[0m (esc)
2281 2281 tag: tip
2282 2282 \x1b[0;31mbarlog: foo\x1b[0m (esc)
2283 2283 user: test
2284 2284 date: Thu Jan 01 00:00:00 1970 +0000
2285 2285 summary: a bunch of weird directories
2286 2286
2287 2287 $ hg --config extensions.names=../names.py log -r 0 --template '{bars}\n'
2288 2288 foo
2289 2289
2290 2290 Templater parse errors:
2291 2291
2292 2292 simple error
2293 2293 $ hg log -r . -T '{shortest(node}'
2294 2294 hg: parse error at 14: unexpected token: end
2295 2295 ({shortest(node}
2296 2296 ^ here)
2297 2297 [255]
2298 2298
2299 2299 multi-line template with error
2300 2300 $ hg log -r . -T 'line 1
2301 2301 > line2
2302 2302 > {shortest(node}
2303 2303 > line4\nline5'
2304 2304 hg: parse error at 27: unexpected token: end
2305 2305 (line 1\nline2\n{shortest(node}\nline4\nline5
2306 2306 ^ here)
2307 2307 [255]
2308 2308
2309 2309 $ cd ..
2310 2310
2311 2311 hg log -f dir across branches
2312 2312
2313 2313 $ hg init acrossbranches
2314 2314 $ cd acrossbranches
2315 2315 $ mkdir d
2316 2316 $ echo a > d/a && hg ci -Aqm a
2317 2317 $ echo b > d/a && hg ci -Aqm b
2318 2318 $ hg up -q 0
2319 2319 $ echo b > d/a && hg ci -Aqm c
2320 2320 $ hg log -f d -T '{desc}' -G
2321 2321 @ c
2322 2322 |
2323 2323 o a
2324 2324
2325 2325 Ensure that largefiles doesn't interfere with following a normal file
2326 2326 $ hg --config extensions.largefiles= log -f d -T '{desc}' -G
2327 2327 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
2328 2328 @ c
2329 2329 |
2330 2330 o a
2331 2331
2332 2332 $ hg log -f d/a -T '{desc}' -G
2333 2333 @ c
2334 2334 |
2335 2335 o a
2336 2336
2337 2337 $ cd ..
2338 2338
2339 2339 hg log -f with linkrev pointing to another branch
2340 2340 -------------------------------------------------
2341 2341
2342 2342 create history with a filerev whose linkrev points to another branch
2343 2343
2344 2344 $ hg init branchedlinkrev
2345 2345 $ cd branchedlinkrev
2346 2346 $ echo 1 > a
2347 2347 $ hg commit -Am 'content1'
2348 2348 adding a
2349 2349 $ echo 2 > a
2350 2350 $ hg commit -m 'content2'
2351 2351 $ hg up --rev 'desc(content1)'
2352 2352 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
2353 2353 $ echo unrelated > unrelated
2354 2354 $ hg commit -Am 'unrelated'
2355 2355 adding unrelated
2356 2356 created new head
2357 2357 $ hg graft -r 'desc(content2)'
2358 2358 grafting 1:2294ae80ad84 "content2"
2359 2359 $ echo 3 > a
2360 2360 $ hg commit -m 'content3'
2361 2361 $ hg log -G
2362 2362 @ changeset: 4:50b9b36e9c5d
2363 2363 | tag: tip
2364 2364 | user: test
2365 2365 | date: Thu Jan 01 00:00:00 1970 +0000
2366 2366 | summary: content3
2367 2367 |
2368 2368 o changeset: 3:15b2327059e5
2369 2369 | user: test
2370 2370 | date: Thu Jan 01 00:00:00 1970 +0000
2371 2371 | summary: content2
2372 2372 |
2373 2373 o changeset: 2:2029acd1168c
2374 2374 | parent: 0:ae0a3c9f9e95
2375 2375 | user: test
2376 2376 | date: Thu Jan 01 00:00:00 1970 +0000
2377 2377 | summary: unrelated
2378 2378 |
2379 2379 | o changeset: 1:2294ae80ad84
2380 2380 |/ user: test
2381 2381 | date: Thu Jan 01 00:00:00 1970 +0000
2382 2382 | summary: content2
2383 2383 |
2384 2384 o changeset: 0:ae0a3c9f9e95
2385 2385 user: test
2386 2386 date: Thu Jan 01 00:00:00 1970 +0000
2387 2387 summary: content1
2388 2388
2389 2389
2390 2390 log -f on the file should list the graft result.
2391 2391
2392 2392 $ hg log -Gf a
2393 2393 @ changeset: 4:50b9b36e9c5d
2394 2394 | tag: tip
2395 2395 | user: test
2396 2396 | date: Thu Jan 01 00:00:00 1970 +0000
2397 2397 | summary: content3
2398 2398 |
2399 2399 o changeset: 3:15b2327059e5
2400 2400 : user: test
2401 2401 : date: Thu Jan 01 00:00:00 1970 +0000
2402 2402 : summary: content2
2403 2403 :
2404 2404 o changeset: 0:ae0a3c9f9e95
2405 2405 user: test
2406 2406 date: Thu Jan 01 00:00:00 1970 +0000
2407 2407 summary: content1
2408 2408
2409 2409
2410 2410 plain log lists the original version
2411 2411 (XXX we should probably list both)
2412 2412
2413 2413 $ hg log -G a
2414 2414 @ changeset: 4:50b9b36e9c5d
2415 2415 : tag: tip
2416 2416 : user: test
2417 2417 : date: Thu Jan 01 00:00:00 1970 +0000
2418 2418 : summary: content3
2419 2419 :
2420 2420 : o changeset: 1:2294ae80ad84
2421 2421 :/ user: test
2422 2422 : date: Thu Jan 01 00:00:00 1970 +0000
2423 2423 : summary: content2
2424 2424 :
2425 2425 o changeset: 0:ae0a3c9f9e95
2426 2426 user: test
2427 2427 date: Thu Jan 01 00:00:00 1970 +0000
2428 2428 summary: content1
2429 2429
2430 2430
2431 2431 hg log -f from the grafted changeset
2432 2432 (The bootstrap should properly take the topology in account)
2433 2433
2434 2434 $ hg up 'desc(content3)^'
2435 2435 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
2436 2436 $ hg log -Gf a
2437 2437 @ changeset: 3:15b2327059e5
2438 2438 : user: test
2439 2439 : date: Thu Jan 01 00:00:00 1970 +0000
2440 2440 : summary: content2
2441 2441 :
2442 2442 o changeset: 0:ae0a3c9f9e95
2443 2443 user: test
2444 2444 date: Thu Jan 01 00:00:00 1970 +0000
2445 2445 summary: content1
2446 2446
2447 2447
2448 2448 Test that we use the first non-hidden changeset in that case.
2449 2449
2450 2450 (hide the changeset)
2451 2451
2452 2452 $ hg log -T '{node}\n' -r 1
2453 2453 2294ae80ad8447bc78383182eeac50cb049df623
2454 2454 $ hg debugobsolete 2294ae80ad8447bc78383182eeac50cb049df623
2455 2455 obsoleted 1 changesets
2456 2456 $ hg log -G
2457 2457 o changeset: 4:50b9b36e9c5d
2458 2458 | tag: tip
2459 2459 | user: test
2460 2460 | date: Thu Jan 01 00:00:00 1970 +0000
2461 2461 | summary: content3
2462 2462 |
2463 2463 @ changeset: 3:15b2327059e5
2464 2464 | user: test
2465 2465 | date: Thu Jan 01 00:00:00 1970 +0000
2466 2466 | summary: content2
2467 2467 |
2468 2468 o changeset: 2:2029acd1168c
2469 2469 | parent: 0:ae0a3c9f9e95
2470 2470 | user: test
2471 2471 | date: Thu Jan 01 00:00:00 1970 +0000
2472 2472 | summary: unrelated
2473 2473 |
2474 2474 o changeset: 0:ae0a3c9f9e95
2475 2475 user: test
2476 2476 date: Thu Jan 01 00:00:00 1970 +0000
2477 2477 summary: content1
2478 2478
2479 2479
2480 2480 Check that log on the file does not drop the file revision.
2481 2481
2482 2482 $ hg log -G a
2483 2483 o changeset: 4:50b9b36e9c5d
2484 2484 | tag: tip
2485 2485 | user: test
2486 2486 | date: Thu Jan 01 00:00:00 1970 +0000
2487 2487 | summary: content3
2488 2488 |
2489 2489 @ changeset: 3:15b2327059e5
2490 2490 : user: test
2491 2491 : date: Thu Jan 01 00:00:00 1970 +0000
2492 2492 : summary: content2
2493 2493 :
2494 2494 o changeset: 0:ae0a3c9f9e95
2495 2495 user: test
2496 2496 date: Thu Jan 01 00:00:00 1970 +0000
2497 2497 summary: content1
2498 2498
2499 2499
2500 2500 Even when a head revision is linkrev-shadowed.
2501 2501
2502 2502 $ hg log -T '{node}\n' -r 4
2503 2503 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
2504 2504 $ hg debugobsolete 50b9b36e9c5df2c6fc6dcefa8ad0da929e84aed2
2505 2505 obsoleted 1 changesets
2506 2506 $ hg log -G a
2507 2507 @ changeset: 3:15b2327059e5
2508 2508 : tag: tip
2509 2509 : user: test
2510 2510 : date: Thu Jan 01 00:00:00 1970 +0000
2511 2511 : summary: content2
2512 2512 :
2513 2513 o changeset: 0:ae0a3c9f9e95
2514 2514 user: test
2515 2515 date: Thu Jan 01 00:00:00 1970 +0000
2516 2516 summary: content1
2517 2517
2518 2518
2519 2519 $ cd ..
2520 2520
2521 2521 Even when the file revision is missing from some head:
2522 2522
2523 2523 $ hg init issue4490
2524 2524 $ cd issue4490
2525 2525 $ echo '[experimental]' >> .hg/hgrc
2526 2526 $ echo 'evolution.createmarkers=True' >> .hg/hgrc
2527 2527 $ echo a > a
2528 2528 $ hg ci -Am0
2529 2529 adding a
2530 2530 $ echo b > b
2531 2531 $ hg ci -Am1
2532 2532 adding b
2533 2533 $ echo B > b
2534 2534 $ hg ci --amend -m 1
2535 2535 $ hg up 0
2536 2536 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2537 2537 $ echo c > c
2538 2538 $ hg ci -Am2
2539 2539 adding c
2540 2540 created new head
2541 2541 $ hg up 'head() and not .'
2542 2542 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
2543 2543 $ hg log -G
2544 2544 o changeset: 3:db815d6d32e6
2545 2545 | tag: tip
2546 2546 | parent: 0:f7b1eb17ad24
2547 2547 | user: test
2548 2548 | date: Thu Jan 01 00:00:00 1970 +0000
2549 2549 | summary: 2
2550 2550 |
2551 2551 | @ changeset: 2:9bc8ce7f9356
2552 2552 |/ parent: 0:f7b1eb17ad24
2553 2553 | user: test
2554 2554 | date: Thu Jan 01 00:00:00 1970 +0000
2555 2555 | summary: 1
2556 2556 |
2557 2557 o changeset: 0:f7b1eb17ad24
2558 2558 user: test
2559 2559 date: Thu Jan 01 00:00:00 1970 +0000
2560 2560 summary: 0
2561 2561
2562 2562 $ hg log -f -G b
2563 2563 @ changeset: 2:9bc8ce7f9356
2564 2564 | parent: 0:f7b1eb17ad24
2565 2565 ~ user: test
2566 2566 date: Thu Jan 01 00:00:00 1970 +0000
2567 2567 summary: 1
2568 2568
2569 2569 $ hg log -G b
2570 2570 @ changeset: 2:9bc8ce7f9356
2571 2571 | parent: 0:f7b1eb17ad24
2572 2572 ~ user: test
2573 2573 date: Thu Jan 01 00:00:00 1970 +0000
2574 2574 summary: 1
2575 2575
2576 2576 $ cd ..
2577 2577
2578 2578 Check proper report when the manifest changes but not the file issue4499
2579 2579 ------------------------------------------------------------------------
2580 2580
2581 2581 $ hg init issue4499
2582 2582 $ cd issue4499
2583 2583 $ for f in A B C D F E G H I J K L M N O P Q R S T U; do
2584 2584 > echo 1 > $f;
2585 2585 > hg add $f;
2586 2586 > done
2587 2587 $ hg commit -m 'A1B1C1'
2588 2588 $ echo 2 > A
2589 2589 $ echo 2 > B
2590 2590 $ echo 2 > C
2591 2591 $ hg commit -m 'A2B2C2'
2592 2592 $ hg up 0
2593 2593 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
2594 2594 $ echo 3 > A
2595 2595 $ echo 2 > B
2596 2596 $ echo 2 > C
2597 2597 $ hg commit -m 'A3B2C2'
2598 2598 created new head
2599 2599
2600 2600 $ hg log -G
2601 2601 @ changeset: 2:fe5fc3d0eb17
2602 2602 | tag: tip
2603 2603 | parent: 0:abf4f0e38563
2604 2604 | user: test
2605 2605 | date: Thu Jan 01 00:00:00 1970 +0000
2606 2606 | summary: A3B2C2
2607 2607 |
2608 2608 | o changeset: 1:07dcc6b312c0
2609 2609 |/ user: test
2610 2610 | date: Thu Jan 01 00:00:00 1970 +0000
2611 2611 | summary: A2B2C2
2612 2612 |
2613 2613 o changeset: 0:abf4f0e38563
2614 2614 user: test
2615 2615 date: Thu Jan 01 00:00:00 1970 +0000
2616 2616 summary: A1B1C1
2617 2617
2618 2618
2619 2619 Log -f on B should reports current changesets
2620 2620
2621 2621 $ hg log -fG B
2622 2622 @ changeset: 2:fe5fc3d0eb17
2623 2623 | tag: tip
2624 2624 | parent: 0:abf4f0e38563
2625 2625 | user: test
2626 2626 | date: Thu Jan 01 00:00:00 1970 +0000
2627 2627 | summary: A3B2C2
2628 2628 |
2629 2629 o changeset: 0:abf4f0e38563
2630 2630 user: test
2631 2631 date: Thu Jan 01 00:00:00 1970 +0000
2632 2632 summary: A1B1C1
2633 2633
2634 2634 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now