Patchwork D8082: manifest: rewrite filesnotin to not make superfluous manifest copies

login
register
mail settings
Submitter phabricator
Date Feb. 5, 2020, 10:34 p.m.
Message ID <differential-rev-PHID-DREV-7izcciuk2mxyoj7i64ud-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44967/
State Superseded
Headers show

Comments

phabricator - Feb. 5, 2020, 10:34 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8082

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -22,6 +22,7 @@ 
 from .pycompat import getattr
 from . import (
     error,
+    match as matchmod,
     mdiff,
     pathutil,
     policy,
@@ -481,17 +482,11 @@ 
 
     def filesnotin(self, m2, match=None):
         '''Set of files in this manifest that are not in the other'''
-        if match:
-            m1 = self.matches(match)
-            m2 = m2.matches(match)
-            return m1.filesnotin(m2)
-        diff = self.diff(m2)
-        files = set(
-            filepath
-            for filepath, hashflags in pycompat.iteritems(diff)
-            if hashflags[1][0] is None
-        )
-        return files
+        if match is not None:
+            match = matchmod.badmatch(match, lambda path, msg: None)
+            sm2 = set(m2.walk(match))
+            return {f for f in self.walk(match) if f not in sm2}
+        return {f for f in self if f not in m2}
 
     @propertycache
     def _dirs(self):