Show More
@@ -415,6 +415,22 b' class repowatcher(object):' | |||||
415 | self.statcache.pop(wpath, None) |
|
415 | self.statcache.pop(wpath, None) | |
416 | raise |
|
416 | raise | |
417 |
|
417 | |||
|
418 | def eventaction(code): | |||
|
419 | def decorator(f): | |||
|
420 | def wrapper(self, wpath): | |||
|
421 | if code == 'm' and wpath in self.lastevent and \ | |||
|
422 | self.lastevent[wpath] in 'cm': | |||
|
423 | return | |||
|
424 | self.lastevent[wpath] = code | |||
|
425 | self.timeout = 250 | |||
|
426 | ||||
|
427 | f(self, wpath) | |||
|
428 | ||||
|
429 | wrapper.func_name = f.func_name | |||
|
430 | return wrapper | |||
|
431 | return decorator | |||
|
432 | ||||
|
433 | @eventaction('c') | |||
418 | def created(self, wpath): |
|
434 | def created(self, wpath): | |
419 | if wpath == '.hgignore': |
|
435 | if wpath == '.hgignore': | |
420 | self.update_hgignore() |
|
436 | self.update_hgignore() | |
@@ -425,6 +441,7 b' class repowatcher(object):' | |||||
425 | except OSError: |
|
441 | except OSError: | |
426 | pass |
|
442 | pass | |
427 |
|
443 | |||
|
444 | @eventaction('m') | |||
428 | def modified(self, wpath): |
|
445 | def modified(self, wpath): | |
429 | if wpath == '.hgignore': |
|
446 | if wpath == '.hgignore': | |
430 | self.update_hgignore() |
|
447 | self.update_hgignore() | |
@@ -436,6 +453,7 b' class repowatcher(object):' | |||||
436 | except OSError: |
|
453 | except OSError: | |
437 | pass |
|
454 | pass | |
438 |
|
455 | |||
|
456 | @eventaction('d') | |||
439 | def deleted(self, wpath): |
|
457 | def deleted(self, wpath): | |
440 | if wpath == '.hgignore': |
|
458 | if wpath == '.hgignore': | |
441 | self.update_hgignore() |
|
459 | self.update_hgignore() | |
@@ -446,21 +464,6 b' class repowatcher(object):' | |||||
446 |
|
464 | |||
447 | self.deletefile(wpath, self.repo.dirstate[wpath]) |
|
465 | self.deletefile(wpath, self.repo.dirstate[wpath]) | |
448 |
|
466 | |||
449 | def work(self, wpath, evt): |
|
|||
450 | try: |
|
|||
451 | if evt == 'c': |
|
|||
452 | self.created(wpath) |
|
|||
453 | elif evt == 'm': |
|
|||
454 | if wpath in self.lastevent and self.lastevent[wpath] in 'cm': |
|
|||
455 | return |
|
|||
456 | self.modified(wpath) |
|
|||
457 | elif evt == 'd': |
|
|||
458 | self.deleted(wpath) |
|
|||
459 |
|
||||
460 | self.lastevent[wpath] = evt |
|
|||
461 | finally: |
|
|||
462 | self.timeout = 250 |
|
|||
463 |
|
||||
464 | def process_create(self, wpath, evt): |
|
467 | def process_create(self, wpath, evt): | |
465 | if self.ui.debugflag: |
|
468 | if self.ui.debugflag: | |
466 | self.ui.note(_('%s event: created %s\n') % |
|
469 | self.ui.note(_('%s event: created %s\n') % | |
@@ -469,7 +472,7 b' class repowatcher(object):' | |||||
469 | if evt.mask & inotify.IN_ISDIR: |
|
472 | if evt.mask & inotify.IN_ISDIR: | |
470 | self.scan(wpath) |
|
473 | self.scan(wpath) | |
471 | else: |
|
474 | else: | |
472 |
self. |
|
475 | self.created(wpath) | |
473 |
|
476 | |||
474 | def process_delete(self, wpath, evt): |
|
477 | def process_delete(self, wpath, evt): | |
475 | if self.ui.debugflag: |
|
478 | if self.ui.debugflag: | |
@@ -482,7 +485,7 b' class repowatcher(object):' | |||||
482 | self.deletefile(join(wpath, wfn), '?') |
|
485 | self.deletefile(join(wpath, wfn), '?') | |
483 | self.scan(wpath) |
|
486 | self.scan(wpath) | |
484 | else: |
|
487 | else: | |
485 |
self. |
|
488 | self.deleted(wpath) | |
486 |
|
489 | |||
487 | def process_modify(self, wpath, evt): |
|
490 | def process_modify(self, wpath, evt): | |
488 | if self.ui.debugflag: |
|
491 | if self.ui.debugflag: | |
@@ -490,7 +493,7 b' class repowatcher(object):' | |||||
490 | (self.event_time(), wpath)) |
|
493 | (self.event_time(), wpath)) | |
491 |
|
494 | |||
492 | if not (evt.mask & inotify.IN_ISDIR): |
|
495 | if not (evt.mask & inotify.IN_ISDIR): | |
493 |
self. |
|
496 | self.modified(wpath) | |
494 |
|
497 | |||
495 | def process_unmount(self, evt): |
|
498 | def process_unmount(self, evt): | |
496 | self.ui.warn(_('filesystem containing %s was unmounted\n') % |
|
499 | self.ui.warn(_('filesystem containing %s was unmounted\n') % |
General Comments 0
You need to be logged in to leave comments.
Login now