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
--- a/mercurial/commands.py Tue Jul 08 16:24:23 2014 -0700
+++ 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
@@ -6016,3 +6017,15 @@
"There is NO\nwarranty; "
"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]))
--- a/mercurial/extensions.py Tue Jul 08 16:24:23 2014 -0700
+++ 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, 'getversion')
+ and callable(module.getversion)):
+ version = module.getversion()
+ 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