diff mercurial/narrowspec.py @ 39556:8d8e61df8259

narrowspec: validate patterns when loading and saving spec file Patterns should be normalized and validated before being passed into narrowspec.save(). Let's assert that by checking immediately before writing the narrow spec file. And let's assert that patterns loaded from the spec file also conform. Differential Revision: https://phab.mercurial-scm.org/D4524
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 11 Sep 2018 15:28:41 -0700
parents 0d572769046a
children 10a8472f6662
line wrap: on
line diff
--- a/mercurial/narrowspec.py	Mon Sep 10 22:34:19 2018 +0900
+++ b/mercurial/narrowspec.py	Tue Sep 11 15:28:41 2018 -0700
@@ -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)