Patchwork [v4] version: show enabled extensions (issue4209)

login
register
mail settings
Submitter anatoly techtonik
Date July 4, 2014, 8:02 a.m.
Message ID <867f0469a179167b2eeb.1404460976@BlackBox>
Download mbox | patch
Permalink /patch/5098/
State Accepted
Commit 48e26de917f3eec886e83b95fbf400f219e9ecfe
Headers show

Comments

anatoly techtonik - July 4, 2014, 8:02 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 867f0469a179167b2eeb70337beafcf2ae9524d9
# Parent  2392b9e1936628faeec818368169a68b1fadd95f
version: show enabled extensions (issue4209)

This code is based by hg-versions extension (GPLv2)
by Markus Zapke-Gruendemann <info@keimlink.de>


http://mercurial.selenic.com/wiki/VersionsExtension
Augie Fackler - July 9, 2014, 2:35 a.m.
On Jul 4, 2014, at 4:02 AM, anatoly techtonik <techtonik@gmail.com> wrote:

> # HG changeset patch
> # User anatoly techtonik <techtonik@gmail.com>
> # Date 1402397077 -10800
> #      Tue Jun 10 13:44:37 2014 +0300
> # Branch stable
> # Node ID 867f0469a179167b2eeb70337beafcf2ae9524d9
> # Parent  2392b9e1936628faeec818368169a68b1fadd95f
> version: show enabled extensions (issue4209)

Queud! I'm satisfied enough with this that I'd like to see it land now - folks should feel encouraged to send follow-ups if needed.

Thanks for bearing with us!

> 
> This code is based by hg-versions extension (GPLv2)
> by Markus Zapke-Gruendemann <info@keimlink.de>
> 
> 
> http://mercurial.selenic.com/wiki/VersionsExtension
> 
> diff -r 2392b9e19366 -r 867f0469a179 mercurial/commands.py
> --- a/mercurial/commands.py	Tue Jul 01 23:32:18 2014 -0500
> +++ b/mercurial/commands.py	Tue Jun 10 13:44:37 2014 +0300
> @@ -14,6 +14,7 @@
> import patch, help, encoding, templatekw, discovery
> import archival, changegroup, cmdutil, hbisect
> import sshserver, hgweb, commandserver
> +import extensions
> from hgweb import server as hgweb_server
> import merge as mergemod
> import minirst, revset, fileset
> @@ -5921,6 +5922,19 @@
>         "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
>     ))
> 
> +    ui.note(_("\nEnabled extensions:\n\n"))
> +    if ui.verbose:
> +        # format names and versions into columns
> +        names = []
> +        vers = []
> +        for name, module in extensions.extensions():
> +            names.append(name)
> +            vers.append(extensions.moduleversion(module))
> +        maxnamelen = max(len(n) for n in names)
> +        for i, name in enumerate(names):
> +            ui.write("  %-*s  %s\n" % (maxnamelen, name, vers[i]))
> +
> +
> norepo = ("clone init version help debugcommands debugcomplete"
>           " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
>           " debugknown debuggetbundle debugbundle")
> diff -r 2392b9e19366 -r 867f0469a179 mercurial/extensions.py
> --- a/mercurial/extensions.py	Tue Jul 01 23:32:18 2014 -0500
> +++ b/mercurial/extensions.py	Tue Jun 10 13:44:37 2014 +0300
> @@ -367,3 +367,16 @@
>         exts[ename] = doc.splitlines()[0].strip()
> 
>     return exts
> +
> +def moduleversion(module):
> +    '''return version information from given module as a string'''
> +    if (util.safehasattr(module, 'get_version')
> +          and callable(module.get_version)):
> +        version = module.get_version()
> +    elif util.safehasattr(module, '__version__'):
> +        version = module.__version__
> +    else:
> +        version = ''
> +    if isinstance(version, (list, tuple)):
> +        version = '.'.join(str(o) for o in version)
> +    return version
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Augie Fackler - July 9, 2014, 3:03 a.m.
On Jul 8, 2014, at 10:35 PM, Augie Fackler <raf@durin42.com> wrote:

> 
> On Jul 4, 2014, at 4:02 AM, anatoly techtonik <techtonik@gmail.com> wrote:
> 
>> # HG changeset patch
>> # User anatoly techtonik <techtonik@gmail.com>
>> # Date 1402397077 -10800
>> #      Tue Jun 10 13:44:37 2014 +0300
>> # Branch stable
>> # Node ID 867f0469a179167b2eeb70337beafcf2ae9524d9
>> # Parent  2392b9e1936628faeec818368169a68b1fadd95f
>> version: show enabled extensions (issue4209)
> 
> Queud! I'm satisfied enough with this that I'd like to see it land now - folks should feel encouraged to send follow-ups if needed.
> 
> Thanks for bearing with us!

I neglected to mention one change I decided to make for consistency with the rest of hg: s/get_version/getversion/, but other than that I'm pushing the patch as-is.

