Patchwork [3,of,9] merge: use intersectmatchers() in "m2-vs-ma optimization"

login
register
mail settings
Submitter via Mercurial-devel
Date May 26, 2017, 11:32 p.m.
Message ID <83a81ef5b6282eae5e21.1495841569@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20942/
State Accepted
Headers show

Comments

via Mercurial-devel - May 26, 2017, 11:32 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1494632013 25200
#      Fri May 12 16:33:33 2017 -0700
# Node ID 83a81ef5b6282eae5e214c64273e0f6f80310716
# Parent  0318efe4a69d9ff1684d7194898be8e016b7c62e
merge: use intersectmatchers() in "m2-vs-ma optimization"

It doesn't seem like this can actually happen, but seems like cleaner
anyway.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -823,11 +823,9 @@ 
 
     # Don't use m2-vs-ma optimization if:
     # - ma is the same as m1 or m2, which we're just going to diff again later
-    # - The matcher is set already, so we can't override it
     # - The caller specifically asks for a full diff, which is useful during bid
     #   merge.
-    if (pa not in ([wctx, p2] + wctx.parents()) and
-        matcher is None and not forcefulldiff):
+    if (pa not in ([wctx, p2] + wctx.parents()) and not forcefulldiff):
         # Identify which files are relevant to the merge, so we can limit the
         # total m1-vs-m2 diff to just those files. This has significant
         # performance benefits in large repositories.
@@ -839,7 +837,8 @@ 
                 relevantfiles.add(copykey)
         for movedirkey in movewithdir.iterkeys():
             relevantfiles.add(movedirkey)
-        matcher = scmutil.matchfiles(repo, relevantfiles)
+        filesmatcher = scmutil.matchfiles(repo, relevantfiles)
+        matcher = matchmod.intersectmatchers(matcher, filesmatcher)
 
     diff = m1.diff(m2, match=matcher)