[PATCH 6 of 6] filemerge: show actual capabilities of internal merge tools

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Aug 15 14:35:38 EDT 2018


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1534252828 -32400
#      Tue Aug 14 22:20:28 2018 +0900
# Node ID f65c2eed9d606cbe7c5c76a8787f2db710abc445
# Parent  813cc2cf9c0cae1928584518afb4558c443b77b7
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r f65c2eed9d60
# EXP-Topic filemerge-refactor
filemerge: show actual capabilities of internal merge tools

This information is useful to know which internal merge tools can be
applied safely on binary files and/or symlinks.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -989,6 +989,12 @@ def loadinternalmerge(ui, extname, regis
         internals['internal:' + name] = func
         internalsdoc[fullname] = func
 
+        capabilities = sorted([k for k, v in func.capabilities.items() if v])
+        if capabilities:
+            capdesc = _("(actual capabilities: %s)") % ', '.join(capabilities)
+            func.__doc__ = (func.__doc__ +
+                            pycompat.sysstr("\n\n    %s" % capdesc))
+
 # load built-in merge tools explicitly to setup internalsdoc
 loadinternalmerge(None, None, internaltool)
 
diff --git a/mercurial/help/merge-tools.txt b/mercurial/help/merge-tools.txt
--- a/mercurial/help/merge-tools.txt
+++ b/mercurial/help/merge-tools.txt
@@ -36,8 +36,9 @@ merge tools are:
 
 .. internaltoolsmarker
 
-Internal tools are always available and do not require a GUI but will by default
-not handle symlinks or binary files.
+Internal tools are always available and do not require a GUI but will
+by default not handle symlinks or binary files. See next section for
+detail about "actual capabilities" described above.
 
 Choosing a merge tool
 =====================
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1829,18 +1829,26 @@ Test dynamic list of merge tools only sh
         This implies premerge. Therefore, files aren't dumped, if premerge runs
         successfully. Use :forcedump to forcibly write files out.
   
+        (actual capabilities: binary, symlink)
+  
       ":fail"
         Rather than attempting to merge files that were modified on both
         branches, it marks them as unresolved. The resolve command must be used
         to resolve these conflicts.
   
+        (actual capabilities: binary, symlink)
+  
       ":forcedump"
         Creates three versions of the files as same as :dump, but omits
         premerge.
   
+        (actual capabilities: binary, symlink)
+  
       ":local"
         Uses the local 'p1()' version of files as the merged version.
   
+        (actual capabilities: binary, symlink)
+  
       ":merge"
         Uses the internal non-interactive simple merge algorithm for merging
         files. It will fail if there are any conflicts and leave markers in the
@@ -1864,10 +1872,14 @@ Test dynamic list of merge tools only sh
       ":other"
         Uses the other 'p2()' version of files as the merged version.
   
+        (actual capabilities: binary, symlink)
+  
       ":prompt"
         Asks the user which of the local 'p1()' or the other 'p2()' version to
         keep as the merged version.
   
+        (actual capabilities: binary, symlink)
+  
       ":tagmerge"
         Uses the internal tag merge algorithm (experimental).
   
@@ -1877,7 +1889,8 @@ Test dynamic list of merge tools only sh
         markers are inserted.
   
       Internal tools are always available and do not require a GUI but will by
-      default not handle symlinks or binary files.
+      default not handle symlinks or binary files. See next section for detail
+      about "actual capabilities" described above.
   
       Choosing a merge tool
       =====================


More information about the Mercurial-devel mailing list