/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_push.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 10:24:48 UTC
  • mfrom: (6910 work)
  • mto: This revision was merged to the branch mainline in revision 6913.
  • Revision ID: jelmer@jelmer.uk-20180324102448-132p8l8t5ogdzhhu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        # become the revision-history.
59
59
        mine = self.make_from_branch_and_tree('mine')
60
60
        mine.commit('1st post', allow_pointless=True)
61
 
        other = self.sprout_to(mine.controldir, 'other').open_workingtree()
 
61
        try:
 
62
            other = self.sprout_to(mine.controldir, 'other').open_workingtree()
 
63
        except errors.NoRoundtrippingSupport:
 
64
            raise tests.TestNotApplicable(
 
65
                'lossless push between %r and %r not supported' %
 
66
                (self.branch_format_from, self.branch_format_to))
62
67
        m1 = other.commit('my change', allow_pointless=True)
63
 
        mine.merge_from_branch(other.branch)
 
68
        try:
 
69
            mine.merge_from_branch(other.branch)
 
70
        except errors.NoRoundtrippingSupport:
 
71
            raise tests.TestNotApplicable(
 
72
                'lossless push between %r and %r not supported' %
 
73
                (self.branch_format_from, self.branch_format_to))
64
74
        p2 = mine.commit('merge my change')
65
75
        result = mine.branch.push(other.branch)
66
76
        self.assertEqual(p2, other.branch.last_revision())
75
85
        # directly accessible.
76
86
        mine = self.make_from_branch_and_tree('mine')
77
87
        p1 = mine.commit('1st post', allow_pointless=True)
78
 
        target = self.sprout_to(mine.controldir, 'target').open_workingtree()
 
88
        try:
 
89
            target = self.sprout_to(mine.controldir, 'target').open_workingtree()
 
90
        except errors.NoRoundtrippingSupport:
 
91
            raise tests.TestNotApplicable(
 
92
                'lossless push between %r and %r not supported' %
 
93
                (self.branch_format_from, self.branch_format_to))
79
94
        m1 = target.commit('my change', allow_pointless=True)
80
95
        other = self.sprout_to(mine.controldir, 'other').open_workingtree()
81
96
        other.merge_from_branch(target.branch)
82
97
        o2 = other.commit('merge my change')
83
 
        mine.merge_from_branch(other.branch)
 
98
        try:
 
99
            mine.merge_from_branch(other.branch)
 
100
        except errors.NoRoundtrippingSupport:
 
101
            raise tests.TestNotApplicable(
 
102
                'lossless push between %r and %r not supported' %
 
103
                (self.branch_format_from, self.branch_format_to))
84
104
        p2 = mine.commit('merge other')
85
105
        mine.branch.push(target.branch)
86
106
        self.assertEqual(p2, target.branch.last_revision())
96
116
            return
97
117
        rev1 = checkout.commit('master')
98
118
 
99
 
        other_bzrdir = self.sprout_from(master_tree.branch.controldir, 'other')
 
119
        try:
 
120
            other_bzrdir = self.sprout_from(master_tree.branch.controldir, 'other')
 
121
        except errors.NoRoundtrippingSupport:
 
122
            raise tests.TestNotApplicable(
 
123
                'lossless push between %r and %r not supported' %
 
124
                (self.branch_format_from, self.branch_format_to))
100
125
        other = other_bzrdir.open_workingtree()
101
126
        rev2 = other.commit('other commit')
102
127
        # now push, which should update both checkout and master.
130
155
        source.add(['a'])
131
156
        source.commit('a')
132
157
 
133
 
        source.branch.lock_read()
134
158
        try:
135
 
            target.lock_write()
136
 
            try:
 
159
            with source.branch.lock_read(), target.lock_write():
137
160
                source.branch.push(target, stop_revision=source.last_revision())
138
 
            finally:
139
 
                target.unlock()
140
 
        finally:
141
 
            source.branch.unlock()
 
161
        except errors.NoRoundtrippingSupport:
 
162
            raise tests.TestNotApplicable(
 
163
                'lossless push between %r and %r not supported' %
 
164
                (self.branch_format_from, self.branch_format_to))
 
165
 
 
166
    def test_push_uses_read_lock_lossy(self):
 
167
        """Push should only need a read lock on the source side."""
 
168
        source = self.make_from_branch_and_tree('source')
 
169
        target = self.make_to_branch('target')
 
170
 
 
171
        self.build_tree(['source/a'])
 
172
        source.add(['a'])
 
173
        source.commit('a')
 
174
 
 
175
        try:
 
176
            with source.branch.lock_read(), target.lock_write():
 
177
                source.branch.push(target, stop_revision=source.last_revision(), lossy=True)
 
178
        except errors.LossyPushToSameVCS:
 
179
            raise tests.TestNotApplicable(
 
180
                'push between branches of same format')
142
181
 
143
182
    def test_push_within_repository(self):
144
183
        """Push from one branch to another inside the same repository."""
172
211
        tree.commit('a')
173
212
 
174
213
        to_branch = self.make_to_branch('repo/branch')
175
 
        tree.branch.push(to_branch)
176
 
 
177
 
        self.assertEqual(tree.branch.last_revision(),
178
 
                         to_branch.last_revision())
 
214
        try:
 
215
            tree.branch.push(to_branch)
 
216
        except errors.NoRoundtrippingSupport:
 
217
            tree.branch.push(to_branch, lossy=True)
 
218
        else:
 
219
            self.assertEqual(tree.branch.last_revision(),
 
220
                             to_branch.last_revision())
179
221
 
180
222
    def test_push_overwrite_of_non_tip_with_stop_revision(self):
181
223
        """Combining the stop_revision and overwrite options works.
186
228
        target = self.make_to_branch('target')
187
229
 
188
230
        source.commit('1st commit')
189
 
        source.branch.push(target)
 
231
        try:
 
232
            source.branch.push(target)
 
233
        except errors.NoRoundtrippingSupport:
 
234
            raise tests.TestNotApplicable(
 
235
                'lossless push between %r and %r not supported' %
 
236
                (self.branch_format_from, self.branch_format_to))
190
237
        rev2 = source.commit('2nd commit')
191
238
        source.commit('3rd commit')
192
239
 
267
314
        remote_bzrdir = local.controldir.sprout(
268
315
            self.get_url('remote'), revision_id=third)
269
316
        remote = remote_bzrdir.open_branch()
 
317
        if not remote.repository._format.supports_full_versioned_files:
 
318
            raise tests.TestNotApplicable(
 
319
                'remote is not a VersionedFile repository')
270
320
        # Push fourth revision
271
321
        self.reset_smart_call_log()
272
322
        self.disableOptimisticGetParentMap()