##// END OF EJS Templates
undumprevlog: update to valid Python 3 syntax...
Augie Fackler -
r33874:5d9890d8 default
parent child Browse files
Show More
@@ -1,46 +1,46 b''
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 from __future__ import absolute_import
6 from __future__ import absolute_import, print_function
7
7
8 import sys
8 import sys
9 from mercurial import (
9 from mercurial import (
10 node,
10 node,
11 revlog,
11 revlog,
12 transaction,
12 transaction,
13 util,
13 util,
14 vfs as vfsmod,
14 vfs as vfsmod,
15 )
15 )
16
16
17 for fp in (sys.stdin, sys.stdout, sys.stderr):
17 for fp in (sys.stdin, sys.stdout, sys.stderr):
18 util.setbinary(fp)
18 util.setbinary(fp)
19
19
20 opener = vfsmod.vfs('.', False)
20 opener = vfsmod.vfs('.', False)
21 tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
21 tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
22 "undump.journal")
22 "undump.journal")
23 while True:
23 while True:
24 l = sys.stdin.readline()
24 l = sys.stdin.readline()
25 if not l:
25 if not l:
26 break
26 break
27 if l.startswith("file:"):
27 if l.startswith("file:"):
28 f = l[6:-1]
28 f = l[6:-1]
29 r = revlog.revlog(opener, f)
29 r = revlog.revlog(opener, f)
30 print f
30 print(f)
31 elif l.startswith("node:"):
31 elif l.startswith("node:"):
32 n = node.bin(l[6:-1])
32 n = node.bin(l[6:-1])
33 elif l.startswith("linkrev:"):
33 elif l.startswith("linkrev:"):
34 lr = int(l[9:-1])
34 lr = int(l[9:-1])
35 elif l.startswith("parents:"):
35 elif l.startswith("parents:"):
36 p = l[9:-1].split()
36 p = l[9:-1].split()
37 p1 = node.bin(p[0])
37 p1 = node.bin(p[0])
38 p2 = node.bin(p[1])
38 p2 = node.bin(p[1])
39 elif l.startswith("length:"):
39 elif l.startswith("length:"):
40 length = int(l[8:-1])
40 length = int(l[8:-1])
41 sys.stdin.readline() # start marker
41 sys.stdin.readline() # start marker
42 d = sys.stdin.read(length)
42 d = sys.stdin.read(length)
43 sys.stdin.readline() # end marker
43 sys.stdin.readline() # end marker
44 r.addrevision(d, tr, lr, p1, p2)
44 r.addrevision(d, tr, lr, p1, p2)
45
45
46 tr.close()
46 tr.close()
General Comments 0
You need to be logged in to leave comments. Login now