##// END OF EJS Templates
contrib: fix typo...
Raphaël Gomès -
r47948:5d5abfdc default
parent child Browse files
Show More
@@ -1,60 +1,60 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
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.node import hex
8 from mercurial.node import hex
9 from mercurial import (
9 from mercurial import (
10 encoding,
10 encoding,
11 pycompat,
11 pycompat,
12 revlog,
12 revlog,
13 )
13 )
14 from mercurial.utils import procutil
14 from mercurial.utils import procutil
15
15
16 from mercurial.revlogutils import (
16 from mercurial.revlogutils import (
17 constants as revlog_constants,
17 constants as revlog_constants,
18 )
18 )
19
19
20 for fp in (sys.stdin, sys.stdout, sys.stderr):
20 for fp in (sys.stdin, sys.stdout, sys.stderr):
21 procutil.setbinary(fp)
21 procutil.setbinary(fp)
22
22
23
23
24 def binopen(path, mode=b'rb'):
24 def binopen(path, mode=b'rb'):
25 if b'b' not in mode:
25 if b'b' not in mode:
26 mode = mode + b'b'
26 mode = mode + b'b'
27 return open(path, pycompat.sysstr(mode))
27 return open(path, pycompat.sysstr(mode))
28
28
29
29
30 binopen.options = {}
30 binopen.options = {}
31
31
32
32
33 def printb(data, end=b'\n'):
33 def printb(data, end=b'\n'):
34 sys.stdout.flush()
34 sys.stdout.flush()
35 procutil.stdout.write(data + end)
35 procutil.stdout.write(data + end)
36
36
37
37
38 for f in sys.argv[1:]:
38 for f in sys.argv[1:]:
39 localf = encoding.strtolocal(f)
39 localf = encoding.strtolocal(f)
40 if not localf.endswith(b'.i'):
40 if not localf.endswith(b'.i'):
41 print("file:", f, file=sys.stderr)
41 print("file:", f, file=sys.stderr)
42 print(" invalida filename", file=sys.stderr)
42 print(" invalid filename", file=sys.stderr)
43
43
44 r = revlog.revlog(
44 r = revlog.revlog(
45 binopen,
45 binopen,
46 target=(revlog_constants.KIND_OTHER, b'dump-revlog'),
46 target=(revlog_constants.KIND_OTHER, b'dump-revlog'),
47 radix=localf[:-2],
47 radix=localf[:-2],
48 )
48 )
49 print("file:", f)
49 print("file:", f)
50 for i in r:
50 for i in r:
51 n = r.node(i)
51 n = r.node(i)
52 p = r.parents(n)
52 p = r.parents(n)
53 d = r.revision(n)
53 d = r.revision(n)
54 printb(b"node: %s" % hex(n))
54 printb(b"node: %s" % hex(n))
55 printb(b"linkrev: %d" % r.linkrev(i))
55 printb(b"linkrev: %d" % r.linkrev(i))
56 printb(b"parents: %s %s" % (hex(p[0]), hex(p[1])))
56 printb(b"parents: %s %s" % (hex(p[0]), hex(p[1])))
57 printb(b"length: %d" % len(d))
57 printb(b"length: %d" % len(d))
58 printb(b"-start-")
58 printb(b"-start-")
59 printb(d)
59 printb(d)
60 printb(b"-end-")
60 printb(b"-end-")
General Comments 0
You need to be logged in to leave comments. Login now