Patchwork D4057: narrowspec: use sparse.parseconfig() to parse narrowspec file

login
register
mail settings
Submitter phabricator
Date Aug. 3, 2018, 4:56 p.m.
Message ID <f6c9457395e72a084f9db0af12910802@localhost.localdomain>
Download mbox | patch
Permalink /patch/33162/
State Not Applicable
Headers show

Comments

phabricator - Aug. 3, 2018, 4:56 p.m.
pulkit updated this revision to Diff 9829.
pulkit edited the summary of this revision.
pulkit retitled this revision from "narrowspec: use sparse.parseconfig() to parse narrowspec file (BC)" to "narrowspec: use sparse.parseconfig() to parse narrowspec file".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4057?vs=9796&id=9829

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

AFFECTED FILES
  mercurial/narrowspec.py
  tests/test-narrow-clone-no-ellipsis.t
  tests/test-narrow-clone.t
  tests/test-narrow-debugcommands.t
  tests/test-narrow-patterns.t

CHANGE DETAILS




To: pulkit, durin42, #hg-reviewers, martinvonz
Cc: martinvonz, mercurial-devel

Patch

diff --git a/tests/test-narrow-patterns.t b/tests/test-narrow-patterns.t
--- a/tests/test-narrow-patterns.t
+++ b/tests/test-narrow-patterns.t
@@ -89,10 +89,10 @@ 
 
   $ cd narrow
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir1
   path:dir2
-  [excludes]
+  [exclude]
   path:dir1/dirA
   path:dir1/dirB
   path:dir2/dirA
@@ -145,10 +145,10 @@ 
   added 9 changesets with 6 changes to 6 files
   new changesets *:* (glob)
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir1
   path:dir2
-  [excludes]
+  [exclude]
   path:dir1/dirB
   path:dir2/dirA
   path:dir2/dirB
@@ -207,10 +207,10 @@ 
   added 11 changesets with 7 changes to 7 files
   new changesets *:* (glob)
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir1
   path:dir2
-  [excludes]
+  [exclude]
   path:dir1/dirA/bar
   path:dir1/dirB
   path:dir2/dirA
@@ -267,10 +267,10 @@ 
   added 13 changesets with 8 changes to 8 files
   new changesets *:* (glob)
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir1
   path:dir2
-  [excludes]
+  [exclude]
   path:dir1/dirA
   path:dir1/dirA/bar
   path:dir1/dirB
@@ -328,10 +328,10 @@ 
   added 13 changesets with 9 changes to 9 files
   new changesets *:* (glob)
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir1
   path:dir2
-  [excludes]
+  [exclude]
   path:dir1/dirA/bar
   path:dir1/dirB
   $ find * | sort
diff --git a/tests/test-narrow-debugcommands.t b/tests/test-narrow-debugcommands.t
--- a/tests/test-narrow-debugcommands.t
+++ b/tests/test-narrow-debugcommands.t
@@ -2,9 +2,9 @@ 
   $ hg init repo
   $ cd repo
   $ cat << EOF > .hg/narrowspec
-  > [includes]
+  > [include]
   > path:foo
-  > [excludes]
+  > [exclude]
   > EOF
   $ echo treemanifest >> .hg/requires
   $ echo narrowhg-experimental >> .hg/requires
diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t
--- a/tests/test-narrow-clone.t
+++ b/tests/test-narrow-clone.t
@@ -35,9 +35,9 @@ 
   testonly-simplestore (reposimplestore !)
 
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir/src/f10
-  [excludes]
+  [exclude]
   $ hg tracked
   I path:dir/src/f10
   $ hg update
@@ -70,9 +70,9 @@ 
   new changesets *:* (glob)
   $ cd narrowdir
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir/tests
-  [excludes]
+  [exclude]
   path:dir/tests/t19
   $ hg tracked
   I path:dir/tests
@@ -115,9 +115,9 @@ 
   new changesets *:* (glob)
   $ cd narrowroot
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:.
-  [excludes]
+  [exclude]
   path:dir/tests
   $ hg tracked
   I path:.
diff --git a/tests/test-narrow-clone-no-ellipsis.t b/tests/test-narrow-clone-no-ellipsis.t
--- a/tests/test-narrow-clone-no-ellipsis.t
+++ b/tests/test-narrow-clone-no-ellipsis.t
@@ -31,9 +31,9 @@ 
   testonly-simplestore (reposimplestore !)
 
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir/src/f10
-  [excludes]
+  [exclude]
   $ hg update
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ find * | sort
@@ -56,9 +56,9 @@ 
   new changesets *:* (glob)
   $ cd narrowdir
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:dir/tests
-  [excludes]
+  [exclude]
   path:dir/tests/t19
   $ hg update
   19 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -98,9 +98,9 @@ 
   new changesets *:* (glob)
   $ cd narrowroot
   $ cat .hg/narrowspec
-  [includes]
+  [include]
   path:.
-  [excludes]
+  [exclude]
   path:dir/tests
   $ hg update
   20 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -13,6 +13,7 @@ 
 from . import (
     error,
     match as matchmod,
+    sparse,
     util,
 )
 
@@ -107,10 +108,10 @@ 
     return set(normalizepattern(p) for p in pats)
 
 def format(includes, excludes):
-    output = '[includes]\n'
+    output = '[include]\n'
     for i in sorted(includes - excludes):
         output += i + '\n'
-    output += '[excludes]\n'
+    output += '[exclude]\n'
     for e in sorted(excludes):
         output += e + '\n'
     return output
@@ -139,7 +140,12 @@ 
             repo.invalidate(clearfilecache=True)
             return set(), set()
         raise
-    return _parsestoredpatterns(spec)
+    # maybe we should care about the profiles returned too
+    includepats, excludepats, __ = sparse.parseconfig(repo.ui, spec, 'narrow')
+    if __:
+        raise error.Abort(_("including other spec files using '%include' is not"
+                            " suported in narrowspec"))
+    return includepats, excludepats
 
 def save(repo, includepats, excludepats):
     spec = format(includepats, excludepats)