> 
>> 
>> This code is based by hg-versions extension (GPLv2)
>> by Markus Zapke-Gruendemann <info@keimlink.de>
>> 
>> 
>> http://mercurial.selenic.com/wiki/VersionsExtension
>> 
>> diff -r 2392b9e19366 -r 867f0469a179 mercurial/commands.py
>> --- a/mercurial/commands.py	Tue Jul 01 23:32:18 2014 -0500
>> +++ b/mercurial/commands.py	Tue Jun 10 13:44:37 2014 +0300
>> @@ -14,6 +14,7 @@
>> import patch, help, encoding, templatekw, discovery
>> import archival, changegroup, cmdutil, hbisect
>> import sshserver, hgweb, commandserver
>> +import extensions
>> from hgweb import server as hgweb_server
>> import merge as mergemod
>> import minirst, revset, fileset
>> @@ -5921,6 +5922,19 @@
>>        "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
>>    ))
>> 
>> +    ui.note(_("\nEnabled extensions:\n\n"))
>> +    if ui.verbose:
>> +        # format names and versions into columns
>> +        names = []
>> +        vers = []
>> +        for name, module in extensions.extensions():
>> +            names.append(name)
>> +            vers.append(extensions.moduleversion(module))
>> +        maxnamelen = max(len(n) for n in names)
>> +        for i, name in enumerate(names):
>> +            ui.write("  %-*s  %s\n" % (maxnamelen, name, vers[i]))
>> +
>> +
>> norepo = ("clone init version help debugcommands debugcomplete"
>>          " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
>>          " debugknown debuggetbundle debugbundle")
>> diff -r 2392b9e19366 -r 867f0469a179 mercurial/extensions.py
>> --- a/mercurial/extensions.py	Tue Jul 01 23:32:18 2014 -0500
>> +++ b/mercurial/extensions.py	Tue Jun 10 13:44:37 2014 +0300
>> @@ -367,3 +367,16 @@
>>        exts[ename] = doc.splitlines()[0].strip()
>> 
>>    return exts
>> +
>> +def moduleversion(module):
>> +    '''return version information from given module as a string'''
>> +    if (util.safehasattr(module, 'get_version')
>> +          and callable(module.get_version)):
>> +        version = module.get_version()
>> +    elif util.safehasattr(module, '__version__'):
>> +        version = module.__version__
>> +    else:
>> +        version = ''
>> +    if isinstance(version, (list, tuple)):
>> +        version = '.'.join(str(o) for o in version)
>> +    return version
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
anatoly techtonik - July 9, 2014, 6:39 a.m.
On Wed, Jul 9, 2014 at 5:35 AM, Augie Fackler <raf@durin42.com> wrote:
> On Jul 4, 2014, at 4:02 AM, anatoly techtonik <techtonik@gmail.com> wrote:
>
>> # HG changeset patch
>> # User anatoly techtonik <techtonik@gmail.com>
>> # Date 1402397077 -10800
>> #      Tue Jun 10 13:44:37 2014 +0300
>> # Branch stable
>> # Node ID 867f0469a179167b2eeb70337beafcf2ae9524d9
>> # Parent  2392b9e1936628faeec818368169a68b1fadd95f
>> version: show enabled extensions (issue4209)
>
> Queud! I'm satisfied enough with this that I'd like to see it land now - folks should feel encouraged to send follow-ups if needed.

Nice. =)

> Thanks for bearing with us!

I understand a lot about review process from both sides, so it was not
hard to follow
the rules. It was not super easy though. From user experience point of view the
process could be improved, so if you're interested I can share my thoughts.

Patch

diff -r 2392b9e19366 -r 867f0469a179 mercurial/commands.py
--- a/mercurial/commands.py	Tue Jul 01 23:32:18 2014 -0500
+++ b/mercurial/commands.py	Tue Jun 10 13:44:37 2014 +0300
@@ -14,6 +14,7 @@ 
 import patch, help, encoding, templatekw, discovery
 import archival, changegroup, cmdutil, hbisect
 import sshserver, hgweb, commandserver
+import extensions
 from hgweb import server as hgweb_server
 import merge as mergemod
 import minirst, revset, fileset
@@ -5921,6 +5922,19 @@ 
         "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
     ))
 
+    ui.note(_("\nEnabled extensions:\n\n"))
+    if ui.verbose:
+        # format names and versions into columns
+        names = []
+        vers = []
+        for name, module in extensions.extensions():
+            names.append(name)
+            vers.append(extensions.moduleversion(module))
+        maxnamelen = max(len(n) for n in names)
+        for i, name in enumerate(names):
+            ui.write("  %-*s  %s\n" % (maxnamelen, name, vers[i]))
+
+
 norepo = ("clone init version help debugcommands debugcomplete"
           " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
           " debugknown debuggetbundle debugbundle")
diff -r 2392b9e19366 -r 867f0469a179 mercurial/extensions.py
--- a/mercurial/extensions.py	Tue Jul 01 23:32:18 2014 -0500
+++ b/mercurial/extensions.py	Tue Jun 10 13:44:37 2014 +0300
@@ -367,3 +367,16 @@ 
         exts[ename] = doc.splitlines()[0].strip()
 
     return exts
+
+def moduleversion(module):
+    '''return version information from given module as a string'''
+    if (util.safehasattr(module, 'get_version')
+          and callable(module.get_version)):
+        version = module.get_version()
+    elif util.safehasattr(module, '__version__'):
+        version = module.__version__
+    else:
+        version = ''
+    if isinstance(version, (list, tuple)):
+        version = '.'.join(str(o) for o in version)
+    return version