Patchwork copies: use intersectmatchers() in non-merge p1 optimization

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 19, 2017, 6:58 a.m.
Message ID <57b175605401373c0c37.1503125934@mimosa>
Download mbox | patch
Permalink /patch/23132/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 19, 2017, 6:58 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1503109413 -32400
#      Sat Aug 19 11:23:33 2017 +0900
# Node ID 57b175605401373c0c37bd9937a209676a734947
# Parent  6f6c87888b228948e202bd5967dc306bed56af7d
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.
via Mercurial-devel - Aug. 22, 2017, 4:35 p.m.
On Fri, Aug 18, 2017 at 11:58 PM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1503109413 -32400
> #      Sat Aug 19 11:23:33 2017 +0900
> # Node ID 57b175605401373c0c37bd9937a209676a734947
> # Parent  6f6c87888b228948e202bd5967dc306bed56af7d
> copies: use intersectmatchers() in non-merge p1 optimization

Queued, thanks.

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -10,6 +10,7 @@  from __future__ import absolute_import
 import heapq
 
 from . import (
+    match as matchmod,
     node,
     pathutil,
     scmutil,
@@ -182,8 +183,9 @@  def _forwardcopies(a, b, match=None):
     # 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)