Rev 4929: (Jelmer) Add NoRoundTrippingSupport exception, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Jan 4 05:40:04 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4929 [merge]
revision-id: pqm at pqm.ubuntu.com-20100104054001-iwx19b3mp8igu88x
parent: pqm at pqm.ubuntu.com-20100104031000-z5cdnjpq7phqxwf2
parent: jelmer at samba.org-20091225134723-j1hhom9o72asamhu
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-01-04 05:40:01 +0000
message:
  (Jelmer) Add NoRoundTrippingSupport exception,
  	and extend 'bzr push' to suggest dpush when it occurs.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/push.py                 push.py-20080606021927-5fe39050e8xne9un-1
  bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
  bzrlib/tests/test_foreign.py   test_foreign.py-20081125004048-ywb901edgp9lluxo-1
=== modified file 'NEWS'
--- a/NEWS	2010-01-04 02:25:11 +0000
+++ b/NEWS	2010-01-04 05:40:01 +0000
@@ -66,6 +66,10 @@
 Improvements
 ************
 
+* Push will now inform the user when they are trying to push to a foreign 
+  VCS for which roundtripping is not supported, and will suggest them to 
+  use dpush. (Jelmer Vernooij)
+
 * Transport network activity indicator is shown more of the time when
   Bazaar is doing network IO.
   (Martin Pool)
@@ -96,6 +100,9 @@
   selftest but may be useful for diff and other operations that generate
   mixed output. (Robert Collins)
 
+* New exception ``NoRoundtrippingSupport``, for use by foreign branch 
+  plugins. (Jelmer Vernooij)
+
 Testing
 *******
 

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2009-08-30 21:34:42 +0000
+++ b/bzrlib/errors.py	2009-12-25 13:47:23 +0000
@@ -3075,3 +3075,15 @@
     def __init__(self, source_branch, target_branch):
         self.source_branch = source_branch
         self.target_branch = target_branch
+
+
+class NoRoundtrippingSupport(BzrError):
+
+    _fmt = ("Roundtripping is not supported between %(source_branch)r and "
+            "%(target_branch)r.")
+
+    internal_error = True
+
+    def __init__(self, source_branch, target_branch):
+        self.source_branch = source_branch
+        self.target_branch = target_branch

=== modified file 'bzrlib/push.py'
--- a/bzrlib/push.py	2009-11-25 06:10:00 +0000
+++ b/bzrlib/push.py	2009-12-25 13:47:23 +0000
@@ -137,6 +137,10 @@
             raise errors.BzrCommandError('These branches have diverged.'
                                     '  See "bzr help diverged-branches"'
                                     ' for more information.')
+        except errors.NoRoundtrippingSupport, e:
+            raise errors.BzrCommandError("It is not possible to losslessly "
+                "push to %s. You may want to use dpush instead." % 
+                    e.target_branch.mapping.vcs.abbreviation)
         except errors.NoRepositoryPresent:
             # we have a bzrdir but no branch or repository
             # XXX: Figure out what to do other than complain.

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-12-03 02:24:54 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-12-25 13:47:23 +0000
@@ -31,7 +31,11 @@
     workingtree
     )
 from bzrlib.repofmt import knitrepo
-from bzrlib.tests import http_server
+from bzrlib.tests import (
+    blackbox,
+    http_server,
+    test_foreign,
+    )
 from bzrlib.transport import memory
 
 
@@ -768,3 +772,26 @@
         self.set_config_push_strict('oFF')
         self.assertPushFails(['--strict'])
         self.assertPushSucceeds([])
+
+
+class TestPushForeign(blackbox.ExternalBase):
+
+    def setUp(self):
+        super(TestPushForeign, self).setUp()
+        test_foreign.register_dummy_foreign_for_test(self)
+
+    def make_dummy_builder(self, relpath):
+        builder = self.make_branch_builder(
+            relpath, format=test_foreign.DummyForeignVcsDirFormat())
+        builder.build_snapshot('revid', None,
+            [('add', ('', 'TREE_ROOT', 'directory', None)),
+             ('add', ('foo', 'fooid', 'file', 'bar'))])
+        return builder
+
+    def test_no_roundtripping(self):
+        target_branch = self.make_dummy_builder('dp').get_branch()
+        source_tree = self.make_branch_and_tree("dc")
+        output, error = self.run_bzr("push -d dc dp", retcode=3)
+        self.assertEquals("", output)
+        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
+            " push to dummy. You may want to use dpush instead.\n")

=== modified file 'bzrlib/tests/test_foreign.py'
--- a/bzrlib/tests/test_foreign.py	2009-10-19 00:54:12 +0000
+++ b/bzrlib/tests/test_foreign.py	2009-12-25 13:47:23 +0000
@@ -103,6 +103,9 @@
     def is_compatible(source, target):
         return isinstance(target, DummyForeignVcsBranch)
 
+    def push(self, overwrite=False, stop_revision=None):
+        raise errors.NoRoundtrippingSupport(self.source, self.target)
+
     def lossy_push(self, stop_revision=None):
         result = branch.BranchPushResult()
         result.source_branch = self.source
@@ -351,6 +354,13 @@
         self.assertNotEquals("A Dummy VCS Dir",
                              newdir._format.get_format_string())
 
+    def test_push_not_supported(self):
+        source_tree = self.make_branch_and_tree("source")
+        target_tree = self.make_branch_and_tree("target", 
+            format=DummyForeignVcsDirFormat())
+        self.assertRaises(errors.NoRoundtrippingSupport, 
+            source_tree.branch.push, target_tree.branch)
+
     def test_lossy_push_empty(self):
         source_tree = self.make_branch_and_tree("source")
         target_tree = self.make_branch_and_tree("target", 




More information about the bazaar-commits mailing list