mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
packs: add debug commands to view pack contents
Summary: Some simple debug commands to print the contents of each pack. Test Plan: Ran it manually, and added a simple test Reviewers: #mercurial, ttung, mitrandir Reviewed By: mitrandir Differential Revision: https://phabricator.intern.facebook.com/D3277233 Signature: t1:3277233:1463085196:c54fc875d536a96150bb1461b77247a5d7a9402c
This commit is contained in:
parent
ad5352432e
commit
5e4370b46d
@ -754,6 +754,16 @@ def debugremotefilelog(ui, *args, **opts):
|
||||
def verifyremotefilelog(ui, *args, **opts):
|
||||
return debugcommands.verifyremotefilelog(ui, *args, **opts)
|
||||
|
||||
@command('debugdatapack', [
|
||||
], _('hg debugdatapack <path>'), norepo=True)
|
||||
def debugremotefilelog(ui, path, *args, **opts):
|
||||
return debugcommands.debugdatapack(ui, path, *args, **opts)
|
||||
|
||||
@command('debughistorypack', [
|
||||
], _('hg debughistorypack <path>'), norepo=True)
|
||||
def debughistorypack(ui, path, *args, **opts):
|
||||
return debugcommands.debughistorypack(ui, path, *args, **opts)
|
||||
|
||||
@command('prefetch', [
|
||||
('r', 'rev', [], _('prefetch the specified revisions'), _('REV')),
|
||||
] + commands.walkopts, _('hg prefetch [OPTIONS] [FILE...]'))
|
||||
|
@ -8,7 +8,7 @@
|
||||
from mercurial import util, filelog, revlog
|
||||
from mercurial.node import bin, hex, nullid, nullrev, short
|
||||
from mercurial.i18n import _
|
||||
import shallowrepo
|
||||
import datapack, historypack, shallowrepo
|
||||
import os, lz4
|
||||
|
||||
def debugremotefilelog(ui, *args, **opts):
|
||||
@ -190,3 +190,35 @@ def parsefileblob(path, decompress):
|
||||
start = divider + 1
|
||||
|
||||
return size, firstnode, mapping
|
||||
|
||||
def debugdatapack(ui, path, *args, **kwargs):
|
||||
dpack = datapack.datapack(path)
|
||||
|
||||
lastfilename = None
|
||||
for filename, node, deltabase, deltalen in dpack.iterentries():
|
||||
if filename != lastfilename:
|
||||
ui.write("\n%s\n" % filename)
|
||||
ui.write("%s%s%s\n" % (
|
||||
"Node".ljust(14),
|
||||
"Delta Base".ljust(14),
|
||||
"Delta Length".ljust(6)))
|
||||
lastfilename = filename
|
||||
ui.write("%s %s %s\n" % (short(node), short(deltabase), deltalen))
|
||||
|
||||
def debughistorypack(ui, path, *args, **kwargs):
|
||||
hpack = historypack.historypack(path)
|
||||
|
||||
lastfilename = None
|
||||
for entry in hpack.iterentries():
|
||||
filename, node, p1node, p2node, linknode, copyfrom = entry
|
||||
if filename != lastfilename:
|
||||
ui.write("\n%s\n" % filename)
|
||||
ui.write("%s%s%s%s%s\n" % (
|
||||
"Node".ljust(14),
|
||||
"P1 Node".ljust(14),
|
||||
"P2 Node".ljust(14),
|
||||
"Link Node".ljust(14),
|
||||
"Copy From"))
|
||||
lastfilename = filename
|
||||
ui.write("%s %s %s %s %s\n" % (short(node), short(p1node),
|
||||
short(p2node), short(linknode), copyfrom))
|
||||
|
@ -123,6 +123,24 @@
|
||||
$TESTTMP/hgcache/master/packs/92a06d8b76a23b6e6150cf877ea75ed993e0b2d8.dataidx
|
||||
$TESTTMP/hgcache/master/packs/92a06d8b76a23b6e6150cf877ea75ed993e0b2d8.datapack
|
||||
|
||||
# Test debug commands
|
||||
|
||||
$ hg debugdatapack $TESTTMP/hgcache/master/packs/92a06d8b76a23b6e6150cf877ea75ed993e0b2d8
|
||||
|
||||
x
|
||||
Node Delta Base Delta Length
|
||||
1bb2e6237e03 000000000000 13
|
||||
d4a3ed9310e5 1bb2e6237e03 17
|
||||
aee31534993a d4a3ed9310e5 17
|
||||
$ hg debughistorypack $TESTTMP/hgcache/master/packs/3bebfba849e7aed8e598b92b296aeaff4784393b
|
||||
|
||||
x
|
||||
Node P1 Node P2 Node Link Node Copy From
|
||||
1bb2e6237e03 d4a3ed9310e5 000000000000 0b03bbc9e1e7
|
||||
d4a3ed9310e5 aee31534993a 000000000000 421535db10b6
|
||||
aee31534993a 1406e7411862 000000000000 a89d614e2364
|
||||
1406e7411862 000000000000 000000000000 b292c1e3311f
|
||||
|
||||
# Test copy tracing from a pack
|
||||
$ cd ../master
|
||||
$ hg mv x y
|
||||
|
Loading…
Reference in New Issue
Block a user