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