Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 49487:f59e49f6bee4
branching: merge stable into default
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 01 Sep 2022 16:51:26 +0200 |
parents | a3ac3f1623dd f69bffd00abe |
children | 266bb5c86f4b |
comparison
equal
deleted
inserted
replaced
49486:5acbc550d987 | 49487:f59e49f6bee4 |
---|---|
1183 ) | 1183 ) |
1184 def debugdiscovery(ui, repo, remoteurl=b"default", **opts): | 1184 def debugdiscovery(ui, repo, remoteurl=b"default", **opts): |
1185 """runs the changeset discovery protocol in isolation | 1185 """runs the changeset discovery protocol in isolation |
1186 | 1186 |
1187 The local peer can be "replaced" by a subset of the local repository by | 1187 The local peer can be "replaced" by a subset of the local repository by |
1188 using the `--local-as-revs` flag. Int he same way, usual `remote` peer can | 1188 using the `--local-as-revs` flag. In the same way, the usual `remote` peer |
1189 be "replaced" by a subset of the local repository using the | 1189 can be "replaced" by a subset of the local repository using the |
1190 `--local-as-revs` flag. This is useful to efficiently debug pathological | 1190 `--remote-as-revs` flag. This is useful to efficiently debug pathological |
1191 discovery situation. | 1191 discovery situations. |
1192 | 1192 |
1193 The following developer oriented config are relevant for people playing with this command: | 1193 The following developer oriented config are relevant for people playing with this command: |
1194 | 1194 |
1195 * devel.discovery.exchange-heads=True | 1195 * devel.discovery.exchange-heads=True |
1196 | 1196 |
1274 | 1274 |
1275 def doit(pushedrevs, remoteheads, remote=remote): | 1275 def doit(pushedrevs, remoteheads, remote=remote): |
1276 if not util.safehasattr(remote, b'branches'): | 1276 if not util.safehasattr(remote, b'branches'): |
1277 # enable in-client legacy support | 1277 # enable in-client legacy support |
1278 remote = localrepo.locallegacypeer(remote.local()) | 1278 remote = localrepo.locallegacypeer(remote.local()) |
1279 if remote_revs: | |
1280 r = remote._repo.filtered(b'debug-discovery-remote-filter') | |
1281 remote._repo = r | |
1279 common, _in, hds = treediscovery.findcommonincoming( | 1282 common, _in, hds = treediscovery.findcommonincoming( |
1280 repo, remote, force=True, audit=data | 1283 repo, remote, force=True, audit=data |
1281 ) | 1284 ) |
1282 common = set(common) | 1285 common = set(common) |
1283 if not opts.get(b'nonheads'): | 1286 if not opts.get(b'nonheads'): |
1297 nodes = None | 1300 nodes = None |
1298 if pushedrevs: | 1301 if pushedrevs: |
1299 revs = logcmdutil.revrange(repo, pushedrevs) | 1302 revs = logcmdutil.revrange(repo, pushedrevs) |
1300 nodes = [repo[r].node() for r in revs] | 1303 nodes = [repo[r].node() for r in revs] |
1301 common, any, hds = setdiscovery.findcommonheads( | 1304 common, any, hds = setdiscovery.findcommonheads( |
1302 ui, repo, remote, ancestorsof=nodes, audit=data | 1305 ui, |
1306 repo, | |
1307 remote, | |
1308 ancestorsof=nodes, | |
1309 audit=data, | |
1310 abortwhenunrelated=False, | |
1303 ) | 1311 ) |
1304 return common, hds | 1312 return common, hds |
1305 | 1313 |
1306 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) | 1314 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) |
1307 localrevs = opts[b'rev'] | 1315 localrevs = opts[b'rev'] |
1320 with may_capture_output(): | 1328 with may_capture_output(): |
1321 with util.timedcm('debug-discovery') as t: | 1329 with util.timedcm('debug-discovery') as t: |
1322 common, hds = doit(localrevs, remoterevs) | 1330 common, hds = doit(localrevs, remoterevs) |
1323 | 1331 |
1324 # compute all statistics | 1332 # compute all statistics |
1333 if len(common) == 1 and repo.nullid in common: | |
1334 common = set() | |
1325 heads_common = set(common) | 1335 heads_common = set(common) |
1326 heads_remote = set(hds) | 1336 heads_remote = set(hds) |
1327 heads_local = set(repo.heads()) | 1337 heads_local = set(repo.heads()) |
1328 # note: they cannot be a local or remote head that is in common and not | 1338 # note: they cannot be a local or remote head that is in common and not |
1329 # itself a head of common. | 1339 # itself a head of common. |
1373 fm.startitem() | 1383 fm.startitem() |
1374 fm.data(**pycompat.strkwargs(data)) | 1384 fm.data(**pycompat.strkwargs(data)) |
1375 # display discovery summary | 1385 # display discovery summary |
1376 fm.plain(b"elapsed time: %(elapsed)f seconds\n" % data) | 1386 fm.plain(b"elapsed time: %(elapsed)f seconds\n" % data) |
1377 fm.plain(b"round-trips: %(total-roundtrips)9d\n" % data) | 1387 fm.plain(b"round-trips: %(total-roundtrips)9d\n" % data) |
1388 if b'total-round-trips-heads' in data: | |
1389 fm.plain( | |
1390 b" round-trips-heads: %(total-round-trips-heads)9d\n" % data | |
1391 ) | |
1392 if b'total-round-trips-branches' in data: | |
1393 fm.plain( | |
1394 b" round-trips-branches: %(total-round-trips-branches)9d\n" | |
1395 % data | |
1396 ) | |
1397 if b'total-round-trips-between' in data: | |
1398 fm.plain( | |
1399 b" round-trips-between: %(total-round-trips-between)9d\n" % data | |
1400 ) | |
1378 fm.plain(b"queries: %(total-queries)9d\n" % data) | 1401 fm.plain(b"queries: %(total-queries)9d\n" % data) |
1402 if b'total-queries-branches' in data: | |
1403 fm.plain(b" queries-branches: %(total-queries-branches)9d\n" % data) | |
1404 if b'total-queries-between' in data: | |
1405 fm.plain(b" queries-between: %(total-queries-between)9d\n" % data) | |
1379 fm.plain(b"heads summary:\n") | 1406 fm.plain(b"heads summary:\n") |
1380 fm.plain(b" total common heads: %(nb-common-heads)9d\n" % data) | 1407 fm.plain(b" total common heads: %(nb-common-heads)9d\n" % data) |
1381 fm.plain(b" also local heads: %(nb-common-heads-local)9d\n" % data) | 1408 fm.plain(b" also local heads: %(nb-common-heads-local)9d\n" % data) |
1382 fm.plain(b" also remote heads: %(nb-common-heads-remote)9d\n" % data) | 1409 fm.plain(b" also remote heads: %(nb-common-heads-remote)9d\n" % data) |
1383 fm.plain(b" both: %(nb-common-heads-both)9d\n" % data) | 1410 fm.plain(b" both: %(nb-common-heads-both)9d\n" % data) |