Mercurial > hg-stable
changeset 2566:d8560b458f76
Convert hg annotate to context api
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 28 Jun 2006 17:42:17 -0500 |
parents | 7f78ca2c7977 |
children | 2748253b49c2 |
files | mercurial/commands.py mercurial/context.py |
diffstat | 2 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Jun 28 17:11:42 2006 -0500 +++ b/mercurial/commands.py Wed Jun 28 17:42:17 2006 -0500 @@ -701,15 +701,18 @@ ucache = {} def getname(rev): - cl = repo.changelog.read(repo.changelog.node(rev)) - return trimuser(ui, cl[1], rev, ucache) + try: + return ucache[rev] + except: + u = trimuser(ui, repo.changectx(rev).user(), rev, ucache) + ucache[rev] = u + return u dcache = {} def getdate(rev): datestr = dcache.get(rev) if datestr is None: - cl = repo.changelog.read(repo.changelog.node(rev)) - datestr = dcache[rev] = util.datestr(cl[2]) + datestr = dcache[rev] = util.datestr(repo.changectx(rev).date()) return datestr if not pats: @@ -720,20 +723,15 @@ if not opts['user'] and not opts['changeset'] and not opts['date']: opts['number'] = 1 - if opts['rev']: - node = repo.changelog.lookup(opts['rev']) - else: - node = repo.dirstate.parents()[0] - change = repo.changelog.read(node) - mmap = repo.manifest.read(change[0]) + ctx = repo.changectx(opts['rev'] or repo.dirstate.parents()[0]) for src, abs, rel, exact in walk(repo, pats, opts, node=node): - f = repo.file(abs) - if not opts['text'] and util.binary(f.read(mmap[abs])): + fctx = ctx.filectx(abs) + if not opts['text'] and util.binary(fctx.data()): ui.write(_("%s: binary file\n") % ((pats and rel) or abs)) continue - lines = f.annotate(mmap[abs]) + lines = fctx.annotate() pieces = [] for o, f in opmap:
--- a/mercurial/context.py Wed Jun 28 17:11:42 2006 -0500 +++ b/mercurial/context.py Wed Jun 28 17:42:17 2006 -0500 @@ -119,3 +119,6 @@ # hard for renames c = self._filelog.children(self._filenode) return [ filectx(self._repo, self._path, fileid=x) for x in c ] + + def annotate(self): + return self._filelog.annotate(self._filenode)