/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-01-13 16:27:22 UTC
  • mfrom: (4634.119.6 2.0)
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: john@arbash-meinel.com-20100113162722-c177orxwb4fo19xe
Merge bzr/2.0@4725, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007, 2008 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 (
35
 
    blackbox,
36
 
    http_server,
37
 
    test_foreign,
38
 
    test_server,
39
 
    )
 
34
from bzrlib.tests import http_server
40
35
from bzrlib.transport import memory
41
36
 
42
37
 
258
253
        # upwards without agreement from bzr's network support maintainers.
259
254
        self.assertLength(11, self.hpss_calls)
260
255
 
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
 
 
277
256
    def test_push_smart_with_default_stacking_url_path_segment(self):
278
257
        # If the default stacked-on location is a path element then branches
279
258
        # we push there over the smart server are stacked and their
585
564
 
586
565
class RedirectingMemoryServer(memory.MemoryServer):
587
566
 
588
 
    def start_server(self):
 
567
    def setUp(self):
589
568
        self._dirs = {'/': None}
590
569
        self._files = {}
591
570
        self._locks = {}
599
578
        result._locks = self._locks
600
579
        return result
601
580
 
602
 
    def stop_server(self):
 
581
    def tearDown(self):
603
582
        transport.unregister_transport(self._scheme, self._memory_factory)
604
583
 
605
584
 
608
587
    def setUp(self):
609
588
        tests.TestCaseWithTransport.setUp(self)
610
589
        self.memory_server = RedirectingMemoryServer()
611
 
        self.start_server(self.memory_server)
 
590
        self.memory_server.setUp()
 
591
        self.addCleanup(self.memory_server.tearDown)
 
592
 
612
593
        # Make the branch and tree that we'll be pushing.
613
594
        t = self.make_branch_and_tree('tree')
614
595
        self.build_tree(['tree/file'])
661
642
    _default_wd = 'local'
662
643
    _default_errors = ['Working tree ".*/local/" has uncommitted '
663
644
                       'changes \(See bzr status\)\.',]
664
 
    _default_additional_error = 'Use --no-strict to force the push.\n'
665
 
    _default_additional_warning = 'Uncommitted changes will not be pushed.'
666
 
 
 
645
    _default_pushed_revid = 'modified'
667
646
 
668
647
    def assertPushFails(self, args):
669
 
        out, err = self.run_bzr_error(self._default_errors,
670
 
                                      self._default_command + args,
671
 
                                      working_dir=self._default_wd, retcode=3)
672
 
        self.assertContainsRe(err, self._default_additional_error)
 
648
        self.run_bzr_error(self._default_errors, self._default_command + args,
 
649
                           working_dir=self._default_wd, retcode=3)
673
650
 
674
 
    def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None):
675
 
        if with_warning:
676
 
            error_regexes = self._default_errors
677
 
        else:
678
 
            error_regexes = []
679
 
        out, err = self.run_bzr(self._default_command + args,
680
 
                                working_dir=self._default_wd,
681
 
                                error_regexes=error_regexes)
682
 
        if with_warning:
683
 
            self.assertContainsRe(err, self._default_additional_warning)
684
 
        else:
685
 
            self.assertNotContainsRe(err, self._default_additional_warning)
686
 
        branch_from = branch.Branch.open(self._default_wd)
687
 
        if revid_to_push is None:
688
 
            revid_to_push = branch_from.last_revision()
689
 
        branch_to = branch.Branch.open('to')
690
 
        repo_to = branch_to.repository
691
 
        self.assertTrue(repo_to.has_revision(revid_to_push))
692
 
        self.assertEqual(revid_to_push, branch_to.last_revision())
 
651
    def assertPushSucceeds(self, args, pushed_revid=None):
 
652
        self.run_bzr(self._default_command + args,
 
653
                     working_dir=self._default_wd)
 
654
        if pushed_revid is None:
 
655
            pushed_revid = self._default_pushed_revid
 
656
        tree_to = workingtree.WorkingTree.open('to')
 
657
        repo_to = tree_to.branch.repository
 
658
        self.assertTrue(repo_to.has_revision(pushed_revid))
 
659
        self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
693
660
 
694
661
 
695
662
 
725
692
 
726
693
    def setUp(self):
727
694
        super(TestPushStrictWithChanges, self).setUp()
728
 
        # Apply the changes defined in load_tests: one of _uncommitted_changes,
729
 
        # _pending_merges or _out_of_sync_trees
730
695
        getattr(self, self._changes_type)()
731
696
 
732
697
    def _uncommitted_changes(self):
756
721
        self._default_wd = 'checkout'
757
722
        self._default_errors = ["Working tree is out of date, please run"
758
723
                                " 'bzr update'\.",]
 
724
        self._default_pushed_revid = 'modified-in-local'
759
725
 
760
726
    def test_push_default(self):
761
 
        self.assertPushSucceeds([], with_warning=True)
 
727
        self.assertPushFails([])
762
728
 
763
729
    def test_push_with_revision(self):
764
 
        self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
 
730
        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
765
731
 
766
732
    def test_push_no_strict(self):
767
733
        self.assertPushSucceeds(['--no-strict'])
775
741
 
776
742
    def test_push_bogus_config_var_ignored(self):
777
743
        self.set_config_push_strict("I don't want you to be strict")
778
 
        self.assertPushSucceeds([], with_warning=True)
 
744
        self.assertPushFails([])
779
745
 
780
746
    def test_push_no_strict_command_line_override_config(self):
781
747
        self.set_config_push_strict('yES')
786
752
        self.set_config_push_strict('oFF')
787
753
        self.assertPushFails(['--strict'])
788
754
        self.assertPushSucceeds([])
789
 
 
790
 
 
791
 
class TestPushForeign(blackbox.ExternalBase):
792
 
 
793
 
    def setUp(self):
794
 
        super(TestPushForeign, self).setUp()
795
 
        test_foreign.register_dummy_foreign_for_test(self)
796
 
 
797
 
    def make_dummy_builder(self, relpath):
798
 
        builder = self.make_branch_builder(
799
 
            relpath, format=test_foreign.DummyForeignVcsDirFormat())
800
 
        builder.build_snapshot('revid', None,
801
 
            [('add', ('', 'TREE_ROOT', 'directory', None)),
802
 
             ('add', ('foo', 'fooid', 'file', 'bar'))])
803
 
        return builder
804
 
 
805
 
    def test_no_roundtripping(self):
806
 
        target_branch = self.make_dummy_builder('dp').get_branch()
807
 
        source_tree = self.make_branch_and_tree("dc")
808
 
        output, error = self.run_bzr("push -d dc dp", retcode=3)
809
 
        self.assertEquals("", output)
810
 
        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
811
 
            " push to dummy. You may want to use dpush instead.\n")