Re: [PATCH 3 of 5] show: standarize abort output with help output

2017-04-13 Thread Ryan McElroy

On 4/12/17 4:29 PM, Yuya Nishihara wrote:

On Wed, 12 Apr 2017 12:35:22 +0100, Ryan McElroy wrote:

On 4/11/17 2:01 PM, Yuya Nishihara wrote:

On Mon, 10 Apr 2017 02:41:05 -0700, Ryan McElroy wrote:



show: standarize abort output with help output



 Available views:
 
-   bookmarks   bookmarks and their associated changeset

+  bookmarks -- bookmarks and their associated changeset

Perhaps the original version derives from "hg help", which seems more
standard.

So to be clear we're okay with the divergent output here? It bothers me
since both are sharing the same "source of truth" (the docblocks), but I
can get over it.

I prefer not having the divergent output, but the original output with no
dash seems more common.

Perhaps we wouldn't want to modify docstring by registrar. The comment says
"consider using formatter" so we'll need (name, doc) pair not "name doc"
string, something like this:


It looks like Greg just sent out some patches cleaning up the output a 
bit. I'll wait to see discussion on those before I proceed in any 
particular direction here.




@@ -36,8 +36,8 @@ command = cmdutil.command(cmdtable)
  class showcmdfunc(registrar._funcregistrarbase):
  """Register a function to be invoked for an `hg show `."""
  
-# Used by _formatdoc().

-_docformat = '%s -- %s'
+def _formatdoc(self, decl, doc):
+return doc
  
  def _extrasetup(self, name, func, fmtopic=None):

  """Called with decorator arguments to register a show view.
@@ -87,7 +87,8 @@ def show(ui, repo, view=None, template=N
  ui.write('\n')
  
  for name, func in sorted(views.items()):

-ui.write(('%s\n') % func.__doc__)
+# this will be fm.write() ?
+ui.write((' %s   %s\n') % (name, func.__doc__))
  
  ui.write('\n')

  raise error.Abort(_('no view requested'),


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 5] show: standarize abort output with help output

2017-04-12 Thread Gregory Szorc
On Mon, Apr 10, 2017 at 2:41 AM, Ryan McElroy  wrote:

> # HG changeset patch
> # User Ryan McElroy 
> # Date 1491585973 25200
> #  Fri Apr 07 10:26:13 2017 -0700
> # Node ID ee1bd54bfda1dd1aea0f9b2397ddeae42d58c54a
> # Parent  9397e5834ce19a95fbc6a6bb1cf099ec3c00f8f3
> show: standarize abort output with help output
>

I just saw this patch and realized I just sent another patch that
conflicts. Sorry about that.

I didn't give much thought to the formatting of help output for `hg show`
when I implemented it. I wanted to focus on more pressing matters (like
getting *something* landed). The block at the bottom of show.py adjusting
__doc__ in cmdtable is super hacky. And I support any improvement to it.


>
> diff --git a/hgext/show.py b/hgext/show.py
> --- a/hgext/show.py
> +++ b/hgext/show.py
> @@ -131,5 +131,5 @@ def showbookmarks(ui, repo, fm):
>  # TODO make this more robust.
>  longest = max(map(len, showview._table.keys()))
>  for key in sorted(showview._table.keys()):
> -cmdtable['show'][0].__doc__ += ' %s   %s\n' % (
> +cmdtable['show'][0].__doc__ += (showview._docformat + '\n') % (
>  key.ljust(longest), showview._table[key]._origdoc)
> diff --git a/tests/test-show.t b/tests/test-show.t
> --- a/tests/test-show.t
> +++ b/tests/test-show.t
> @@ -37,7 +37,7 @@ No arguments shows available views
>
>Available views:
>
> -   bookmarks   bookmarks and their associated changeset
> +  bookmarks -- bookmarks and their associated changeset
>
>(use 'hg help -e show' to show help for the show extension)
>
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 5] show: standarize abort output with help output

2017-04-12 Thread Yuya Nishihara
On Wed, 12 Apr 2017 12:35:22 +0100, Ryan McElroy wrote:
> On 4/11/17 2:01 PM, Yuya Nishihara wrote:
> > On Mon, 10 Apr 2017 02:41:05 -0700, Ryan McElroy wrote:
> >> # HG changeset patch
> >> # User Ryan McElroy 
> >> # Date 1491585973 25200
> >> #  Fri Apr 07 10:26:13 2017 -0700
> >> # Node ID ee1bd54bfda1dd1aea0f9b2397ddeae42d58c54a
> >> # Parent  9397e5834ce19a95fbc6a6bb1cf099ec3c00f8f3
> >> show: standarize abort output with help output
> >>
> >> diff --git a/hgext/show.py b/hgext/show.py
> >> --- a/hgext/show.py
> >> +++ b/hgext/show.py
> >> @@ -131,5 +131,5 @@ def showbookmarks(ui, repo, fm):
> >>   # TODO make this more robust.
> >>   longest = max(map(len, showview._table.keys()))
> >>   for key in sorted(showview._table.keys()):
> >> -cmdtable['show'][0].__doc__ += ' %s   %s\n' % (
> >> +cmdtable['show'][0].__doc__ += (showview._docformat + '\n') % (
> >>   key.ljust(longest), showview._table[key]._origdoc)
> >> diff --git a/tests/test-show.t b/tests/test-show.t
> >> --- a/tests/test-show.t
> >> +++ b/tests/test-show.t
> >> @@ -37,7 +37,7 @@ No arguments shows available views
> >> 
> >> Available views:
> >> 
> >> -   bookmarks   bookmarks and their associated changeset
> >> +  bookmarks -- bookmarks and their associated changeset
> > Perhaps the original version derives from "hg help", which seems more
> > standard.
> 
> So to be clear we're okay with the divergent output here? It bothers me 
> since both are sharing the same "source of truth" (the docblocks), but I 
> can get over it.

I prefer not having the divergent output, but the original output with no
dash seems more common.

Perhaps we wouldn't want to modify docstring by registrar. The comment says
"consider using formatter" so we'll need (name, doc) pair not "name doc"
string, something like this:

@@ -36,8 +36,8 @@ command = cmdutil.command(cmdtable)
 class showcmdfunc(registrar._funcregistrarbase):
 """Register a function to be invoked for an `hg show `."""
 
-# Used by _formatdoc().
-_docformat = '%s -- %s'
+def _formatdoc(self, decl, doc):
+return doc
 
 def _extrasetup(self, name, func, fmtopic=None):
 """Called with decorator arguments to register a show view.
