changeset 50832:7d54b877782e

config: migrate `opts` to native kwargs
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 01:08:58 -0400
parents afddb0d5be4f
children de3191c0cec9
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Aug 20 01:02:52 2023 -0400
+++ b/mercurial/commands.py	Sun Aug 20 01:08:58 2023 -0400
@@ -2313,19 +2313,18 @@
 
     """
 
-    opts = pycompat.byteskwargs(opts)
-    editopts = (b'edit', b'local', b'global', b'shared', b'non_shared')
+    editopts = ('edit', 'local', 'global', 'shared', 'non_shared')
     if any(opts.get(o) for o in editopts):
         cmdutil.check_at_most_one_arg(opts, *editopts[1:])
-        if opts.get(b'local'):
+        if opts.get('local'):
             if not repo:
                 raise error.InputError(
                     _(b"can't use --local outside a repository")
                 )
             paths = [repo.vfs.join(b'hgrc')]
-        elif opts.get(b'global'):
+        elif opts.get('global'):
             paths = rcutil.systemrcpath()
-        elif opts.get(b'shared'):
+        elif opts.get('shared'):
             if not repo.shared():
                 raise error.InputError(
                     _(b"repository is not shared; can't use --shared")
@@ -2338,7 +2337,7 @@
                     )
                 )
             paths = [vfsmod.vfs(repo.sharedpath).join(b'hgrc')]
-        elif opts.get(b'non_shared'):
+        elif opts.get('non_shared'):
             paths = [repo.vfs.join(b'hgrc-not-shared')]
         else:
             paths = rcutil.userrcpath()
@@ -2347,9 +2346,9 @@
             if os.path.exists(f):
                 break
         else:
-            if opts.get(b'global'):
+            if opts.get('global'):
                 samplehgrc = uimod.samplehgrcs[b'global']
-            elif opts.get(b'local'):
+            elif opts.get('local'):
                 samplehgrc = uimod.samplehgrcs[b'local']
             else:
                 samplehgrc = uimod.samplehgrcs[b'user']
@@ -2368,7 +2367,7 @@
         )
         return
     ui.pager(b'config')
-    fm = ui.formatter(b'config', opts)
+    fm = ui.formatter(b'config', pycompat.byteskwargs(opts))
     for t, f in rcutil.rccomponents():
         if t == b'path':
             ui.debug(b'read config from: %s\n' % f)
@@ -2379,7 +2378,7 @@
             pass
         else:
             raise error.ProgrammingError(b'unknown rctype: %s' % t)
-    untrusted = bool(opts.get(b'untrusted'))
+    untrusted = bool(opts.get('untrusted'))
 
     selsections = selentries = []
     if values:
@@ -2390,8 +2389,8 @@
     selentries = set(selentries)
 
     matched = False
-    all_known = opts[b'exp_all_known']
-    show_source = ui.debugflag or opts.get(b'source')
+    all_known = opts['exp_all_known']
+    show_source = ui.debugflag or opts.get('source')
     entries = ui.walkconfig(untrusted=untrusted, all_known=all_known)
     for section, name, value in entries:
         source = ui.configsource(section, name, untrusted)