D4532: narrow: set opts['narrow'] instead of local variable

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Sep 12 00:27:32 UTC 2018


indygreg created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will allow the command function in core to infer the presence
  of the option without duplicating logic.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4532

AFFECTED FILES
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -66,7 +66,6 @@
     """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
     opts = pycompat.byteskwargs(opts)
     wrappedextraprepare = util.nullcontextmanager()
-    opts_narrow = opts['narrow']
     narrowspecfile = opts['narrowspec']
 
     if narrowspecfile:
@@ -87,11 +86,11 @@
         narrowspec.validatepatterns(excludes)
 
         # narrowspec is passed so we should assume that user wants narrow clone
-        opts_narrow = True
+        opts['narrow'] = True
         opts['include'].extend(includes)
         opts['exclude'].extend(excludes)
 
-    if opts_narrow:
+    if opts['narrow']:
         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
             # Create narrow spec patterns from clone flags
             includepats = narrowspec.parsepatterns(opts['include'])
@@ -114,7 +113,7 @@
             '_pullbundle2extraprepare', pullbundle2extraprepare_widen)
 
     def pullnarrow(orig, repo, *args, **kwargs):
-        if opts_narrow:
+        if opts['narrow']:
             repo.requirements.add(repository.NARROW_REQUIREMENT)
             repo._writerequirements()
 



To: indygreg, durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list