Patchwork [3,of,7,V2,mergedriver] filemerge: introduce a premerge flag and function

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 12, 2015, 7:45 a.m.
Message ID <5c1221d9a424db9c9d27.1444635938@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10950/
State Accepted
Headers show

Comments

Siddharth Agarwal - Oct. 12, 2015, 7:45 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1444621624 25200
#      Sun Oct 11 20:47:04 2015 -0700
# Node ID 5c1221d9a424db9c9d27b5cda1194248746a6be3
# Parent  23d773a1a116fa545dacda86f0a0cea76cf347cf
filemerge: introduce a premerge flag and function

This flag will let us get to our overall goal of performing all premerges
before any merges.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -536,9 +536,11 @@  def mergerecordupdates(orig, repo, actio
 
 # Override filemerge to prompt the user about how they wish to merge
 # largefiles. This will handle identical edits without prompting the user.
-def overridefilemerge(origfn, repo, mynode, orig, fcd, fco, fca, labels=None):
+def overridefilemerge(origfn, premerge, repo, mynode, orig, fcd, fco, fca,
+                      labels=None):
     if not lfutil.isstandin(orig):
-        return origfn(repo, mynode, orig, fcd, fco, fca, labels=labels)
+        return origfn(premerge, repo, mynode, orig, fcd, fco, fca,
+                      labels=labels)
 
     ahash = fca.data().strip().lower()
     dhash = fcd.data().strip().lower()
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -435,9 +435,10 @@  def _formatlabels(repo, fcd, fco, fca, l
         newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad))
     return newlabels
 
-def _filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
+def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
     """perform a 3-way merge in the working directory
 
+    premerge = whether this is a premerge
     mynode = parent node before merge
     orig = original local filename before merge
     fco = other file context
@@ -515,7 +516,7 @@  def _filemerge(repo, mynode, orig, fcd, 
         if markerstyle != 'basic':
             labels = _formatlabels(repo, fcd, fco, fca, labels)
 
-        if mergetype == fullmerge:
+        if premerge and mergetype == fullmerge:
             r = _premerge(repo, toolconf, files, labels=labels)
 
         if not r:  # premerge successfully merged the file
@@ -569,8 +570,13 @@  def _check(r, ui, tool, fcd, files):
 
     return r
 
+def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
+    return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
+
 def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
-    return _filemerge(repo, mynode, orig, fcd, fco, fca, labels=labels)
+    # premerge = True is temporary -- will be changed to False once premerge
+    # function above is ready
+    return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
 
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = internals.values()