changeset 12131:c061f9882ff7

debugdata: try to access filelogs through repo, if possible If a repository is accesible, first treat the filename as a working copy file and try to open its filelog. Fallback to opening the file directly as a revlog, as before.
author Sune Foldager <cryo@cyanite.org>
date Wed, 01 Sep 2010 14:55:03 +0200
parents 48735ce02345
children 8a0e5b0c0ba9
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Sep 01 12:28:34 2010 +0200
+++ b/mercurial/commands.py	Wed Sep 01 14:55:03 2010 +0200
@@ -1214,9 +1214,15 @@
         ui.write(line)
         ui.write("\n")
 
-def debugdata(ui, file_, rev):
+def debugdata(ui, repo, file_, rev):
     """dump the contents of a data file revision"""
-    r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
+    r = None
+    if repo:
+        filelog = repo.file(file_)
+        if len(filelog):
+            r = filelog
+    if not r:
+        r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
     try:
         ui.write(r.revision(r.lookup(rev)))
     except KeyError:
@@ -4476,7 +4482,8 @@
     "version": (version_, []),
 }
 
-norepo = ("clone init version help debugcommands debugcomplete debugdata"
+norepo = ("clone init version help debugcommands debugcomplete"
           " debugindex debugindexdot debugdate debuginstall debugfsinfo"
           " debugpushkey")
-optionalrepo = ("identify paths serve showconfig debugancestor debugdag")
+optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
+                " debugdata")