Show More
@@ -0,0 +1,21 | |||
|
1 | #!/bin/bash | |
|
2 | # http://www.selenic.com/mercurial/bts/issue352 | |
|
3 | ||
|
4 | hg init foo | |
|
5 | cd foo | |
|
6 | ||
|
7 | A=`echo -e -n 'he\rllo'` | |
|
8 | ||
|
9 | echo foo > "hell | |
|
10 | o" | |
|
11 | echo foo > "$A" | |
|
12 | hg add | |
|
13 | hg ci -A -m m | |
|
14 | rm "$A" | |
|
15 | ls | |
|
16 | hg add | |
|
17 | # BUG ? we don't walk on filenames with '\n' (regexp related) ? | |
|
18 | hg debugwalk | |
|
19 | hg ci -A -m m | |
|
20 | ||
|
21 | exit 0 |
@@ -0,0 +1,7 | |||
|
1 | adding he llo | |
|
2 | abort: '\n' and '\r' disallowed in filenames | |
|
3 | adding he llo | |
|
4 | abort: '\n' and '\r' disallowed in filenames | |
|
5 | hell | |
|
6 | o | |
|
7 | nothing changed |
@@ -211,7 +211,7 class dirstate(object): | |||
|
211 | 211 | self.dirs.setdefault(pc, 0) |
|
212 | 212 | self.dirs[pc] += delta |
|
213 | 213 | |
|
214 |
def check |
|
|
214 | def checkinterfering(self, files): | |
|
215 | 215 | def prefixes(f): |
|
216 | 216 | for c in strutil.rfindall(f, '/'): |
|
217 | 217 | yield f[:c] |
@@ -219,6 +219,7 class dirstate(object): | |||
|
219 | 219 | self.initdirs() |
|
220 | 220 | seendirs = {} |
|
221 | 221 | for f in files: |
|
222 | # shadows | |
|
222 | 223 | if self.dirs.get(f): |
|
223 | 224 | raise util.Abort(_('directory named %r already in dirstate') % |
|
224 | 225 | f) |
@@ -229,6 +230,9 class dirstate(object): | |||
|
229 | 230 | raise util.Abort(_('file named %r already in dirstate') % |
|
230 | 231 | d) |
|
231 | 232 | seendirs[d] = True |
|
233 | # disallowed | |
|
234 | if '\r' in f or '\n' in f: | |
|
235 | raise util.Abort(_("'\\n' and '\\r' disallowed in filenames")) | |
|
232 | 236 | |
|
233 | 237 | def update(self, files, state, **kw): |
|
234 | 238 | ''' current states: |
@@ -242,7 +246,7 class dirstate(object): | |||
|
242 | 246 | self.markdirty() |
|
243 | 247 | if state == "a": |
|
244 | 248 | self.initdirs() |
|
245 |
self.check |
|
|
249 | self.checkinterfering(files) | |
|
246 | 250 | for f in files: |
|
247 | 251 | if state == "r": |
|
248 | 252 | self.map[f] = ('r', 0, 0, 0) |
@@ -138,6 +138,10 class manifest(revlog): | |||
|
138 | 138 | return "".join([struct.pack(">lll", d[0], d[1], len(d[2])) + d[2] \ |
|
139 | 139 | for d in x ]) |
|
140 | 140 | |
|
141 | def checkforbidden(f): | |
|
142 | if '\n' in f or '\r' in f: | |
|
143 | raise RevlogError(_("'\\n' and '\\r' disallowed in filenames")) | |
|
144 | ||
|
141 | 145 | # if we're using the listcache, make sure it is valid and |
|
142 | 146 | # parented by the same node we're diffing against |
|
143 | 147 | if not changed or not self.listcache or not p1 or \ |
@@ -145,6 +149,9 class manifest(revlog): | |||
|
145 | 149 | files = map.keys() |
|
146 | 150 | files.sort() |
|
147 | 151 | |
|
152 | for f in files: | |
|
153 | checkforbidden(f) | |
|
154 | ||
|
148 | 155 | # if this is changed to support newlines in filenames, |
|
149 | 156 | # be sure to check the templates/ dir again (especially *-raw.tmpl) |
|
150 | 157 | text = ["%s\000%s%s\n" % (f, hex(map[f]), map.flags(f)) for f in files] |
@@ -153,6 +160,8 class manifest(revlog): | |||
|
153 | 160 | else: |
|
154 | 161 | addlist = self.listcache |
|
155 | 162 | |
|
163 | for f in changed[0]: | |
|
164 | checkforbidden(f) | |
|
156 | 165 | # combine the changed lists into one list for sorting |
|
157 | 166 | work = [[x, 0] for x in changed[0]] |
|
158 | 167 | work[len(work):] = [[x, 1] for x in changed[1]] |
General Comments 0
You need to be logged in to leave comments.
Login now