Rev 4642: (robertc) Handle IncompatibleRepositories better with bzr:// connections. (Robert Collins) in http://bazaar.launchpad.net/~lifeless/bzr/2.0

Robert Collins robertc at robertcollins.net
Thu Aug 27 06:22:19 BST 2009


At http://bazaar.launchpad.net/~lifeless/bzr/2.0

------------------------------------------------------------
revno: 4642
revision-id: robertc at robertcollins.net-20090827052214-k3wgb0cqupehghnr
parent: pqm at pqm.ubuntu.com-20090826181204-7tnwrg25c2zi1x51
committer: Robert Collins <robertc at robertcollins.net>
branch nick: 2.0
timestamp: Thu 2009-08-27 15:22:14 +1000
message:
  (robertc) Handle IncompatibleRepositories better with bzr:// connections. (Robert Collins)
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2009-08-21 05:48:59 +0000
+++ b/bzrlib/errors.py	2009-08-27 05:22:14 +0000
@@ -793,6 +793,12 @@
 
 
 class IncompatibleRepositories(BzrError):
+    """Report an error that two repositories are not compatible.
+
+    Note that the source and target repositories are permitted to be strings:
+    this exception is thrown from the smart server and may refer to a
+    repository the client hasn't opened.
+    """
 
     _fmt = "%(target)s\n" \
             "is not compatible with\n" \

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2009-08-17 03:51:44 +0000
+++ b/bzrlib/remote.py	2009-08-27 05:22:14 +0000
@@ -2759,7 +2759,10 @@
                     'Missing key %r in context %r', key_err.args[0], context)
                 raise err
 
-    if err.error_verb == 'NoSuchRevision':
+    if err.error_verb == 'IncompatibleRepositories':
+        raise errors.IncompatibleRepositories(err.error_args[0],
+            err.error_args[1], err.error_args[2])
+    elif err.error_verb == 'NoSuchRevision':
         raise NoSuchRevision(find('branch'), err.error_args[0])
     elif err.error_verb == 'nosuchrevision':
         raise NoSuchRevision(find('repository'), err.error_args[0])

=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py	2009-08-14 00:55:42 +0000
+++ b/bzrlib/smart/request.py	2009-08-27 05:22:14 +0000
@@ -364,6 +364,9 @@
         return ('FileExists', err.path)
     elif isinstance(err, errors.DirectoryNotEmpty):
         return ('DirectoryNotEmpty', err.path)
+    elif isinstance(err, errors.IncompatibleRepositories):
+        return ('IncompatibleRepositories', str(err.source), str(err.target),
+            str(err.details))
     elif isinstance(err, errors.ShortReadvError):
         return ('ShortReadvError', err.path, str(err.offset), str(err.length),
                 str(err.actual))

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2009-08-17 21:24:24 +0000
+++ b/bzrlib/tests/test_remote.py	2009-08-27 05:22:14 +0000
@@ -2668,6 +2668,13 @@
         expected_error = errors.ReadError(path)
         self.assertEqual(expected_error, translated_error)
 
+    def test_IncompatibleRepositories(self):
+        translated_error = self.translateTuple(('IncompatibleRepositories',
+            "repo1", "repo2", "details here"))
+        expected_error = errors.IncompatibleRepositories("repo1", "repo2",
+            "details here")
+        self.assertEqual(expected_error, translated_error)
+
     def test_PermissionDenied_no_args(self):
         path = 'a path'
         translated_error = self.translateTuple(('PermissionDenied',), path=path)




More information about the bazaar-commits mailing list