view contrib/undumprevlog @ 17401:a826b1d7f5b2

zsh completion: add new options for existing commands * backout: add --tool; * bisect: add --extend; * bookmarks: add --inactive; * branches: add --closed; * bundle: add --rev, --all, --branch; * cat: add --decode; * clone: add --updaterev, --branch, --pull and use common-with-qclone opts; * commit: add --close-branch; * diff: add --change, --reverse, --stat, --text, --unified; * export: add --rev; * grep: add --date; * heads: add --topo, --closed; * help: add --extension, --command, --keywords; complete additional help topics also, not commands only; * identify: add --bookmark and remote_opts; * import: add --no-commit, --exact, --import-branch, --date, --user, --similarity and commit options; * log: add --user, --date, --stat, --git, --graph; * manifest: add --rev; * push: add --new-branch; * resolve: add --all, --no-status, --tool and pattern options; * revert: add --date; * serve: add --prefix, --web-conf, --pid-file, --cmdserver, --certificate; * status: add --change; * tag: add --force, --edit, --remove; * tip: add --git; * update: add --check, --date.
author Nikolaj Sjujskij <sterkrig@myopera.com>
date Thu, 16 Aug 2012 19:03:01 +0400
parents 659f34b833b9
children cba222f01056
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, "undump.journal")
while 1:
    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()