comparison contrib/undumprevlog @ 6433:ec5d77eb3431

add simple dump and undump scripts to contrib/
author Matt Mackall <mpm@selenic.com>
date Mon, 31 Mar 2008 21:49:32 -0500
parents
children 9c426da6b03b
comparison
equal deleted inserted replaced
6432:b1204fd06c2e 6433:ec5d77eb3431
1 #!/usr/bin/env python
2 # Undump a dump from dumprevlog
3 # $ hg init
4 # $ undumprevlog < repo.dump
5
6 import sys
7 from mercurial import revlog, node, util, transaction
8
9 opener = util.opener('.', False)
10 tr = transaction.transaction(sys.stderr.write, opener, "undump.journal")
11 while 1:
12 l = sys.stdin.readline()
13 if not l:
14 break
15 if l.startswith("file:"):
16 f = l[6:-1]
17 r = revlog.revlog(opener, f)
18 print f
19 elif l.startswith("node:"):
20 n = node.bin(l[6:-1])
21 elif l.startswith("linkrev:"):
22 lr = int(l[9:-1])
23 elif l.startswith("parents:"):
24 p = l[9:-1].split()
25 p1 = node.bin(p[0])
26 p2 = node.bin(p[1])
27 elif l.startswith("length:"):
28 length = int(l[8:-1])
29 sys.stdin.readline() # start marker
30 d = sys.stdin.read(length)
31 sys.stdin.readline() # end marker
32 r.addrevision(d, tr, lr, p1, p2)
33
34 tr.close()