changeset 50904:4803cea1e5ab

narrow: migrate `opts` to native kwargs
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 17:04:17 -0400
parents ee393dbfe5cb
children 75b90a8eb168
files hgext/narrow/narrowcommands.py
diffstat 1 files changed, 23 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py	Sun Aug 20 16:51:49 2023 -0400
+++ b/hgext/narrow/narrowcommands.py	Sun Aug 20 17:04:17 2023 -0400
@@ -87,9 +87,8 @@
 
 def clonenarrowcmd(orig, ui, repo, *args, **opts):
     """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
-    opts = pycompat.byteskwargs(opts)
     wrappedextraprepare = util.nullcontextmanager()
-    narrowspecfile = opts[b'narrowspec']
+    narrowspecfile = opts['narrowspec']
 
     if narrowspecfile:
         filepath = os.path.join(encoding.getcwd(), narrowspecfile)
@@ -115,24 +114,25 @@
         narrowspec.validatepatterns(excludes)
 
         # narrowspec is passed so we should assume that user wants narrow clone
-        opts[b'narrow'] = True
-        opts[b'include'].extend(includes)
-        opts[b'exclude'].extend(excludes)
+        opts['narrow'] = True
+        opts['include'].extend(includes)
+        opts['exclude'].extend(excludes)
 
-    if opts[b'narrow']:
+    if opts['narrow']:
 
         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
             orig(pullop, kwargs)
 
-            if opts.get(b'depth'):
-                kwargs[b'depth'] = opts[b'depth']
+            if opts.get('depth'):
+                # TODO: fix exchange._pullbundle2extraprepare()
+                kwargs[b'depth'] = opts['depth']
 
         wrappedextraprepare = extensions.wrappedfunction(
             exchange, '_pullbundle2extraprepare', pullbundle2extraprepare_widen
         )
 
     with wrappedextraprepare:
-        return orig(ui, repo, *args, **pycompat.strkwargs(opts))
+        return orig(ui, repo, *args, **opts)
 
 
 def pullnarrowcmd(orig, ui, repo, *args, **opts):
@@ -511,7 +511,6 @@
     add --addinclude, --addexclude rules in bulk. Like the other include and
     exclude switches, the changes are applied immediately.
     """
-    opts = pycompat.byteskwargs(opts)
     if requirements.NARROW_REQUIREMENT not in repo.requirements:
         raise error.InputError(
             _(
@@ -522,11 +521,11 @@
 
     # Before supporting, decide whether it "hg tracked --clear" should mean
     # tracking no paths or all paths.
-    if opts[b'clear']:
+    if opts['clear']:
         raise error.InputError(_(b'the --clear option is not yet supported'))
 
     # import rules from a file
-    newrules = opts.get(b'import_rules')
+    newrules = opts.get('import_rules')
     if newrules:
         try:
             filepath = os.path.join(encoding.getcwd(), newrules)
@@ -546,16 +545,16 @@
                     b"is not supported in narrowspec"
                 )
             )
-        opts[b'addinclude'].extend(includepats)
-        opts[b'addexclude'].extend(excludepats)
+        opts['addinclude'].extend(includepats)
+        opts['addexclude'].extend(excludepats)
 
-    addedincludes = narrowspec.parsepatterns(opts[b'addinclude'])
-    removedincludes = narrowspec.parsepatterns(opts[b'removeinclude'])
-    addedexcludes = narrowspec.parsepatterns(opts[b'addexclude'])
-    removedexcludes = narrowspec.parsepatterns(opts[b'removeexclude'])
-    autoremoveincludes = opts[b'auto_remove_includes']
+    addedincludes = narrowspec.parsepatterns(opts['addinclude'])
+    removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
+    addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
+    removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
+    autoremoveincludes = opts['auto_remove_includes']
 
-    update_working_copy = opts[b'update_working_copy']
+    update_working_copy = opts['update_working_copy']
     only_show = not (
         addedincludes
         or removedincludes
@@ -570,7 +569,7 @@
     if only_show:
         oldincludes, oldexcludes = repo.narrowpats
         ui.pager(b'tracked')
-        fm = ui.formatter(b'narrow', opts)
+        fm = ui.formatter(b'narrow', pycompat.byteskwargs(opts))
         for i in sorted(oldincludes):
             fm.startitem()
             fm.write(b'status', b'%s ', b'I', label=b'narrow.included')
@@ -614,7 +613,7 @@
         # also define the set of revisions to update for widening.
         path = urlutil.get_unique_pull_path_obj(b'tracked', ui, remotepath)
         ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(path.loc))
-        remote = hg.peer(repo, opts, path)
+        remote = hg.peer(repo, pycompat.byteskwargs(opts), path)
 
         try:
             # check narrow support before doing anything if widening needs to be
@@ -670,8 +669,8 @@
                     oldexcludes,
                     newincludes,
                     newexcludes,
-                    opts[b'force_delete_local_changes'],
-                    opts[b'backup'],
+                    opts['force_delete_local_changes'],
+                    opts['backup'],
                 )
                 # _narrow() updated the narrowspec and _widen() below needs to
                 # use the updated values as its base (otherwise removed includes