Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 12132:8a0e5b0c0ba9
debugindex(dot): 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 <sune.foldager@edlund.dk> |
---|---|
date | Wed, 01 Sep 2010 15:03:45 +0200 |
parents | c061f9882ff7 |
children | 441a74b8def1 |
comparison
equal
deleted
inserted
replaced
12131:c061f9882ff7 | 12132:8a0e5b0c0ba9 |
---|---|
1238 ui.write("standard: %s\n" % util.datestr(d)) | 1238 ui.write("standard: %s\n" % util.datestr(d)) |
1239 if range: | 1239 if range: |
1240 m = util.matchdate(range) | 1240 m = util.matchdate(range) |
1241 ui.write("match: %s\n" % m(d[0])) | 1241 ui.write("match: %s\n" % m(d[0])) |
1242 | 1242 |
1243 def debugindex(ui, file_): | 1243 def debugindex(ui, repo, file_): |
1244 """dump the contents of an index file""" | 1244 """dump the contents of an index file""" |
1245 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | 1245 r = None |
1246 if repo: | |
1247 filelog = repo.file(file_) | |
1248 if len(filelog): | |
1249 r = filelog | |
1250 if not r: | |
1251 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | |
1246 ui.write(" rev offset length base linkrev" | 1252 ui.write(" rev offset length base linkrev" |
1247 " nodeid p1 p2\n") | 1253 " nodeid p1 p2\n") |
1248 for i in r: | 1254 for i in r: |
1249 node = r.node(i) | 1255 node = r.node(i) |
1250 try: | 1256 try: |
1253 pp = [nullid, nullid] | 1259 pp = [nullid, nullid] |
1254 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( | 1260 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
1255 i, r.start(i), r.length(i), r.base(i), r.linkrev(i), | 1261 i, r.start(i), r.length(i), r.base(i), r.linkrev(i), |
1256 short(node), short(pp[0]), short(pp[1]))) | 1262 short(node), short(pp[0]), short(pp[1]))) |
1257 | 1263 |
1258 def debugindexdot(ui, file_): | 1264 def debugindexdot(ui, repo, file_): |
1259 """dump an index DAG as a graphviz dot file""" | 1265 """dump an index DAG as a graphviz dot file""" |
1260 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | 1266 r = None |
1267 if repo: | |
1268 filelog = repo.file(file_) | |
1269 if len(filelog): | |
1270 r = filelog | |
1271 if not r: | |
1272 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | |
1261 ui.write("digraph G {\n") | 1273 ui.write("digraph G {\n") |
1262 for i in r: | 1274 for i in r: |
1263 node = r.node(i) | 1275 node = r.node(i) |
1264 pp = r.parents(node) | 1276 pp = r.parents(node) |
1265 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | 1277 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
4481 "verify": (verify, []), | 4493 "verify": (verify, []), |
4482 "version": (version_, []), | 4494 "version": (version_, []), |
4483 } | 4495 } |
4484 | 4496 |
4485 norepo = ("clone init version help debugcommands debugcomplete" | 4497 norepo = ("clone init version help debugcommands debugcomplete" |
4486 " debugindex debugindexdot debugdate debuginstall debugfsinfo" | 4498 " debugdate debuginstall debugfsinfo debugpushkey") |
4487 " debugpushkey") | |
4488 optionalrepo = ("identify paths serve showconfig debugancestor debugdag" | 4499 optionalrepo = ("identify paths serve showconfig debugancestor debugdag" |
4489 " debugdata") | 4500 " debugdata debugindex debugindexdot") |