changeset 21524:47b97d9af27e

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.
author Durham Goode <durham@fb.com>
date Thu, 08 May 2014 16:54:23 -0700
parents 9fb6f328576a
children 559f01f19cf6
files hgext/largefiles/overrides.py mercurial/filemerge.py mercurial/merge.py
diffstat 3 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Tue Apr 22 13:32:05 2014 -0700
+++ b/hgext/largefiles/overrides.py	Thu May 08 16:54:23 2014 -0700
@@ -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()
--- a/mercurial/filemerge.py	Tue Apr 22 13:32:05 2014 -0700
+++ b/mercurial/filemerge.py	Thu May 08 16:54:23 2014 -0700
@@ -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.
 
@@ -318,7 +320,7 @@
     return [_formatconflictmarker(repo, cd, tmpl, labels[0], pad),
             _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
@@ -376,10 +378,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,
--- a/mercurial/merge.py	Tue Apr 22 13:32:05 2014 -0700
+++ b/mercurial/merge.py	Thu May 08 16:54:23 2014 -0700
@@ -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]
@@ -629,7 +630,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
@@ -734,7 +735,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:
@@ -990,7 +991,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
 
@@ -1170,7 +1171,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)