Patchwork help.merge-tools: do not double document merge tools

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 10, 2015, 8:13 a.m.
Message ID <4546a7e61c56a89e2083.1423556006@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/7772/
State Accepted
Commit be83fd9d46d50cee78dac78706b4811118a5f164
Headers show

Comments

Gregory Szorc - Feb. 10, 2015, 8:13 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1423552059 28800
#      Mon Feb 09 23:07:39 2015 -0800
# Node ID 4546a7e61c56a89e20832fd9dba35f5a3a2bb019
# Parent  adea44d4aa1a829527a1b345716ee22dbdf5cfaf
help.merge-tools: do not double document merge tools

Merge tools were being double documented in help system output due
to functions being defined under multiple names in the merge tools
dictionary.

Establish a new dictionary for just the tools to document and
use it from the help system so we don't get double output.

Double documentation likely plagues other auto-documented items
as well. It might be a good idea to eventually compare function
instances to filter out duplicate entries from dictionaries
passed to ``makeitemsdoc``. However, without an easy way to break
ties, this may result in some functions being advertised over
their modern equivalents. This would be a noble patch series.
But it isn't one this author is willing to tackle at this time.
Yuya Nishihara - Feb. 10, 2015, 2:45 p.m.
On Tue, 10 Feb 2015 00:13:26 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1423552059 28800
> #      Mon Feb 09 23:07:39 2015 -0800
> # Node ID 4546a7e61c56a89e20832fd9dba35f5a3a2bb019
> # Parent  adea44d4aa1a829527a1b345716ee22dbdf5cfaf
> help.merge-tools: do not double document merge tools
> 
> Merge tools were being double documented in help system output due
> to functions being defined under multiple names in the merge tools
> dictionary.
> 
> Establish a new dictionary for just the tools to document and
> use it from the help system so we don't get double output.
> 
> Double documentation likely plagues other auto-documented items
> as well. It might be a good idea to eventually compare function
> instances to filter out duplicate entries from dictionaries
> passed to ``makeitemsdoc``. However, without an easy way to break
> ties, this may result in some functions being advertised over
> their modern equivalents. This would be a noble patch series.
> But it isn't one this author is willing to tackle at this time.
> 
> diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
> --- a/mercurial/filemerge.py
> +++ b/mercurial/filemerge.py
> @@ -20,16 +20,19 @@ def _toolbool(ui, tool, part, default=Fa
>  def _toollist(ui, tool, part, default=[]):
>      return ui.configlist("merge-tools", tool + "." + part, default)
>  
>  internals = {}
> +# Merge tools to document.
> +internalsdoc = {}
>  
>  def internaltool(name, trymerge, onfailure=None):
>      '''return a decorator for populating internal merge tool table'''
>      def decorator(func):
>          fullname = ':' + name
>          func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip()
>          internals[fullname] = func
>          internals['internal:' + name] = func
> +        internalsdoc[fullname] = func
>          func.trymerge = trymerge
>          func.onfailure = onfailure
>          return func
>      return decorator

i18nfunctions are also doubled though it seems duplicates are removed by
xgettext.
Augie Fackler - Feb. 10, 2015, 3:56 p.m.
On Tue, Feb 10, 2015 at 12:13:26AM -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1423552059 28800
> #      Mon Feb 09 23:07:39 2015 -0800
> # Node ID 4546a7e61c56a89e20832fd9dba35f5a3a2bb019
> # Parent  adea44d4aa1a829527a1b345716ee22dbdf5cfaf
> help.merge-tools: do not double document merge tools

queued, and I'm adding a test. In the future, it'd probably be good to
add tests for stuff like this so we know the output is stable in the
future.

>
> Merge tools were being double documented in help system output due
> to functions being defined under multiple names in the merge tools
> dictionary.
>
> Establish a new dictionary for just the tools to document and
> use it from the help system so we don't get double output.
>
> Double documentation likely plagues other auto-documented items
> as well. It might be a good idea to eventually compare function
> instances to filter out duplicate entries from dictionaries
> passed to ``makeitemsdoc``. However, without an easy way to break
> ties, this may result in some functions being advertised over
> their modern equivalents. This would be a noble patch series.
> But it isn't one this author is willing to tackle at this time.
>
> diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
> --- a/mercurial/filemerge.py
> +++ b/mercurial/filemerge.py
> @@ -20,16 +20,19 @@ def _toolbool(ui, tool, part, default=Fa
>  def _toollist(ui, tool, part, default=[]):
>      return ui.configlist("merge-tools", tool + "." + part, default)
>
>  internals = {}
> +# Merge tools to document.
> +internalsdoc = {}
>
>  def internaltool(name, trymerge, onfailure=None):
>      '''return a decorator for populating internal merge tool table'''
>      def decorator(func):
>          fullname = ':' + name
>          func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip()
>          internals[fullname] = func
>          internals['internal:' + name] = func
> +        internalsdoc[fullname] = func
>          func.trymerge = trymerge
>          func.onfailure = onfailure
>          return func
>      return decorator
> diff --git a/mercurial/help.py b/mercurial/help.py
> --- a/mercurial/help.py
> +++ b/mercurial/help.py
> @@ -203,9 +203,10 @@ def addtopicsymbols(topic, marker, symbo
>          return makeitemsdoc(topic, doc, marker, symbols, dedent=dedent)
>      addtopichook(topic, add)
>
>  addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
> -addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
> +addtopicsymbols('merge-tools', '.. internaltoolsmarker',
> +                filemerge.internalsdoc)
>  addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
>  addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords)
>  addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
>  addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -20,16 +20,19 @@  def _toolbool(ui, tool, part, default=Fa
 def _toollist(ui, tool, part, default=[]):
     return ui.configlist("merge-tools", tool + "." + part, default)
 
 internals = {}
+# Merge tools to document.
+internalsdoc = {}
 
 def internaltool(name, trymerge, onfailure=None):
     '''return a decorator for populating internal merge tool table'''
     def decorator(func):
         fullname = ':' + name
         func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip()
         internals[fullname] = func
         internals['internal:' + name] = func
+        internalsdoc[fullname] = func
         func.trymerge = trymerge
         func.onfailure = onfailure
         return func
     return decorator
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -203,9 +203,10 @@  def addtopicsymbols(topic, marker, symbo
         return makeitemsdoc(topic, doc, marker, symbols, dedent=dedent)
     addtopichook(topic, add)
 
 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
-addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
+addtopicsymbols('merge-tools', '.. internaltoolsmarker',
+                filemerge.internalsdoc)
 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
 addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords)
 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,