Patchwork version: show enabled extensions (issue4209)

login
register
mail settings
Submitter anatoly techtonik
Date June 10, 2014, 10:49 a.m.
Message ID <bd3150aeb5949c8ca230.1402397350@BlackBox>
Download mbox | patch
Permalink /patch/4961/
State Superseded
Headers show

Comments

anatoly techtonik - June 10, 2014, 10:49 a.m.
# HG changeset patch
# User anatoly techtonik <techtonik@gmail.com>
# Date 1402397077 -10800
#      Tue Jun 10 13:44:37 2014 +0300
# Branch stable
# Node ID bd3150aeb5949c8ca2304bf52c6206730b73a8f9
# Parent  14560418856dbd2b1b5d0bf1b4ae3bceffc4eef0
version: show enabled extensions (issue4209)

Inspired by:
http://mercurial.selenic.com/wiki/VersionsExtension
Greg Ward - June 10, 2014, 1:35 p.m.
On 10 June 2014, anatoly techtonik said:
> # HG changeset patch
> # User anatoly techtonik <techtonik@gmail.com>
> # Date 1402397077 -10800
> #      Tue Jun 10 13:44:37 2014 +0300
> # Branch stable
> # Node ID bd3150aeb5949c8ca2304bf52c6206730b73a8f9
> # Parent  14560418856dbd2b1b5d0bf1b4ae3bceffc4eef0
> version: show enabled extensions (issue4209)

Nice idea!

> Inspired by:
> http://mercurial.selenic.com/wiki/VersionsExtension
> 
> diff -r 14560418856d -r bd3150aeb594 mercurial/commands.py
> --- a/mercurial/commands.py	Mon May 26 19:02:11 2014 +0200
> +++ b/mercurial/commands.py	Tue Jun 10 13:44:37 2014 +0300
> @@ -5911,8 +5911,11 @@
>  @command('version', [])
>  def version_(ui):
>      """output version and copyright information"""
> +    # output always

Unnecessary comment. If a reader does not know what ui.write() does,
he should read the docstring.

>      ui.write(_("Mercurial Distributed SCM (version %s)\n")
>               % util.version())
> +
> +    # output when --quiet it not present

Ditto.

>      ui.status(_(
>          "(see http://mercurial.selenic.com for more information)\n"
>          "\nCopyright (C) 2005-2014 Matt Mackall and others\n"
> @@ -5921,6 +5924,16 @@
>          "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
>      ))
>  
> +    # output when --verbose flag is active

Ditto.

> +    # This code is inspired by hg-versions extension (GPLv2)
> +    # by Markus Zapke-Gruendemann <info@keimlink.de>
> +    ui.note(_("\nEnabled extensions:\n\n"))
> +    if ui.verbose:
> +        for name, module in ui.configitems('extensions'):
> +            ui.write("  %s\n" % name)

I believe this shows *configured* extensions, whether or not they
loaded successfully. Probably better to use
mercurial.extensions.enabled() to get the extensions that were
*successfully* enabled.

(Mercurial prints a pretty loud warning when it fails to enable an
extension that you have configured, so I don't think there's any need
to give more info about such failures.)

       Greg

Patch

diff -r 14560418856d -r bd3150aeb594 mercurial/commands.py
--- a/mercurial/commands.py	Mon May 26 19:02:11 2014 +0200
+++ b/mercurial/commands.py	Tue Jun 10 13:44:37 2014 +0300
@@ -5911,8 +5911,11 @@ 
 @command('version', [])
 def version_(ui):
     """output version and copyright information"""
+    # output always
     ui.write(_("Mercurial Distributed SCM (version %s)\n")
              % util.version())
+
+    # output when --quiet it not present
     ui.status(_(
         "(see http://mercurial.selenic.com for more information)\n"
         "\nCopyright (C) 2005-2014 Matt Mackall and others\n"
@@ -5921,6 +5924,16 @@ 
         "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
     ))
 
+    # output when --verbose flag is active
+
+    # This code is inspired by hg-versions extension (GPLv2)
+    # by Markus Zapke-Gruendemann <info@keimlink.de>
+    ui.note(_("\nEnabled extensions:\n\n"))
+    if ui.verbose:
+        for name, module in ui.configitems('extensions'):
+            ui.write("  %s\n" % name)
+
+
 norepo = ("clone init version help debugcommands debugcomplete"
           " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
           " debugknown debuggetbundle debugbundle")