2008-04-01 06:49:32 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Undump a dump from dumprevlog
|
|
|
|
# $ hg init
|
|
|
|
# $ undumprevlog < repo.dump
|
|
|
|
|
2017-08-22 19:58:51 +03:00
|
|
|
from __future__ import absolute_import, print_function
|
2016-05-12 23:53:45 +03:00
|
|
|
|
2008-04-01 06:49:32 +04:00
|
|
|
import sys
|
2016-05-12 23:53:45 +03:00
|
|
|
from mercurial import (
|
|
|
|
node,
|
|
|
|
revlog,
|
|
|
|
transaction,
|
|
|
|
util,
|
2017-03-02 15:32:49 +03:00
|
|
|
vfs as vfsmod,
|
2016-05-12 23:53:45 +03:00
|
|
|
)
|
2008-04-01 06:49:32 +04:00
|
|
|
|
2008-04-04 18:39:44 +04:00
|
|
|
for fp in (sys.stdin, sys.stdout, sys.stderr):
|
2011-05-06 17:25:35 +04:00
|
|
|
util.setbinary(fp)
|
2008-04-04 18:39:44 +04:00
|
|
|
|
2017-03-02 15:32:49 +03:00
|
|
|
opener = vfsmod.vfs('.', False)
|
2014-10-18 07:49:39 +04:00
|
|
|
tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
|
|
|
|
"undump.journal")
|
2013-04-17 05:39:36 +04:00
|
|
|
while True:
|
2008-04-01 06:49:32 +04:00
|
|
|
l = sys.stdin.readline()
|
|
|
|
if not l:
|
|
|
|
break
|
|
|
|
if l.startswith("file:"):
|
|
|
|
f = l[6:-1]
|
|
|
|
r = revlog.revlog(opener, f)
|
2017-08-22 19:58:51 +03:00
|
|
|
print(f)
|
2008-04-01 06:49:32 +04:00
|
|
|
elif l.startswith("node:"):
|
|
|
|
n = node.bin(l[6:-1])
|
|
|
|
elif l.startswith("linkrev:"):
|
|
|
|
lr = int(l[9:-1])
|
|
|
|
elif l.startswith("parents:"):
|
|
|
|
p = l[9:-1].split()
|
|
|
|
p1 = node.bin(p[0])
|
|
|
|
p2 = node.bin(p[1])
|
|
|
|
elif l.startswith("length:"):
|
|
|
|
length = int(l[8:-1])
|
|
|
|
sys.stdin.readline() # start marker
|
|
|
|
d = sys.stdin.read(length)
|
|
|
|
sys.stdin.readline() # end marker
|
|
|
|
r.addrevision(d, tr, lr, p1, p2)
|
|
|
|
|
|
|
|
tr.close()
|