view contrib/undumprevlog @ 23969:01e5b7323a48 stable

extdiff: reintroduce backward compatibility with manual quoting of parameters 72a89cf86fcd broke things ... and the following cleanups didn't fix all issues. It didn't work with the diffargs shipped in mergetools.rc with explicit quoting. Parameters would end up with being quoted twice - especially if they really needed quoting. To work around that, look for explicit quotes around the variables that will be substituted with proper quoting. Also accept an additional prefix so we can handle both --foo='$parent' and '--foo=$parent' It will however still fail if the user intentionally place the variable inside a quoted string, as in 'parent $parent is on the left' There is currently no good way to handle that, short of knowing exactly which quoting mechanism will be used.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 28 Jan 2015 02:28:39 +0100
parents 5bd1f6572db0
children 4f76c0c490b3
line wrap: on
line source

#!/usr/bin/env python
# Undump a dump from dumprevlog
# $ hg init
# $ undumprevlog < repo.dump

import sys
from mercurial import revlog, node, scmutil, util, transaction

for fp in (sys.stdin, sys.stdout, sys.stderr):
    util.setbinary(fp)

opener = scmutil.opener('.', False)
tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
                             "undump.journal")
while True:
    l = sys.stdin.readline()
    if not l:
        break
    if l.startswith("file:"):
        f = l[6:-1]
        r = revlog.revlog(opener, f)
        print f
    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()