diff hgext/narrow/narrowrepo.py @ 36464:3f0af89e008d

narrow: move requirement constant to core My short-term goal is to move narrowrepo.narrowmatch() onto localrepo and this is a necessary step for that. I put the constant in changegroup.py, unlike REVLOGV2_REQUIREMENT, which is in localrepo.py, since we'll need to access it from the changegroup module eventually. Differential Revision: https://phab.mercurial-scm.org/D2487
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 28 Feb 2018 10:21:43 -0800
parents 9fd8c2a3db5a
children a8b4d7673d8e
line wrap: on
line diff
--- a/hgext/narrow/narrowrepo.py	Wed Feb 21 14:36:42 2018 +0530
+++ b/hgext/narrow/narrowrepo.py	Wed Feb 28 10:21:43 2018 -0800
@@ -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: