D4524: narrowspec: validate patterns when loading and saving spec file

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Tue Sep 11 23:42:05 UTC 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8d8e61df8259: narrowspec: validate patterns when loading and saving spec file (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4524?vs=10901&id=10905

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

AFFECTED FILES
  mercurial/narrowspec.py
  tests/test-narrow-patterns.t

CHANGE DETAILS

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
@@ -439,3 +439,31 @@
   abort: invalid prefix on narrow pattern: set:ignored
   (narrow patterns must begin with one of the following: path:, rootfilesin:)
   [255]
+
+  $ cat .hg/store/narrowspec
+  [include]
+  path:dir1
+  path:dir1/dirA
+  [exclude]
+
+  $ cat > .hg/store/narrowspec << EOF
+  > [include]
+  > glob:**
+  > EOF
+
+  $ hg tracked
+  abort: invalid prefix on narrow pattern: glob:**
+  (narrow patterns must begin with one of the following: path:, rootfilesin:)
+  [255]
+
+  $ cat > .hg/store/narrowspec << EOF
+  > [include]
+  > path:.
+  > [exclude]
+  > set:ignored
+  > EOF
+
+  $ hg tracked
+  abort: invalid prefix on narrow pattern: set:ignored
+  (narrow patterns must begin with one of the following: path:, rootfilesin:)
+  [255]
diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -164,9 +164,15 @@
     if profiles:
         raise error.Abort(_("including other spec files using '%include' is not"
                             " supported in narrowspec"))
+
+    validatepatterns(includepats)
+    validatepatterns(excludepats)
+
     return includepats, excludepats
 
 def save(repo, includepats, excludepats):
+    validatepatterns(includepats)
+    validatepatterns(excludepats)
     spec = format(includepats, excludepats)
     repo.svfs.write(FILENAME, spec)
 



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


More information about the Mercurial-devel mailing list