# HG changeset patch # User Martin von Zweigbergk # Date 2018-12-30 07:40:18 # Node ID 44a51c1c8e173804ae76eb68e31613e7024ed931 # Parent a2ae27993e1638aea09afeff43e0efe712d35053 narrow: move copytonarrowspec() out of setnarrowpats() I think it was a mistake to write the working copy's narrowspec every time the store narrowspec is written. This starts separating those actions. Differential Revision: https://phab.mercurial-scm.org/D5509 diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py --- a/hgext/narrow/narrowbundle2.py +++ b/hgext/narrow/narrowbundle2.py @@ -151,6 +151,7 @@ def _handlechangespec_2(op, inpart): op.repo.requirements.add(repository.NARROW_REQUIREMENT) op.repo._writerequirements() op.repo.setnarrowpats(includepats, excludepats) + narrowspec.copytoworkingcopy(op.repo) @bundle2.parthandler(_CHANGESPECPART) def _handlechangespec(op, inpart): diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -245,6 +245,7 @@ def _narrow(ui, repo, remote, commoninc, # Update narrowspec before removing revlogs, so repo won't be # corrupt in case of crash repo.setnarrowpats(newincludes, newexcludes) + narrowspec.copytoworkingcopy(repo) for f in todelete: ui.status(_('deleting %s\n') % f) @@ -316,6 +317,7 @@ def _widen(ui, repo, remote, commoninc, transactiongetter=tgetter) repo.setnewnarrowpats() + narrowspec.copytoworkingcopy(repo) actions = merge.emptyactions() addgaction = actions['g'].append diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -737,6 +737,7 @@ def clone(ui, peeropts, source, dest=Non if narrow: with local.wlock(), local.lock(): local.setnarrowpats(storeincludepats, storeexcludepats) + narrowspec.copytoworkingcopy(local) u = util.url(abspath) defaulturl = bytes(u) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1259,7 +1259,6 @@ class localrepository(object): def setnarrowpats(self, newincludes, newexcludes): narrowspec.save(self, newincludes, newexcludes) - narrowspec.copytoworkingcopy(self) self.invalidate(clearfilecache=True) def __getitem__(self, changeid): diff --git a/tests/test-narrow-expanddirstate.t b/tests/test-narrow-expanddirstate.t --- a/tests/test-narrow-expanddirstate.t +++ b/tests/test-narrow-expanddirstate.t @@ -71,6 +71,7 @@ have this method available in narrowhg p > if not repo.currenttransaction(): > ui.develwarn(b'expandnarrowspec called outside of transaction!') > repo.setnarrowpats(includes, excludes) + > narrowspec.copytoworkingcopy(repo) > newmatcher = narrowspec.match(repo.root, includes, excludes) > added = matchmod.differencematcher(newmatcher, currentmatcher) > for f in repo[b'.'].manifest().walk(added):