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