From d91aae83516d0326a0c4d19153f18d675674cc4c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 20 Jan 2010 09:27:16 -0500 Subject: [PATCH] Adjust to modern mercurial version definition. hg-stable$ hg log --patch mercurial/util.py ... changeset: 7640:9626819b2e3d user: Matt Mackall 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 ... --- libbe/storage/vcs/hg.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py index 076943a..4993233 100644 --- a/libbe/storage/vcs/hg.py +++ b/libbe/storage/vcs/hg.py @@ -23,11 +23,21 @@ Mercurial (hg) backend. 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 @@ -57,9 +67,9 @@ class Hg(base.VCS): 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: -- 2.26.2