D4526: narrow: validate spec files are well-formed during clone (BC)
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Tue Sep 11 18:52:43 UTC 2018
indygreg created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4526
AFFECTED FILES
hgext/narrow/narrowcommands.py
tests/test-narrow-clone-no-ellipsis.t
tests/test-narrow-clone.t
CHANGE DETAILS
diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t
--- a/tests/test-narrow-clone.t
+++ b/tests/test-narrow-clone.t
@@ -237,7 +237,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
@@ -248,7 +248,7 @@
$ cat > narrowspecs <<EOF
> [include]
> path:dir/tests/
- > file:dir/src/f12
+ > path:file:dir/src/f12
> EOF
$ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
@@ -276,6 +276,5 @@
$ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs
reading narrowspec from '$TESTTMP/narrowspecs'
- requesting all changes
abort: narrow pattern must begin with the following prefixes: path:, rootfilesin:; got glob:**
[255]
diff --git a/tests/test-narrow-clone-no-ellipsis.t b/tests/test-narrow-clone-no-ellipsis.t
--- a/tests/test-narrow-clone-no-ellipsis.t
+++ b/tests/test-narrow-clone-no-ellipsis.t
@@ -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 <<EOF
> [include]
> path:dir/tests/
- > file:dir/src/f12
+ > path:file:dir/src/f12
> EOF
$ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -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)
To: indygreg, durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list