undumprevlog
48 lines
| 1.2 KiB
| text/plain
|
TextLexer
/ contrib / undumprevlog
|
r46434 | #!/usr/bin/env python3 | ||
|
r6433 | # Undump a dump from dumprevlog | ||
# $ hg init | ||||
# $ undumprevlog < repo.dump | ||||
|
r33874 | from __future__ import absolute_import, print_function | ||
|
r29167 | |||
|
r6433 | import sys | ||
|
r29167 | from mercurial import ( | ||
|
r39983 | encoding, | ||
|
r29167 | node, | ||
revlog, | ||||
transaction, | ||||
|
r31248 | vfs as vfsmod, | ||
|
r29167 | ) | ||
|
r44058 | from mercurial.utils import procutil | ||
|
r6433 | |||
|
r6466 | for fp in (sys.stdin, sys.stdout, sys.stderr): | ||
|
r37138 | procutil.setbinary(fp) | ||
|
r6466 | |||
|
r39983 | opener = vfsmod.vfs(b'.', False) | ||
|
r44058 | tr = transaction.transaction( | ||
sys.stderr.write, opener, {b'store': opener}, b"undump.journal" | ||||
) | ||||
|
r19022 | while True: | ||
|
r6433 | l = sys.stdin.readline() | ||
if not l: | ||||
break | ||||
if l.startswith("file:"): | ||||
|
r39983 | f = encoding.strtolocal(l[6:-1]) | ||
|
r6433 | r = revlog.revlog(opener, f) | ||
|
r45598 | procutil.stdout.write(b'%s\n' % f) | ||
|
r6433 | 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]) | ||||
|
r44058 | sys.stdin.readline() # start marker | ||
|
r39983 | d = encoding.strtolocal(sys.stdin.read(length)) | ||
|
r44058 | sys.stdin.readline() # end marker | ||
|
r6433 | r.addrevision(d, tr, lr, p1, p2) | ||
tr.close() | ||||