Mercurial > hg
comparison mercurial/store.py @ 17782:8095306c1fb2
store: move __contains__() implementation from class fncache into fncachestore
This restores the previous semantics of fncache.__contains__().
(a followup to b9a56b816ff2)
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Fri, 12 Oct 2012 10:40:09 +0200 |
parents | aad3bce98f76 |
children | df55ce6854c3 |
comparison
equal
deleted
inserted
replaced
17781:8ce535745500 | 17782:8095306c1fb2 |
---|---|
424 self._load() | 424 self._load() |
425 if fn not in self.entries: | 425 if fn not in self.entries: |
426 self._dirty = True | 426 self._dirty = True |
427 self.entries.add(fn) | 427 self.entries.add(fn) |
428 | 428 |
429 def __contains__(self, path): | 429 def __contains__(self, fn): |
430 if self.entries is None: | 430 if self.entries is None: |
431 self._load() | 431 self._load() |
432 # Check for files (exact match) | 432 return fn in self.entries |
433 if path + ".i" in self.entries: | |
434 return True | |
435 # Now check for directories (prefix match) | |
436 if not path.endswith('/'): | |
437 path += '/' | |
438 for e in self.entries: | |
439 if e.startswith(path): | |
440 return True | |
441 return False | |
442 | 433 |
443 def __iter__(self): | 434 def __iter__(self): |
444 if self.entries is None: | 435 if self.entries is None: |
445 self._load() | 436 self._load() |
446 return iter(self.entries) | 437 return iter(self.entries) |
522 self.fncache.write() | 513 self.fncache.write() |
523 | 514 |
524 def __contains__(self, path): | 515 def __contains__(self, path): |
525 '''Checks if the store contains path''' | 516 '''Checks if the store contains path''' |
526 path = "/".join(("data", path)) | 517 path = "/".join(("data", path)) |
527 return path in self.fncache | 518 # check for files (exact match) |
519 if path + '.i' in self.fncache: | |
520 return True | |
521 # now check for directories (prefix match) | |
522 if not path.endswith('/'): | |
523 path += '/' | |
524 for e in self.fncache: | |
525 if e.startswith(path): | |
526 return True | |
527 return False | |
528 | 528 |
529 def store(requirements, path, vfstype): | 529 def store(requirements, path, vfstype): |
530 if 'store' in requirements: | 530 if 'store' in requirements: |
531 if 'fncache' in requirements: | 531 if 'fncache' in requirements: |
532 return fncachestore(path, vfstype, 'dotencode' in requirements) | 532 return fncachestore(path, vfstype, 'dotencode' in requirements) |