hg: write narrow patterns after repo creation
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 11 Sep 2018 17:22:15 -0700
changeset 39571 cb675e95a2c2
parent 39570 841c82d1a973
child 39572 c8ea5c7ec99d
hg: write narrow patterns after repo creation Now that hg.clone() knows when a narrow clone is requested, it makes sense to have it update the narrow patterns for the repo soon after the repo is created, before any exchange occurs. Previously, the narrow extension was monkeypatching an exchange function to do this. The old code is redundant and has been removed. Differential Revision: https://phab.mercurial-scm.org/D4541
hgext/narrow/narrowcommands.py
mercurial/hg.py
--- a/hgext/narrow/narrowcommands.py	Tue Sep 11 16:59:17 2018 -0700
+++ b/hgext/narrow/narrowcommands.py	Tue Sep 11 17:22:15 2018 -0700
@@ -92,19 +92,6 @@
 
     if opts['narrow']:
         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
-            # Create narrow spec patterns from clone flags
-            includepats = narrowspec.parsepatterns(opts['include'])
-            excludepats = narrowspec.parsepatterns(opts['exclude'])
-
-            if not includepats and excludepats:
-                # If nothing was included, we assume the user meant to include
-                # everything, except what they asked to exclude.
-                includepats = {'path:.'}
-
-            pullop.repo.setnarrowpats(includepats, excludepats)
-
-            # This will populate 'includepats' etc with the values from the
-            # narrowspec we just saved.
             orig(pullop, kwargs)
 
             if opts.get('depth'):
--- a/mercurial/hg.py	Tue Sep 11 16:59:17 2018 -0700
+++ b/mercurial/hg.py	Tue Sep 11 17:22:15 2018 -0700
@@ -737,6 +737,10 @@
                 revs = None
             local = destpeer.local()
             if local:
+                if narrow:
+                    with local.lock():
+                        local.setnarrowpats(storeincludepats, storeexcludepats)
+
                 u = util.url(abspath)
                 defaulturl = bytes(u)
                 local.ui.setconfig('paths', 'default', defaulturl, 'clone')