convert hg cat to new context api
authorMatt Mackall <mpm@selenic.com>
Wed, 28 Jun 2006 17:11:42 -0500
changeset 2565 7f78ca2c7977
parent 2564 55e592041076
child 2566 d8560b458f76
convert hg cat to new context api
mercurial/commands.py
--- 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