##// END OF EJS Templates
add a check for filetype when walking
Benoit Boissinot -
r1392:32d8068b default
parent child Browse files
Show More
@@ -268,6 +268,22 b' class dirstate:'
268 # directly by this function, but might be modified by your statmatch call.
268 # directly by this function, but might be modified by your statmatch call.
269 #
269 #
270 def walkhelper(self, files, statmatch, dc):
270 def walkhelper(self, files, statmatch, dc):
271 def supported_type(f, st):
272 if stat.S_ISREG(st.st_mode):
273 return True
274 else:
275 kind = 'unknown'
276 if stat.S_ISCHR(st.st_mode): kind = 'character device'
277 elif stat.S_ISBLK(st.st_mode): kind = 'block device'
278 elif stat.S_ISFIFO(st.st_mode): kind = 'fifo'
279 elif stat.S_ISLNK(st.st_mode): kind = 'symbolic link'
280 elif stat.S_ISSOCK(st.st_mode): kind = 'socket'
281 elif stat.S_ISDIR(st.st_mode): kind = 'directory'
282 self.ui.warn('%s: unsupported file type (type is %s)\n' % (
283 util.pathto(self.getcwd(), f),
284 kind))
285 return False
286
271 # recursion free walker, faster than os.walk.
287 # recursion free walker, faster than os.walk.
272 def findfiles(s):
288 def findfiles(s):
273 retfiles = []
289 retfiles = []
@@ -290,10 +306,11 b' class dirstate:'
290 ds = os.path.join(nd, f +'/')
306 ds = os.path.join(nd, f +'/')
291 if statmatch(ds, st):
307 if statmatch(ds, st):
292 work.append(p)
308 work.append(p)
293 else:
309 elif supported_type(np, st):
294 if statmatch(np, st):
310 if statmatch(np, st):
295 yield util.pconvert(np)
311 yield util.pconvert(np)
296
312
313
297 known = {'.hg': 1}
314 known = {'.hg': 1}
298 def seen(fn):
315 def seen(fn):
299 if fn in known: return True
316 if fn in known: return True
@@ -315,27 +332,17 b' class dirstate:'
315 sorted.sort()
332 sorted.sort()
316 for fl in sorted:
333 for fl in sorted:
317 yield 'f', fl
334 yield 'f', fl
318 elif stat.S_ISREG(st.st_mode):
335 else:
319 ff = util.normpath(ff)
336 ff = util.normpath(ff)
320 if seen(ff):
337 if seen(ff):
321 continue
338 continue
322 found = False
339 found = False
323 self.blockignore = True
340 self.blockignore = True
324 if statmatch(ff, st):
341 if supported_type(ff, st) and statmatch(ff, st):
325 found = True
342 found = True
326 self.blockignore = False
343 self.blockignore = False
327 if found:
344 if found:
328 yield 'f', ff
345 yield 'f', ff
329 else:
330 kind = 'unknown'
331 if stat.S_ISCHR(st.st_mode): kind = 'character device'
332 elif stat.S_ISBLK(st.st_mode): kind = 'block device'
333 elif stat.S_ISFIFO(st.st_mode): kind = 'fifo'
334 elif stat.S_ISLNK(st.st_mode): kind = 'symbolic link'
335 elif stat.S_ISSOCK(st.st_mode): kind = 'socket'
336 self.ui.warn('%s: unsupported file type (type is %s)\n' % (
337 util.pathto(self.getcwd(), ff),
338 kind))
339
346
340 # step two run through anything left in the dc hash and yield
347 # step two run through anything left in the dc hash and yield
341 # if we haven't already seen it
348 # if we haven't already seen it
@@ -368,8 +375,6 b' class dirstate:'
368 if self.ignore(fn): return False
375 if self.ignore(fn): return False
369 return match(fn)
376 return match(fn)
370
377
371 if not stat.S_ISREG(s.st_mode):
372 return False
373 c = dc.pop(fn, None)
378 c = dc.pop(fn, None)
374 if c:
379 if c:
375 type, mode, size, time = c
380 type, mode, size, time = c
General Comments 0
You need to be logged in to leave comments. Login now