comparison mercurial/manifest.py @ 24666:3092885b5b32

manifestdict: inline _intersectfiles() The _intersectfiles() method is only called from one place, it's pretty short, and its caller has to be aware when it's appropriate to call it (when the number of files in the matcher is not too large), so let's inline it.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 08 Apr 2015 10:01:31 -0700
parents 5326820a2952
children 19c5b0913960
comparison
equal deleted inserted replaced
24665:5326820a2952 24666:3092885b5b32
196 return self._lm.iterkeys() 196 return self._lm.iterkeys()
197 197
198 def keys(self): 198 def keys(self):
199 return list(self.iterkeys()) 199 return list(self.iterkeys())
200 200
201 def _intersectfiles(self, files):
202 '''make a new lazymanifest with the intersection of self with files
203
204 The algorithm assumes that files is much smaller than self.'''
205 ret = manifestdict()
206 lm = self._lm
207 for fn in files:
208 if fn in lm:
209 ret._lm[fn] = lm[fn]
210 return ret
211
212 def filesnotin(self, m2): 201 def filesnotin(self, m2):
213 '''Set of files in this manifest that are not in the other''' 202 '''Set of files in this manifest that are not in the other'''
214 files = set(self) 203 files = set(self)
215 files.difference_update(m2) 204 files.difference_update(m2)
216 return files 205 return files
263 return self.copy() 252 return self.copy()
264 253
265 files = match.files() 254 files = match.files()
266 if (len(files) < 100 and (match.isexact() or 255 if (len(files) < 100 and (match.isexact() or
267 (not match.anypats() and util.all(fn in self for fn in files)))): 256 (not match.anypats() and util.all(fn in self for fn in files)))):
268 return self._intersectfiles(files) 257 m = manifestdict()
258 lm = self._lm
259 for fn in match.files():
260 if fn in lm:
261 m._lm[fn] = lm[fn]
262 return m
269 263
270 m = manifestdict('') 264 m = manifestdict('')
271 m._lm = self._lm.filtercopy(match) 265 m._lm = self._lm.filtercopy(match)
272 return m 266 return m
273 267