Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 39814:ddca38941b2b
annotate: pass in wdir rev and node to formatter (BC)
This is a part of the unification series. The 'ff..' hash is preferred over
None as it is a valid revision specifier.
https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Sanity_check_output
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Sep 2018 17:26:23 +0900 |
parents | a677261e7422 |
children | f6874567a93b |
comparison
equal
deleted
inserted
replaced
39813:a677261e7422 | 39814:ddca38941b2b |
---|---|
17 from .node import ( | 17 from .node import ( |
18 hex, | 18 hex, |
19 nullid, | 19 nullid, |
20 nullrev, | 20 nullrev, |
21 short, | 21 short, |
22 wdirhex, | |
23 wdirrev, | |
22 ) | 24 ) |
23 from . import ( | 25 from . import ( |
24 archival, | 26 archival, |
25 bookmarks, | 27 bookmarks, |
26 bundle2, | 28 bundle2, |
311 if ui.quiet: | 313 if ui.quiet: |
312 datefunc = dateutil.shortdate | 314 datefunc = dateutil.shortdate |
313 else: | 315 else: |
314 datefunc = dateutil.datestr | 316 datefunc = dateutil.datestr |
315 if ctx.rev() is None: | 317 if ctx.rev() is None: |
316 def hexfn(node): | |
317 if node is None: | |
318 return None | |
319 else: | |
320 return hex(node) | |
321 if opts.get('changeset'): | 318 if opts.get('changeset'): |
322 # omit "+" suffix which is appended to node hex | 319 # omit "+" suffix which is appended to node hex |
323 def formatrev(rev): | 320 def formatrev(rev): |
324 if rev is None: | 321 if rev == wdirrev: |
325 return '%d' % ctx.p1().rev() | 322 return '%d' % ctx.p1().rev() |
326 else: | 323 else: |
327 return '%d' % rev | 324 return '%d' % rev |
328 else: | 325 else: |
329 def formatrev(rev): | 326 def formatrev(rev): |
330 if rev is None: | 327 if rev == wdirrev: |
331 return '%d+' % ctx.p1().rev() | 328 return '%d+' % ctx.p1().rev() |
332 else: | 329 else: |
333 return '%d ' % rev | 330 return '%d ' % rev |
334 def formathex(h): | 331 def formathex(h): |
335 if h is None: | 332 if h == wdirhex: |
336 return '%s+' % shorthex(hex(ctx.p1().node())) | 333 return '%s+' % shorthex(hex(ctx.p1().node())) |
337 else: | 334 else: |
338 return '%s ' % shorthex(h) | 335 return '%s ' % shorthex(h) |
339 else: | 336 else: |
340 hexfn = hex | |
341 formatrev = b'%d'.__mod__ | 337 formatrev = b'%d'.__mod__ |
342 formathex = shorthex | 338 formathex = shorthex |
343 | 339 |
344 opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser), | 340 opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser), |
345 ('rev', ' ', lambda x: x.fctx.rev(), formatrev), | 341 ('rev', ' ', lambda x: scmutil.intrev(x.fctx), formatrev), |
346 ('node', ' ', lambda x: hexfn(x.fctx.node()), formathex), | 342 ('node', ' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex), |
347 ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)), | 343 ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)), |
348 ('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr), | 344 ('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr), |
349 ('line_number', ':', lambda x: x.lineno, pycompat.bytestr), | 345 ('line_number', ':', lambda x: x.lineno, pycompat.bytestr), |
350 ] | 346 ] |
351 opnamemap = {'rev': 'number', 'node': 'changeset', 'path': 'file'} | 347 opnamemap = {'rev': 'number', 'node': 'changeset', 'path': 'file'} |