diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6026,6 +6026,7 @@ def version_(ui): 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])) + if names: + maxnamelen = max(len(n) for n in names) + for i, name in enumerate(names): + ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i])) diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -748,6 +748,17 @@ Declare the version as supporting this h Test version number support in 'hg version': $ echo '__version__ = (1, 2, 3)' >> throw.py $ rm -f throw.pyc throw.pyo + $ hg version -v + Mercurial Distributed SCM (version *) (glob) + (see http://mercurial.selenic.com for more information) + + Copyright (C) 2005-* Matt Mackall and others (glob) + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Enabled extensions: + + $ hg version -v --config extensions.throw=throw.py Mercurial Distributed SCM (version *) (glob) (see http://mercurial.selenic.com for more information)