copies: use intersectmatchers() in non-merge p1 optimization
authorYuya Nishihara <yuya@tcha.org>
Sat, 19 Aug 2017 11:23:33 +0900
changeset 33886 252fb66ee5bb
parent 33885 4e8a46c25fac
child 33887 63773d7497b6
copies: use intersectmatchers() in non-merge p1 optimization This enables the optimization introduced by d4247c306d82 for non-rebase cases. Before, the match couldn't be narrowed if it was e.g. alwaysmatcher. The logic is copied from bd56bea5ecf8.
mercurial/copies.py
--- a/mercurial/copies.py	Tue Aug 22 11:00:00 2017 +0200
+++ b/mercurial/copies.py	Sat Aug 19 11:23:33 2017 +0900
@@ -10,6 +10,7 @@
 import heapq
 
 from . import (
+    match as matchmod,
     node,
     pathutil,
     scmutil,
@@ -182,8 +183,9 @@
     # optimization, since the ctx.files() for a merge commit is not correct for
     # this comparison.
     forwardmissingmatch = match
-    if not match and b.p1() == a and b.p2().node() == node.nullid:
-        forwardmissingmatch = scmutil.matchfiles(a._repo, b.files())
+    if b.p1() == a and b.p2().node() == node.nullid:
+        filesmatcher = scmutil.matchfiles(a._repo, b.files())
+        forwardmissingmatch = matchmod.intersectmatchers(match, filesmatcher)
     missing = _computeforwardmissing(a, b, match=forwardmissingmatch)
 
     ancestrycontext = a._repo.changelog.ancestors([b.rev()], inclusive=True)