##// END OF EJS Templates
inotify: do not defer inotify events processing...
Nicolas Dumazet -
r8605:ed2d9bdb default
parent child Browse files
Show More
@@ -151,8 +151,7 b' class repowatcher(object):'
151 self.watches = 0
151 self.watches = 0
152 self.last_event = None
152 self.last_event = None
153
153
154 self.eventq = {}
154 self.lastevent = {}
155 self.deferred = 0
156
155
157 self.ds_info = self.dirstate_info()
156 self.ds_info = self.dirstate_info()
158 self.handle_timeout()
157 self.handle_timeout()
@@ -447,24 +446,21 b' class repowatcher(object):'
447
446
448 self.deletefile(wpath, self.repo.dirstate[wpath])
447 self.deletefile(wpath, self.repo.dirstate[wpath])
449
448
450 def schedule_work(self, wpath, evt):
449 def work(self, wpath, evt):
451 prev = self.eventq.setdefault(wpath, [])
452 try:
450 try:
453 if prev and evt == 'm' and prev[-1] in 'cm':
451 if evt == 'c':
454 return
452 self.created(wpath)
455 self.eventq[wpath].append(evt)
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
456 finally:
461 finally:
457 self.deferred += 1
458 self.timeout = 250
462 self.timeout = 250
459
463
460 def deferred_event(self, wpath, evt):
461 if evt == 'c':
462 self.created(wpath)
463 elif evt == 'm':
464 self.modified(wpath)
465 elif evt == 'd':
466 self.deleted(wpath)
467
468 def process_create(self, wpath, evt):
464 def process_create(self, wpath, evt):
469 if self.ui.debugflag:
465 if self.ui.debugflag:
470 self.ui.note(_('%s event: created %s\n') %
466 self.ui.note(_('%s event: created %s\n') %
@@ -473,7 +469,7 b' class repowatcher(object):'
473 if evt.mask & inotify.IN_ISDIR:
469 if evt.mask & inotify.IN_ISDIR:
474 self.scan(wpath)
470 self.scan(wpath)
475 else:
471 else:
476 self.schedule_work(wpath, 'c')
472 self.work(wpath, 'c')
477
473
478 def process_delete(self, wpath, evt):
474 def process_delete(self, wpath, evt):
479 if self.ui.debugflag:
475 if self.ui.debugflag:
@@ -486,7 +482,7 b' class repowatcher(object):'
486 self.deletefile(join(wpath, wfn), '?')
482 self.deletefile(join(wpath, wfn), '?')
487 self.scan(wpath)
483 self.scan(wpath)
488 else:
484 else:
489 self.schedule_work(wpath, 'd')
485 self.work(wpath, 'd')
490
486
491 def process_modify(self, wpath, evt):
487 def process_modify(self, wpath, evt):
492 if self.ui.debugflag:
488 if self.ui.debugflag:
@@ -494,7 +490,7 b' class repowatcher(object):'
494 (self.event_time(), wpath))
490 (self.event_time(), wpath))
495
491
496 if not (evt.mask & inotify.IN_ISDIR):
492 if not (evt.mask & inotify.IN_ISDIR):
497 self.schedule_work(wpath, 'm')
493 self.work(wpath, 'm')
498
494
499 def process_unmount(self, evt):
495 def process_unmount(self, evt):
500 self.ui.warn(_('filesystem containing %s was unmounted\n') %
496 self.ui.warn(_('filesystem containing %s was unmounted\n') %
@@ -533,6 +529,8 b' class repowatcher(object):'
533 elif evt.mask & (inotify.IN_CREATE | inotify.IN_MOVED_TO):
529 elif evt.mask & (inotify.IN_CREATE | inotify.IN_MOVED_TO):
534 self.process_create(wpath, evt)
530 self.process_create(wpath, evt)
535
531
532 self.lastevent.clear()
533
536 def handle_timeout(self):
534 def handle_timeout(self):
537 if not self.registered:
535 if not self.registered:
538 if self.ui.debugflag:
536 if self.ui.debugflag:
@@ -542,16 +540,6 b' class repowatcher(object):'
542 self.master.poll.register(self, select.POLLIN)
540 self.master.poll.register(self, select.POLLIN)
543 self.registered = True
541 self.registered = True
544
542
545 if self.eventq:
546 if self.ui.debugflag:
547 self.ui.note(_('%s processing %d deferred events as %d\n') %
548 (self.event_time(), self.deferred,
549 len(self.eventq)))
550 for wpath, evts in sorted(self.eventq.iteritems()):
551 for evt in evts:
552 self.deferred_event(wpath, evt)
553 self.eventq.clear()
554 self.deferred = 0
555 self.timeout = None
543 self.timeout = None
556
544
557 def shutdown(self):
545 def shutdown(self):
General Comments 0
You need to be logged in to leave comments. Login now