Show More
@@ -241,6 +241,22 b' class dirstate:' | |||
|
241 | 241 | bs += 1 |
|
242 | 242 | return ret |
|
243 | 243 | |
|
244 | def supported_type(self, f, st, verbose=True): | |
|
245 | if stat.S_ISREG(st.st_mode): | |
|
246 | return True | |
|
247 | if verbose: | |
|
248 | kind = 'unknown' | |
|
249 | if stat.S_ISCHR(st.st_mode): kind = _('character device') | |
|
250 | elif stat.S_ISBLK(st.st_mode): kind = _('block device') | |
|
251 | elif stat.S_ISFIFO(st.st_mode): kind = _('fifo') | |
|
252 | elif stat.S_ISLNK(st.st_mode): kind = _('symbolic link') | |
|
253 | elif stat.S_ISSOCK(st.st_mode): kind = _('socket') | |
|
254 | elif stat.S_ISDIR(st.st_mode): kind = _('directory') | |
|
255 | self.ui.warn(_('%s: unsupported file type (type is %s)\n') % ( | |
|
256 | util.pathto(self.getcwd(), f), | |
|
257 | kind)) | |
|
258 | return False | |
|
259 | ||
|
244 | 260 | def statwalk(self, files=None, match=util.always, dc=None): |
|
245 | 261 | self.read() |
|
246 | 262 | |
@@ -278,22 +294,6 b' class dirstate:' | |||
|
278 | 294 | # directly by this function, but might be modified by your statmatch call. |
|
279 | 295 | # |
|
280 | 296 | def walkhelper(self, files, statmatch, dc): |
|
281 | def supported_type(f, st): | |
|
282 | if stat.S_ISREG(st.st_mode): | |
|
283 | return True | |
|
284 | else: | |
|
285 | kind = 'unknown' | |
|
286 | if stat.S_ISCHR(st.st_mode): kind = _('character device') | |
|
287 | elif stat.S_ISBLK(st.st_mode): kind = _('block device') | |
|
288 | elif stat.S_ISFIFO(st.st_mode): kind = _('fifo') | |
|
289 | elif stat.S_ISLNK(st.st_mode): kind = _('symbolic link') | |
|
290 | elif stat.S_ISSOCK(st.st_mode): kind = _('socket') | |
|
291 | elif stat.S_ISDIR(st.st_mode): kind = _('directory') | |
|
292 | self.ui.warn(_('%s: unsupported file type (type is %s)\n') % ( | |
|
293 | util.pathto(self.getcwd(), f), | |
|
294 | kind)) | |
|
295 | return False | |
|
296 | ||
|
297 | 297 | # recursion free walker, faster than os.walk. |
|
298 | 298 | def findfiles(s): |
|
299 | 299 | retfiles = [] |
@@ -316,9 +316,13 b' class dirstate:' | |||
|
316 | 316 | ds = os.path.join(nd, f +'/') |
|
317 | 317 | if statmatch(ds, st): |
|
318 | 318 | work.append(p) |
|
319 |
|
|
|
320 | yield util.pconvert(np), st | |
|
321 | ||
|
319 | if statmatch(np, st) and np in dc: | |
|
320 | yield 'm', util.pconvert(np), st | |
|
321 | elif statmatch(np, st): | |
|
322 | if self.supported_type(np, st): | |
|
323 | yield 'f', util.pconvert(np), st | |
|
324 | elif np in dc: | |
|
325 | yield 'm', util.pconvert(np), st | |
|
322 | 326 | |
|
323 | 327 | known = {'.hg': 1} |
|
324 | 328 | def seen(fn): |
@@ -337,22 +341,22 b' class dirstate:' | |||
|
337 | 341 | inst.strerror)) |
|
338 | 342 | continue |
|
339 | 343 | if stat.S_ISDIR(st.st_mode): |
|
340 |
cmp |
|
|
344 | cmp1 = (lambda x, y: cmp(x[1], y[1])) | |
|
341 | 345 | sorted = [ x for x in findfiles(f) ] |
|
342 |
sorted.sort(cmp |
|
|
343 |
for |
|
|
344 |
yield |
|
|
346 | sorted.sort(cmp1) | |
|
347 | for e in sorted: | |
|
348 | yield e | |
|
345 | 349 | else: |
|
346 | 350 | ff = util.normpath(ff) |
|
347 | 351 | if seen(ff): |
|
348 | 352 | continue |
|
349 | found = False | |
|
350 | 353 | self.blockignore = True |
|
351 |
if statmatch(ff, st) |
|
|
352 | found = True | |
|
354 | if statmatch(ff, st): | |
|
355 | if self.supported_type(ff, st): | |
|
356 | yield 'f', ff, st | |
|
357 | elif ff in dc: | |
|
358 | yield 'm', ff, st | |
|
353 | 359 | self.blockignore = False |
|
354 | if found: | |
|
355 | yield 'f', ff, st | |
|
356 | 360 | |
|
357 | 361 | # step two run through anything left in the dc hash and yield |
|
358 | 362 | # if we haven't already seen it |
@@ -373,13 +377,20 b' class dirstate:' | |||
|
373 | 377 | unknown.append(fn) |
|
374 | 378 | continue |
|
375 | 379 | if src == 'm': |
|
380 | nonexistent = True | |
|
381 | if not st: | |
|
376 | 382 | try: |
|
377 | st = os.stat(fn) | |
|
383 | st = os.lstat(fn) | |
|
378 | 384 | except OSError, inst: |
|
385 | if inst.errno != errno.ENOENT: | |
|
386 | raise | |
|
387 | st = None | |
|
388 | # We need to re-check that it is a valid file | |
|
389 | if st and self.supported_type(fn, st): | |
|
390 | nonexistent = False | |
|
379 | 391 | # XXX: what to do with file no longer present in the fs |
|
380 | 392 | # who are not removed in the dirstate ? |
|
381 |
|
|
|
382 | raise | |
|
393 | if nonexistent: | |
|
383 | 394 | deleted.append(fn) |
|
384 | 395 | continue |
|
385 | 396 | # check the common case first |
@@ -6,19 +6,27 b' echo 123 > c' | |||
|
6 | 6 | hg add a c |
|
7 | 7 | hg commit -m "first" -d "0 0" a c |
|
8 | 8 | echo 123 > b |
|
9 | echo %% should show b unknown | |
|
9 | 10 | hg status |
|
10 | 11 | echo 12 > c |
|
12 | echo %% should show b unknown and c modified | |
|
11 | 13 | hg status |
|
12 | 14 | hg add b |
|
15 | echo %% should show b added and c modified | |
|
13 | 16 | hg status |
|
14 | 17 | hg rm a |
|
18 | echo %% should show a removed, b added and c modified | |
|
15 | 19 | hg status |
|
16 | 20 | hg revert a |
|
21 | echo %% should show b added and c modified | |
|
17 | 22 | hg status |
|
18 | 23 | hg revert b |
|
24 | echo %% should show b unknown and c modified | |
|
19 | 25 | hg status |
|
20 | 26 | hg revert c |
|
27 | echo %% should show b unknown | |
|
21 | 28 | hg status |
|
29 | echo %% should show a b and c | |
|
22 | 30 | ls |
|
23 | 31 | |
|
24 | 32 | true |
@@ -1,16 +1,24 b'' | |||
|
1 | %% should show b unknown | |
|
1 | 2 | ? b |
|
3 | %% should show b unknown and c modified | |
|
2 | 4 | M c |
|
3 | 5 | ? b |
|
6 | %% should show b added and c modified | |
|
4 | 7 | M c |
|
5 | 8 | A b |
|
9 | %% should show a removed, b added and c modified | |
|
6 | 10 | M c |
|
7 | 11 | A b |
|
8 | 12 | R a |
|
13 | %% should show b added and c modified | |
|
9 | 14 | M c |
|
10 | 15 | A b |
|
16 | %% should show b unknown and c modified | |
|
11 | 17 | M c |
|
12 | 18 | ? b |
|
19 | %% should show b unknown | |
|
13 | 20 | ? b |
|
21 | %% should show a b and c | |
|
14 | 22 | a |
|
15 | 23 | b |
|
16 | 24 | c |
@@ -22,3 +22,20 b' hg addremove' | |||
|
22 | 22 | |
|
23 | 23 | #Assert screamed here before, should go by without consequence |
|
24 | 24 | hg commit -m 'is there a bug?' |
|
25 | ||
|
26 | cd .. ; rm -rf test | |
|
27 | hg init test; cd test; | |
|
28 | ||
|
29 | mkdir dir | |
|
30 | touch a.c dir/a.o dir/b.o | |
|
31 | # test what happens if we want to trick hg | |
|
32 | hg commit -A -m 0 | |
|
33 | echo "relglob:*.o" > .hgignore | |
|
34 | rm a.c | |
|
35 | rm dir/a.o | |
|
36 | rm dir/b.o | |
|
37 | mkdir dir/a.o | |
|
38 | ln -sf nonexist dir/b.o | |
|
39 | mkfifo a.c | |
|
40 | # it should show a.c, dir/a.o and dir/b.o removed | |
|
41 | hg status |
@@ -4,3 +4,12 b' bar: unsupported file type (type is symb' | |||
|
4 | 4 | bar: unsupported file type (type is symbolic link) |
|
5 | 5 | adding bomb |
|
6 | 6 | bar: unsupported file type (type is symbolic link) |
|
7 | adding a.c | |
|
8 | adding dir/a.o | |
|
9 | adding dir/b.o | |
|
10 | a.c: unsupported file type (type is fifo) | |
|
11 | dir/b.o: unsupported file type (type is symbolic link) | |
|
12 | R a.c | |
|
13 | R dir/a.o | |
|
14 | R dir/b.o | |
|
15 | ? .hgignore |
General Comments 0
You need to be logged in to leave comments.
Login now