~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-06 13:52:02 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070606135202-mqhxcv6z57uce434
Fix merge multiple connections. Test suite *not* passing (sftp
refactoring pending but unrelated to merge).

* bzrlib/builtins.py:
(cmd_merge.run): Fix the multiple connections bug by reusing the
tramsport used to check for a bundle and keep all other used
transports in possible_transports.
(_merge_helper): Add a possible_transports parameter for
reuse.

* bzrlib/transport/__init__.py:
(Transport._reuse_for): By default, Transports are not reusable.
(ConnectedTransport._reuse_for): ConnectedTransports are reusable
under certain conditions.
(_urlRE): Fix misleading group name.
(_try_transport_factories): Moved after get_transport (another use
case for moved lines). The do_catching_redirections was
incorrectly inserted between get_transport and
_try_transport_factories.

* bzrlib/tests/test_transport.py:
(TestReusedTransports.test_reuse_same_transport)
(TestReusedTransports.test_don_t_reuse_different_transport): Add
more tests.

* bzrlib/merge.py:
(_get_tree, Merger.set_other): Add a possible_transports parameter
for reuse.

* bzrlib/bzrdir.py:
(BzrDir.open_containing): Add a possible_transports parameter for
reuse.

* bzrlib/branch.py:
(Branch.open_containing): Add a possible_transports parameter for
reuse.

Show diffs side-by-side

added added

removed removed

Lines of Context:
685
685
    """Tests for transport reuse"""
686
686
 
687
687
    def test_reuse_same_transport(self):
688
 
        t = get_transport('http://foo/')
689
 
        t2 = get_transport('http://foo/', possible_transports=[t])
690
 
        self.assertIs(t, t2)
 
688
        t1 = get_transport('http://foo/')
 
689
        t2 = get_transport('http://foo/', possible_transports=[t1])
 
690
        self.assertIs(t1, t2)
 
691
 
 
692
        # Also check that final '/' are handled correctly
 
693
        t3 = get_transport('http://foo/path/')
 
694
        t4 = get_transport('http://foo/path', possible_transports=[t3])
 
695
        self.assertIs(t3, t4)
 
696
 
 
697
        t3 = get_transport('http://foo/path')
 
698
        t4 = get_transport('http://foo/path/', possible_transports=[t3])
 
699
        self.assertIs(t3, t4)
691
700
 
692
701
    def test_don_t_reuse_different_transport(self):
693
 
        t = get_transport('http://foo/')
694
 
        t2 = get_transport('http://bar/', possible_transports=[t])
 
702
        t = get_transport('http://foo/path')
 
703
        t2 = get_transport('http://bar/path', possible_transports=[t])
695
704
        self.assertIsNot(t, t2)
696
705
 
697
706