mercurial/commands.py
changeset 39813 a677261e7422
parent 39770 c48738923dba
child 39814 ddca38941b2b
equal deleted inserted replaced
39812:94ca3579e84e 39813:a677261e7422
   301     if rev:
   301     if rev:
   302         repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
   302         repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
   303     ctx = scmutil.revsingle(repo, rev)
   303     ctx = scmutil.revsingle(repo, rev)
   304 
   304 
   305     rootfm = ui.formatter('annotate', opts)
   305     rootfm = ui.formatter('annotate', opts)
       
   306     if ui.debugflag:
       
   307         shorthex = pycompat.identity
       
   308     else:
       
   309         def shorthex(h):
       
   310             return h[:12]
   306     if ui.quiet:
   311     if ui.quiet:
   307         datefunc = dateutil.shortdate
   312         datefunc = dateutil.shortdate
   308     else:
   313     else:
   309         datefunc = dateutil.datestr
   314         datefunc = dateutil.datestr
   310     if ctx.rev() is None:
   315     if ctx.rev() is None:
   311         def hexfn(node):
   316         def hexfn(node):
   312             if node is None:
   317             if node is None:
   313                 return None
   318                 return None
   314             else:
   319             else:
   315                 return rootfm.hexfunc(node)
   320                 return hex(node)
   316         if opts.get('changeset'):
   321         if opts.get('changeset'):
   317             # omit "+" suffix which is appended to node hex
   322             # omit "+" suffix which is appended to node hex
   318             def formatrev(rev):
   323             def formatrev(rev):
   319                 if rev is None:
   324                 if rev is None:
   320                     return '%d' % ctx.p1().rev()
   325                     return '%d' % ctx.p1().rev()
   324             def formatrev(rev):
   329             def formatrev(rev):
   325                 if rev is None:
   330                 if rev is None:
   326                     return '%d+' % ctx.p1().rev()
   331                     return '%d+' % ctx.p1().rev()
   327                 else:
   332                 else:
   328                     return '%d ' % rev
   333                     return '%d ' % rev
   329         def formathex(hex):
   334         def formathex(h):
   330             if hex is None:
   335             if h is None:
   331                 return '%s+' % rootfm.hexfunc(ctx.p1().node())
   336                 return '%s+' % shorthex(hex(ctx.p1().node()))
   332             else:
   337             else:
   333                 return '%s ' % hex
   338                 return '%s ' % shorthex(h)
   334     else:
   339     else:
   335         hexfn = rootfm.hexfunc
   340         hexfn = hex
   336         formatrev = formathex = pycompat.bytestr
   341         formatrev = b'%d'.__mod__
       
   342         formathex = shorthex
   337 
   343 
   338     opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
   344     opmap = [('user', ' ', lambda x: x.fctx.user(), ui.shortuser),
   339              ('rev', ' ', lambda x: x.fctx.rev(), formatrev),
   345              ('rev', ' ', lambda x: x.fctx.rev(), formatrev),
   340              ('node', ' ', lambda x: hexfn(x.fctx.node()), formathex),
   346              ('node', ' ', lambda x: hexfn(x.fctx.node()), formathex),
   341              ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),
   347              ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)),