changeset 2565:7f78ca2c7977

convert hg cat to new context api
author Matt Mackall <mpm@selenic.com>
date Wed, 28 Jun 2006 17:11:42 -0500
parents 55e592041076
children d8560b458f76
files mercurial/commands.py
diffstat 1 files changed, 4 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jun 28 17:08:10 2006 -0500
+++ b/mercurial/commands.py	Wed Jun 28 17:11:42 2006 -0500
@@ -880,19 +880,10 @@
     %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