diff mercurial/sparse.py @ 45355:a1f51c7dce0f

repository: introduce constant for sparse repo requirement and use it In future we will like to much cleaner logic around which requirement is for working copy and which can go in store. To start with that, we first need to de-clutter the requirement values spread around and replace them with constants. Differential Revision: https://phab.mercurial-scm.org/D8911
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 08 Aug 2020 10:06:32 -0700
parents 3c783ff08d40
children 77b8588dd84e
line wrap: on
line diff
--- a/mercurial/sparse.py	Fri Aug 07 16:02:13 2020 +0530
+++ b/mercurial/sparse.py	Sat Aug 08 10:06:32 2020 -0700
@@ -24,8 +24,10 @@
     scmutil,
     util,
 )
+from .interfaces import repository
 from .utils import hashutil
 
+
 # Whether sparse features are enabled. This variable is intended to be
 # temporary to facilitate porting sparse to core. It should eventually be
 # a per-repo option, possibly a repo requirement.
@@ -606,11 +608,11 @@
     # updated. But this requires massive rework to matcher() and its
     # consumers.
 
-    if b'exp-sparse' in oldrequires and removing:
-        repo.requirements.discard(b'exp-sparse')
+    if repository.SPARSE_REQUIREMENT in oldrequires and removing:
+        repo.requirements.discard(repository.SPARSE_REQUIREMENT)
         scmutil.writereporequirements(repo)
-    elif b'exp-sparse' not in oldrequires:
-        repo.requirements.add(b'exp-sparse')
+    elif repository.SPARSE_REQUIREMENT not in oldrequires:
+        repo.requirements.add(repository.SPARSE_REQUIREMENT)
         scmutil.writereporequirements(repo)
 
     try: