diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -165,9 +165,15 @@ if profiles: raise error.Abort(_("including other spec files using '%include' is not" " suported 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) 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 @@ -437,3 +437,29 @@ $ hg tracked --addexclude set:ignored abort: narrow pattern must begin with the following prefixes: path:, rootfilesin:; got set:ignored [255] + + $ cat .hg/store/narrowspec + [include] + path:dir1 + path:dir1/dirA + [exclude] + + $ cat > .hg/store/narrowspec << EOF + > [include] + > glob:** + > EOF + + $ hg tracked + abort: narrow pattern must begin with the following prefixes: path:, rootfilesin:; got glob:** + [255] + + $ cat > .hg/store/narrowspec << EOF + > [include] + > path:. + > [exclude] + > set:ignored + > EOF + + $ hg tracked + abort: narrow pattern must begin with the following prefixes: path:, rootfilesin:; got set:ignored + [255]