~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

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