view contrib/dumprevlog @ 39647:543a788eea2d

py3: allow run-tests.py to run on Windows This is now functional: HGMODULEPOLICY=py py -3 run-tests.py --local test-help.t --pure --view bcompare However, on this machine without a C compiler, it tries to load cext anyway, and blows up. I haven't looked into why, other than to see that it does set the environment variable. When the test exits though, I see it can't find killdaemons.py, get-with-headers.py, etc. I have no idea why these changes are needed, given that it runs on Linux. But os.system() is insisting that it take a str, and subprocess.Popen() blows up without str: Errored test-help.t: Traceback (most recent call last): File "run-tests.py", line 810, in run self.runTest() File "run-tests.py", line 858, in runTest ret, out = self._run(env) File "run-tests.py", line 1268, in _run exitcode, output = self._runcommand(cmd, env) File "run-tests.py", line 1141, in _runcommand env=env) File "C:\Program Files\Python37\lib\subprocess.py", line 756, in __init__ restore_signals, start_new_session) File "C:\Program Files\Python37\lib\subprocess.py", line 1100, in _execute_child args = list2cmdline(args) File "C:\Program Files\Python37\lib\subprocess.py", line 511, in list2cmdline needquote = (" " in arg) or ("\t" in arg) or not arg TypeError: argument of type 'int' is not iterable This is exactly how it crashes when trying to spin up a pager too. I left one instance of os.system() unchanged in _installhg(), because it doesn't get there.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 15 Sep 2018 00:04:06 -0400
parents a8a902d7176e
children a063b84ce064
line wrap: on
line source

#!/usr/bin/env python
# Dump revlogs as raw data stream
# $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump

from __future__ import absolute_import, print_function

import sys
from mercurial import (
    node,
    revlog,
)
from mercurial.utils import (
    procutil,
)

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

def binopen(path, mode='rb'):
    if 'b' not in mode:
        mode = mode + 'b'
    return open(path, mode)

for f in sys.argv[1:]:
    r = revlog.revlog(binopen, f)
    print("file:", f)
    for i in r:
        n = r.node(i)
        p = r.parents(n)
        d = r.revision(n)
        print("node:", node.hex(n))
        print("linkrev:", r.linkrev(i))
        print("parents:", node.hex(p[0]), node.hex(p[1]))
        print("length:", len(d))
        print("-start-")
        print(d)
        print("-end-")