@@ -87,7 +87,8 @@ def show(ui, repo, view=None, template=N
 ui.write('\n')
 
 for name, func in sorted(views.items()):
-ui.write(('%s\n') % func.__doc__)
+# this will be fm.write() ?
+ui.write((' %s   %s\n') % (name, func.__doc__))
 
 ui.write('\n')
 raise error.Abort(_('no view requested'),
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 5] show: standarize abort output with help output

2017-04-12 Thread Ryan McElroy

On 4/11/17 2:01 PM, Yuya Nishihara wrote:

On Mon, 10 Apr 2017 02:41:05 -0700, Ryan McElroy wrote:

# HG changeset patch
# User Ryan McElroy 
# Date 1491585973 25200
#  Fri Apr 07 10:26:13 2017 -0700
# Node ID ee1bd54bfda1dd1aea0f9b2397ddeae42d58c54a
# Parent  9397e5834ce19a95fbc6a6bb1cf099ec3c00f8f3
show: standarize abort output with help output

diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -131,5 +131,5 @@ def showbookmarks(ui, repo, fm):
  # TODO make this more robust.
  longest = max(map(len, showview._table.keys()))
  for key in sorted(showview._table.keys()):
-cmdtable['show'][0].__doc__ += ' %s   %s\n' % (
+cmdtable['show'][0].__doc__ += (showview._docformat + '\n') % (
  key.ljust(longest), showview._table[key]._origdoc)
diff --git a/tests/test-show.t b/tests/test-show.t
--- a/tests/test-show.t
+++ b/tests/test-show.t
@@ -37,7 +37,7 @@ No arguments shows available views

Available views:

-   bookmarks   bookmarks and their associated changeset

+  bookmarks -- bookmarks and their associated changeset

Perhaps the original version derives from "hg help", which seems more
standard.



So to be clear we're okay with the divergent output here? It bothers me 
since both are sharing the same "source of truth" (the docblocks), but I 
can get over it.

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 5] show: standarize abort output with help output

2017-04-11 Thread Yuya Nishihara
On Mon, 10 Apr 2017 02:41:05 -0700, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy 
> # Date 1491585973 25200
> #  Fri Apr 07 10:26:13 2017 -0700
> # Node ID ee1bd54bfda1dd1aea0f9b2397ddeae42d58c54a
> # Parent  9397e5834ce19a95fbc6a6bb1cf099ec3c00f8f3
> show: standarize abort output with help output
> 
> diff --git a/hgext/show.py b/hgext/show.py
> --- a/hgext/show.py
> +++ b/hgext/show.py
> @@ -131,5 +131,5 @@ def showbookmarks(ui, repo, fm):
>  # TODO make this more robust.
>  longest = max(map(len, showview._table.keys()))
>  for key in sorted(showview._table.keys()):
> -cmdtable['show'][0].__doc__ += ' %s   %s\n' % (
> +cmdtable['show'][0].__doc__ += (showview._docformat + '\n') % (
>  key.ljust(longest), showview._table[key]._origdoc)
> diff --git a/tests/test-show.t b/tests/test-show.t
> --- a/tests/test-show.t
> +++ b/tests/test-show.t
> @@ -37,7 +37,7 @@ No arguments shows available views
>
>Available views:
>
> -   bookmarks   bookmarks and their associated changeset
> +  bookmarks -- bookmarks and their associated changeset

Perhaps the original version derives from "hg help", which seems more
standard.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel