Mercurial > hg
annotate 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 |
rev | line source |
---|---|
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # Dump revlogs as raw data stream |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 |
29166
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
5 from __future__ import absolute_import, print_function |
29165
a212ca70205c
py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
14233
diff
changeset
|
6 |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 import sys |
29165
a212ca70205c
py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
14233
diff
changeset
|
8 from mercurial import ( |
a212ca70205c
py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
14233
diff
changeset
|
9 node, |
a212ca70205c
py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
14233
diff
changeset
|
10 revlog, |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35964
diff
changeset
|
11 ) |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35964
diff
changeset
|
12 from mercurial.utils import ( |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35964
diff
changeset
|
13 procutil, |
29165
a212ca70205c
py3: make contrib/dumprevlog use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
14233
diff
changeset
|
14 ) |
6466
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
15 |
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
16 for fp in (sys.stdin, sys.stdout, sys.stderr): |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35964
diff
changeset
|
17 procutil.setbinary(fp) |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 |
35964
a915465a731e
dumprevlog: handle being passed a mode parameter
Boris Feld <boris.feld@octobus.net>
parents:
29166
diff
changeset
|
19 def binopen(path, mode='rb'): |
a915465a731e
dumprevlog: handle being passed a mode parameter
Boris Feld <boris.feld@octobus.net>
parents:
29166
diff
changeset
|
20 if 'b' not in mode: |
a915465a731e
dumprevlog: handle being passed a mode parameter
Boris Feld <boris.feld@octobus.net>
parents:
29166
diff
changeset
|
21 mode = mode + 'b' |
a915465a731e
dumprevlog: handle being passed a mode parameter
Boris Feld <boris.feld@octobus.net>
parents:
29166
diff
changeset
|
22 return open(path, mode) |
a915465a731e
dumprevlog: handle being passed a mode parameter
Boris Feld <boris.feld@octobus.net>
parents:
29166
diff
changeset
|
23 |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 for f in sys.argv[1:]: |
6466
9c426da6b03b
contrib: fix binary file issues with dumprevlog on Windows
Adrian Buehlmann <adrian@cadifra.com>
parents:
6433
diff
changeset
|
25 r = revlog.revlog(binopen, f) |
29166
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
26 print("file:", f) |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6466
diff
changeset
|
27 for i in r: |
6433
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
28 n = r.node(i) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 p = r.parents(n) |
ec5d77eb3431
add simple dump and undump scripts to contrib/
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
30 d = r.revision(n) |
29166
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
31 print("node:", node.hex(n)) |
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
32 print("linkrev:", r.linkrev(i)) |
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
33 print("parents:", node.hex(p[0]), node.hex(p[1])) |
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
34 print("length:", len(d)) |
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
35 print("-start-") |
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
36 print(d) |
6359b80f15fb
py3: make contrib/dumprevlog use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29165
diff
changeset
|
37 print("-end-") |