Mercurial > hg
comparison hgext/inotify/server.py @ 6961:12163fb21fce
i18n: mark strings for translation in inotify extension
author | Martin Geisler <mg@daimi.au.dk> |
---|---|
date | Sun, 31 Aug 2008 16:12:03 +0200 |
parents | b5a6fce0bc29 |
children | ddfcefab8b97 |
comparison
equal
deleted
inserted
replaced
6960:46da38eef1b0 | 6961:12163fb21fce |
---|---|
4 # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> | 4 # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> |
5 # | 5 # |
6 # This software may be used and distributed according to the terms | 6 # This software may be used and distributed according to the terms |
7 # of the GNU General Public License, incorporated herein by reference. | 7 # of the GNU General Public License, incorporated herein by reference. |
8 | 8 |
9 from mercurial.i18n import gettext as _ | 9 from mercurial.i18n import _ |
10 from mercurial import osutil, ui, util | 10 from mercurial import osutil, ui, util |
11 import common | 11 import common |
12 import errno, os, select, socket, stat, struct, sys, time | 12 import errno, os, select, socket, stat, struct, sys, time |
13 | 13 |
14 try: | 14 try: |
288 else: | 288 else: |
289 if oldstatus in self.statuskeys and oldstatus != status: | 289 if oldstatus in self.statuskeys and oldstatus != status: |
290 del self.dir(self.statustrees[oldstatus], root)[fn] | 290 del self.dir(self.statustrees[oldstatus], root)[fn] |
291 if self.ui.debugflag and oldstatus != status: | 291 if self.ui.debugflag and oldstatus != status: |
292 if isdir: | 292 if isdir: |
293 self.ui.note('status: %r dir(%d) -> %s\n' % | 293 self.ui.note(_('status: %r dir(%d) -> %s\n') % |
294 (wfn, len(oldstatus), status)) | 294 (wfn, len(oldstatus), status)) |
295 else: | 295 else: |
296 self.ui.note('status: %r %s -> %s\n' % | 296 self.ui.note(_('status: %r %s -> %s\n') % |
297 (wfn, oldstatus, status)) | 297 (wfn, oldstatus, status)) |
298 if not isdir: | 298 if not isdir: |
299 if status and status != 'i': | 299 if status and status != 'i': |
300 d[fn] = status | 300 d[fn] = status |
301 if status in self.statuskeys: | 301 if status in self.statuskeys: |
380 # But it's easier to do nothing than to open that can of | 380 # But it's easier to do nothing than to open that can of |
381 # worms. | 381 # worms. |
382 | 382 |
383 if self.repo.dirstate.ignorefunc is not None: | 383 if self.repo.dirstate.ignorefunc is not None: |
384 self.repo.dirstate.ignorefunc = None | 384 self.repo.dirstate.ignorefunc = None |
385 self.ui.note('rescanning due to .hgignore change\n') | 385 self.ui.note(_('rescanning due to .hgignore change\n')) |
386 self.scan() | 386 self.scan() |
387 | 387 |
388 def getstat(self, wpath): | 388 def getstat(self, wpath): |
389 try: | 389 try: |
390 return self.statcache[wpath] | 390 return self.statcache[wpath] |
465 else: | 465 else: |
466 self.schedule_work(wpath, 'c') | 466 self.schedule_work(wpath, 'c') |
467 | 467 |
468 def process_delete(self, wpath, evt): | 468 def process_delete(self, wpath, evt): |
469 if self.ui.debugflag: | 469 if self.ui.debugflag: |
470 self.ui.note(('%s event: deleted %s\n') % | 470 self.ui.note(_('%s event: deleted %s\n') % |
471 (self.event_time(), wpath)) | 471 (self.event_time(), wpath)) |
472 | 472 |
473 if evt.mask & inotify.IN_ISDIR: | 473 if evt.mask & inotify.IN_ISDIR: |
474 self.scan(wpath) | 474 self.scan(wpath) |
475 else: | 475 else: |
488 evt.fullpath) | 488 evt.fullpath) |
489 sys.exit(0) | 489 sys.exit(0) |
490 | 490 |
491 def handle_event(self, fd, event): | 491 def handle_event(self, fd, event): |
492 if self.ui.debugflag: | 492 if self.ui.debugflag: |
493 self.ui.note('%s readable: %d bytes\n' % | 493 self.ui.note(_('%s readable: %d bytes\n') % |
494 (self.event_time(), self.threshold.readable())) | 494 (self.event_time(), self.threshold.readable())) |
495 if not self.threshold(): | 495 if not self.threshold(): |
496 if self.registered: | 496 if self.registered: |
497 if self.ui.debugflag: | 497 if self.ui.debugflag: |
498 self.ui.note('%s below threshold - unhooking\n' % | 498 self.ui.note(_('%s below threshold - unhooking\n') % |
499 (self.event_time())) | 499 (self.event_time())) |
500 self.master.poll.unregister(fd) | 500 self.master.poll.unregister(fd) |
501 self.registered = False | 501 self.registered = False |
502 self.timeout = 250 | 502 self.timeout = 250 |
503 else: | 503 else: |
504 self.read_events() | 504 self.read_events() |
505 | 505 |
506 def read_events(self, bufsize=None): | 506 def read_events(self, bufsize=None): |
507 events = self.watcher.read(bufsize) | 507 events = self.watcher.read(bufsize) |
508 if self.ui.debugflag: | 508 if self.ui.debugflag: |
509 self.ui.note('%s reading %d events\n' % | 509 self.ui.note(_('%s reading %d events\n') % |
510 (self.event_time(), len(events))) | 510 (self.event_time(), len(events))) |
511 for evt in events: | 511 for evt in events: |
512 wpath = self.wpath(evt) | 512 wpath = self.wpath(evt) |
513 if evt.mask & inotify.IN_UNMOUNT: | 513 if evt.mask & inotify.IN_UNMOUNT: |
514 self.process_unmount(wpath, evt) | 514 self.process_unmount(wpath, evt) |
521 self.process_create(wpath, evt) | 521 self.process_create(wpath, evt) |
522 | 522 |
523 def handle_timeout(self): | 523 def handle_timeout(self): |
524 if not self.registered: | 524 if not self.registered: |
525 if self.ui.debugflag: | 525 if self.ui.debugflag: |
526 self.ui.note('%s hooking back up with %d bytes readable\n' % | 526 self.ui.note(_('%s hooking back up with %d bytes readable\n') % |
527 (self.event_time(), self.threshold.readable())) | 527 (self.event_time(), self.threshold.readable())) |
528 self.read_events(0) | 528 self.read_events(0) |
529 self.master.poll.register(self, select.POLLIN) | 529 self.master.poll.register(self, select.POLLIN) |
530 self.registered = True | 530 self.registered = True |
531 | 531 |
532 if self.eventq: | 532 if self.eventq: |
533 if self.ui.debugflag: | 533 if self.ui.debugflag: |
534 self.ui.note('%s processing %d deferred events as %d\n' % | 534 self.ui.note(_('%s processing %d deferred events as %d\n') % |
535 (self.event_time(), self.deferred, | 535 (self.event_time(), self.deferred, |
536 len(self.eventq))) | 536 len(self.eventq))) |
537 for wpath, evts in util.sort(self.eventq.items()): | 537 for wpath, evts in util.sort(self.eventq.items()): |
538 for evt in evts: | 538 for evt in evts: |
539 self.deferred_event(wpath, evt) | 539 self.deferred_event(wpath, evt) |
669 if obj.timeout is not None and (timeout is None or obj.timeout < timeout): | 669 if obj.timeout is not None and (timeout is None or obj.timeout < timeout): |
670 timeout, timeobj = obj.timeout, obj | 670 timeout, timeobj = obj.timeout, obj |
671 try: | 671 try: |
672 if self.ui.debugflag: | 672 if self.ui.debugflag: |
673 if timeout is None: | 673 if timeout is None: |
674 self.ui.note('polling: no timeout\n') | 674 self.ui.note(_('polling: no timeout\n')) |
675 else: | 675 else: |
676 self.ui.note('polling: %sms timeout\n' % timeout) | 676 self.ui.note(_('polling: %sms timeout\n') % timeout) |
677 events = self.poll.poll(timeout) | 677 events = self.poll.poll(timeout) |
678 except select.error, err: | 678 except select.error, err: |
679 if err[0] == errno.EINTR: | 679 if err[0] == errno.EINTR: |
680 continue | 680 continue |
681 raise | 681 raise |