Check version of bzr-rebase before using it.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 19 Oct 2007 11:50:16 +0000 (13:50 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 19 Oct 2007 11:50:16 +0000 (13:50 +0200)
NEWS
upgrade.py

diff --git a/NEWS b/NEWS
index 3093fe7b565161f0bdd3e34d18924b3e44fdd97f..8cbb5b4fba39ce188cad1275a1afe65b5c79ce36 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,8 @@ bzr-svn 0.4.4 UNRELEASED
 
    * Use revprop lists rather than just commit message when committing.
 
+   * The version of bzr-rebase is now checked before it's being used.
+
   BUG FIXES
 
    * Fix compatibility with 0.92.
index 44530dca4f63654e3ba1485379ca516096aafad1..faac2fe527860f728666018bfa879cae12fd6da0 100644 (file)
@@ -135,6 +135,17 @@ def generate_upgrade_map(revs):
 
     return rename_map
 
+MIN_REBASE_VERSION = (0, 2)
+
+def check_rebase_version():
+    try:
+        from bzrlib.plugins.rebase import version_info as rebase_version_info
+        if rebase_version_info[:2] < MIN_REBASE_VERSION:
+            raise RebaseNotPresent("Version %r present, at least %r required" 
+                                   % (rebase_version_info, MIN_REBASE_VERSION))
+    except ImportError, e:
+        raise RebaseNotPresent(e)
+
 
 def create_upgrade_plan(repository, svn_repository, revision_id=None,
                         allow_changes=False):
@@ -148,10 +159,8 @@ def create_upgrade_plan(repository, svn_repository, revision_id=None,
         of revisions.
     :return: Tuple with a rebase plan and map of renamed revisions.
     """
-    try:
-        from bzrlib.plugins.rebase.rebase import generate_transpose_plan
-    except ImportError, e:
-        raise RebaseNotPresent(e)
+    from bzrlib.plugins.rebase.rebase import generate_transpose_plan
+    check_rebase_version()
 
     graph = repository.get_revision_graph(revision_id)
     upgrade_map = generate_upgrade_map(graph.keys())
@@ -189,11 +198,9 @@ def upgrade_repository(repository, svn_repository, revision_id=None,
     :param verbose: Whether to print list of rewrites
     :return: Dictionary of mapped revisions
     """
-    try:
-        from bzrlib.plugins.rebase.rebase import (
-            replay_snapshot, rebase, rebase_todo)
-    except ImportError, e:
-        raise RebaseNotPresent(e)
+    check_rebase_version()
+    from bzrlib.plugins.rebase.rebase import (
+        replay_snapshot, rebase, rebase_todo)
 
     # Find revisions that need to be upgraded, create
     # dictionary with revision ids in key, new parents in value