Patchwork D2487: narrow: move requirement constant to core

login
register
mail settings
Submitter phabricator
Date March 1, 2018, 2:17 a.m.
Message ID <57f1ab300f58bb5002bdc45f6e0a0a42@localhost.localdomain>
Download mbox | patch
Permalink /patch/28520/
State Not Applicable
Headers show

Comments

phabricator - March 1, 2018, 2:17 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd93553662d0a: narrow: move requirement constant to core (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2487?vs=6187&id=6220

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

AFFECTED FILES
  hgext/narrow/__init__.py
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowchangegroup.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowrepo.py
  mercurial/changegroup.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -32,6 +32,10 @@ 
 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
 _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH"
 
+# 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):
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -9,6 +9,7 @@ 
 
 from mercurial import (
     bundlerepo,
+    changegroup,
     hg,
     localrepo,
     match as matchmod,
@@ -20,19 +21,15 @@ 
     narrowrevlog,
 )
 
-# When narrowing is finalized and no longer subject to format changes,
-# we should move this to just "narrow" or similar.
-REQUIREMENT = 'narrowhg-experimental'
-
 def wrappostshare(orig, sourcerepo, destrepo, **kwargs):
     orig(sourcerepo, destrepo, **kwargs)
-    if REQUIREMENT in sourcerepo.requirements:
+    if changegroup.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 (REQUIREMENT in repo.requirements
+    if (changegroup.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
@@ -11,6 +11,7 @@ 
 from mercurial.i18n import _
 from mercurial import (
     cmdutil,
+    changegroup,
     commands,
     discovery,
     error,
@@ -105,7 +106,7 @@ 
             repo.__class__.__bases__ = (repo.__class__.__bases__[0],
                                         repo.unfiltered().__class__)
         if opts_narrow:
-            repo.requirements.add(narrowrepo.REQUIREMENT)
+            repo.requirements.add(changegroup.NARROW_REQUIREMENT)
             repo._writerequirements()
 
         return orig(repo, *args, **kwargs)
@@ -118,7 +119,7 @@ 
 def pullnarrowcmd(orig, ui, repo, *args, **opts):
     """Wraps pull command to allow modifying narrow spec."""
     wrappedextraprepare = util.nullcontextmanager()
-    if narrowrepo.REQUIREMENT in repo.requirements:
+    if changegroup.NARROW_REQUIREMENT in repo.requirements:
 
         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
             orig(pullop, kwargs)
@@ -132,7 +133,7 @@ 
 
 def archivenarrowcmd(orig, ui, repo, *args, **opts):
     """Wraps archive command to narrow the default includes."""
-    if narrowrepo.REQUIREMENT in repo.requirements:
+    if changegroup.NARROW_REQUIREMENT in repo.requirements:
         repo_includes, repo_excludes = repo.narrowpats
         includes = set(opts.get(r'include', []))
         excludes = set(opts.get(r'exclude', []))
@@ -146,7 +147,7 @@ 
 
 def pullbundle2extraprepare(orig, pullop, kwargs):
     repo = pullop.repo
-    if narrowrepo.REQUIREMENT not in repo.requirements:
+    if changegroup.NARROW_REQUIREMENT not in repo.requirements:
         return orig(pullop, kwargs)
 
     if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
@@ -333,7 +334,7 @@ 
     empty and will not match any files.
     """
     opts = pycompat.byteskwargs(opts)
-    if narrowrepo.REQUIREMENT not in repo.requirements:
+    if changegroup.NARROW_REQUIREMENT not in repo.requirements:
         ui.warn(_('The narrow command is only supported on respositories cloned'
                   ' with --narrow.\n'))
         return 1
diff --git a/hgext/narrow/narrowchangegroup.py b/hgext/narrow/narrowchangegroup.py
--- a/hgext/narrow/narrowchangegroup.py
+++ b/hgext/narrow/narrowchangegroup.py
@@ -19,15 +19,11 @@ 
     util,
 )
 
-from . import (
-    narrowrepo,
-)
-
 def setup():
 
     def supportedoutgoingversions(orig, repo):
         versions = orig(repo)
-        if narrowrepo.REQUIREMENT in repo.requirements:
+        if changegroup.NARROW_REQUIREMENT in repo.requirements:
             versions.discard('01')
             versions.discard('02')
         return versions
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -30,10 +30,6 @@ 
     wireproto,
 )
 
-from . import (
-    narrowrepo,
-)
-
 NARROWCAP = 'narrow'
 _NARROWACL_SECTION = 'narrowhgacl'
 _CHANGESPECPART = NARROWCAP + ':changespec'
@@ -366,8 +362,8 @@ 
     includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
     excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
     narrowspec.save(op.repo, includepats, excludepats)
-    if not narrowrepo.REQUIREMENT in op.repo.requirements:
-        op.repo.requirements.add(narrowrepo.REQUIREMENT)
+    if not changegroup.NARROW_REQUIREMENT in op.repo.requirements:
+        op.repo.requirements.add(changegroup.NARROW_REQUIREMENT)
         op.repo._writerequirements()
     op.repo.invalidate(clearfilecache=True)
 
diff --git a/hgext/narrow/__init__.py b/hgext/narrow/__init__.py
--- a/hgext/narrow/__init__.py
+++ b/hgext/narrow/__init__.py
@@ -15,6 +15,7 @@ 
 testedwith = 'ships-with-hg-core'
 
 from mercurial import (
+    changegroup,
     extensions,
     hg,
     localrepo,
@@ -55,7 +56,7 @@ 
 # Export the commands table for Mercurial to see.
 cmdtable = narrowcommands.table
 
-localrepo.localrepository._basesupported.add(narrowrepo.REQUIREMENT)
+localrepo.localrepository._basesupported.add(changegroup.NARROW_REQUIREMENT)
 
 def uisetup(ui):
     """Wraps user-facing mercurial commands with narrow-aware versions."""
@@ -71,7 +72,7 @@ 
     if not isinstance(repo, localrepo.localrepository):
         return
 
-    if narrowrepo.REQUIREMENT in repo.requirements:
+    if changegroup.NARROW_REQUIREMENT in repo.requirements:
         narrowrepo.wraprepo(repo, True)
         narrowcopies.setup(repo)
         narrowdirstate.setup(repo)