comparison mercurial/manifest.py @ 24495:d2a3a2808974

manifest: make manifest.intersectfiles() internal manifest.intersectfiles() is just a utility used by manifest.matches(), and a future commit removes intersectfiles for treemanifest for optimization purposes. This commit makes the intersectfiles methods on manifestdict and treemanifest internal, and converts its test to a more generic testMatches(), which has the exact same coverage.
author Drew Gottlieb <drgott@google.com>
date Mon, 30 Mar 2015 10:43:52 -0700
parents bfb754050ccd
children ecac0dd246a8
comparison
equal deleted inserted replaced
24494:f2b87f4856bf 24495:d2a3a2808974
129 return self._lm.iterkeys() 129 return self._lm.iterkeys()
130 130
131 def keys(self): 131 def keys(self):
132 return list(self.iterkeys()) 132 return list(self.iterkeys())
133 133
134 def intersectfiles(self, files): 134 def _intersectfiles(self, files):
135 '''make a new lazymanifest with the intersection of self with files 135 '''make a new lazymanifest with the intersection of self with files
136 136
137 The algorithm assumes that files is much smaller than self.''' 137 The algorithm assumes that files is much smaller than self.'''
138 ret = manifestdict() 138 ret = manifestdict()
139 lm = self._lm 139 lm = self._lm
164 return self.copy() 164 return self.copy()
165 165
166 files = match.files() 166 files = match.files()
167 if (len(files) < 100 and (match.isexact() or 167 if (len(files) < 100 and (match.isexact() or
168 (not match.anypats() and util.all(fn in self for fn in files)))): 168 (not match.anypats() and util.all(fn in self for fn in files)))):
169 return self.intersectfiles(files) 169 return self._intersectfiles(files)
170 170
171 lm = manifestdict('') 171 lm = manifestdict('')
172 lm._lm = self._lm.filtercopy(match) 172 lm._lm = self._lm.filtercopy(match)
173 return lm 173 return lm
174 174
465 copy._dirs[d] = self._dirs[d].copy() 465 copy._dirs[d] = self._dirs[d].copy()
466 copy._files = dict.copy(self._files) 466 copy._files = dict.copy(self._files)
467 copy._flags = dict.copy(self._flags) 467 copy._flags = dict.copy(self._flags)
468 return copy 468 return copy
469 469
470 def intersectfiles(self, files): 470 def _intersectfiles(self, files):
471 '''make a new treemanifest with the intersection of self with files 471 '''make a new treemanifest with the intersection of self with files
472 472
473 The algorithm assumes that files is much smaller than self.''' 473 The algorithm assumes that files is much smaller than self.'''
474 ret = treemanifest() 474 ret = treemanifest()
475 for fn in files: 475 for fn in files:
519 return self.copy() 519 return self.copy()
520 520
521 files = match.files() 521 files = match.files()
522 if (match.isexact() or 522 if (match.isexact() or
523 (not match.anypats() and util.all(fn in self for fn in files))): 523 (not match.anypats() and util.all(fn in self for fn in files))):
524 return self.intersectfiles(files) 524 return self._intersectfiles(files)
525 525
526 m = self.copy() 526 m = self.copy()
527 for fn in m.keys(): 527 for fn in m.keys():
528 if not match(fn): 528 if not match(fn):
529 del m[fn] 529 del m[fn]