diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -880,19 +880,10 @@ def cat(ui, repo, file1, *pats, **opts): %d dirname of file being printed, or '.' if in repo root %p root-relative path name of file being printed """ - mf = {} - rev = opts['rev'] - if rev: - node = repo.lookup(rev) - else: - node = repo.changelog.tip() - change = repo.changelog.read(node) - mf = repo.manifest.read(change[0]) - for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, node): - r = repo.file(abs) - n = mf[abs] - fp = make_file(repo, opts['output'], node, pathname=abs) - fp.write(r.read(n)) + ctx = repo.changectx(opts['rev'] or -1) + for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, ctx.node()): + fp = make_file(repo, opts['output'], ctx.node(), pathname=abs) + fp.write(ctx.filectx(abs).data()) def clone(ui, source, dest=None, **opts): """make a copy of an existing repository