contrib/undumprevlog
author Yuya Nishihara <yuya@tcha.org>
Thu, 22 May 2014 22:05:26 +0900
branchstable
changeset 21543 21b3513d43e4
parent 19022 cba222f01056
child 23310 5bd1f6572db0
permissions -rwxr-xr-x
proxy: remove unneeded _set_hostport for compatibility with Python 2.7.7rc1 With Python 2.7.7rc1, "hg pull" through HTTP CONNECT tunnel fails due to the removal of _set_hostport [1]. ... File "mercurial/url.py", line 372, in https_open return self.do_open(self._makeconnection, req) ... File "mercurial/url.py", line 342, in connect _generic_proxytunnel(self) File "mercurial/url.py", line 228, in _generic_proxytunnel self._set_hostport(self.host, self.port) AttributeError: httpsconnection instance has no attribute '_set_hostport' self._set_hostport(self.host, self.port) should be noop and can be removed because: - _set_hostport() [2] was the function to parse "host:port" string and set them to self.host and self.port, - and (self.host, self.port) pair should be valid since connect() is called prior to _generic_proxytunnel(). [1]: http://hg.python.org/cpython/rev/568041fd8090 [2]: http://hg.python.org/cpython/file/3a1db0d2747e/Lib/httplib.py#l721

#!/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, "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()