[PATCH 2 of 6] filemerge: set actual capabilities of internal merge tools
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Aug 15 14:35:34 EDT 2018
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1534244907 -32400
# Tue Aug 14 20:08:27 2018 +0900
# Node ID ca968875ed9869cbfa464af05c2a217219f298ed
# Parent cffd12b0d927a859e99c8b5e3f451512c85999d1
# Available At https://bitbucket.org/foozy/mercurial-wip
# hg pull https://bitbucket.org/foozy/mercurial-wip -r ca968875ed98
# EXP-Topic filemerge-refactor
filemerge: set actual capabilities of internal merge tools
This information is used to detect actual capabilities of internal
merge tools by subsequent patches.
For convenience, this patch assumes that merge tools typed as
"nomerge" have both binary files and symlinks capabilities.
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -470,7 +470,7 @@ def _itagmerge(repo, mynode, orig, fcd,
success, status = tagmerge.merge(repo, fcd, fco, fca)
return success, status, False
- at internaltool('dump', fullmerge)
+ at internaltool('dump', fullmerge, binary=True, symlink=True)
def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
"""
Creates three versions of the files to merge, containing the
@@ -496,7 +496,7 @@ def _idump(repo, mynode, orig, fcd, fco,
repo.wwrite(fd + ".base", fca.data(), fca.flags())
return False, 1, False
- at internaltool('forcedump', mergeonly)
+ at internaltool('forcedump', mergeonly, binary=True, symlink=True)
def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
labels=None):
"""
diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -399,7 +399,8 @@ class internalmerge(_funcregistrarbase):
internalmerge = registrar.internalmerge()
@internalmerge('mymerge', internalmerge.mergeonly,
- onfailure=None, precheck=None):
+ onfailure=None, precheck=None,
+ binary=False, symlink=False):
def mymergefunc(repo, mynode, orig, fcd, fco, fca,
toolconf, files, labels=None):
'''Explanation of this internal merge tool ....
@@ -430,6 +431,12 @@ class internalmerge(_funcregistrarbase):
'files' and 'labels'. If it returns false value, merging is aborted
immediately (and file is marked as "unresolved").
+ Optional argument 'binary' is a binary files capability of internal
+ merge tool. 'nomerge' merge type implies binary=True.
+
+ Optional argument 'symlink' is a symlinks capability of inetrnal
+ merge function. 'nomerge' merge type implies symlink=True.
+
'internalmerge' instance in example above can be used to
decorate multiple functions.
@@ -447,7 +454,14 @@ class internalmerge(_funcregistrarbase):
fullmerge = 'fullmerge' # both premerge and merge
def _extrasetup(self, name, func, mergetype,
- onfailure=None, precheck=None):
+ onfailure=None, precheck=None,
+ binary=False, symlink=False):
func.mergetype = mergetype
func.onfailure = onfailure
func.precheck = precheck
+
+ binarycap = binary or mergetype == self.nomerge
+ symlinkcap = symlink or mergetype == self.nomerge
+
+ # actual capabilities, which this internal merge tool has
+ func.capabilities = {"binary": binarycap, "symlink": symlinkcap}
More information about the Mercurial-devel
mailing list