D2201: narrowspec: move module into core

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Tue Feb 13 00:31:36 UTC 2018


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

REVISION SUMMARY
  Having support for parsing the narrow specification in core is
  necessary for moving many other parts of narrow to core.
  
  We do still want to harmonize the narrow spec with the sparse
  spec. And the format needs to be documented. But this shouldn't
  hold up the code moving to core.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowcommands.py
  hgext/narrow/narrowdirstate.py
  hgext/narrow/narrowrepo.py
  hgext/narrow/narrowspec.py
  hgext/narrow/narrowwirepeer.py
  mercurial/narrowspec.py
  tests/test-narrow-expanddirstate.t

CHANGE DETAILS

diff --git a/tests/test-narrow-expanddirstate.t b/tests/test-narrow-expanddirstate.t
--- a/tests/test-narrow-expanddirstate.t
+++ b/tests/test-narrow-expanddirstate.t
@@ -51,22 +51,22 @@
   > from mercurial import extensions
   > from mercurial import localrepo
   > from mercurial import match as matchmod
+  > from mercurial import narrowspec
   > from mercurial import patch
   > from mercurial import util as hgutil
   > 
   > def expandnarrowspec(ui, repo, newincludes=None):
   >   if not newincludes:
   >     return
   >   import sys
   >   newincludes = set([newincludes])
-  >   narrowhg = extensions.find('narrow')
   >   includes, excludes = repo.narrowpats
-  >   currentmatcher = narrowhg.narrowspec.match(repo.root, includes, excludes)
+  >   currentmatcher = narrowspec.match(repo.root, includes, excludes)
   >   includes = includes | newincludes
   >   if not repo.currenttransaction():
   >     ui.develwarn('expandnarrowspec called outside of transaction!')
   >   repo.setnarrowpats(includes, excludes)
-  >   newmatcher = narrowhg.narrowspec.match(repo.root, includes, excludes)
+  >   newmatcher = narrowspec.match(repo.root, includes, excludes)
   >   added = matchmod.differencematcher(newmatcher, currentmatcher)
   >   for f in repo['.'].manifest().walk(added):
   >     repo.dirstate.normallookup(f)
diff --git a/hgext/narrow/narrowspec.py b/mercurial/narrowspec.py
rename from hgext/narrow/narrowspec.py
rename to mercurial/narrowspec.py
--- a/hgext/narrow/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -9,8 +9,8 @@
 
 import errno
 
-from mercurial.i18n import _
-from mercurial import (
+from .i18n import _
+from . import (
     error,
     hg,
     match as matchmod,
@@ -89,7 +89,7 @@
     # We use newlines as separators in the narrowspec file, so don't allow them
     # in patterns.
     if _numlines(pat) > 1:
-        raise error.Abort('newlines are not allowed in narrowspec paths')
+        raise error.Abort(_('newlines are not allowed in narrowspec paths'))
 
     components = pat.split('/')
     if '.' in components or '..' in components:
diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -12,11 +12,10 @@
     error,
     extensions,
     hg,
+    narrowspec,
     node,
 )
 
-from . import narrowspec
-
 def uisetup():
     def peersetup(ui, peer):
         # We must set up the expansion before reposetup below, since it's used
diff --git a/hgext/narrow/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -12,12 +12,12 @@
     hg,
     localrepo,
     match as matchmod,
+    narrowspec,
     scmutil,
 )
 
 from . import (
     narrowrevlog,
-    narrowspec,
 )
 
 # When narrowing is finalized and no longer subject to format changes,
diff --git a/hgext/narrow/narrowdirstate.py b/hgext/narrow/narrowdirstate.py
--- a/hgext/narrow/narrowdirstate.py
+++ b/hgext/narrow/narrowdirstate.py
@@ -13,11 +13,10 @@
     error,
     extensions,
     match as matchmod,
+    narrowspec,
     util as hgutil,
 )
 
-from . import narrowspec
-
 def setup(repo):
     """Add narrow spec dirstate ignore, block changes outside narrow spec."""
 
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -18,6 +18,7 @@
     extensions,
     hg,
     merge,
+    narrowspec,
     node,
     registrar,
     repair,
@@ -28,7 +29,6 @@
 from . import (
     narrowbundle2,
     narrowrepo,
-    narrowspec,
 )
 
 table = {}
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -24,14 +24,14 @@
     error,
     exchange,
     extensions,
+    narrowspec,
     repair,
     util,
     wireproto,
 )
 
 from . import (
     narrowrepo,
-    narrowspec,
 )
 
 NARROWCAP = 'narrow'



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


More information about the Mercurial-devel mailing list