D4094: narrow: move requirement constant from changegroup to repository
This revision was automatically updated to reflect the committed changes. Closed by commit rHGa232e6744ba3: narrow: move requirement constant from changegroup to repository (authored by martinvonz, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4094?vs=9856=9863 REVISION DETAIL https://phab.mercurial-scm.org/D4094 AFFECTED FILES hgext/narrow/__init__.py hgext/narrow/narrowbundle2.py hgext/narrow/narrowcommands.py hgext/narrow/narrowrepo.py mercurial/changegroup.py mercurial/exchange.py mercurial/localrepo.py mercurial/repository.py CHANGE DETAILS diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -15,6 +15,10 @@ interfaceutil, ) +# When narrowing is finalized and no longer subject to format changes, +# we should move this to just "narrow" or similar. +NARROW_REQUIREMENT = 'narrowhg-experimental' + class ipeerconnection(interfaceutil.Interface): """Represents a "connection" to a repository. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -825,7 +825,7 @@ @repofilecache(narrowspec.FILENAME) def _narrowmatch(self): -if changegroup.NARROW_REQUIREMENT not in self.requirements: +if repository.NARROW_REQUIREMENT not in self.requirements: return matchmod.always(self.root, '') include, exclude = self.narrowpats return narrowspec.match(self.root, include=include, exclude=exclude) diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -34,6 +34,7 @@ phases, pushkey, pycompat, +repository, scmutil, sslutil, streamclone, @@ -1432,7 +1433,7 @@ old_heads = unficl.heads() clstart = len(unficl) _pullbundle2(pullop) -if changegroup.NARROW_REQUIREMENT in repo.requirements: +if repository.NARROW_REQUIREMENT in repo.requirements: # XXX narrow clones filter the heads on the server side during # XXX getbundle and result in partial replies as well. # XXX Disable pull bundles in this case as band aid to avoid diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -26,6 +26,7 @@ mdiff, phases, pycompat, +repository, util, ) @@ -39,10 +40,6 @@ LFS_REQUIREMENT = 'lfs' -# When narrowing is finalized and no longer subject to format changes, -# we should move this to just "narrow" or similar. -NARROW_REQUIREMENT = 'narrowhg-experimental' - readexactly = util.readexactly def getchunk(stream): @@ -914,7 +911,7 @@ # support versions 01 and 02. versions.discard('01') versions.discard('02') -if NARROW_REQUIREMENT in repo.requirements: +if repository.NARROW_REQUIREMENT in repo.requirements: # Versions 01 and 02 don't support revlog flags, and we need to # support that for stripping and unbundling to work. versions.discard('01') diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -8,9 +8,9 @@ from __future__ import absolute_import from mercurial import ( -changegroup, hg, narrowspec, +repository, ) from . import ( @@ -20,13 +20,13 @@ def wrappostshare(orig, sourcerepo, destrepo, **kwargs): orig(sourcerepo, destrepo, **kwargs) -if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements: +if repository.NARROW_REQUIREMENT in sourcerepo.requirements: with destrepo.wlock(): with destrepo.vfs('shared', 'a') as fp: fp.write(narrowspec.FILENAME + '\n') def unsharenarrowspec(orig, ui, repo, repopath): -if (changegroup.NARROW_REQUIREMENT in repo.requirements +if (repository.NARROW_REQUIREMENT in repo.requirements and repo.path == repopath and repo.shared()): srcrepo = hg.sharedreposource(repo) with srcrepo.vfs(narrowspec.FILENAME) as f: diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -10,7 +10,6 @@ from mercurial.i18n import _ from mercurial import ( -changegroup, cmdutil, commands, discovery, @@ -24,6 +23,7 @@ pycompat, registrar, repair, +repository, repoview, util, ) @@ -101,7 +101,7 @@ def pullnarrow(orig, repo, *args, **kwargs): if opts_narrow: -repo.requirements.add(changegroup.NARROW_REQUIREMENT) +repo.requirements.add(repository.NARROW_REQUIREMENT) repo._writerequirements() return orig(repo, *args, **kwargs) @@ -114,7 +114,7 @@ def pullnarrowcmd(orig, ui, repo, *args, **opts):
D4094: narrow: move requirement constant from changegroup to repository
martinvonz created this revision. Herald added a reviewer: durin42. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY As suggested by Gregory Szorc. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4094 AFFECTED FILES hgext/narrow/__init__.py hgext/narrow/narrowbundle2.py hgext/narrow/narrowcommands.py hgext/narrow/narrowrepo.py mercurial/changegroup.py mercurial/exchange.py mercurial/localrepo.py mercurial/repository.py CHANGE DETAILS diff --git a/mercurial/repository.py b/mercurial/repository.py --- a/mercurial/repository.py +++ b/mercurial/repository.py @@ -15,6 +15,10 @@ interfaceutil, ) +# When narrowing is finalized and no longer subject to format changes, +# we should move this to just "narrow" or similar. +NARROW_REQUIREMENT = 'narrowhg-experimental' + class ipeerconnection(interfaceutil.Interface): """Represents a "connection" to a repository. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -825,7 +825,7 @@ @repofilecache(narrowspec.FILENAME) def _narrowmatch(self): -if changegroup.NARROW_REQUIREMENT not in self.requirements: +if repository.NARROW_REQUIREMENT not in self.requirements: return matchmod.always(self.root, '') include, exclude = self.narrowpats return narrowspec.match(self.root, include=include, exclude=exclude) diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -34,6 +34,7 @@ phases, pushkey, pycompat, +repository, scmutil, sslutil, streamclone, @@ -1432,7 +1433,7 @@ old_heads = unficl.heads() clstart = len(unficl) _pullbundle2(pullop) -if changegroup.NARROW_REQUIREMENT in repo.requirements: +if repository.NARROW_REQUIREMENT in repo.requirements: # XXX narrow clones filter the heads on the server side during # XXX getbundle and result in partial replies as well. # XXX Disable pull bundles in this case as band aid to avoid diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -26,6 +26,7 @@ mdiff, phases, pycompat, +repository, util, ) @@ -39,10 +40,6 @@ LFS_REQUIREMENT = 'lfs' -# When narrowing is finalized and no longer subject to format changes, -# we should move this to just "narrow" or similar. -NARROW_REQUIREMENT = 'narrowhg-experimental' - readexactly = util.readexactly def getchunk(stream): @@ -914,7 +911,7 @@ # support versions 01 and 02. versions.discard('01') versions.discard('02') -if NARROW_REQUIREMENT in repo.requirements: +if repository.NARROW_REQUIREMENT in repo.requirements: # Versions 01 and 02 don't support revlog flags, and we need to # support that for stripping and unbundling to work. versions.discard('01') diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py --- a/hgext/narrow/narrowrepo.py +++ b/hgext/narrow/narrowrepo.py @@ -8,9 +8,9 @@ from __future__ import absolute_import from mercurial import ( -changegroup, hg, narrowspec, +repository, ) from . import ( @@ -20,13 +20,13 @@ def wrappostshare(orig, sourcerepo, destrepo, **kwargs): orig(sourcerepo, destrepo, **kwargs) -if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements: +if repository.NARROW_REQUIREMENT in sourcerepo.requirements: with destrepo.wlock(): with destrepo.vfs('shared', 'a') as fp: fp.write(narrowspec.FILENAME + '\n') def unsharenarrowspec(orig, ui, repo, repopath): -if (changegroup.NARROW_REQUIREMENT in repo.requirements +if (repository.NARROW_REQUIREMENT in repo.requirements and repo.path == repopath and repo.shared()): srcrepo = hg.sharedreposource(repo) with srcrepo.vfs(narrowspec.FILENAME) as f: diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -10,7 +10,6 @@ from mercurial.i18n import _ from mercurial import ( -changegroup, cmdutil, commands, discovery, @@ -24,6 +23,7 @@ pycompat, registrar, repair, +repository, repoview, util, ) @@ -101,7 +101,7 @@ def pullnarrow(orig, repo, *args, **kwargs): if opts_narrow: -repo.requirements.add(changegroup.NARROW_REQUIREMENT) +repo.requirements.add(repository.NARROW_REQUIREMENT) repo._writerequirements() return orig(repo, *args, **kwargs) @@ -114,7 +114,7 @@ def pullnarrowcmd(orig, ui, repo, *args, **opts): """Wraps pull command to allow modifying narrow spec.""" wrappedextraprepare =