[Pkg-bazaar-commits] ./bzr-gtk/unstable r137: Warn about incompatible versions (taken from bzrtools, thanks Aaron).

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:45:52 UTC 2009


------------------------------------------------------------
revno: 137
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2007-01-30 18:26:34 +0100
message:
  Warn about incompatible versions (taken from bzrtools, thanks Aaron).
  
  Update version to 0.14.
modified:
  __init__.py
  setup.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-01-29 23:53:29 +0000
+++ b/__init__.py	2007-01-30 17:26:34 +0000
@@ -14,6 +14,44 @@
 
 """GTK+ frontends to Bazaar commands """
 
+import bzrlib
+
+__version__ = '0.14.0'
+version_info = tuple(int(n) for n in __version__.split('.'))
+
+
+def check_bzrlib_version(desired):
+    """Check that bzrlib is compatible.
+
+    If version is < bzr-gtk version, assume incompatible.
+    If version == bzr-gtk version, assume completely compatible
+    If version == bzr-gtk version + 1, assume compatible, with deprecations
+    Otherwise, assume incompatible.
+    """
+    desired_plus = (desired[0], desired[1]+1)
+    bzrlib_version = bzrlib.version_info[:2]
+    if bzrlib_version == desired:
+        return
+    try:
+        from bzrlib.trace import warning
+    except ImportError:
+        # get the message out any way we can
+        from warnings import warn as warning
+    if bzrlib_version < desired:
+        warning('Installed bzr version %s is too old to be used with bzr-gtk'
+                ' %s.' % (bzrlib.__version__, __version__))
+        # Not using BzrNewError, because it may not exist.
+        raise Exception, ('Version mismatch', version_info)
+    else:
+        warning('bzr-gtk is not up to date with installed bzr version %s.'
+                ' \nThere should be a newer version available, e.g. %i.%i.' 
+                % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
+        if bzrlib_version != desired_plus:
+            raise Exception, 'Version mismatch'
+
+
+check_bzrlib_version(version_info[:2])
+
 from bzrlib import errors
 from bzrlib.commands import Command, register_command, display_command
 from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
@@ -25,9 +63,6 @@
 
 import os.path
 
-__version__ = '0.13.0'
-
-
 def import_pygtk():
     try:
         import pygtk

=== modified file 'setup.py'
--- a/setup.py	2006-12-13 13:20:25 +0000
+++ b/setup.py	2007-01-30 17:26:34 +0000
@@ -49,7 +49,7 @@
 
 setup(
     name = "bzr-gtk",
-    version = "0.13.0",
+    version = "0.14.0",
     maintainer = "Jelmer Vernooij",
     maintainer_email = "jelmer at samba.org",
     description = "GTK+ Frontends for various Bazaar commands",



More information about the Pkg-bazaar-commits mailing list