Mercurial > hg
comparison hgext/inotify/server.py @ 8787:9aca76502280
inotify: server: move split() out of server
split() has nothing to do with the server logic, it does not need to be
in the class. Move it on top, next to join() which does the opposite.
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Wed, 27 May 2009 00:29:11 +0900 |
parents | 55af9be4efac |
children | 23730a475363 |
comparison
equal
deleted
inserted
replaced
8786:55af9be4efac | 8787:9aca76502280 |
---|---|
23 if a: | 23 if a: |
24 if a[-1] == '/': | 24 if a[-1] == '/': |
25 return a + b | 25 return a + b |
26 return a + '/' + b | 26 return a + '/' + b |
27 return b | 27 return b |
28 | |
29 def split(path): | |
30 c = path.rfind('/') | |
31 if c == -1: | |
32 return '', path | |
33 return path[:c], path[c+1:] | |
28 | 34 |
29 walk_ignored_errors = (errno.ENOENT, errno.ENAMETOOLONG) | 35 walk_ignored_errors = (errno.ENOENT, errno.ENAMETOOLONG) |
30 | 36 |
31 def walkrepodirs(repo): | 37 def walkrepodirs(repo): |
32 '''Iterate over all subdirectories of this repo. | 38 '''Iterate over all subdirectories of this repo. |
249 return 'x' | 255 return 'x' |
250 except TypeError: | 256 except TypeError: |
251 return 'd' | 257 return 'd' |
252 return tree | 258 return tree |
253 | 259 |
254 def split(self, path): | |
255 c = path.rfind('/') | |
256 if c == -1: | |
257 return '', path | |
258 return path[:c], path[c+1:] | |
259 | |
260 def filestatus(self, fn, st): | 260 def filestatus(self, fn, st): |
261 try: | 261 try: |
262 type_, mode, size, time = self.repo.dirstate._map[fn][:4] | 262 type_, mode, size, time = self.repo.dirstate._map[fn][:4] |
263 except KeyError: | 263 except KeyError: |
264 type_ = '?' | 264 type_ = '?' |
305 Update the stored status of a file or directory. | 305 Update the stored status of a file or directory. |
306 | 306 |
307 newstatus: - char in (statuskeys + 'ni'), new status to apply. | 307 newstatus: - char in (statuskeys + 'ni'), new status to apply. |
308 - or None, to stop tracking wfn | 308 - or None, to stop tracking wfn |
309 ''' | 309 ''' |
310 root, fn = self.split(wfn) | 310 root, fn = split(wfn) |
311 d = self.dir(self.tree, root) | 311 d = self.dir(self.tree, root) |
312 | 312 |
313 oldstatus = d.get(fn) | 313 oldstatus = d.get(fn) |
314 # oldstatus can be either: | 314 # oldstatus can be either: |
315 # - None : fn is new | 315 # - None : fn is new |
344 nuke = [] | 344 nuke = [] |
345 for wfn, ignore in self.walk(key, self.statustrees[key]): | 345 for wfn, ignore in self.walk(key, self.statustrees[key]): |
346 if wfn not in self.repo.dirstate: | 346 if wfn not in self.repo.dirstate: |
347 nuke.append(wfn) | 347 nuke.append(wfn) |
348 for wfn in nuke: | 348 for wfn in nuke: |
349 root, fn = self.split(wfn) | 349 root, fn = split(wfn) |
350 del self.dir(self.statustrees[key], root)[fn] | 350 del self.dir(self.statustrees[key], root)[fn] |
351 del self.dir(self.tree, root)[fn] | 351 del self.dir(self.tree, root)[fn] |
352 | 352 |
353 def scan(self, topdir=''): | 353 def scan(self, topdir=''): |
354 ds = self.repo.dirstate._map.copy() | 354 ds = self.repo.dirstate._map.copy() |