##// END OF EJS Templates
filectx.annotate: return filectx for each line instead of rev
Brendan Cully -
r3146:e69a0cbe default
parent child Browse files
Show More
@@ -604,29 +604,14 b' def annotate(ui, repo, *pats, **opts):'
604 604 detects as binary. With -a, annotate will generate an annotation
605 605 anyway, probably with undesirable results.
606 606 """
607 def getnode(rev):
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
607 getdate = util.cachefunc(lambda x: util.datestr(x.date()))
625 608
626 609 if not pats:
627 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 615 ['date', getdate]]
631 616 if not opts['user'] and not opts['changeset'] and not opts['date']:
632 617 opts['number'] = 1
@@ -7,7 +7,7 b''
7 7
8 8 from node import *
9 9 from demandload import demandload
10 demandload(globals(), "ancestor")
10 demandload(globals(), "ancestor util")
11 11
12 12 class changectx(object):
13 13 """A changecontext object makes access to data related to a particular
@@ -155,7 +155,12 b' class filectx(object):'
155 155 filelog=self._filelog) for x in c ]
156 156
157 157 def annotate(self):
158 return self._filelog.annotate(self._filenode)
158 getctx = util.cachefunc(lambda x: filectx(self._repo, self._path,
159 changeid=x,
160 filelog=self._filelog))
161 hist = self._filelog.annotate(self._filenode)
162
163 return [(getctx(rev), line) for rev, line in hist]
159 164
160 165 def ancestor(self, fc2):
161 166 """
General Comments 0
You need to be logged in to leave comments. Login now