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

login
register
mail settings
Submitter anatoly techtonik
Date June 13, 2014, 9:21 p.m.
Message ID <c490acacbf9869e1c8e9.1402694491@BlackBox>
Download mbox | patch
Permalink /patch/5000/
State Superseded
Commit 48e26de917f3eec886e83b95fbf400f219e9ecfe
Headers show

Comments

anatoly techtonik - June 13, 2014, 9:21 p.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 c490acacbf9869e1c8e9ed5cb5d281c0643190ec
# Parent  14560418856dbd2b1b5d0bf1b4ae3bceffc4eef0
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
Siddharth Agarwal - June 14, 2014, 5:41 a.m.
On 06/13/2014 02:21 PM, anatoly techtonik 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 c490acacbf9869e1c8e9ed5cb5d281c0643190ec
> # Parent  14560418856dbd2b1b5d0bf1b4ae3bceffc4eef0
> version: show enabled extensions (issue4209)
>
> This code is based by hg-versions extension (GPLv2)
> by Markus Zapke-Gruendemann <info@keimlink.de>

Can we have some tests for this please? A basic one will do, just to 
make sure this doesn't break.

>
>
> http://mercurial.selenic.com/wiki/VersionsExtension
>
> diff -r 14560418856d -r c490acacbf98 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
> @@ -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 14560418856d -r c490acacbf98 mercurial/extensions.py
> --- a/mercurial/extensions.py	Mon May 26 19:02:11 2014 +0200
> +++ 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 - June 14, 2014, 7:13 a.m.
On Sat, Jun 14, 2014 at 8:41 AM, Siddharth Agarwal <sid@less-broken.com>
wrote:

> On 06/13/2014 02:21 PM, anatoly techtonik 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 c490acacbf9869e1c8e9ed5cb5d281c0643190ec
>> # Parent  14560418856dbd2b1b5d0bf1b4ae3bceffc4eef0
>> version: show enabled extensions (issue4209)
>>
>> This code is based by hg-versions extension (GPLv2)
>> by Markus Zapke-Gruendemann <info@keimlink.de>
>>
>
> Can we have some tests for this please? A basic one will do, just to make
> sure this doesn't break.
>

Sorry, there is no such thing as a basic mercurial test for me, and I am
afraid that don't have much time to setup test environment on my bloody
windoze.
Greg Ward - June 15, 2014, 1:29 a.m.
On 14 June 2014, anatoly techtonik said:
> Sorry, there is no such thing as a basic mercurial test for me, and I am
> afraid that don't have much time to setup test environment on my bloody
> windoze.

Did you try

  http://mercurial.selenic.com/wiki/HackableMercurial#Running_the_test_suite_under_MSYS

?

       Greg
anatoly techtonik - June 16, 2014, 7:04 a.m.
On Sun, Jun 15, 2014 at 4:29 AM, Greg Ward <greg@gerg.ca> wrote:

> On 14 June 2014, anatoly techtonik said:
> > Sorry, there is no such thing as a basic mercurial test for me, and I am
> > afraid that don't have much time to setup test environment on my bloody
> > windoze.
>
> Did you try
>
>
> http://mercurial.selenic.com/wiki/HackableMercurial#Running_the_test_suite_under_MSYS
>
> ?
>

No, sorry.  I am afraid this week my time spent on Mercurial is over.

Have you seen my v3 patch? I seem to send it, but didn't receive any
replies or confirmation from ML.
anatoly techtonik - June 16, 2014, 7:21 a.m.
On Mon, Jun 16, 2014 at 10:04 AM, anatoly techtonik <techtonik@gmail.com>
wrote:

> On Sun, Jun 15, 2014 at 4:29 AM, Greg Ward <greg@gerg.ca> wrote:
>
>> On 14 June 2014, anatoly techtonik said:
>> > Sorry, there is no such thing as a basic mercurial test for me, and I am
>> > afraid that don't have much time to setup test environment on my bloody
>> > windoze.
>>
>> Did you try
>>
>>
>> http://mercurial.selenic.com/wiki/HackableMercurial#Running_the_test_suite_under_MSYS
>>
>> ?
>>
>
> No, sorry.  I am afraid this week my time spent on Mercurial is over.
>
> Have you seen my v3 patch? I seem to send it, but didn't receive any
> replies or confirmation from ML.
>

Nevermind. It is GMail bug that linked v3 thread into v2.

Patch

diff -r 14560418856d -r c490acacbf98 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
@@ -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 14560418856d -r c490acacbf98 mercurial/extensions.py
--- a/mercurial/extensions.py	Mon May 26 19:02:11 2014 +0200
+++ 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