Patchwork [3,of,4,more-matchers] merge: rework manifestmerge to use a matcher

login
register
mail settings
Submitter Augie Fackler
Date Dec. 15, 2015, 3:17 a.m.
Message ID <5eee49ed60caa99be140.1450149439@imladris.local>
Download mbox | patch
Permalink /patch/12050/
State Accepted
Headers show

Comments

Augie Fackler - Dec. 15, 2015, 3:17 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1450144042 18000
#      Mon Dec 14 20:47:22 2015 -0500
# Node ID 5eee49ed60caa99be140f7f80ac7fb07f1c0324d
# Parent  39b26fa17e85304fe227f06a7a7cc3cffa02ad19
merge: rework manifestmerge to use a matcher

This opens the door to working slightly more closely with the manifest
type and lettig it optimize out some of the diff comparisons for us,
and also makes life significantly easier for narrowhg.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -683,15 +683,17 @@  def driverconclude(repo, ms, wctx, label
     This is currently not implemented -- it's an extension point."""
     return True
 
-def manifestmerge(repo, wctx, p2, pa, branchmerge, force, partial,
+def manifestmerge(repo, wctx, p2, pa, branchmerge, force, matcher,
                   acceptremote, followcopies):
     """
     Merge p1 and p2 with ancestor pa and generate merge action list
 
     branchmerge and force are as passed in to update
-    partial = function to filter file lists
+    matcher = matcher to filter file lists
     acceptremote = accept the incoming changes without prompting
     """
+    if matcher is not None and matcher.always():
+        matcher = None
 
     copy, movewithdir, diverge, renamedelete = {}, {}, {}, {}
 
@@ -705,7 +707,7 @@  def manifestmerge(repo, wctx, p2, pa, br
 
     repo.ui.note(_("resolving manifests\n"))
     repo.ui.debug(" branchmerge: %s, force: %s, partial: %s\n"
-                  % (bool(branchmerge), bool(force), bool(partial)))
+                  % (bool(branchmerge), bool(force), bool(matcher)))
     repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, wctx, p2))
 
     m1, m2, ma = wctx.manifest(), p2.manifest(), pa.manifest()
@@ -724,7 +726,7 @@  def manifestmerge(repo, wctx, p2, pa, br
 
     actions = {}
     for f, ((n1, fl1), (n2, fl2)) in diff.iteritems():
-        if partial and not partial(f):
+        if matcher and not matcher(f):
             continue
         if n1 and n2: # file exists on both local and remote side
             if f not in ma:
@@ -844,14 +846,9 @@  def _resolvetrivial(repo, wctx, mctx, an
 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force,
                      acceptremote, followcopies, matcher=None):
     "Calculate the actions needed to merge mctx into wctx using ancestors"
-    if matcher is None or matcher.always():
-        partial = False
-    else:
-        partial = matcher.matchfn
-
     if len(ancestors) == 1: # default
         actions, diverge, renamedelete = manifestmerge(
-            repo, wctx, mctx, ancestors[0], branchmerge, force, partial,
+            repo, wctx, mctx, ancestors[0], branchmerge, force, matcher,
             acceptremote, followcopies)
         _checkunknownfiles(repo, wctx, mctx, force, actions)
 
@@ -866,7 +863,7 @@  def calculateupdates(repo, wctx, mctx, a
         for ancestor in ancestors:
             repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor)
             actions, diverge1, renamedelete1 = manifestmerge(
-                repo, wctx, mctx, ancestor, branchmerge, force, partial,
+                repo, wctx, mctx, ancestor, branchmerge, force, matcher,
                 acceptremote, followcopies)
             _checkunknownfiles(repo, wctx, mctx, force, actions)