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()
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)
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()
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)
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())
97
117
rev1 = checkout.commit('master')
99
other_bzrdir = self.sprout_from(master_tree.branch.controldir, 'other')
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')
133
source.branch.lock_read()
159
with source.branch.lock_read(), target.lock_write():
137
160
source.branch.push(target, stop_revision=source.last_revision())
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))
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')
171
self.build_tree(['source/a'])
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')
143
182
def test_push_within_repository(self):
144
183
"""Push from one branch to another inside the same repository."""
174
213
to_branch = self.make_to_branch('repo/branch')
175
tree.branch.push(to_branch)
177
self.assertEqual(tree.branch.last_revision(),
178
to_branch.last_revision())
215
tree.branch.push(to_branch)
216
except errors.NoRoundtrippingSupport:
217
tree.branch.push(to_branch, lossy=True)
219
self.assertEqual(tree.branch.last_revision(),
220
to_branch.last_revision())
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')
188
230
source.commit('1st commit')
189
source.branch.push(target)
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')
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()