Mercurial > public > mercurial-scm > hg
comparison mercurial/manifest.py @ 24550:4daae7edf166
treemanifest: remove treemanifest._intersectfiles()
In preparation for the optimization in the following commit, this commit
removes treemanifest.matches()'s call to _intersectfiles(), and removes
_intersectfiles() itself since it's unused at this point.
author | Drew Gottlieb <drgott@google.com> |
---|---|
date | Fri, 27 Mar 2015 13:16:13 -0700 |
parents | b538ae24aa97 |
children | 4fdf5eac5b39 |
comparison
equal
deleted
inserted
replaced
24549:bcf0de51326e | 24550:4daae7edf166 |
---|---|
478 copy._dirs[d] = self._dirs[d].copy() | 478 copy._dirs[d] = self._dirs[d].copy() |
479 copy._files = dict.copy(self._files) | 479 copy._files = dict.copy(self._files) |
480 copy._flags = dict.copy(self._flags) | 480 copy._flags = dict.copy(self._flags) |
481 return copy | 481 return copy |
482 | 482 |
483 def _intersectfiles(self, files): | |
484 '''make a new treemanifest with the intersection of self with files | |
485 | |
486 The algorithm assumes that files is much smaller than self.''' | |
487 ret = treemanifest() | |
488 for fn in files: | |
489 if fn in self: | |
490 ret[fn] = self[fn] | |
491 flags = self.flags(fn) | |
492 if flags: | |
493 ret.setflag(fn, flags) | |
494 return ret | |
495 | |
496 def filesnotin(self, m2): | 483 def filesnotin(self, m2): |
497 '''Set of files in this manifest that are not in the other''' | 484 '''Set of files in this manifest that are not in the other''' |
498 files = set() | 485 files = set() |
499 def _filesnotin(t1, t2): | 486 def _filesnotin(t1, t2): |
500 for d, m1 in t1._dirs.iteritems(): | 487 for d, m1 in t1._dirs.iteritems(): |
528 | 515 |
529 def matches(self, match): | 516 def matches(self, match): |
530 '''generate a new manifest filtered by the match argument''' | 517 '''generate a new manifest filtered by the match argument''' |
531 if match.always(): | 518 if match.always(): |
532 return self.copy() | 519 return self.copy() |
533 | |
534 files = match.files() | |
535 if (match.isexact() or | |
536 (not match.anypats() and util.all(fn in self for fn in files))): | |
537 return self._intersectfiles(files) | |
538 | 520 |
539 m = self.copy() | 521 m = self.copy() |
540 for fn in m.keys(): | 522 for fn in m.keys(): |
541 if not match(fn): | 523 if not match(fn): |
542 del m[fn] | 524 del m[fn] |