Show More
@@ -6,6 +6,10 b'' | |||
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | |
|
9 | from mercurial.i18n import _ | |
|
10 | ||
|
11 | from mercurial.utils import stringutil | |
|
12 | ||
|
9 | 13 | from mercurial import ( |
|
10 | 14 | bundle2, |
|
11 | 15 | error, |
@@ -82,20 +86,38 b' def narrow_widen(' | |||
|
82 | 86 | # work around ''.split(',') => [''] |
|
83 | 87 | return data.split(b',') if data else [] |
|
84 | 88 | |
|
85 | oldincludes = splitpaths(oldincludes) | |
|
86 | newincludes = splitpaths(newincludes) | |
|
87 | oldexcludes = splitpaths(oldexcludes) | |
|
88 | newexcludes = splitpaths(newexcludes) | |
|
89 | oldincludes = set(splitpaths(oldincludes)) | |
|
90 | newincludes = set(splitpaths(newincludes)) | |
|
91 | oldexcludes = set(splitpaths(oldexcludes)) | |
|
92 | newexcludes = set(splitpaths(newexcludes)) | |
|
89 | 93 | |
|
90 | 94 | # enforce narrow acl if set |
|
91 | 95 | if repo.ui.has_section(exchange._NARROWACL_SECTION): |
|
92 |
exchange.applynarrowacl( |
|
|
96 | kwargs = exchange.applynarrowacl( | |
|
97 | repo, {'includepats': newincludes, 'excludepats': newexcludes} | |
|
98 | ) | |
|
99 | newincludes = kwargs['includepats'] | |
|
100 | requiredexcludes = kwargs['excludepats'] - newexcludes | |
|
101 | if requiredexcludes: | |
|
102 | # XXX: The below code to get the username was copied from exchange.py, | |
|
103 | # where it is noted that this is technically a layering violation for | |
|
104 | # assuming the existence of HTTP. Using it anyway to make the error | |
|
105 | # message consistent with the error message for invalid includes. | |
|
106 | ui = repo.ui | |
|
107 | username = ui.shortuser( | |
|
108 | ui.environ.get(b'REMOTE_USER') or ui.username() | |
|
109 | ) | |
|
110 | raise error.Abort( | |
|
111 | _(b"The following excludes cannot be removed for %s: %s") | |
|
112 | % (username, stringutil.pprint(list(requiredexcludes))) | |
|
113 | ) | |
|
114 | newexcludes = kwargs['excludepats'] | |
|
93 | 115 | |
|
94 | 116 | # validate the patterns |
|
95 |
narrowspec.validatepatterns( |
|
|
96 |
narrowspec.validatepatterns( |
|
|
97 |
narrowspec.validatepatterns( |
|
|
98 |
narrowspec.validatepatterns( |
|
|
117 | narrowspec.validatepatterns(oldincludes) | |
|
118 | narrowspec.validatepatterns(newincludes) | |
|
119 | narrowspec.validatepatterns(oldexcludes) | |
|
120 | narrowspec.validatepatterns(newexcludes) | |
|
99 | 121 | |
|
100 | 122 | common = wireprototypes.decodelist(commonheads) |
|
101 | 123 | known = wireprototypes.decodelist(known) |
@@ -64,18 +64,12 b' Narrow should not be able to remove the ' | |||
|
64 | 64 | $ hg -R narrowclone1 tracked --removeexclude f3 |
|
65 | 65 | comparing with http://localhost:$HGPORT1/ |
|
66 | 66 | searching for changes |
|
67 | adding changesets | |
|
68 | adding manifests | |
|
69 | adding file changes | |
|
70 | added 0 changesets with 1 changes to 1 files | |
|
67 | abort: The following excludes cannot be removed for test: ['path:f3'] | |
|
68 | [255] | |
|
71 | 69 | $ ls -A -1 narrowclone1 | sort |
|
72 | 70 | .hg |
|
73 | 71 | f1 |
|
74 | 72 | f2 |
|
75 | f3 | |
|
76 | 73 | $ hg -R narrowclone1 tracked |
|
77 | 74 | I path:. |
|
78 | ||
|
79 | ||
|
80 | XXX: BUG! This test demonstrates that we are presently | |
|
81 | able to gain access to f3 by removing the exclusion. | |
|
75 | X path:f3 |
General Comments 0
You need to be logged in to leave comments.
Login now