# HG changeset patch # User Pulkit Goyal # Date 2018-08-03 16:59:04 # Node ID f64ebe7d225913b8bf3122ed3a03cf7a6abbf0ee # Parent 8fe62ad9f4ff68477905b896446bbf4d8fc563de narrowspec: use sparse.parseconfig() to parse narrowspec file (BC) This also make narrow files use 'include' and 'exclude' instead of plural forms which are 'includes' and 'excludes'. This is BC because existing narrowspecs have to replace excludes, includes words with exclude and include i.e. their singular versions. Differential Revision: https://phab.mercurial-scm.org/D4057 diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py --- a/mercurial/narrowspec.py +++ b/mercurial/narrowspec.py @@ -13,6 +13,7 @@ from .i18n import _ from . import ( error, match as matchmod, + sparse, util, ) @@ -107,10 +108,10 @@ def parsepatterns(pats): 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,13 @@ def load(repo): repo.invalidate(clearfilecache=True) return set(), set() raise - return _parsestoredpatterns(spec) + # maybe we should care about the profiles returned too + includepats, excludepats, profiles = sparse.parseconfig(repo.ui, spec, + 'narrow') + if profiles: + 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) 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