Rev 4297: Move UI exception raising back to branch.py. in http://people.ubuntu.com/~robertc/baz2.0/pending/push.roundtrips

Robert Collins robertc at robertcollins.net
Wed Apr 22 04:49:14 BST 2009


At http://people.ubuntu.com/~robertc/baz2.0/pending/push.roundtrips

------------------------------------------------------------
revno: 4297
revision-id: robertc at robertcollins.net-20090422034909-3wx0mov5o1tpxybe
parent: robertc at robertcollins.net-20090422023623-7juu383fqtbu3yzv
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Wed 2009-04-22 13:49:09 +1000
message:
  Move UI exception raising back to branch.py.
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2009-04-22 02:36:23 +0000
+++ b/bzrlib/branch.py	2009-04-22 03:49:09 +0000
@@ -1149,9 +1149,26 @@
         # clone call. Or something. 20090224 RBC/spiv.
         if revision_id is None:
             revision_id = self.last_revision()
-        dir_to = self.bzrdir.clone_on_transport(to_transport,
-            revision_id=revision_id, stacked_on=stacked_on,
-            create_prefix=create_prefix, use_existing_dir=use_existing_dir)
+        try:
+            dir_to = self.bzrdir.clone_on_transport(to_transport,
+                revision_id=revision_id, stacked_on=stacked_on,
+                create_prefix=create_prefix, use_existing_dir=use_existing_dir)
+        except errors.FileExists:
+            if not use_existing_dir:
+                raise errors.BzrCommandError("Target directory %s"
+                     " already exists, but does not have a valid .bzr"
+                     " directory. Supply --use-existing-dir to push"
+                     " there anyway." % to_transport.base)
+        except errors.NoSuchFile:
+            if not create_prefix:
+                raise errors.BzrCommandError("Parent directory of %s"
+                    " does not exist."
+                    "\nYou may supply --create-prefix to create all"
+                    " leading parent directories."
+                    % to_transport.base)
+        except errors.TooManyRedirections:
+            raise errors.BzrCommandError("Too many redirections trying "
+                                         "to make %s." % to_transport.base)
         return dir_to.open_branch()
 
     def create_checkout(self, to_location, revision_id=None,

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-04-22 02:36:23 +0000
+++ b/bzrlib/bzrdir.py	2009-04-22 03:49:09 +0000
@@ -212,21 +212,11 @@
                 redirected)
         except errors.FileExists:
             if not use_existing_dir:
-                raise errors.BzrCommandError("Target directory %s"
-                     " already exists, but does not have a valid .bzr"
-                     " directory. Supply --use-existing-dir to push"
-                     " there anyway." % transport.base)
+                raise
         except errors.NoSuchFile:
             if not create_prefix:
-                raise errors.BzrCommandError("Parent directory of %s"
-                    " does not exist."
-                    "\nYou may supply --create-prefix to create all"
-                    " leading parent directories."
-                    % transport.base)
+                raise
             transport.create_prefix()
-        except errors.TooManyRedirections:
-            raise errors.BzrCommandError("Too many redirections trying "
-                                         "to make %s." % transport.base)
 
         # Now the target directory exists, but doesn't have a .bzr
         # directory. So we need to create it, along with any work to create




More information about the bazaar-commits mailing list