/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 breezy/tests/per_interbranch/test_pull.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from breezy import errors
22
22
from breezy.memorytree import MemoryTree
23
23
from breezy.revision import NULL_REVISION
 
24
from breezy.tests import TestNotApplicable
24
25
from breezy.tests.per_interbranch import TestCaseWithInterBranch
25
26
 
26
27
 
35
36
        # become the revision-history.
36
37
        parent = self.make_from_branch_and_tree('parent')
37
38
        parent.commit('1st post', allow_pointless=True)
38
 
        mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
39
        try:
 
40
            mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
41
        except errors.NoRoundtrippingSupport:
 
42
            raise TestNotApplicable(
 
43
                'lossless push between %r and %r not supported' %
 
44
                (self.branch_format_from, self.branch_format_to))
39
45
        mine.commit('my change', allow_pointless=True)
40
 
        parent.merge_from_branch(mine.branch)
 
46
        try:
 
47
            parent.merge_from_branch(mine.branch)
 
48
        except errors.NoRoundtrippingSupport:
 
49
            raise TestNotApplicable(
 
50
                'lossless push between %r and %r not supported' %
 
51
                (self.branch_format_from, self.branch_format_to))
41
52
        p2 = parent.commit('merge my change')
42
53
        mine.pull(parent.branch)
43
54
        self.assertEqual(p2, mine.branch.last_revision())
49
60
        # directly accessible.
50
61
        parent = self.make_from_branch_and_tree('parent')
51
62
        parent.commit('1st post', allow_pointless=True)
52
 
        mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
63
        try:
 
64
            mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
65
        except errors.NoRoundtrippingSupport:
 
66
            raise TestNotApplicable(
 
67
                'lossless push between %r and %r not supported' %
 
68
                (self.branch_format_from, self.branch_format_to))
53
69
        mine.commit('my change', allow_pointless=True)
54
70
        other = self.sprout_to(parent.controldir, 'other').open_workingtree()
55
71
        other.merge_from_branch(mine.branch)
56
72
        other.commit('merge my change')
57
 
        parent.merge_from_branch(other.branch)
 
73
        try:
 
74
            parent.merge_from_branch(other.branch)
 
75
        except errors.NoRoundtrippingSupport:
 
76
            raise TestNotApplicable(
 
77
                'lossless push between %r and %r not supported' %
 
78
                (self.branch_format_from, self.branch_format_to))
58
79
        p2 = parent.commit('merge other')
59
80
        mine.pull(parent.branch)
60
81
        self.assertEqual(p2, mine.branch.last_revision())
64
85
        master_tree = self.make_from_branch_and_tree('master')
65
86
        master_tree.commit('master')
66
87
        checkout = master_tree.branch.create_checkout('checkout')
67
 
        other = self.sprout_to(master_tree.branch.controldir, 'other').open_workingtree()
 
88
        try:
 
89
            other = self.sprout_to(master_tree.branch.controldir, 'other').open_workingtree()
 
90
        except errors.NoRoundtrippingSupport:
 
91
            raise TestNotApplicable(
 
92
                'lossless push between %r and %r not supported' %
 
93
                (self.branch_format_from, self.branch_format_to))
68
94
        rev2 = other.commit('other commit')
69
95
        # now pull, which should update both checkout and master.
70
 
        checkout.branch.pull(other.branch)
 
96
        try:
 
97
            checkout.branch.pull(other.branch)
 
98
        except errors.NoRoundtrippingSupport:
 
99
            raise TestNotApplicable(
 
100
                'lossless push between %r and %r not supported' %
 
101
                (self.branch_format_from, self.branch_format_to))
71
102
        self.assertEqual(rev2, checkout.branch.last_revision())
72
103
        self.assertEqual(rev2, master_tree.branch.last_revision())
73
104
 
77
108
        other = self.sprout_to(master_tree.branch.controldir, 'other').open_branch()
78
109
        # move the branch out of the way on disk to cause a connection
79
110
        # error.
80
 
        master_tree.branch.controldir.destroy_branch()
 
111
        try:
 
112
            master_tree.branch.controldir.destroy_branch()
 
113
        except errors.UnsupportedOperation:
 
114
            raise TestNotApplicable(
 
115
                'control format does not support destroying default branch')
81
116
        # try to pull, which should raise a BoundBranchConnectionFailure.
82
117
        self.assertRaises(errors.BoundBranchConnectionFailure,
83
118
                          checkout.branch.pull, other)
85
120
    def test_pull_returns_result(self):
86
121
        parent = self.make_from_branch_and_tree('parent')
87
122
        p1 = parent.commit('1st post')
88
 
        mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
123
        try:
 
124
            mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
125
        except errors.NoRoundtrippingSupport:
 
126
            raise TestNotApplicable(
 
127
                'lossless push between %r and %r not supported' %
 
128
                (self.branch_format_from, self.branch_format_to))
89
129
        m1 = mine.commit('my change')
90
 
        result = parent.branch.pull(mine.branch)
 
130
        try:
 
131
            result = parent.branch.pull(mine.branch)
 
132
        except errors.NoRoundtrippingSupport:
 
133
            raise TestNotApplicable(
 
134
                'lossless push between %r and %r not supported' %
 
135
                (self.branch_format_from, self.branch_format_to))
91
136
        self.assertIsNot(None, result)
92
137
        self.assertIs(mine.branch, result.source_branch)
93
138
        self.assertIs(parent.branch, result.target_branch)
102
147
    def test_pull_overwrite(self):
103
148
        tree_a = self.make_from_branch_and_tree('tree_a')
104
149
        tree_a.commit('message 1')
105
 
        tree_b = self.sprout_to(tree_a.controldir, 'tree_b').open_workingtree()
106
 
        rev2a = tree_a.commit('message 2')
107
 
        rev2b = tree_b.commit('message 2')
108
 
        self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
150
        try:
 
151
            tree_b = self.sprout_to(tree_a.controldir, 'tree_b').open_workingtree()
 
152
        except errors.NoRoundtrippingSupport:
 
153
            raise TestNotApplicable(
 
154
                'lossless push between %r and %r not supported' %
 
155
                (self.branch_format_from, self.branch_format_to))
 
156
 
 
157
        rev2a = tree_a.commit('message 2a')
 
158
        rev2b = tree_b.commit('message 2b')
 
159
        try:
 
160
            self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
161
        except errors.NoRoundtrippingSupport:
 
162
            raise TestNotApplicable(
 
163
                'lossless push between %r and %r not supported' %
 
164
                (self.branch_format_from, self.branch_format_to))
109
165
        self.assertRaises(errors.DivergedBranches,
110
166
                          tree_a.branch.pull, tree_b.branch,
111
167
                          overwrite=False, stop_revision=rev2b)