durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -23,17 +23,17 @@
     narrowspec,
 )
 
-requirement = 'narrowhg'
+REQUIREMENT = 'narrowhg'
 
 def wrappostshare(orig, sourcerepo, destrepo, **kwargs):
     orig(sourcerepo, destrepo, **kwargs)
-    if requirement in sourcerepo.requirements:
+    if 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 (REQUIREMENT in repo.requirements
         and repo.path == repopath and repo.shared()):
         srcrepo = share._getsrcrepo(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
@@ -103,7 +103,7 @@
             repo.__class__.__bases__ = (repo.__class__.__bases__[0],
                                         repo.unfiltered().__class__)
         if opts_narrow:
-            repo.requirements.add(narrowrepo.requirement)
+            repo.requirements.add(narrowrepo.REQUIREMENT)
             repo._writerequirements()
 
         return orig(repo, *args, **kwargs)
@@ -116,7 +116,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 narrowrepo.REQUIREMENT in repo.requirements:
 
         def pullbundle2extraprepare_widen(orig, pullop, kwargs):
             orig(pullop, kwargs)
@@ -130,7 +130,7 @@
 
 def archivenarrowcmd(orig, ui, repo, *args, **opts):
     """Wraps archive command to narrow the default includes."""
-    if narrowrepo.requirement in repo.requirements:
+    if narrowrepo.REQUIREMENT in repo.requirements:
         repo_includes, repo_excludes = repo.narrowpats
         includes = set(opts.get('include', []))
         excludes = set(opts.get('exclude', []))
@@ -144,7 +144,7 @@
 
 def pullbundle2extraprepare(orig, pullop, kwargs):
     repo = pullop.repo
-    if narrowrepo.requirement not in repo.requirements:
+    if narrowrepo.REQUIREMENT not in repo.requirements:
         return orig(pullop, kwargs)
 
     if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps:
@@ -330,7 +330,7 @@
     If --clear is specified without any further options, the narrowspec will be
     empty and will not match any files.
     """
-    if narrowrepo.requirement not in repo.requirements:
+    if narrowrepo.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
@@ -27,7 +27,7 @@
 
     def supportedoutgoingversions(orig, repo):
         versions = orig(repo)
-        if narrowrepo.requirement in repo.requirements:
+        if narrowrepo.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
@@ -368,8 +368,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 narrowrepo.REQUIREMENT in op.repo.requirements:
+        op.repo.requirements.add(narrowrepo.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
@@ -55,7 +55,7 @@
 # Export the commands table for Mercurial to see.
 cmdtable = narrowcommands.table
 
-localrepo.localrepository._basesupported.add(narrowrepo.requirement)
+localrepo.localrepository._basesupported.add(narrowrepo.REQUIREMENT)
 
 def uisetup(ui):
     """Wraps user-facing mercurial commands with narrow-aware versions."""
@@ -72,7 +72,7 @@
     if not isinstance(repo, localrepo.localrepository):
         return
 
-    if narrowrepo.requirement in repo.requirements:
+    if narrowrepo.REQUIREMENT in repo.requirements:
         narrowrepo.wraprepo(repo, True)
         narrowcopies.setup(repo)
         narrowdirstate.setup(repo)



To: durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to