comparison mercurial/debugcommands.py @ 46782:67a2ecea8bd9

debugdiscovery: also integrate the discovery output in the json one We add a way for formatter to informs code that free output is unwanted, and we incorporate it in the json output. Differential Revision: https://phab.mercurial-scm.org/D10224
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 Mar 2021 17:09:42 +0100
parents 3a8cf5b9c820
children b6ac612445e0
comparison
equal deleted inserted replaced
46781:3a8cf5b9c820 46782:67a2ecea8bd9
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import codecs 10 import codecs
11 import collections 11 import collections
12 import contextlib
12 import difflib 13 import difflib
13 import errno 14 import errno
14 import glob 15 import glob
15 import operator 16 import operator
16 import os 17 import os
1087 ) 1088 )
1088 return common, hds 1089 return common, hds
1089 1090
1090 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) 1091 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
1091 localrevs = opts[b'rev'] 1092 localrevs = opts[b'rev']
1092 with util.timedcm('debug-discovery') as t: 1093
1093 common, hds = doit(localrevs, remoterevs) 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 # compute all statistics 1109 # compute all statistics
1096 heads_common = set(common) 1110 heads_common = set(common)
1097 heads_remote = set(hds) 1111 heads_remote = set(hds)
1098 heads_local = set(repo.heads()) 1112 heads_local = set(repo.heads())
1139 data[b'nb-ini_und-heads'] = len(heads_initial_undecided) 1153 data[b'nb-ini_und-heads'] = len(heads_initial_undecided)
1140 data[b'nb-ini_und-roots'] = len(roots_initial_undecided) 1154 data[b'nb-ini_und-roots'] = len(roots_initial_undecided)
1141 data[b'nb-ini_und-common'] = len(common_initial_undecided) 1155 data[b'nb-ini_und-common'] = len(common_initial_undecided)
1142 data[b'nb-ini_und-missing'] = len(missing_initial_undecided) 1156 data[b'nb-ini_und-missing'] = len(missing_initial_undecided)
1143 1157
1144 fm = ui.formatter(b'debugdiscovery', opts)
1145 fm.startitem() 1158 fm.startitem()
1146 fm.data(**pycompat.strkwargs(data)) 1159 fm.data(**pycompat.strkwargs(data))
1147 # display discovery summary 1160 # display discovery summary
1148 fm.plain(b"elapsed time: %(elapsed)f seconds\n" % data) 1161 fm.plain(b"elapsed time: %(elapsed)f seconds\n" % data)
1149 fm.plain(b"round-trips: %(total-roundtrips)9d\n" % data) 1162 fm.plain(b"round-trips: %(total-roundtrips)9d\n" % data)