Show More
@@ -113,8 +113,33 b' def _explain_watch_limit(ui, repo, count' | |||||
113 | raise util.Abort(_('cannot watch %s until inotify watch limit is raised') |
|
113 | raise util.Abort(_('cannot watch %s until inotify watch limit is raised') | |
114 | % repo.root) |
|
114 | % repo.root) | |
115 |
|
115 | |||
116 |
class |
|
116 | class pollable(object): | |
|
117 | """ | |||
|
118 | Interface to support polling. | |||
|
119 | The file descriptor returned by fileno() is registered to a polling | |||
|
120 | object. | |||
|
121 | Usage: | |||
|
122 | Every tick, check if an event has happened since the last tick: | |||
|
123 | * If yes, call handle_events | |||
|
124 | * If no, call handle_timeout | |||
|
125 | """ | |||
117 | poll_events = select.POLLIN |
|
126 | poll_events = select.POLLIN | |
|
127 | def fileno(self): | |||
|
128 | raise NotImplementedError | |||
|
129 | ||||
|
130 | def handle_events(self, events): | |||
|
131 | raise NotImplementedError | |||
|
132 | ||||
|
133 | def handle_timeout(self): | |||
|
134 | raise NotImplementedError | |||
|
135 | ||||
|
136 | def shutdown(self): | |||
|
137 | raise NotImplementedError | |||
|
138 | ||||
|
139 | class repowatcher(pollable): | |||
|
140 | """ | |||
|
141 | Watches inotify events | |||
|
142 | """ | |||
118 | statuskeys = 'almr!?' |
|
143 | statuskeys = 'almr!?' | |
119 | mask = ( |
|
144 | mask = ( | |
120 | inotify.IN_ATTRIB | |
|
145 | inotify.IN_ATTRIB | | |
@@ -540,7 +565,7 b' class repowatcher(object):' | |||||
540 | self.ui.note(_('%s hooking back up with %d bytes readable\n') % |
|
565 | self.ui.note(_('%s hooking back up with %d bytes readable\n') % | |
541 | (self.event_time(), self.threshold.readable())) |
|
566 | (self.event_time(), self.threshold.readable())) | |
542 | self.read_events(0) |
|
567 | self.read_events(0) | |
543 |
self.master.poll.register(self, sel |
|
568 | self.master.poll.register(self, self.poll_events) | |
544 | self.registered = True |
|
569 | self.registered = True | |
545 |
|
570 | |||
546 | self.timeout = None |
|
571 | self.timeout = None | |
@@ -555,9 +580,10 b' class repowatcher(object):' | |||||
555 | """ |
|
580 | """ | |
556 | return sorted(tuple[0][len(self.wprefix):] for tuple in self.watcher) |
|
581 | return sorted(tuple[0][len(self.wprefix):] for tuple in self.watcher) | |
557 |
|
582 | |||
558 |
class server( |
|
583 | class server(pollable): | |
559 | poll_events = select.POLLIN |
|
584 | """ | |
560 |
|
585 | Listens for client queries on unix socket inotify.sock | ||
|
586 | """ | |||
561 | def __init__(self, ui, repo, repowatcher, timeout): |
|
587 | def __init__(self, ui, repo, repowatcher, timeout): | |
562 | self.ui = ui |
|
588 | self.ui = ui | |
563 | self.repo = repo |
|
589 | self.repo = repo |
General Comments 0
You need to be logged in to leave comments.
Login now