Show More
@@ -28,7 +28,7 b' binopen.options = {}' | |||||
28 |
|
28 | |||
29 | def printb(data, end=b'\n'): |
|
29 | def printb(data, end=b'\n'): | |
30 | sys.stdout.flush() |
|
30 | sys.stdout.flush() | |
31 |
p |
|
31 | procutil.stdout.write(data + end) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | for f in sys.argv[1:]: |
|
34 | for f in sys.argv[1:]: |
@@ -45,8 +45,8 b' class ParseError(Exception):' | |||||
45 |
|
45 | |||
46 |
|
46 | |||
47 | def showhelp(): |
|
47 | def showhelp(): | |
48 |
p |
|
48 | procutil.stdout.write(usage) | |
49 |
p |
|
49 | procutil.stdout.write(b'\noptions:\n') | |
50 |
|
50 | |||
51 | out_opts = [] |
|
51 | out_opts = [] | |
52 | for shortopt, longopt, default, desc in options: |
|
52 | for shortopt, longopt, default, desc in options: | |
@@ -62,11 +62,11 b' def showhelp():' | |||||
62 | ) |
|
62 | ) | |
63 | opts_len = max([len(opt[0]) for opt in out_opts]) |
|
63 | opts_len = max([len(opt[0]) for opt in out_opts]) | |
64 | for first, second in out_opts: |
|
64 | for first, second in out_opts: | |
65 |
p |
|
65 | procutil.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) | |
66 |
|
66 | |||
67 |
|
67 | |||
68 | try: |
|
68 | try: | |
69 |
for fp in (sys.stdin, p |
|
69 | for fp in (sys.stdin, procutil.stdout, sys.stderr): | |
70 | procutil.setbinary(fp) |
|
70 | procutil.setbinary(fp) | |
71 |
|
71 | |||
72 | opts = {} |
|
72 | opts = {} | |
@@ -92,11 +92,11 b' try:' | |||||
92 | ) |
|
92 | ) | |
93 | except ParseError as e: |
|
93 | except ParseError as e: | |
94 | e = stringutil.forcebytestr(e) |
|
94 | e = stringutil.forcebytestr(e) | |
95 |
p |
|
95 | procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) | |
96 | showhelp() |
|
96 | showhelp() | |
97 | sys.exit(1) |
|
97 | sys.exit(1) | |
98 | except error.Abort as e: |
|
98 | except error.Abort as e: | |
99 |
p |
|
99 | procutil.stderr.write(b"abort: %s\n" % e) | |
100 | sys.exit(255) |
|
100 | sys.exit(255) | |
101 | except KeyboardInterrupt: |
|
101 | except KeyboardInterrupt: | |
102 | sys.exit(255) |
|
102 | sys.exit(255) |
@@ -9,7 +9,6 b' import sys' | |||||
9 | from mercurial import ( |
|
9 | from mercurial import ( | |
10 | encoding, |
|
10 | encoding, | |
11 | node, |
|
11 | node, | |
12 | pycompat, |
|
|||
13 | revlog, |
|
12 | revlog, | |
14 | transaction, |
|
13 | transaction, | |
15 | vfs as vfsmod, |
|
14 | vfs as vfsmod, | |
@@ -30,7 +29,7 b' while True:' | |||||
30 | if l.startswith("file:"): |
|
29 | if l.startswith("file:"): | |
31 | f = encoding.strtolocal(l[6:-1]) |
|
30 | f = encoding.strtolocal(l[6:-1]) | |
32 | r = revlog.revlog(opener, f) |
|
31 | r = revlog.revlog(opener, f) | |
33 |
p |
|
32 | procutil.stdout.write(b'%s\n' % f) | |
34 | elif l.startswith("node:"): |
|
33 | elif l.startswith("node:"): | |
35 | n = node.bin(l[6:-1]) |
|
34 | n = node.bin(l[6:-1]) | |
36 | elif l.startswith("linkrev:"): |
|
35 | elif l.startswith("linkrev:"): |
@@ -30,7 +30,10 b' from mercurial import (' | |||||
30 | scmutil, |
|
30 | scmutil, | |
31 | util, |
|
31 | util, | |
32 | ) |
|
32 | ) | |
33 |
from mercurial.utils import |
|
33 | from mercurial.utils import ( | |
|
34 | procutil, | |||
|
35 | stringutil, | |||
|
36 | ) | |||
34 |
|
37 | |||
35 | cmdtable = {} |
|
38 | cmdtable = {} | |
36 | command = registrar.command(cmdtable) |
|
39 | command = registrar.command(cmdtable) | |
@@ -689,7 +692,7 b' def releasenotes(ui, repo, file_=None, *' | |||||
689 | def debugparsereleasenotes(ui, path, repo=None): |
|
692 | def debugparsereleasenotes(ui, path, repo=None): | |
690 | """parse release notes and print resulting data structure""" |
|
693 | """parse release notes and print resulting data structure""" | |
691 | if path == b'-': |
|
694 | if path == b'-': | |
692 |
text = p |
|
695 | text = procutil.stdin.read() | |
693 | else: |
|
696 | else: | |
694 | with open(path, b'rb') as fh: |
|
697 | with open(path, b'rb') as fh: | |
695 | text = fh.read() |
|
698 | text = fh.read() |
@@ -22,8 +22,8 b' Create an extension to test bundle2 API' | |||||
22 | > from mercurial import changegroup |
|
22 | > from mercurial import changegroup | |
23 | > from mercurial import error |
|
23 | > from mercurial import error | |
24 | > from mercurial import obsolete |
|
24 | > from mercurial import obsolete | |
25 | > from mercurial import pycompat |
|
|||
26 | > from mercurial import registrar |
|
25 | > from mercurial import registrar | |
|
26 | > from mercurial.utils import procutil | |||
27 | > |
|
27 | > | |
28 | > |
|
28 | > | |
29 | > try: |
|
29 | > try: | |
@@ -148,7 +148,7 b' Create an extension to test bundle2 API' | |||||
148 | > bundler.newpart(b'output', data=genraise(), mandatory=False) |
|
148 | > bundler.newpart(b'output', data=genraise(), mandatory=False) | |
149 | > |
|
149 | > | |
150 | > if path is None: |
|
150 | > if path is None: | |
151 |
> file = p |
|
151 | > file = procutil.stdout | |
152 | > else: |
|
152 | > else: | |
153 | > file = open(path, 'wb') |
|
153 | > file = open(path, 'wb') | |
154 | > |
|
154 | > | |
@@ -181,7 +181,7 b' Create an extension to test bundle2 API' | |||||
181 | > lock = repo.lock() |
|
181 | > lock = repo.lock() | |
182 | > tr = repo.transaction(b'processbundle') |
|
182 | > tr = repo.transaction(b'processbundle') | |
183 | > try: |
|
183 | > try: | |
184 |
> unbundler = bundle2.getunbundler(ui, p |
|
184 | > unbundler = bundle2.getunbundler(ui, procutil.stdin) | |
185 | > op = bundle2.processbundle(repo, unbundler, lambda: tr) |
|
185 | > op = bundle2.processbundle(repo, unbundler, lambda: tr) | |
186 | > tr.close() |
|
186 | > tr.close() | |
187 | > except error.BundleValueError as exc: |
|
187 | > except error.BundleValueError as exc: | |
@@ -192,7 +192,7 b' Create an extension to test bundle2 API' | |||||
192 | > if tr is not None: |
|
192 | > if tr is not None: | |
193 | > tr.release() |
|
193 | > tr.release() | |
194 | > lock.release() |
|
194 | > lock.release() | |
195 |
> remains = p |
|
195 | > remains = procutil.stdin.read() | |
196 | > ui.write(b'%i unread bytes\n' % len(remains)) |
|
196 | > ui.write(b'%i unread bytes\n' % len(remains)) | |
197 | > if op.records[b'song']: |
|
197 | > if op.records[b'song']: | |
198 | > totalverses = sum(r[b'verses'] for r in op.records[b'song']) |
|
198 | > totalverses = sum(r[b'verses'] for r in op.records[b'song']) | |
@@ -207,7 +207,7 b' Create an extension to test bundle2 API' | |||||
207 | > @command(b'statbundle2', [], b'') |
|
207 | > @command(b'statbundle2', [], b'') | |
208 | > def cmdstatbundle2(ui, repo): |
|
208 | > def cmdstatbundle2(ui, repo): | |
209 | > """print statistic on the bundle2 container read from stdin""" |
|
209 | > """print statistic on the bundle2 container read from stdin""" | |
210 |
> unbundler = bundle2.getunbundler(ui, p |
|
210 | > unbundler = bundle2.getunbundler(ui, procutil.stdin) | |
211 | > try: |
|
211 | > try: | |
212 | > params = unbundler.params |
|
212 | > params = unbundler.params | |
213 | > except error.BundleValueError as exc: |
|
213 | > except error.BundleValueError as exc: |
@@ -573,11 +573,13 b' Test internal debugstacktrace command' | |||||
573 | $ cat > debugstacktrace.py << EOF |
|
573 | $ cat > debugstacktrace.py << EOF | |
574 | > from __future__ import absolute_import |
|
574 | > from __future__ import absolute_import | |
575 | > from mercurial import ( |
|
575 | > from mercurial import ( | |
576 | > pycompat, |
|
|||
577 | > util, |
|
576 | > util, | |
578 | > ) |
|
577 | > ) | |
|
578 | > from mercurial.utils import ( | |||
|
579 | > procutil, | |||
|
580 | > ) | |||
579 | > def f(): |
|
581 | > def f(): | |
580 |
> util.debugstacktrace(f=p |
|
582 | > util.debugstacktrace(f=procutil.stdout) | |
581 | > g() |
|
583 | > g() | |
582 | > def g(): |
|
584 | > def g(): | |
583 | > util.dst(b'hello from g\\n', skip=1) |
|
585 | > util.dst(b'hello from g\\n', skip=1) | |
@@ -588,15 +590,15 b' Test internal debugstacktrace command' | |||||
588 | > EOF |
|
590 | > EOF | |
589 | $ "$PYTHON" debugstacktrace.py |
|
591 | $ "$PYTHON" debugstacktrace.py | |
590 | stacktrace at: |
|
592 | stacktrace at: | |
591 |
*debugstacktrace.py:1 |
|
593 | *debugstacktrace.py:16 in * (glob) | |
592 |
*debugstacktrace.py: |
|
594 | *debugstacktrace.py:9 in f (glob) | |
593 | hello from g at: |
|
595 | hello from g at: | |
594 |
*debugstacktrace.py:1 |
|
596 | *debugstacktrace.py:16 in * (glob) | |
595 |
*debugstacktrace.py: |
|
597 | *debugstacktrace.py:10 in f (glob) | |
596 | hi ... |
|
598 | hi ... | |
597 | from h hidden in g at: |
|
599 | from h hidden in g at: | |
598 |
*debugstacktrace.py: |
|
600 | *debugstacktrace.py:10 in f (glob) | |
599 |
*debugstacktrace.py:1 |
|
601 | *debugstacktrace.py:13 in g (glob) | |
600 |
|
602 | |||
601 | Test debugcapabilities command: |
|
603 | Test debugcapabilities command: | |
602 |
|
604 |
@@ -1917,9 +1917,9 b' such str.lower().' | |||||
1917 | > EOF |
|
1917 | > EOF | |
1918 |
|
1918 | |||
1919 | $ "$PYTHON" <<EOF | sh |
|
1919 | $ "$PYTHON" <<EOF | sh | |
1920 |
> from mercurial import p |
|
1920 | > from mercurial.utils import procutil | |
1921 | > upper = b"\x8bL\x98^" |
|
1921 | > upper = b"\x8bL\x98^" | |
1922 |
> p |
|
1922 | > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper) | |
1923 | > EOF |
|
1923 | > EOF | |
1924 | \x8bL\x98^ (esc) |
|
1924 | \x8bL\x98^ (esc) | |
1925 | ---- |
|
1925 | ---- | |
@@ -1928,9 +1928,9 b' such str.lower().' | |||||
1928 |
|
1928 | |||
1929 |
|
1929 | |||
1930 | $ "$PYTHON" <<EOF | sh |
|
1930 | $ "$PYTHON" <<EOF | sh | |
1931 |
> from mercurial import p |
|
1931 | > from mercurial.utils import procutil | |
1932 | > lower = b"\x8bl\x98^" |
|
1932 | > lower = b"\x8bl\x98^" | |
1933 |
> p |
|
1933 | > procutil.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower) | |
1934 | > EOF |
|
1934 | > EOF | |
1935 | \x8bl\x98^ (esc) |
|
1935 | \x8bl\x98^ (esc) | |
1936 | ---- |
|
1936 | ---- |
@@ -14,10 +14,12 b' by the WSGI standard and strictly implem' | |||||
14 | > dispatch, |
|
14 | > dispatch, | |
15 | > encoding, |
|
15 | > encoding, | |
16 | > hg, |
|
16 | > hg, | |
17 | > pycompat, |
|
|||
18 | > ui as uimod, |
|
17 | > ui as uimod, | |
19 | > util, |
|
18 | > util, | |
20 | > ) |
|
19 | > ) | |
|
20 | > from mercurial.utils import ( | |||
|
21 | > procutil, | |||
|
22 | > ) | |||
21 | > ui = uimod.ui |
|
23 | > ui = uimod.ui | |
22 | > from mercurial.hgweb import hgweb_mod |
|
24 | > from mercurial.hgweb import hgweb_mod | |
23 | > stringio = util.stringio |
|
25 | > stringio = util.stringio | |
@@ -69,8 +71,8 b' by the WSGI standard and strictly implem' | |||||
69 | > for c in i(env, startrsp): |
|
71 | > for c in i(env, startrsp): | |
70 | > pass |
|
72 | > pass | |
71 | > sys.stdout.flush() |
|
73 | > sys.stdout.flush() | |
72 |
> p |
|
74 | > procutil.stdout.write(b'---- ERRORS\n') | |
73 |
> p |
|
75 | > procutil.stdout.write(b'%s\n' % errors.getvalue()) | |
74 | > print('---- OS.ENVIRON wsgi variables') |
|
76 | > print('---- OS.ENVIRON wsgi variables') | |
75 | > print(sorted([x for x in os.environ if x.startswith('wsgi')])) |
|
77 | > print(sorted([x for x in os.environ if x.startswith('wsgi')])) | |
76 | > print('---- request.ENVIRON wsgi variables') |
|
78 | > print('---- request.ENVIRON wsgi variables') |
@@ -19,9 +19,8 b' Test applying context diffs' | |||||
19 | > EOF |
|
19 | > EOF | |
20 | $ cat > cat.py <<EOF |
|
20 | $ cat > cat.py <<EOF | |
21 | > import sys |
|
21 | > import sys | |
22 |
> from mercurial import p |
|
22 | > from mercurial.utils import procutil, stringutil | |
23 | > from mercurial.utils import stringutil |
|
23 | > procutil.stdout.write(b'%s\n' | |
24 | > pycompat.stdout.write(b'%s\n' |
|
|||
25 | > % stringutil.pprint(open(sys.argv[1], 'rb').read())) |
|
24 | > % stringutil.pprint(open(sys.argv[1], 'rb').read())) | |
26 | > EOF |
|
25 | > EOF | |
27 |
|
26 |
@@ -697,6 +697,7 b" absence doesn't cause an abort.)" | |||||
697 | > revlog, |
|
697 | > revlog, | |
698 | > ) |
|
698 | > ) | |
699 | > from mercurial.utils import ( |
|
699 | > from mercurial.utils import ( | |
|
700 | > procutil, | |||
700 | > stringutil, |
|
701 | > stringutil, | |
701 | > ) |
|
702 | > ) | |
702 | > def hash(rawtext): |
|
703 | > def hash(rawtext): | |
@@ -713,7 +714,7 b" absence doesn't cause an abort.)" | |||||
713 | > texts = [fl.rawdata(i) for i in fl] |
|
714 | > texts = [fl.rawdata(i) for i in fl] | |
714 | > flags = [int(fl._revlog.flags(i)) for i in fl] |
|
715 | > flags = [int(fl._revlog.flags(i)) for i in fl] | |
715 | > hashes = [hash(t) for t in texts] |
|
716 | > hashes = [hash(t) for t in texts] | |
716 |
> p |
|
717 | > procutil.stdout.write(b' %s: rawsizes=%r flags=%r hashes=%s\n' | |
717 | > % (name, sizes, flags, stringutil.pprint(hashes))) |
|
718 | > % (name, sizes, flags, stringutil.pprint(hashes))) | |
718 | > EOF |
|
719 | > EOF | |
719 |
|
720 |
@@ -1575,15 +1575,15 b' Test cbor filter:' | |||||
1575 | > from __future__ import absolute_import |
|
1575 | > from __future__ import absolute_import | |
1576 | > from mercurial import ( |
|
1576 | > from mercurial import ( | |
1577 | > dispatch, |
|
1577 | > dispatch, | |
1578 | > pycompat, |
|
|||
1579 | > ) |
|
1578 | > ) | |
1580 | > from mercurial.utils import ( |
|
1579 | > from mercurial.utils import ( | |
1581 | > cborutil, |
|
1580 | > cborutil, | |
|
1581 | > procutil, | |||
1582 | > stringutil, |
|
1582 | > stringutil, | |
1583 | > ) |
|
1583 | > ) | |
1584 | > dispatch.initstdio() |
|
1584 | > dispatch.initstdio() | |
1585 |
> items = cborutil.decodeall(p |
|
1585 | > items = cborutil.decodeall(procutil.stdin.read()) | |
1586 |
> p |
|
1586 | > procutil.stdout.write(stringutil.pprint(items, indent=1) + b'\n') | |
1587 | > EOF |
|
1587 | > EOF | |
1588 |
|
1588 | |||
1589 | $ hg log -T "{rev|cbor}" -R a -l2 | "$PYTHON" "$TESTTMP/decodecbor.py" |
|
1589 | $ hg log -T "{rev|cbor}" -R a -l2 | "$PYTHON" "$TESTTMP/decodecbor.py" |
@@ -675,20 +675,20 b' test CBOR style:' | |||||
675 | > from __future__ import absolute_import |
|
675 | > from __future__ import absolute_import | |
676 | > from mercurial import ( |
|
676 | > from mercurial import ( | |
677 | > dispatch, |
|
677 | > dispatch, | |
678 | > pycompat, |
|
|||
679 | > ) |
|
678 | > ) | |
680 | > from mercurial.utils import ( |
|
679 | > from mercurial.utils import ( | |
681 | > cborutil, |
|
680 | > cborutil, | |
|
681 | > procutil, | |||
682 | > stringutil, |
|
682 | > stringutil, | |
683 | > ) |
|
683 | > ) | |
684 | > dispatch.initstdio() |
|
684 | > dispatch.initstdio() | |
685 |
> data = p |
|
685 | > data = procutil.stdin.read() | |
686 | > # our CBOR decoder doesn't support parsing indefinite-length arrays, |
|
686 | > # our CBOR decoder doesn't support parsing indefinite-length arrays, | |
687 | > # but the log output is indefinite stream by nature. |
|
687 | > # but the log output is indefinite stream by nature. | |
688 | > assert data[:1] == cborutil.BEGIN_INDEFINITE_ARRAY |
|
688 | > assert data[:1] == cborutil.BEGIN_INDEFINITE_ARRAY | |
689 | > assert data[-1:] == cborutil.BREAK |
|
689 | > assert data[-1:] == cborutil.BREAK | |
690 | > items = cborutil.decodeall(data[1:-1]) |
|
690 | > items = cborutil.decodeall(data[1:-1]) | |
691 |
> p |
|
691 | > procutil.stdout.write(stringutil.pprint(items, indent=1) + b'\n') | |
692 | > EOF |
|
692 | > EOF | |
693 |
|
693 | |||
694 | $ hg log -k nosuch -Tcbor | "$PYTHON" "$TESTTMP/decodecborarray.py" |
|
694 | $ hg log -k nosuch -Tcbor | "$PYTHON" "$TESTTMP/decodecborarray.py" |
General Comments 0
You need to be logged in to leave comments.
Login now