Patchwork [2,of,6,V5] merge: add labels parameter from merge.update to filemerge

login
register
mail settings
Submitter Durham Goode
Date May 16, 2014, 11:48 p.m.
Message ID <aa7b917657f71be18f89.1400284116@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/4790/
State Accepted
Headers show

Comments

Durham Goode - May 16, 2014, 11:48 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1399593263 25200
#      Thu May 08 16:54:23 2014 -0700
# Node ID aa7b917657f71be18f8923069941a8d46994c617
# Parent  d2d3257218fddf9b672bc419bce5aade1ca86ec4
merge: add labels parameter from merge.update to filemerge

Adds a labels function parameter to all the functions between merge.update and
filemerge.filemerge. This will allow commands like rebase to specify custom
marker labels.
Pierre-Yves David - May 18, 2014, 8:27 a.m.
On 05/16/2014 04:48 PM, Durham Goode wrote:
> @@ -287,7 +287,8 @@
>           f = self._repo.opener("merge/" + hash)
>           self._repo.wwrite(dfile, f.read(), flags)
>           f.close()
> -        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca)
> +        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca,
> +            labels=labels)

Wrong indentation. I fixed it.

>           if r is None:
>               # no real conflict
>               del self._state[dfile]

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -452,9 +452,9 @@ 
 
 # 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):
+def overridefilemerge(origfn, repo, mynode, orig, fcd, fco, fca, labels=None):
     if not lfutil.isstandin(orig):
-        return origfn(repo, mynode, orig, fcd, fco, fca)
+        return origfn(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
@@ -300,6 +300,8 @@ 
     '{ifeq(branch, "default", "", "{branch} ")}' +
     '- {author|user}: "{desc|firstline}"')
 
+_defaultconflictlabels = ['local', 'other']
+
 def _formatlabels(repo, fcd, fco, labels):
     """Formats the given labels using the conflict marker template.
 
@@ -321,7 +323,7 @@ 
         _formatconflictmarker(repo, co, tmpl, labels[1], pad),
     ]
 
-def filemerge(repo, mynode, orig, fcd, fco, fca):
+def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
     """perform a 3-way merge in the working directory
 
     mynode = parent node before merge
@@ -379,10 +381,12 @@ 
     ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
 
     markerstyle = ui.config('ui', 'mergemarkers', 'detailed')
-    labels = ['local', 'other']
     if markerstyle == 'basic':
-        formattedlabels = labels
+        formattedlabels = _defaultconflictlabels
     else:
+        if not labels:
+            labels = _defaultconflictlabels
+
         formattedlabels = _formatlabels(repo, fcd, fco, labels)
 
     needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -264,7 +264,7 @@ 
             if entry[0] == 'u':
                 yield f
 
-    def resolve(self, dfile, wctx):
+    def resolve(self, dfile, wctx, labels=None):
         """rerun merge process for file path `dfile`"""
         if self[dfile] == 'r':
             return 0
@@ -287,7 +287,8 @@ 
         f = self._repo.opener("merge/" + hash)
         self._repo.wwrite(dfile, f.read(), flags)
         f.close()
-        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca)
+        r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca,
+            labels=labels)
         if r is None:
             # no real conflict
             del self._state[dfile]
@@ -610,7 +611,7 @@ 
     if i > 0:
         yield i, f
 
-def applyupdates(repo, actions, wctx, mctx, overwrite):
+def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
     """apply the merge action list to the working directory
 
     wctx is the working copy context
@@ -698,7 +699,7 @@ 
                                  overwrite)
                 continue
             audit(f)
-            r = ms.resolve(f, wctx)
+            r = ms.resolve(f, wctx, labels=labels)
             if r is not None and r > 0:
                 unresolved += 1
             else:
@@ -911,7 +912,7 @@ 
                 repo.dirstate.normal(f)
 
 def update(repo, node, branchmerge, force, partial, ancestor=None,
-           mergeancestor=False):
+           mergeancestor=False, labels=None):
     """
     Perform a merge between the working directory and the given node
 
@@ -1091,7 +1092,7 @@ 
             # note that we're in the middle of an update
             repo.vfs.write('updatestate', p2.hex())
 
-        stats = applyupdates(repo, actions, wc, p2, overwrite)
+        stats = applyupdates(repo, actions, wc, p2, overwrite, labels=labels)
 
         if not partial:
             repo.setparents(fp1, fp2)