13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Tests for branch.push behaviour."""
19
19
from cStringIO import StringIO
22
22
from bzrlib import (
31
33
from bzrlib.branch import Branch
222
225
# fulltext record for f-id @ rev-1, then this will fail.
223
226
remote_branch = Branch.open(self.get_url('remote'))
224
227
trunk.push(remote_branch)
225
remote_branch.check()
228
check.check_dwim(remote_branch.base, False, True, True)
230
def test_no_get_parent_map_after_insert_stream(self):
231
# Effort test for bug 331823
232
self.setup_smart_server_with_call_log()
233
# Make a local branch with four revisions. Four revisions because:
234
# one to push, one there for _walk_to_common_revisions to find, one we
235
# don't want to access, one for luck :)
236
if isinstance(self.branch_format, branch.BranchReferenceFormat):
237
# This test could in principle apply to BranchReferenceFormat, but
238
# make_branch_builder doesn't support it.
239
raise tests.TestSkipped(
240
"BranchBuilder can't make reference branches.")
242
builder = self.make_branch_builder('local')
243
except (errors.TransportNotPossible, errors.UninitializableFormat):
244
raise tests.TestNotApplicable('format not directly constructable')
245
builder.start_series()
246
builder.build_snapshot('first', None, [
247
('add', ('', 'root-id', 'directory', ''))])
248
builder.build_snapshot('second', ['first'], [])
249
builder.build_snapshot('third', ['second'], [])
250
builder.build_snapshot('fourth', ['third'], [])
251
builder.finish_series()
252
local = builder.get_branch()
253
local = branch.Branch.open(self.get_vfs_only_url('local'))
254
# Initial push of three revisions
255
remote_bzrdir = local.bzrdir.sprout(
256
self.get_url('remote'), revision_id='third')
257
remote = remote_bzrdir.open_branch()
258
# Push fourth revision
259
self.reset_smart_call_log()
260
self.disableOptimisticGetParentMap()
261
self.assertFalse(local.is_locked())
263
hpss_call_names = [item.call.method for item in self.hpss_calls]
264
self.assertTrue('Repository.insert_stream_1.19' in hpss_call_names)
265
insert_stream_idx = hpss_call_names.index(
266
'Repository.insert_stream_1.19')
267
calls_after_insert_stream = hpss_call_names[insert_stream_idx:]
268
# After inserting the stream the client has no reason to query the
269
# remote graph any further.
271
['Repository.insert_stream_1.19', 'Repository.insert_stream_1.19',
272
'get', 'Branch.set_last_revision_info', 'Branch.unlock'],
273
calls_after_insert_stream)
275
def disableOptimisticGetParentMap(self):
276
# Tweak some class variables to stop remote get_parent_map calls asking
277
# for or receiving more data than the caller asked for.
278
old_flag = SmartServerRepositoryGetParentMap.no_extra_results
279
inter_class = repository.InterRepository
280
old_batch_size = inter_class._walk_to_common_revisions_batch_size
281
inter_class._walk_to_common_revisions_batch_size = 1
282
SmartServerRepositoryGetParentMap.no_extra_results = True
284
SmartServerRepositoryGetParentMap.no_extra_results = old_flag
285
inter_class._walk_to_common_revisions_batch_size = old_batch_size
286
self.addCleanup(reset_values)
228
289
class TestPushHook(TestCaseWithBranch):