##// END OF EJS Templates
debugdiscovery: also integrate the discovery output in the json one...
marmoute -
r47503:67a2ecea default
parent child Browse files
Show More
@@ -9,6 +9,7 b' from __future__ import absolute_import'
9 9
10 10 import codecs
11 11 import collections
12 import contextlib
12 13 import difflib
13 14 import errno
14 15 import glob
@@ -1089,8 +1090,21 b' def debugdiscovery(ui, repo, remoteurl=b'
1089 1090
1090 1091 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
1091 1092 localrevs = opts[b'rev']
1092 with util.timedcm('debug-discovery') as t:
1093 common, hds = doit(localrevs, remoterevs)
1093
1094 fm = ui.formatter(b'debugdiscovery', opts)
1095 if fm.strict_format:
1096
1097 @contextlib.contextmanager
1098 def may_capture_output():
1099 ui.pushbuffer()
1100 yield
1101 data[b'output'] = ui.popbuffer()
1102
1103 else:
1104 may_capture_output = util.nullcontextmanager
1105 with may_capture_output():
1106 with util.timedcm('debug-discovery') as t:
1107 common, hds = doit(localrevs, remoterevs)
1094 1108
1095 1109 # compute all statistics
1096 1110 heads_common = set(common)
@@ -1141,7 +1155,6 b' def debugdiscovery(ui, repo, remoteurl=b'
1141 1155 data[b'nb-ini_und-common'] = len(common_initial_undecided)
1142 1156 data[b'nb-ini_und-missing'] = len(missing_initial_undecided)
1143 1157
1144 fm = ui.formatter(b'debugdiscovery', opts)
1145 1158 fm.startitem()
1146 1159 fm.data(**pycompat.strkwargs(data))
1147 1160 # display discovery summary
@@ -178,6 +178,11 b' class _nullconverter(object):'
178 178
179 179
180 180 class baseformatter(object):
181
182 # set to True if the formater output a strict format that does not support
183 # arbitrary output in the stream.
184 strict_format = False
185
181 186 def __init__(self, ui, topic, opts, converter):
182 187 self._ui = ui
183 188 self._topic = topic
@@ -418,6 +423,9 b' class cborformatter(baseformatter):'
418 423
419 424
420 425 class jsonformatter(baseformatter):
426
427 strict_format = True
428
421 429 def __init__(self, ui, out, topic, opts):
422 430 baseformatter.__init__(self, ui, topic, opts, _nullconverter)
423 431 self._out = out
@@ -1734,13 +1734,6 b' Test -T json output'
1734 1734 > --local-as-revs 'first(heads(all()), 25)' \
1735 1735 > --remote-as-revs 'last(heads(all()), 25)' \
1736 1736 > --config devel.discovery.randomize=false
1737 query 1; heads
1738 searching for changes
1739 taking quick initial sample
1740 query 2; still undecided: 375, sample size is: 81
1741 sampling from both directions
1742 query 3; still undecided: 3, sample size is: 3
1743 3 total queries in *s (glob)
1744 1737 [
1745 1738 {
1746 1739 "elapsed": *, (glob)
@@ -1763,6 +1756,7 b' Test -T json output'
1763 1756 "nb-revs": 400,
1764 1757 "nb-revs-common": 300,
1765 1758 "nb-revs-missing": 100,
1759 "output": "query 1; heads\nsearching for changes\ntaking quick initial sample\nquery 2; still undecided: 375, sample size is: 81\nsampling from both directions\nquery 3; still undecided: 3, sample size is: 3\n3 total queries in *s\n", (glob)
1766 1760 "total-roundtrips": 3
1767 1761 }
1768 1762 ]
General Comments 0
You need to be logged in to leave comments. Login now