Mercurial > hg
comparison hgext/inotify/server.py @ 8791:23730a475363
inotify.server: the decorator eventaction() shouldn't be a method of repowatcher
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 13 Jun 2009 18:41:28 +0200 |
parents | 9aca76502280 |
children | 3e23b1d20837 |
comparison
equal
deleted
inserted
replaced
8790:72af80052bd9 | 8791:23730a475363 |
---|---|
139 def handle_timeout(self): | 139 def handle_timeout(self): |
140 raise NotImplementedError | 140 raise NotImplementedError |
141 | 141 |
142 def shutdown(self): | 142 def shutdown(self): |
143 raise NotImplementedError | 143 raise NotImplementedError |
144 | |
145 def eventaction(code): | |
146 """ | |
147 Decorator to help handle events in repowatcher | |
148 """ | |
149 def decorator(f): | |
150 def wrapper(self, wpath): | |
151 if code == 'm' and wpath in self.lastevent and \ | |
152 self.lastevent[wpath] in 'cm': | |
153 return | |
154 self.lastevent[wpath] = code | |
155 self.timeout = 250 | |
156 | |
157 f(self, wpath) | |
158 | |
159 wrapper.func_name = f.func_name | |
160 return wrapper | |
161 return decorator | |
144 | 162 |
145 class repowatcher(pollable): | 163 class repowatcher(pollable): |
146 """ | 164 """ |
147 Watches inotify events | 165 Watches inotify events |
148 """ | 166 """ |
437 return ret | 455 return ret |
438 except OSError: | 456 except OSError: |
439 self.statcache.pop(wpath, None) | 457 self.statcache.pop(wpath, None) |
440 raise | 458 raise |
441 | 459 |
442 def eventaction(code): | |
443 def decorator(f): | |
444 def wrapper(self, wpath): | |
445 if code == 'm' and wpath in self.lastevent and \ | |
446 self.lastevent[wpath] in 'cm': | |
447 return | |
448 self.lastevent[wpath] = code | |
449 self.timeout = 250 | |
450 | |
451 f(self, wpath) | |
452 | |
453 wrapper.func_name = f.func_name | |
454 return wrapper | |
455 return decorator | |
456 | |
457 @eventaction('c') | 460 @eventaction('c') |
458 def created(self, wpath): | 461 def created(self, wpath): |
459 if wpath == '.hgignore': | 462 if wpath == '.hgignore': |
460 self.update_hgignore() | 463 self.update_hgignore() |
461 try: | 464 try: |