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'} |