##// END OF EJS Templates
dumprevlog: handle being passed a mode parameter...
Boris Feld -
r35982:a915465a default
parent child Browse files
Show More
@@ -1,31 +1,35 b''
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 from __future__ import absolute_import, print_function
5 from __future__ import absolute_import, print_function
6
6
7 import sys
7 import sys
8 from mercurial import (
8 from mercurial import (
9 node,
9 node,
10 revlog,
10 revlog,
11 util,
11 util,
12 )
12 )
13
13
14 for fp in (sys.stdin, sys.stdout, sys.stderr):
14 for fp in (sys.stdin, sys.stdout, sys.stderr):
15 util.setbinary(fp)
15 util.setbinary(fp)
16
16
17 def binopen(path, mode='rb'):
18 if 'b' not in mode:
19 mode = mode + 'b'
20 return open(path, mode)
21
17 for f in sys.argv[1:]:
22 for f in sys.argv[1:]:
18 binopen = lambda fn: open(fn, 'rb')
19 r = revlog.revlog(binopen, f)
23 r = revlog.revlog(binopen, f)
20 print("file:", f)
24 print("file:", f)
21 for i in r:
25 for i in r:
22 n = r.node(i)
26 n = r.node(i)
23 p = r.parents(n)
27 p = r.parents(n)
24 d = r.revision(n)
28 d = r.revision(n)
25 print("node:", node.hex(n))
29 print("node:", node.hex(n))
26 print("linkrev:", r.linkrev(i))
30 print("linkrev:", r.linkrev(i))
27 print("parents:", node.hex(p[0]), node.hex(p[1]))
31 print("parents:", node.hex(p[0]), node.hex(p[1]))
28 print("length:", len(d))
32 print("length:", len(d))
29 print("-start-")
33 print("-start-")
30 print(d)
34 print(d)
31 print("-end-")
35 print("-end-")
General Comments 0
You need to be logged in to leave comments. Login now