suggested patch for version checking in bzrtools and gtk plugins

Elliot Murphy elliot at canonical.com
Wed Jun 6 16:01:34 BST 2007


Hi!

I quite agree with the version checking that is done in the gtk and bzrtools plugins. However, there is one case when I believe that the warnings are excessive: when I'm using the very latest bzrtools and gtk plugins, along with bzr.dev.

Here is a proposed patch which also checks for whether something is a "dev" version, and does not print the warning when you are running +1dev.  When looking at this it strikes me that perhaps bzrlib itself should offer a version checking function for plugins to use. Plugins of course would be free to provide their own, but it doesn't make sense to have this code duplicated in every plugin that wants to do version checking.

For gtk:
=== modified file '__init__.py'
--- __init__.py 2007-05-19 16:21:10 +0000
+++ __init__.py 2007-06-06 14:49:02 +0000
@@ -45,7 +45,13 @@
         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:
+        if bzrlib_version == desired_plus:
+            # allow people to run the next dev version without spewing warnings
+            if bzrlib.version_info[3] != "dev":
+                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]))
+        else:
             raise Exception, 'Version mismatch'


For bzrtools:
=== modified file '__init__.py'
--- __init__.py 2007-03-26 17:16:00 +0000
+++ __init__.py 2007-06-06 14:54:55 +0000
@@ -53,12 +53,15 @@
         # Not using BzrNewError, because it may not exist.
         raise Exception, ('Version mismatch', version_info)
     else:
-        warning('Plugin "Bzrtools" is not up to date with installed Bazaar'
-                ' version %s.\n'
-                ' There should be a newer version of Bzrtools available, e.g.'
-                ' %i.%i.'
-                % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
-        if bzrlib_version != desired_plus:
+        if bzrlib_version == desired_plus:
+            # allow people to run the next dev version without warning
+            if bzrlib.version_info[3] != "dev":
+                warning('Plugin "Bzrtools" is not up to date with installed Bazaar'
+                        ' version %s.\n'
+                        ' There should be a newer version of Bzrtools available, e.g.'
+                        ' %i.%i.'
+                        % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
+        else:
             raise Exception, 'Version mismatch'
 
-- 
Elliot Murphy | https://launchpad.net/~emurphy/



More information about the bazaar mailing list