Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 45957:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 87e7dd8e7734 |
children | 7c539f0febbe |
comparison
equal
deleted
inserted
replaced
45956:346af7687c6f | 45957:89a2afe31e82 |
---|---|
1060 | 1060 |
1061 _chunksize = 4 << 10 | 1061 _chunksize = 4 << 10 |
1062 | 1062 |
1063 | 1063 |
1064 @command( | 1064 @command( |
1065 b'debugdownload', [(b'o', b'output', b'', _(b'path')),], optionalrepo=True | 1065 b'debugdownload', |
1066 [ | |
1067 (b'o', b'output', b'', _(b'path')), | |
1068 ], | |
1069 optionalrepo=True, | |
1066 ) | 1070 ) |
1067 def debugdownload(ui, repo, url, output=None, **opts): | 1071 def debugdownload(ui, repo, url, output=None, **opts): |
1068 """download a resource using Mercurial logic and config | 1072 """download a resource using Mercurial logic and config""" |
1069 """ | |
1070 fh = urlmod.open(ui, url, output) | 1073 fh = urlmod.open(ui, url, output) |
1071 | 1074 |
1072 dest = ui | 1075 dest = ui |
1073 if output: | 1076 if output: |
1074 dest = open(output, b"wb", _chunksize) | 1077 dest = open(output, b"wb", _chunksize) |
1508 ui.write(b'%s: %d\n' % (k, v)) | 1511 ui.write(b'%s: %d\n' % (k, v)) |
1509 | 1512 |
1510 | 1513 |
1511 @command(b'debuginstall', [] + cmdutil.formatteropts, b'', norepo=True) | 1514 @command(b'debuginstall', [] + cmdutil.formatteropts, b'', norepo=True) |
1512 def debuginstall(ui, **opts): | 1515 def debuginstall(ui, **opts): |
1513 '''test Mercurial installation | 1516 """test Mercurial installation |
1514 | 1517 |
1515 Returns 0 on success. | 1518 Returns 0 on success. |
1516 ''' | 1519 """ |
1517 opts = pycompat.byteskwargs(opts) | 1520 opts = pycompat.byteskwargs(opts) |
1518 | 1521 |
1519 problems = 0 | 1522 problems = 0 |
1520 | 1523 |
1521 fm = ui.formatter(b'debuginstall', opts) | 1524 fm = ui.formatter(b'debuginstall', opts) |
2171 _(b'display the on disk meta data for the nodemap'), | 2174 _(b'display the on disk meta data for the nodemap'), |
2172 ), | 2175 ), |
2173 ], | 2176 ], |
2174 ) | 2177 ) |
2175 def debugnodemap(ui, repo, **opts): | 2178 def debugnodemap(ui, repo, **opts): |
2176 """write and inspect on disk nodemap | 2179 """write and inspect on disk nodemap""" |
2177 """ | |
2178 if opts['dump_new']: | 2180 if opts['dump_new']: |
2179 unfi = repo.unfiltered() | 2181 unfi = repo.unfiltered() |
2180 cl = unfi.changelog | 2182 cl = unfi.changelog |
2181 if util.safehasattr(cl.index, "nodemap_data_all"): | 2183 if util.safehasattr(cl.index, "nodemap_data_all"): |
2182 data = cl.index.nodemap_data_all() | 2184 data = cl.index.nodemap_data_all() |
2400 (b'r', b'removed', None, _(b'show only removed files')), | 2402 (b'r', b'removed', None, _(b'show only removed files')), |
2401 ], | 2403 ], |
2402 _(b'FILESPEC...'), | 2404 _(b'FILESPEC...'), |
2403 ) | 2405 ) |
2404 def debugpathcomplete(ui, repo, *specs, **opts): | 2406 def debugpathcomplete(ui, repo, *specs, **opts): |
2405 '''complete part or all of a tracked path | 2407 """complete part or all of a tracked path |
2406 | 2408 |
2407 This command supports shells that offer path name completion. It | 2409 This command supports shells that offer path name completion. It |
2408 currently completes only files already known to the dirstate. | 2410 currently completes only files already known to the dirstate. |
2409 | 2411 |
2410 Completion extends only to the next path segment unless | 2412 Completion extends only to the next path segment unless |
2411 --full is specified, in which case entire paths are used.''' | 2413 --full is specified, in which case entire paths are used.""" |
2412 | 2414 |
2413 def complete(path, acceptable): | 2415 def complete(path, acceptable): |
2414 dirstate = repo.dirstate | 2416 dirstate = repo.dirstate |
2415 spec = os.path.normpath(os.path.join(encoding.getcwd(), path)) | 2417 spec = os.path.normpath(os.path.join(encoding.getcwd(), path)) |
2416 rootdir = repo.root + pycompat.ossep | 2418 rootdir = repo.root + pycompat.ossep |
2585 ui.write(b'%s = %s\n' % (path, tool)) | 2587 ui.write(b'%s = %s\n' % (path, tool)) |
2586 | 2588 |
2587 | 2589 |
2588 @command(b'debugpushkey', [], _(b'REPO NAMESPACE [KEY OLD NEW]'), norepo=True) | 2590 @command(b'debugpushkey', [], _(b'REPO NAMESPACE [KEY OLD NEW]'), norepo=True) |
2589 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): | 2591 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): |
2590 '''access the pushkey key/value protocol | 2592 """access the pushkey key/value protocol |
2591 | 2593 |
2592 With two args, list the keys in the given namespace. | 2594 With two args, list the keys in the given namespace. |
2593 | 2595 |
2594 With five args, set a key to new if it currently is set to old. | 2596 With five args, set a key to new if it currently is set to old. |
2595 Reports success or failure. | 2597 Reports success or failure. |
2596 ''' | 2598 """ |
2597 | 2599 |
2598 target = hg.peer(ui, {}, repopath) | 2600 target = hg.peer(ui, {}, repopath) |
2599 if keyinfo: | 2601 if keyinfo: |
2600 key, old, new = keyinfo | 2602 key, old, new = keyinfo |
2601 with target.commandexecutor() as e: | 2603 with target.commandexecutor() as e: |
3430 ui.writenoi18n(b' %s\n' % stringutil.pprint(value)) | 3432 ui.writenoi18n(b' %s\n' % stringutil.pprint(value)) |
3431 | 3433 |
3432 | 3434 |
3433 @command(b'debugssl', [], b'[SOURCE]', optionalrepo=True) | 3435 @command(b'debugssl', [], b'[SOURCE]', optionalrepo=True) |
3434 def debugssl(ui, repo, source=None, **opts): | 3436 def debugssl(ui, repo, source=None, **opts): |
3435 '''test a secure connection to a server | 3437 """test a secure connection to a server |
3436 | 3438 |
3437 This builds the certificate chain for the server on Windows, installing the | 3439 This builds the certificate chain for the server on Windows, installing the |
3438 missing intermediates and trusted root via Windows Update if necessary. It | 3440 missing intermediates and trusted root via Windows Update if necessary. It |
3439 does nothing on other platforms. | 3441 does nothing on other platforms. |
3440 | 3442 |
3441 If SOURCE is omitted, the 'default' path will be used. If a URL is given, | 3443 If SOURCE is omitted, the 'default' path will be used. If a URL is given, |
3442 that server is used. See :hg:`help urls` for more information. | 3444 that server is used. See :hg:`help urls` for more information. |
3443 | 3445 |
3444 If the update succeeds, retry the original operation. Otherwise, the cause | 3446 If the update succeeds, retry the original operation. Otherwise, the cause |
3445 of the SSL error is likely another issue. | 3447 of the SSL error is likely another issue. |
3446 ''' | 3448 """ |
3447 if not pycompat.iswindows: | 3449 if not pycompat.iswindows: |
3448 raise error.Abort( | 3450 raise error.Abort( |
3449 _(b'certificate chain building is only possible on Windows') | 3451 _(b'certificate chain building is only possible on Windows') |
3450 ) | 3452 ) |
3451 | 3453 |
3783 displayer.close() | 3785 displayer.close() |
3784 | 3786 |
3785 | 3787 |
3786 @command( | 3788 @command( |
3787 b'debuguigetpass', | 3789 b'debuguigetpass', |
3788 [(b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')),], | 3790 [ |
3791 (b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')), | |
3792 ], | |
3789 _(b'[-p TEXT]'), | 3793 _(b'[-p TEXT]'), |
3790 norepo=True, | 3794 norepo=True, |
3791 ) | 3795 ) |
3792 def debuguigetpass(ui, prompt=b''): | 3796 def debuguigetpass(ui, prompt=b''): |
3793 """show prompt to type password""" | 3797 """show prompt to type password""" |
3799 ui.writenoi18n(b'response: %s\n' % r) | 3803 ui.writenoi18n(b'response: %s\n' % r) |
3800 | 3804 |
3801 | 3805 |
3802 @command( | 3806 @command( |
3803 b'debuguiprompt', | 3807 b'debuguiprompt', |
3804 [(b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')),], | 3808 [ |
3809 (b'p', b'prompt', b'', _(b'prompt text'), _(b'TEXT')), | |
3810 ], | |
3805 _(b'[-p TEXT]'), | 3811 _(b'[-p TEXT]'), |
3806 norepo=True, | 3812 norepo=True, |
3807 ) | 3813 ) |
3808 def debuguiprompt(ui, prompt=b''): | 3814 def debuguiprompt(ui, prompt=b''): |
3809 """show plain prompt""" | 3815 """show plain prompt""" |
4312 if ui.verbose: | 4318 if ui.verbose: |
4313 openerargs.update( | 4319 openerargs.update( |
4314 { | 4320 { |
4315 'loggingfh': ui, | 4321 'loggingfh': ui, |
4316 'loggingname': b's', | 4322 'loggingname': b's', |
4317 'loggingopts': {'logdata': True, 'logdataapis': False,}, | 4323 'loggingopts': { |
4324 'logdata': True, | |
4325 'logdataapis': False, | |
4326 }, | |
4318 } | 4327 } |
4319 ) | 4328 ) |
4320 | 4329 |
4321 if ui.debugflag: | 4330 if ui.debugflag: |
4322 openerargs['loggingopts']['logdataapis'] = True | 4331 openerargs['loggingopts']['logdataapis'] = True |