comparison mercurial/debugcommands.py @ 50946:8e5083590cfe

debugdiscovery: migrate `opts` to native kwargs
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 Aug 2023 17:06:47 -0400
parents f7c35a645c2e
children 5dc20e1f0518
comparison
equal deleted inserted replaced
50945:f7c35a645c2e 50946:8e5083590cfe
1232 1232
1233 * devel.discovery.sample-size.initial=100 1233 * devel.discovery.sample-size.initial=100
1234 1234
1235 Control the initial size of the discovery for initial change 1235 Control the initial size of the discovery for initial change
1236 """ 1236 """
1237 opts = pycompat.byteskwargs(opts)
1238 unfi = repo.unfiltered() 1237 unfi = repo.unfiltered()
1239 1238
1240 # setup potential extra filtering 1239 # setup potential extra filtering
1241 local_revs = opts[b"local_as_revs"] 1240 local_revs = opts["local_as_revs"]
1242 remote_revs = opts[b"remote_as_revs"] 1241 remote_revs = opts["remote_as_revs"]
1243 1242
1244 # make sure tests are repeatable 1243 # make sure tests are repeatable
1245 random.seed(int(opts[b'seed'])) 1244 random.seed(int(opts['seed']))
1246 1245
1247 if not remote_revs: 1246 if not remote_revs:
1248 path = urlutil.get_unique_pull_path_obj( 1247 path = urlutil.get_unique_pull_path_obj(
1249 b'debugdiscovery', ui, remoteurl 1248 b'debugdiscovery', ui, remoteurl
1250 ) 1249 )
1251 branches = (path.branch, []) 1250 branches = (path.branch, [])
1252 remote = hg.peer(repo, opts, path) 1251 remote = hg.peer(repo, pycompat.byteskwargs(opts), path)
1253 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(path.loc)) 1252 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(path.loc))
1254 else: 1253 else:
1255 branches = (None, []) 1254 branches = (None, [])
1256 remote_filtered_revs = logcmdutil.revrange( 1255 remote_filtered_revs = logcmdutil.revrange(
1257 unfi, [b"not (::(%s))" % remote_revs] 1256 unfi, [b"not (::(%s))" % remote_revs]
1277 1276
1278 repoview.filtertable[b'debug-discovery-local-filter'] = local_func 1277 repoview.filtertable[b'debug-discovery-local-filter'] = local_func
1279 repo = repo.filtered(b'debug-discovery-local-filter') 1278 repo = repo.filtered(b'debug-discovery-local-filter')
1280 1279
1281 data = {} 1280 data = {}
1282 if opts.get(b'old'): 1281 if opts.get('old'):
1283 1282
1284 def doit(pushedrevs, remoteheads, remote=remote): 1283 def doit(pushedrevs, remoteheads, remote=remote):
1285 if not hasattr(remote, 'branches'): 1284 if not hasattr(remote, 'branches'):
1286 # enable in-client legacy support 1285 # enable in-client legacy support
1287 remote = localrepo.locallegacypeer(remote.local()) 1286 remote = localrepo.locallegacypeer(remote.local())
1290 remote._repo = r 1289 remote._repo = r
1291 common, _in, hds = treediscovery.findcommonincoming( 1290 common, _in, hds = treediscovery.findcommonincoming(
1292 repo, remote, force=True, audit=data 1291 repo, remote, force=True, audit=data
1293 ) 1292 )
1294 common = set(common) 1293 common = set(common)
1295 if not opts.get(b'nonheads'): 1294 if not opts.get('nonheads'):
1296 ui.writenoi18n( 1295 ui.writenoi18n(
1297 b"unpruned common: %s\n" 1296 b"unpruned common: %s\n"
1298 % b" ".join(sorted(short(n) for n in common)) 1297 % b" ".join(sorted(short(n) for n in common))
1299 ) 1298 )
1300 1299
1319 abortwhenunrelated=False, 1318 abortwhenunrelated=False,
1320 ) 1319 )
1321 return common, hds 1320 return common, hds
1322 1321
1323 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None) 1322 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, revs=None)
1324 localrevs = opts[b'rev'] 1323 localrevs = opts['rev']
1325 1324
1326 fm = ui.formatter(b'debugdiscovery', opts) 1325 fm = ui.formatter(b'debugdiscovery', pycompat.byteskwargs(opts))
1327 if fm.strict_format: 1326 if fm.strict_format:
1328 1327
1329 @contextlib.contextmanager 1328 @contextlib.contextmanager
1330 def may_capture_output(): 1329 def may_capture_output():
1331 ui.pushbuffer() 1330 ui.pushbuffer()