Show More
@@ -35,8 +35,7 b' to the repository root.' | |||
|
35 | 35 | |
|
36 | 36 | The special lines ``[include]`` and ``[exclude]`` denote the section |
|
37 | 37 | for includes and excludes that follow, respectively. It is illegal to |
|
38 |
have ``[include]`` after ``[exclude]``. |
|
|
39 | entries are assumed to be in the ``[include]`` section. | |
|
38 | have ``[include]`` after ``[exclude]``. | |
|
40 | 39 | |
|
41 | 40 | Non-special lines resemble file patterns to be added to either includes |
|
42 | 41 | or excludes. The syntax of these lines is documented by :hg:`help patterns`. |
@@ -33,8 +33,10 b' def parseconfig(ui, raw):' | |||
|
33 | 33 | """ |
|
34 | 34 | includes = set() |
|
35 | 35 | excludes = set() |
|
36 | current = includes | |
|
37 | 36 | profiles = set() |
|
37 | current = None | |
|
38 | havesection = False | |
|
39 | ||
|
38 | 40 | for line in raw.split('\n'): |
|
39 | 41 | line = line.strip() |
|
40 | 42 | if not line or line.startswith('#'): |
@@ -45,14 +47,23 b' def parseconfig(ui, raw):' | |||
|
45 | 47 | if line: |
|
46 | 48 | profiles.add(line) |
|
47 | 49 | elif line == '[include]': |
|
48 | if current != includes: | |
|
50 | if havesection and current != includes: | |
|
49 | 51 | # TODO pass filename into this API so we can report it. |
|
50 | 52 | raise error.Abort(_('sparse config cannot have includes ' + |
|
51 | 53 | 'after excludes')) |
|
54 | havesection = True | |
|
55 | current = includes | |
|
52 | 56 | continue |
|
53 | 57 | elif line == '[exclude]': |
|
58 | havesection = True | |
|
54 | 59 | current = excludes |
|
55 | 60 | elif line: |
|
61 | if current is None: | |
|
62 | raise error.Abort(_('sparse config entry outside of ' | |
|
63 | 'section: %s') % line, | |
|
64 | hint=_('add an [include] or [exclude] line ' | |
|
65 | 'to declare the entry type')) | |
|
66 | ||
|
56 | 67 | if line.strip().startswith('/'): |
|
57 | 68 | ui.warn(_('warning: sparse profile cannot use' + |
|
58 | 69 | ' paths starting with /, ignoring %s\n') % line) |
@@ -10,6 +10,18 b' test sparse' | |||
|
10 | 10 | > rebase= |
|
11 | 11 | > EOF |
|
12 | 12 | |
|
13 | Config file without [section] is rejected | |
|
14 | ||
|
15 | $ cat > bad.sparse <<EOF | |
|
16 | > *.html | |
|
17 | > EOF | |
|
18 | ||
|
19 | $ hg debugsparse --import-rules bad.sparse | |
|
20 | abort: sparse config entry outside of section: *.html | |
|
21 | (add an [include] or [exclude] line to declare the entry type) | |
|
22 | [255] | |
|
23 | $ rm bad.sparse | |
|
24 | ||
|
13 | 25 | $ echo a > index.html |
|
14 | 26 | $ echo x > data.py |
|
15 | 27 | $ echo z > readme.txt |
@@ -257,6 +269,7 b' Test file permissions changing across a ' | |||
|
257 | 269 | > EOF |
|
258 | 270 | $ touch a b |
|
259 | 271 | $ cat > .hgsparse <<EOF |
|
272 | > [include] | |
|
260 | 273 | > a |
|
261 | 274 | > EOF |
|
262 | 275 | $ hg commit -Aqm 'initial' |
General Comments 0
You need to be logged in to leave comments.
Login now