# HG changeset patch # User Gregory Szorc # Date 2018-09-12 00:22:15 # Node ID cb675e95a2c2d6b248a9deb459aa7e75edb649a7 # Parent 841c82d1a973a6c40c0092ea7c09479bbece4a1e 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 diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -92,19 +92,6 @@ def clonenarrowcmd(orig, ui, repo, *args 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'): diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -737,6 +737,10 @@ def clone(ui, peeropts, source, dest=Non 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')