##// END OF EJS Templates
py3: byteify contrib/dumprevlog
Matt Harbison -
r39983:a063b84c default
parent child Browse files
Show More
@@ -6,7 +6,9 from __future__ import absolute_import,
6
6
7 import sys
7 import sys
8 from mercurial import (
8 from mercurial import (
9 encoding,
9 node,
10 node,
11 pycompat,
10 revlog,
12 revlog,
11 )
13 )
12 from mercurial.utils import (
14 from mercurial.utils import (
@@ -16,22 +18,26 from mercurial.utils import (
16 for fp in (sys.stdin, sys.stdout, sys.stderr):
18 for fp in (sys.stdin, sys.stdout, sys.stderr):
17 procutil.setbinary(fp)
19 procutil.setbinary(fp)
18
20
19 def binopen(path, mode='rb'):
21 def binopen(path, mode=b'rb'):
20 if 'b' not in mode:
22 if b'b' not in mode:
21 mode = mode + 'b'
23 mode = mode + b'b'
22 return open(path, mode)
24 return open(path, pycompat.sysstr(mode))
25
26 def printb(data, end=b'\n'):
27 sys.stdout.flush()
28 pycompat.stdout.write(data + end)
23
29
24 for f in sys.argv[1:]:
30 for f in sys.argv[1:]:
25 r = revlog.revlog(binopen, f)
31 r = revlog.revlog(binopen, encoding.strtolocal(f))
26 print("file:", f)
32 print("file:", f)
27 for i in r:
33 for i in r:
28 n = r.node(i)
34 n = r.node(i)
29 p = r.parents(n)
35 p = r.parents(n)
30 d = r.revision(n)
36 d = r.revision(n)
31 print("node:", node.hex(n))
37 printb(b"node: %s" % node.hex(n))
32 print("linkrev:", r.linkrev(i))
38 printb(b"linkrev: %d" % r.linkrev(i))
33 print("parents:", node.hex(p[0]), node.hex(p[1]))
39 printb(b"parents: %s %s" % (node.hex(p[0]), node.hex(p[1])))
34 print("length:", len(d))
40 printb(b"length: %d" % len(d))
35 print("-start-")
41 printb(b"-start-")
36 print(d)
42 printb(d)
37 print("-end-")
43 printb(b"-end-")
@@ -92,6 +92,7 test-convert-cvs-synthetic.t
92 test-convert-cvs.t
92 test-convert-cvs.t
93 test-convert-cvsnt-mergepoints.t
93 test-convert-cvsnt-mergepoints.t
94 test-convert-datesort.t
94 test-convert-datesort.t
95 test-contrib-dumprevlog.t
95 test-convert-filemap.t
96 test-convert-filemap.t
96 test-convert-hg-sink.t
97 test-convert-hg-sink.t
97 test-convert-hg-source.t
98 test-convert-hg-source.t
@@ -7,7 +7,9 from __future__ import absolute_import,
7
7
8 import sys
8 import sys
9 from mercurial import (
9 from mercurial import (
10 encoding,
10 node,
11 node,
12 pycompat,
11 revlog,
13 revlog,
12 transaction,
14 transaction,
13 vfs as vfsmod,
15 vfs as vfsmod,
@@ -19,17 +21,17 from mercurial.utils import (
19 for fp in (sys.stdin, sys.stdout, sys.stderr):
21 for fp in (sys.stdin, sys.stdout, sys.stderr):
20 procutil.setbinary(fp)
22 procutil.setbinary(fp)
21
23
22 opener = vfsmod.vfs('.', False)
24 opener = vfsmod.vfs(b'.', False)
23 tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
25 tr = transaction.transaction(sys.stderr.write, opener, {b'store': opener},
24 "undump.journal")
26 b"undump.journal")
25 while True:
27 while True:
26 l = sys.stdin.readline()
28 l = sys.stdin.readline()
27 if not l:
29 if not l:
28 break
30 break
29 if l.startswith("file:"):
31 if l.startswith("file:"):
30 f = l[6:-1]
32 f = encoding.strtolocal(l[6:-1])
31 r = revlog.revlog(opener, f)
33 r = revlog.revlog(opener, f)
32 print(f)
34 pycompat.stdout.write(b'%s\n' % f)
33 elif l.startswith("node:"):
35 elif l.startswith("node:"):
34 n = node.bin(l[6:-1])
36 n = node.bin(l[6:-1])
35 elif l.startswith("linkrev:"):
37 elif l.startswith("linkrev:"):
@@ -41,7 +43,7 while True:
41 elif l.startswith("length:"):
43 elif l.startswith("length:"):
42 length = int(l[8:-1])
44 length = int(l[8:-1])
43 sys.stdin.readline() # start marker
45 sys.stdin.readline() # start marker
44 d = sys.stdin.read(length)
46 d = encoding.strtolocal(sys.stdin.read(length))
45 sys.stdin.readline() # end marker
47 sys.stdin.readline() # end marker
46 r.addrevision(d, tr, lr, p1, p2)
48 r.addrevision(d, tr, lr, p1, p2)
47
49
General Comments 0
You need to be logged in to leave comments. Login now