##// END OF EJS Templates
inotify: server: use wprefix everywhere, introduce prefixlen...
Nicolas Dumazet -
r9349:56fb15ad default
parent child Browse files
Show More
@@ -312,7 +312,8 b' class repowatcher(pollable):'
312 def __init__(self, ui, repo):
312 def __init__(self, ui, repo):
313 self.ui = ui
313 self.ui = ui
314 self.repo = repo
314 self.repo = repo
315 self.wprefix = self.repo.wjoin('')
315 self.wprefix = join(repo.root, '')
316 self.prefixlen = len(self.wprefix)
316 try:
317 try:
317 self.watcher = watcher.watcher()
318 self.watcher = watcher.watcher()
318 except OSError, err:
319 except OSError, err:
@@ -363,7 +364,7 b' class repowatcher(pollable):'
363 return
364 return
364 if self.watcher.path(path) is None:
365 if self.watcher.path(path) is None:
365 if self.ui.debugflag:
366 if self.ui.debugflag:
366 self.ui.note(_('watching %r\n') % path[len(self.wprefix):])
367 self.ui.note(_('watching %r\n') % path[self.prefixlen:])
367 try:
368 try:
368 self.watcher.add(path, mask)
369 self.watcher.add(path, mask)
369 except OSError, err:
370 except OSError, err:
@@ -374,7 +375,7 b' class repowatcher(pollable):'
374 _explain_watch_limit(self.ui, self.repo)
375 _explain_watch_limit(self.ui, self.repo)
375
376
376 def setup(self):
377 def setup(self):
377 self.ui.note(_('watching directories under %r\n') % self.repo.root)
378 self.ui.note(_('watching directories under %r\n') % self.wprefix)
378 self.add_watch(self.repo.path, inotify.IN_DELETE)
379 self.add_watch(self.repo.path, inotify.IN_DELETE)
379 self.check_dirstate()
380 self.check_dirstate()
380
381
@@ -466,11 +467,11 b' class repowatcher(pollable):'
466
467
467 def scan(self, topdir=''):
468 def scan(self, topdir=''):
468 ds = self.repo.dirstate._map.copy()
469 ds = self.repo.dirstate._map.copy()
469 self.add_watch(join(self.repo.root, topdir), self.mask)
470 self.add_watch(join(self.wprefix, topdir), self.mask)
470 for root, dirs, files in walk(self.repo, topdir):
471 for root, dirs, files in walk(self.repo, topdir):
471 for d in dirs:
472 for d in dirs:
472 self.add_watch(join(root, d), self.mask)
473 self.add_watch(join(root, d), self.mask)
473 wroot = root[len(self.wprefix):]
474 wroot = root[self.prefixlen:]
474 for fn in files:
475 for fn in files:
475 wfn = join(wroot, fn)
476 wfn = join(wroot, fn)
476 self.updatefile(wfn, self.getstat(wfn))
477 self.updatefile(wfn, self.getstat(wfn))
@@ -633,7 +634,7 b' class repowatcher(pollable):'
633 (self.event_time(), len(events)))
634 (self.event_time(), len(events)))
634 for evt in events:
635 for evt in events:
635 assert evt.fullpath.startswith(self.wprefix)
636 assert evt.fullpath.startswith(self.wprefix)
636 wpath = evt.fullpath[len(self.wprefix):]
637 wpath = evt.fullpath[self.prefixlen:]
637
638
638 # paths have been normalized, wpath never ends with a '/'
639 # paths have been normalized, wpath never ends with a '/'
639
640
@@ -671,7 +672,7 b' class repowatcher(pollable):'
671 Returns a sorted list of relatives paths currently watched,
672 Returns a sorted list of relatives paths currently watched,
672 for debugging purposes.
673 for debugging purposes.
673 """
674 """
674 return sorted(tuple[0][len(self.wprefix):] for tuple in self.watcher)
675 return sorted(tuple[0][self.prefixlen:] for tuple in self.watcher)
675
676
676 class server(pollable):
677 class server(pollable):
677 """
678 """
General Comments 0
You need to be logged in to leave comments. Login now