Mercurial > hg
comparison hgext/inotify/server.py @ 8385:1536501ade62
inotify: Coding Style: name classes in lowercase.
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Mon, 11 May 2009 08:19:28 +0900 |
parents | 483d9b2103da |
children | 4aad982111b6 |
comparison
equal
deleted
inserted
replaced
8384:483d9b2103da | 8385:1536501ade62 |
---|---|
111 (limit, newlimit)) | 111 (limit, newlimit)) |
112 ui.warn(_('*** echo %d > %s\n') % (newlimit, path)) | 112 ui.warn(_('*** echo %d > %s\n') % (newlimit, path)) |
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 RepoWatcher(object): | 116 class repowatcher(object): |
117 poll_events = select.POLLIN | 117 poll_events = select.POLLIN |
118 statuskeys = 'almr!?' | 118 statuskeys = 'almr!?' |
119 mask = ( | 119 mask = ( |
120 inotify.IN_ATTRIB | | 120 inotify.IN_ATTRIB | |
121 inotify.IN_CREATE | | 121 inotify.IN_CREATE | |
134 self.repo = repo | 134 self.repo = repo |
135 self.wprefix = self.repo.wjoin('') | 135 self.wprefix = self.repo.wjoin('') |
136 self.timeout = None | 136 self.timeout = None |
137 self.master = master | 137 self.master = master |
138 try: | 138 try: |
139 self.watcher = watcher.Watcher() | 139 self.watcher = watcher.watcher() |
140 except OSError, err: | 140 except OSError, err: |
141 raise util.Abort(_('inotify service not available: %s') % | 141 raise util.Abort(_('inotify service not available: %s') % |
142 err.strerror) | 142 err.strerror) |
143 self.threshold = watcher.Threshold(self.watcher) | 143 self.threshold = watcher.threshold(self.watcher) |
144 self.registered = True | 144 self.registered = True |
145 self.fileno = self.watcher.fileno | 145 self.fileno = self.watcher.fileno |
146 | 146 |
147 self.repo.dirstate.__class__.inotifyserver = True | 147 self.repo.dirstate.__class__.inotifyserver = True |
148 | 148 |
540 self.timeout = None | 540 self.timeout = None |
541 | 541 |
542 def shutdown(self): | 542 def shutdown(self): |
543 self.watcher.close() | 543 self.watcher.close() |
544 | 544 |
545 class Server(object): | 545 class server(object): |
546 poll_events = select.POLLIN | 546 poll_events = select.POLLIN |
547 | 547 |
548 def __init__(self, ui, repo, repowatcher, timeout): | 548 def __init__(self, ui, repo, repowatcher, timeout): |
549 self.ui = ui | 549 self.ui = ui |
550 self.repo = repo | 550 self.repo = repo |
656 os.rmdir(os.path.dirname(self.realsockpath)) | 656 os.rmdir(os.path.dirname(self.realsockpath)) |
657 except OSError, err: | 657 except OSError, err: |
658 if err.errno != errno.ENOENT: | 658 if err.errno != errno.ENOENT: |
659 raise | 659 raise |
660 | 660 |
661 class Master(object): | 661 class master(object): |
662 def __init__(self, ui, repo, timeout=None): | 662 def __init__(self, ui, repo, timeout=None): |
663 self.ui = ui | 663 self.ui = ui |
664 self.repo = repo | 664 self.repo = repo |
665 self.poll = select.poll() | 665 self.poll = select.poll() |
666 self.repowatcher = RepoWatcher(ui, repo, self) | 666 self.repowatcher = repowatcher(ui, repo, self) |
667 self.server = Server(ui, repo, self.repowatcher, timeout) | 667 self.server = server(ui, repo, self.repowatcher, timeout) |
668 self.table = {} | 668 self.table = {} |
669 for obj in (self.repowatcher, self.server): | 669 for obj in (self.repowatcher, self.server): |
670 fd = obj.fileno() | 670 fd = obj.fileno() |
671 self.table[fd] = obj | 671 self.table[fd] = obj |
672 self.poll.register(fd, obj.poll_events) | 672 self.poll.register(fd, obj.poll_events) |
725 try: | 725 try: |
726 os.close(fd) | 726 os.close(fd) |
727 except OSError: | 727 except OSError: |
728 pass | 728 pass |
729 | 729 |
730 m = Master(ui, repo) | 730 m = master(ui, repo) |
731 sys.stdout.flush() | 731 sys.stdout.flush() |
732 sys.stderr.flush() | 732 sys.stderr.flush() |
733 | 733 |
734 pid = os.fork() | 734 pid = os.fork() |
735 if pid: | 735 if pid: |