hg-stable$ hg log --patch mercurial/util.py
...
changeset: 7640:
9626819b2e3d
user: Matt Mackall <mpm@selenic.com>
date: Sat Jan 10 18:02:38 2009 -0600
summary: refactor version code
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -142,6 +142,14 @@
"""Find the length in characters of a local string"""
return len(s.decode(_encoding, "replace"))
+def version():
+ """Return version information if available."""
+ try:
+ import __version__
+ return __version__.version
+ except ImportError:
+ return 'unknown'
+
# used by parsedate
...
hg-stable$ hg tags
...
1.2 7823:
11efa41037e2
1.1.2 7497:
11a4eb81fb4f
...
try:
import mercurial
- import mercurial.version
import mercurial.dispatch
import mercurial.ui
except ImportError:
mercurial = None
+
+try:
+ # mercurial >= 1.2
+ from mercurial.util import version
+except ImportError:
+ try:
+ # mercurial <= 1.1.2
+ from mercurial.version import version
+ except ImportError:
+ version = None
+
import os
import os.path
import re
self.__updated = [] # work around http://mercurial.selenic.com/bts/issue618
def _vcs_version(self):
- if mercurial == None:
+ if version == None:
return None
- return mercurial.version.get_version()
+ return version()
def _u_invoke_client(self, *args, **kwargs):
if 'cwd' not in kwargs: