mercurial/commands.py
changeset 3146 e69a0cbe268e
parent 3127 81da3c45aabd
child 3159 e43fd1623fe1
equal deleted inserted replaced
3145:e4ea47c21480 3146:e69a0cbe268e
   602 
   602 
   603     Without the -a option, annotate will avoid processing files it
   603     Without the -a option, annotate will avoid processing files it
   604     detects as binary. With -a, annotate will generate an annotation
   604     detects as binary. With -a, annotate will generate an annotation
   605     anyway, probably with undesirable results.
   605     anyway, probably with undesirable results.
   606     """
   606     """
   607     def getnode(rev):
   607     getdate = util.cachefunc(lambda x: util.datestr(x.date()))
   608         return short(repo.changelog.node(rev))
       
   609 
       
   610     ucache = {}
       
   611     def getname(rev):
       
   612         try:
       
   613             return ucache[rev]
       
   614         except:
       
   615             u = trimuser(ui, repo.changectx(rev).user(), rev, ucache)
       
   616             ucache[rev] = u
       
   617             return u
       
   618 
       
   619     dcache = {}
       
   620     def getdate(rev):
       
   621         datestr = dcache.get(rev)
       
   622         if datestr is None:
       
   623             datestr = dcache[rev] = util.datestr(repo.changectx(rev).date())
       
   624         return datestr
       
   625 
   608 
   626     if not pats:
   609     if not pats:
   627         raise util.Abort(_('at least one file name or pattern required'))
   610         raise util.Abort(_('at least one file name or pattern required'))
   628 
   611 
   629     opmap = [['user', getname], ['number', str], ['changeset', getnode],
   612     opmap = [['user', lambda x: ui.shortuser(x.user())],
       
   613              ['number', lambda x: str(x.rev())],
       
   614              ['changeset', lambda x: short(x.node())],
   630              ['date', getdate]]
   615              ['date', getdate]]
   631     if not opts['user'] and not opts['changeset'] and not opts['date']:
   616     if not opts['user'] and not opts['changeset'] and not opts['date']:
   632         opts['number'] = 1
   617         opts['number'] = 1
   633 
   618 
   634     ctx = repo.changectx(opts['rev'])
   619     ctx = repo.changectx(opts['rev'])