~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_push.py

  • Committer: Martin Pool
  • Date: 2010-02-27 01:34:49 UTC
  • mto: This revision was merged to the branch mainline in revision 5064.
  • Revision ID: mbp@canonical.com-20100227013449-zxostilwfoendxfv
Handle "Directory not empty" from ftp as DirectoryNotEmpty.

FtpTransport._translate_ftp_error can handle all ftp errors; there's no clear
distinction between 'temporary' and 'permament'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
    workingtree
32
32
    )
33
33
from bzrlib.repofmt import knitrepo
34
 
from bzrlib.tests import http_server
 
34
from bzrlib.tests import (
 
35
    blackbox,
 
36
    http_server,
 
37
    test_foreign,
 
38
    test_server,
 
39
    )
35
40
from bzrlib.transport import memory
36
41
 
37
42
 
239
244
        remote = branch.Branch.open('public')
240
245
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
241
246
 
 
247
    def test_push_smart_tags_streaming_acceptance(self):
 
248
        self.setup_smart_server_with_call_log()
 
249
        t = self.make_branch_and_tree('from')
 
250
        rev_id = t.commit(allow_pointless=True, message='first commit')
 
251
        t.branch.tags.set_tag('new-tag', rev_id)
 
252
        self.reset_smart_call_log()
 
253
        self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
 
254
        # This figure represent the amount of work to perform this use case. It
 
255
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
256
        # being too low. If rpc_count increases, more network roundtrips have
 
257
        # become necessary for this use case. Please do not adjust this number
 
258
        # upwards without agreement from bzr's network support maintainers.
 
259
        self.assertLength(11, self.hpss_calls)
 
260
 
 
261
    def test_push_smart_incremental_acceptance(self):
 
262
        self.setup_smart_server_with_call_log()
 
263
        t = self.make_branch_and_tree('from')
 
264
        rev_id1 = t.commit(allow_pointless=True, message='first commit')
 
265
        rev_id2 = t.commit(allow_pointless=True, message='second commit')
 
266
        self.run_bzr(
 
267
            ['push', self.get_url('to-one'), '-r1'], working_dir='from')
 
268
        self.reset_smart_call_log()
 
269
        self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
 
270
        # This figure represent the amount of work to perform this use case. It
 
271
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
272
        # being too low. If rpc_count increases, more network roundtrips have
 
273
        # become necessary for this use case. Please do not adjust this number
 
274
        # upwards without agreement from bzr's network support maintainers.
 
275
        self.assertLength(11, self.hpss_calls)
 
276
 
242
277
    def test_push_smart_with_default_stacking_url_path_segment(self):
243
278
        # If the default stacked-on location is a path element then branches
244
279
        # we push there over the smart server are stacked and their
305
340
        # The push should have created target/a
306
341
        self.failUnlessExists('target/a')
307
342
 
 
343
    def test_push_use_existing_into_empty_bzrdir(self):
 
344
        """'bzr push --use-existing-dir' into a dir with an empty .bzr dir
 
345
        fails.
 
346
        """
 
347
        tree = self.create_simple_tree()
 
348
        self.build_tree(['target/', 'target/.bzr/'])
 
349
        self.run_bzr_error(
 
350
            ['Target directory ../target already contains a .bzr directory, '
 
351
             'but it is not valid.'],
 
352
            'push ../target --use-existing-dir', working_dir='tree')
 
353
 
308
354
    def test_push_onto_repo(self):
309
355
        """We should be able to 'bzr push' into an existing bzrdir."""
310
356
        tree = self.create_simple_tree()
539
585
 
540
586
class RedirectingMemoryServer(memory.MemoryServer):
541
587
 
542
 
    def setUp(self):
 
588
    def start_server(self):
543
589
        self._dirs = {'/': None}
544
590
        self._files = {}
545
591
        self._locks = {}
553
599
        result._locks = self._locks
554
600
        return result
555
601
 
556
 
    def tearDown(self):
 
602
    def stop_server(self):
557
603
        transport.unregister_transport(self._scheme, self._memory_factory)
558
604
 
559
605
 
562
608
    def setUp(self):
563
609
        tests.TestCaseWithTransport.setUp(self)
564
610
        self.memory_server = RedirectingMemoryServer()
565
 
        self.memory_server.setUp()
566
 
        self.addCleanup(self.memory_server.tearDown)
567
 
 
 
611
        self.start_server(self.memory_server)
568
612
        # Make the branch and tree that we'll be pushing.
569
613
        t = self.make_branch_and_tree('tree')
570
614
        self.build_tree(['tree/file'])
667
711
 
668
712
    def setUp(self):
669
713
        super(TestPushStrictWithChanges, self).setUp()
 
714
        # Apply the changes defined in load_tests: one of _uncommitted_changes,
 
715
        # _pending_merges or _out_of_sync_trees
670
716
        getattr(self, self._changes_type)()
671
717
 
672
718
    def _uncommitted_changes(self):
727
773
        self.set_config_push_strict('oFF')
728
774
        self.assertPushFails(['--strict'])
729
775
        self.assertPushSucceeds([])
 
776
 
 
777
 
 
778
class TestPushForeign(blackbox.ExternalBase):
 
779
 
 
780
    def setUp(self):
 
781
        super(TestPushForeign, self).setUp()
 
782
        test_foreign.register_dummy_foreign_for_test(self)
 
783
 
 
784
    def make_dummy_builder(self, relpath):
 
785
        builder = self.make_branch_builder(
 
786
            relpath, format=test_foreign.DummyForeignVcsDirFormat())
 
787
        builder.build_snapshot('revid', None,
 
788
            [('add', ('', 'TREE_ROOT', 'directory', None)),
 
789
             ('add', ('foo', 'fooid', 'file', 'bar'))])
 
790
        return builder
 
791
 
 
792
    def test_no_roundtripping(self):
 
793
        target_branch = self.make_dummy_builder('dp').get_branch()
 
794
        source_tree = self.make_branch_and_tree("dc")
 
795
        output, error = self.run_bzr("push -d dc dp", retcode=3)
 
796
        self.assertEquals("", output)
 
797
        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
 
798
            " push to dummy. You may want to use dpush instead.\n")