Mercurial > hg
comparison tests/test-narrow-clone.t @ 39531:0d572769046a
narrowspec: limit patterns to path: and rootfilesin: (BC)
Some matcher patterns are computationally expensive and may even
have security issues (e.g. evaluating some file sets). For these
reasons, we want to limit the types of matcher patterns that can
be used in narrow specs and by command line arguments used for
defining narrow specs.
This commit teaches ``narrowspec.parsepatterns()`` to validate the
pattern types against "safe" patterns.
Surprisingly, no existing tests broke. So tests for the feature
have been added.
We also added a function to validate a patterns data structure.
This will be used in future commits.
Differential Revision: https://phab.mercurial-scm.org/D4522
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 11 Sep 2018 15:25:35 -0700 |
parents | f4d4bd8c8911 |
children | 8301741e1f89 |
comparison
equal
deleted
inserted
replaced
39530:576b92928cc7 | 39531:0d572769046a |
---|---|
13 $ cd .. | 13 $ cd .. |
14 $ mkdir tests | 14 $ mkdir tests |
15 $ cd tests | 15 $ cd tests |
16 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done | 16 $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done |
17 $ cd ../../.. | 17 $ cd ../../.. |
18 | |
19 Only path: and rootfilesin: pattern prefixes are allowed | |
20 | |
21 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --include 'glob:**' | |
22 requesting all changes | |
23 abort: invalid prefix on narrow pattern: glob:** | |
24 (narrow patterns must begin with one of the following: path:, rootfilesin:) | |
25 [255] | |
26 | |
27 $ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --exclude 'set:ignored' | |
28 requesting all changes | |
29 abort: invalid prefix on narrow pattern: set:ignored | |
30 (narrow patterns must begin with one of the following: path:, rootfilesin:) | |
31 [255] | |
18 | 32 |
19 narrow clone a file, f10 | 33 narrow clone a file, f10 |
20 | 34 |
21 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10" | 35 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10" |
22 requesting all changes | 36 requesting all changes |
252 $ cd specfile | 266 $ cd specfile |
253 $ hg tracked | 267 $ hg tracked |
254 I path:dir/tests | 268 I path:dir/tests |
255 I path:file:dir/src/f12 | 269 I path:file:dir/src/f12 |
256 $ cd .. | 270 $ cd .. |
271 | |
272 Narrow spec with invalid patterns is rejected | |
273 | |
274 $ cat > narrowspecs <<EOF | |
275 > [include] | |
276 > glob:** | |
277 > EOF | |
278 | |
279 $ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs | |
280 reading narrowspec from '$TESTTMP/narrowspecs' | |
281 requesting all changes | |
282 abort: invalid prefix on narrow pattern: glob:** | |
283 (narrow patterns must begin with one of the following: path:, rootfilesin:) | |
284 [255] |