Show More
@@ -1,21 +1,25 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | # Dump revlogs as raw data stream |
|
2 | # Dump revlogs as raw data stream | |
3 | # $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump |
|
3 | # $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump | |
4 |
|
4 | |||
5 | import sys |
|
5 | import sys | |
6 | from mercurial import revlog, node |
|
6 | from mercurial import revlog, node, util | |
|
7 | ||||
|
8 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |||
|
9 | util.set_binary(fp) | |||
7 |
|
10 | |||
8 | for f in sys.argv[1:]: |
|
11 | for f in sys.argv[1:]: | |
9 | r = revlog.revlog(open, f) |
|
12 | binopen = lambda fn: open(fn, 'rb') | |
|
13 | r = revlog.revlog(binopen, f) | |||
10 | print "file:", f |
|
14 | print "file:", f | |
11 | for i in xrange(r.count()): |
|
15 | for i in xrange(r.count()): | |
12 | n = r.node(i) |
|
16 | n = r.node(i) | |
13 | p = r.parents(n) |
|
17 | p = r.parents(n) | |
14 | d = r.revision(n) |
|
18 | d = r.revision(n) | |
15 | print "node:", node.hex(n) |
|
19 | print "node:", node.hex(n) | |
16 | print "linkrev:", r.linkrev(n) |
|
20 | print "linkrev:", r.linkrev(n) | |
17 | print "parents:", node.hex(p[0]), node.hex(p[1]) |
|
21 | print "parents:", node.hex(p[0]), node.hex(p[1]) | |
18 | print "length:", len(d) |
|
22 | print "length:", len(d) | |
19 | print "-start-" |
|
23 | print "-start-" | |
20 | print d |
|
24 | print d | |
21 | print "-end-" |
|
25 | print "-end-" |
@@ -1,34 +1,37 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | # Undump a dump from dumprevlog |
|
2 | # Undump a dump from dumprevlog | |
3 | # $ hg init |
|
3 | # $ hg init | |
4 | # $ undumprevlog < repo.dump |
|
4 | # $ undumprevlog < repo.dump | |
5 |
|
5 | |||
6 | import sys |
|
6 | import sys | |
7 | from mercurial import revlog, node, util, transaction |
|
7 | from mercurial import revlog, node, util, transaction | |
8 |
|
8 | |||
|
9 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |||
|
10 | util.set_binary(fp) | |||
|
11 | ||||
9 | opener = util.opener('.', False) |
|
12 | opener = util.opener('.', False) | |
10 | tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") |
|
13 | tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") | |
11 | while 1: |
|
14 | while 1: | |
12 | l = sys.stdin.readline() |
|
15 | l = sys.stdin.readline() | |
13 | if not l: |
|
16 | if not l: | |
14 | break |
|
17 | break | |
15 | if l.startswith("file:"): |
|
18 | if l.startswith("file:"): | |
16 | f = l[6:-1] |
|
19 | f = l[6:-1] | |
17 | r = revlog.revlog(opener, f) |
|
20 | r = revlog.revlog(opener, f) | |
18 | print f |
|
21 | print f | |
19 | elif l.startswith("node:"): |
|
22 | elif l.startswith("node:"): | |
20 | n = node.bin(l[6:-1]) |
|
23 | n = node.bin(l[6:-1]) | |
21 | elif l.startswith("linkrev:"): |
|
24 | elif l.startswith("linkrev:"): | |
22 | lr = int(l[9:-1]) |
|
25 | lr = int(l[9:-1]) | |
23 | elif l.startswith("parents:"): |
|
26 | elif l.startswith("parents:"): | |
24 | p = l[9:-1].split() |
|
27 | p = l[9:-1].split() | |
25 | p1 = node.bin(p[0]) |
|
28 | p1 = node.bin(p[0]) | |
26 | p2 = node.bin(p[1]) |
|
29 | p2 = node.bin(p[1]) | |
27 | elif l.startswith("length:"): |
|
30 | elif l.startswith("length:"): | |
28 | length = int(l[8:-1]) |
|
31 | length = int(l[8:-1]) | |
29 | sys.stdin.readline() # start marker |
|
32 | sys.stdin.readline() # start marker | |
30 | d = sys.stdin.read(length) |
|
33 | d = sys.stdin.read(length) | |
31 | sys.stdin.readline() # end marker |
|
34 | sys.stdin.readline() # end marker | |
32 | r.addrevision(d, tr, lr, p1, p2) |
|
35 | r.addrevision(d, tr, lr, p1, p2) | |
33 |
|
36 | |||
34 | tr.close() |
|
37 | tr.close() |
General Comments 0
You need to be logged in to leave comments.
Login now