diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -24,6 +24,7 @@ from mercurial import (
     error,
     exchange,
     extensions,
+    narrowspec,
     repair,
     util,
     wireproto,
@@ -31,7 +32,6 @@ from mercurial import (
 
 from . import (
     narrowrepo,
-    narrowspec,
 )
 
 NARROWCAP = 'narrow'
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 @@ from mercurial import (
     extensions,
     hg,
     merge,
+    narrowspec,
     node,
     pycompat,
     registrar,
@@ -29,7 +30,6 @@ from mercurial import (
 from . import (
     narrowbundle2,
     narrowrepo,
-    narrowspec,
 )
 
 table = {}
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 @@ from mercurial import (
     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/narrowrepo.py b/hgext/narrow/narrowrepo.py
--- a/hgext/narrow/narrowrepo.py
+++ b/hgext/narrow/narrowrepo.py
@@ -12,12 +12,12 @@ from mercurial import (
     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/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -12,11 +12,10 @@ from mercurial import (
     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/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 @@ from __future__ import absolute_import
 
 import errno
 
-from mercurial.i18n import _
-from mercurial import (
+from .i18n import _
+from . import (
     error,
     hg,
     match as matchmod,
@@ -89,7 +89,7 @@ def _validatepattern(pat):
     # 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/tests/test-narrow-expanddirstate.t b/tests/test-narrow-expanddirstate.t
--- a/tests/test-narrow-expanddirstate.t
+++ b/tests/test-narrow-expanddirstate.t
@@ -51,6 +51,7 @@ have this method available in narrowhg p
   > 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
   > 
@@ -59,14 +60,13 @@ have this method available in narrowhg p
   >     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)