# HG changeset patch # User Gregory Szorc # Date 1536691630 25200 # Node ID 8301741e1f893ab1f3ba2c73d8df717cf8271eeb # Parent ce20caecacbd23bfbb02ca2fcb014d5e93ca3bdb narrow: validate spec files are well-formed during clone (BC) Previously, specfiles would get read then normalized. We want specfiles to be normalized on read so there is no confusion about what the format of specfiles should be. This commit validates the parsed result of --specfile. If entries aren't prefixed, an error is raised. Previously, validation would occur at exchange time, hence why we dropped a line of test output related to server iteraction. Differential Revision: https://phab.mercurial-scm.org/D4526 diff -r ce20caecacbd -r 8301741e1f89 hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py Tue Sep 11 10:59:21 2018 -0700 +++ b/hgext/narrow/narrowcommands.py Tue Sep 11 11:47:10 2018 -0700 @@ -102,6 +102,9 @@ raise error.Abort(_("cannot specify other files using '%include' in" " narrowspec")) + narrowspec.validatepatterns(includes) + narrowspec.validatepatterns(excludes) + # narrowspec is passed so we should assume that user wants narrow clone opts_narrow = True opts['include'].extend(includes) diff -r ce20caecacbd -r 8301741e1f89 tests/test-narrow-clone-no-ellipsis.t --- a/tests/test-narrow-clone-no-ellipsis.t Tue Sep 11 10:59:21 2018 -0700 +++ b/tests/test-narrow-clone-no-ellipsis.t Tue Sep 11 11:47:10 2018 -0700 @@ -130,7 +130,7 @@ > %include foo > [include] > path:dir/tests/ - > file:dir/src/f12 + > path:file:dir/src/f12 > EOF $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs @@ -141,7 +141,7 @@ $ cat > narrowspecs < [include] > path:dir/tests/ - > file:dir/src/f12 + > path:file:dir/src/f12 > EOF $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs diff -r ce20caecacbd -r 8301741e1f89 tests/test-narrow-clone.t --- a/tests/test-narrow-clone.t Tue Sep 11 10:59:21 2018 -0700 +++ b/tests/test-narrow-clone.t Tue Sep 11 11:47:10 2018 -0700 @@ -239,7 +239,7 @@ > %include foo > [include] > path:dir/tests/ - > dir/src/f12 + > path:file:dir/src/f12 > EOF $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs @@ -250,7 +250,7 @@ $ cat > narrowspecs < [include] > path:dir/tests/ - > file:dir/src/f12 + > path:file:dir/src/f12 > EOF $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs @@ -278,7 +278,6 @@ $ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs reading narrowspec from '$TESTTMP/narrowspecs' - requesting all changes abort: invalid prefix on narrow pattern: glob:** (narrow patterns must begin with one of the following: path:, rootfilesin:) [255]