Show More
@@ -35,9 +35,8 b' class gitlfspointer(dict):' | |||||
35 | try: |
|
35 | try: | |
36 | return cls(l.split(' ', 1) for l in text.splitlines()).validate() |
|
36 | return cls(l.split(' ', 1) for l in text.splitlines()).validate() | |
37 | except ValueError: # l.split returns 1 item instead of 2 |
|
37 | except ValueError: # l.split returns 1 item instead of 2 | |
38 | raise InvalidPointer( |
|
38 | raise InvalidPointer(_('cannot parse git-lfs text: %s') | |
39 |
|
|
39 | % stringutil.pprint(text)) | |
40 | text, bprefix=False)) |
|
|||
41 |
|
40 | |||
42 | def serialize(self): |
|
41 | def serialize(self): | |
43 | sortkeyfunc = lambda x: (x[0] != 'version', x) |
|
42 | sortkeyfunc = lambda x: (x[0] != 'version', x) | |
@@ -66,14 +65,14 b' class gitlfspointer(dict):' | |||||
66 | for k, v in self.iteritems(): |
|
65 | for k, v in self.iteritems(): | |
67 | if k in self._requiredre: |
|
66 | if k in self._requiredre: | |
68 | if not self._requiredre[k].match(v): |
|
67 | if not self._requiredre[k].match(v): | |
69 |
raise InvalidPointer(_('unexpected value: %s=%s') |
|
68 | raise InvalidPointer(_('unexpected value: %s=%s') | |
70 |
k, stringutil.pprint(v |
|
69 | % (k, stringutil.pprint(v))) | |
71 | requiredcount += 1 |
|
70 | requiredcount += 1 | |
72 | elif not self._keyre.match(k): |
|
71 | elif not self._keyre.match(k): | |
73 | raise InvalidPointer(_('unexpected key: %s') % k) |
|
72 | raise InvalidPointer(_('unexpected key: %s') % k) | |
74 | if not self._valuere.match(v): |
|
73 | if not self._valuere.match(v): | |
75 |
raise InvalidPointer(_('unexpected value: %s=%s') |
|
74 | raise InvalidPointer(_('unexpected value: %s=%s') | |
76 |
k, stringutil.pprint(v |
|
75 | % (k, stringutil.pprint(v))) | |
77 | if len(self._requiredre) != requiredcount: |
|
76 | if len(self._requiredre) != requiredcount: | |
78 | miss = sorted(set(self._requiredre.keys()).difference(self.keys())) |
|
77 | miss = sorted(set(self._requiredre.keys()).difference(self.keys())) | |
79 | raise InvalidPointer(_('missed keys: %s') % ', '.join(miss)) |
|
78 | raise InvalidPointer(_('missed keys: %s') % ', '.join(miss)) |
@@ -3017,10 +3017,12 b' def debugwireproto(ui, repo, path=None, ' | |||||
3017 |
|
3017 | |||
3018 | if isinstance(res, wireprotov2peer.commandresponse): |
|
3018 | if isinstance(res, wireprotov2peer.commandresponse): | |
3019 | val = list(res.cborobjects()) |
|
3019 | val = list(res.cborobjects()) | |
3020 |
ui.status(_('response: %s\n') % |
|
3020 | ui.status(_('response: %s\n') % | |
|
3021 | stringutil.pprint(val, bprefix=True)) | |||
3021 |
|
3022 | |||
3022 | else: |
|
3023 | else: | |
3023 |
ui.status(_('response: %s\n') % |
|
3024 | ui.status(_('response: %s\n') % | |
|
3025 | stringutil.pprint(res, bprefix=True)) | |||
3024 |
|
3026 | |||
3025 | elif action == 'batchbegin': |
|
3027 | elif action == 'batchbegin': | |
3026 | if batchedcommands is not None: |
|
3028 | if batchedcommands is not None: | |
@@ -3092,7 +3094,8 b' def debugwireproto(ui, repo, path=None, ' | |||||
3092 | continue |
|
3094 | continue | |
3093 |
|
3095 | |||
3094 | if res.headers.get('Content-Type') == 'application/mercurial-cbor': |
|
3096 | if res.headers.get('Content-Type') == 'application/mercurial-cbor': | |
3095 |
ui.write(_('cbor> %s\n') % |
|
3097 | ui.write(_('cbor> %s\n') % | |
|
3098 | stringutil.pprint(cbor.loads(body), bprefix=True)) | |||
3096 |
|
3099 | |||
3097 | elif action == 'close': |
|
3100 | elif action == 'close': | |
3098 | peer.close() |
|
3101 | peer.close() |
@@ -138,7 +138,7 b' def _exthook(ui, repo, htype, name, cmd,' | |||||
138 | if callable(v): |
|
138 | if callable(v): | |
139 | v = v() |
|
139 | v = v() | |
140 | if isinstance(v, (dict, list)): |
|
140 | if isinstance(v, (dict, list)): | |
141 |
v = stringutil.pprint(v |
|
141 | v = stringutil.pprint(v) | |
142 | env['HG_' + k.upper()] = v |
|
142 | env['HG_' + k.upper()] = v | |
143 |
|
143 | |||
144 | if repo: |
|
144 | if repo: |
@@ -106,8 +106,7 b' class status(tuple):' | |||||
106 | def __repr__(self, *args, **kwargs): |
|
106 | def __repr__(self, *args, **kwargs): | |
107 | return ((r'<status modified=%s, added=%s, removed=%s, deleted=%s, ' |
|
107 | return ((r'<status modified=%s, added=%s, removed=%s, deleted=%s, ' | |
108 | r'unknown=%s, ignored=%s, clean=%s>') % |
|
108 | r'unknown=%s, ignored=%s, clean=%s>') % | |
109 | tuple(pycompat.sysstr(stringutil.pprint( |
|
109 | tuple(pycompat.sysstr(stringutil.pprint(v)) for v in self)) | |
110 | v, bprefix=False)) for v in self)) |
|
|||
111 |
|
110 | |||
112 | def itersubrepos(ctx1, ctx2): |
|
111 | def itersubrepos(ctx1, ctx2): | |
113 | """find subrepos in ctx1 or ctx2""" |
|
112 | """find subrepos in ctx1 or ctx2""" |
@@ -23,7 +23,7 b' from .. import (' | |||||
23 | pycompat, |
|
23 | pycompat, | |
24 | ) |
|
24 | ) | |
25 |
|
25 | |||
26 |
def pprint(o, bprefix= |
|
26 | def pprint(o, bprefix=False): | |
27 | """Pretty print an object.""" |
|
27 | """Pretty print an object.""" | |
28 | if isinstance(o, bytes): |
|
28 | if isinstance(o, bytes): | |
29 | if bprefix: |
|
29 | if bprefix: |
@@ -28,7 +28,7 b' def writeauth(items):' | |||||
28 | return ui |
|
28 | return ui | |
29 |
|
29 | |||
30 | def test(auth, urls=None): |
|
30 | def test(auth, urls=None): | |
31 | print('CFG:', pycompat.sysstr(stringutil.pprint(auth))) |
|
31 | print('CFG:', pycompat.sysstr(stringutil.pprint(auth, bprefix=True))) | |
32 | prefixes = set() |
|
32 | prefixes = set() | |
33 | for k in auth: |
|
33 | for k in auth: | |
34 | prefixes.add(k.split('.', 1)[0]) |
|
34 | prefixes.add(k.split('.', 1)[0]) |
@@ -18,7 +18,7 b' def debugformat(text, form, **kwargs):' | |||||
18 | if type(out) == tuple: |
|
18 | if type(out) == tuple: | |
19 | print(out[0][:-1].decode('utf8')) |
|
19 | print(out[0][:-1].decode('utf8')) | |
20 | print("-" * 70) |
|
20 | print("-" * 70) | |
21 |
print(stringutil.pprint(out[1] |
|
21 | print(stringutil.pprint(out[1]).decode('utf8')) | |
22 | else: |
|
22 | else: | |
23 | print(out[:-1].decode('utf8')) |
|
23 | print(out[:-1].decode('utf8')) | |
24 | print("-" * 70) |
|
24 | print("-" * 70) |
@@ -15,7 +15,7 b' testui.pushbuffer()' | |||||
15 | testui.write((b'buffered\n')) |
|
15 | testui.write((b'buffered\n')) | |
16 | testui.warn((b'warning\n')) |
|
16 | testui.warn((b'warning\n')) | |
17 | testui.write_err(b'error\n') |
|
17 | testui.write_err(b'error\n') | |
18 | print(stringutil.pprint(testui.popbuffer()).decode('ascii')) |
|
18 | print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii')) | |
19 |
|
19 | |||
20 | # test dispatch.dispatch with the same ui object |
|
20 | # test dispatch.dispatch with the same ui object | |
21 | hgrc = open(os.environ["HGRCPATH"], 'wb') |
|
21 | hgrc = open(os.environ["HGRCPATH"], 'wb') |
@@ -51,7 +51,7 b' parsed = dispatch._parseconfig(testui, [' | |||||
51 | ]) |
|
51 | ]) | |
52 |
|
52 | |||
53 | def pprint(obj): |
|
53 | def pprint(obj): | |
54 |
return stringutil.pprint(obj |
|
54 | return stringutil.pprint(obj).decode('ascii') | |
55 |
|
55 | |||
56 | print(pprint(testui.configitems(b'values'))) |
|
56 | print(pprint(testui.configitems(b'values'))) | |
57 | print(pprint(testui.configitems(b'lists'))) |
|
57 | print(pprint(testui.configitems(b'lists'))) |
@@ -108,4 +108,5 b' with clt.commandexecutor() as e:' | |||||
108 | fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'}) |
|
108 | fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'}) | |
109 | fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'}) |
|
109 | fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'}) | |
110 |
|
110 | |||
111 |
printb(stringutil.pprint([f.result() for f in (fgreet1, fgreet2)] |
|
111 | printb(stringutil.pprint([f.result() for f in (fgreet1, fgreet2)], | |
|
112 | bprefix=True)) |
General Comments 0
You need to be logged in to leave comments.
Login now