Mercurial > public > mercurial-scm > hg
comparison mercurial/manifest.py @ 44286:bbecb6d80aa7
manifest: rewrite filesnotin to not make superfluous manifest copies
This also skips using diff() when all we care about is the filenames. I'm
expecting the built in set logic to be plenty fast. For really large manifests
with a matcher in play this should copy substantially less data around.
Differential Revision: https://phab.mercurial-scm.org/D8082
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 05 Feb 2020 16:58:50 -0500 |
parents | 63d84c18247a |
children | 0bf3b5e80d30 |
comparison
equal
deleted
inserted
replaced
44285:63d84c18247a | 44286:bbecb6d80aa7 |
---|---|
21 ) | 21 ) |
22 from .pycompat import getattr | 22 from .pycompat import getattr |
23 from . import ( | 23 from . import ( |
24 encoding, | 24 encoding, |
25 error, | 25 error, |
26 match as matchmod, | |
26 mdiff, | 27 mdiff, |
27 pathutil, | 28 pathutil, |
28 policy, | 29 policy, |
29 pycompat, | 30 pycompat, |
30 revlog, | 31 revlog, |
480 def keys(self): | 481 def keys(self): |
481 return list(self.iterkeys()) | 482 return list(self.iterkeys()) |
482 | 483 |
483 def filesnotin(self, m2, match=None): | 484 def filesnotin(self, m2, match=None): |
484 '''Set of files in this manifest that are not in the other''' | 485 '''Set of files in this manifest that are not in the other''' |
485 if match: | 486 if match is not None: |
486 m1 = self.matches(match) | 487 match = matchmod.badmatch(match, lambda path, msg: None) |
487 m2 = m2.matches(match) | 488 sm2 = set(m2.walk(match)) |
488 return m1.filesnotin(m2) | 489 return {f for f in self.walk(match) if f not in sm2} |
489 diff = self.diff(m2) | 490 return {f for f in self if f not in m2} |
490 files = set( | |
491 filepath | |
492 for filepath, hashflags in pycompat.iteritems(diff) | |
493 if hashflags[1][0] is None | |
494 ) | |
495 return files | |
496 | 491 |
497 @propertycache | 492 @propertycache |
498 def _dirs(self): | 493 def _dirs(self): |
499 return pathutil.dirs(self) | 494 return pathutil.dirs(self) |
500 | 495 |