~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-05-10 07:46:15 UTC
  • mfrom: (5844 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5845.
  • Revision ID: jelmer@samba.org-20110510074615-eptod049ndjxc4i7
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 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
114
114
        self.assertRaises(errors.BoundBranchConnectionFailure,
115
115
                other.branch.push, checkout.branch)
116
116
 
 
117
    def test_push_new_tag_to_bound_branch(self):
 
118
        master = self.make_branch('master')
 
119
        bound = self.make_branch('bound')
 
120
        try:
 
121
            bound.bind(master)
 
122
        except errors.UpgradeRequired:
 
123
            raise tests.TestNotApplicable(
 
124
                'Format does not support bound branches')
 
125
        other = bound.bzrdir.sprout('other').open_branch()
 
126
        try:
 
127
            other.tags.set_tag('new-tag', 'some-rev')
 
128
        except errors.TagsNotSupported:
 
129
            raise tests.TestNotApplicable('Format does not support tags')
 
130
        other.push(bound)
 
131
        self.assertEqual({'new-tag': 'some-rev'}, bound.tags.get_tag_dict())
 
132
        self.assertEqual({'new-tag': 'some-rev'}, master.tags.get_tag_dict())
 
133
 
117
134
    def test_push_uses_read_lock(self):
118
135
        """Push should only need a read lock on the source side."""
119
136
        source = self.make_branch_and_tree('source')
201
218
        source.branch.push(target, stop_revision='rev-2', overwrite=True)
202
219
        self.assertEqual('rev-2', target.last_revision())
203
220
 
 
221
    def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
 
222
        # See https://bugs.launchpad.net/bzr/+bug/465517
 
223
        t = self.get_transport('target')
 
224
        t.ensure_base()
 
225
        bzrdir = self.bzrdir_format.initialize_on_transport(t)
 
226
        try:
 
227
            bzrdir.open_branch()
 
228
        except errors.NotBranchError:
 
229
            pass
 
230
        else:
 
231
            raise tests.TestNotApplicable('older formats can\'t have a repo'
 
232
                                          ' without a branch')
 
233
        try:
 
234
            source = self.make_branch_builder('source',
 
235
                                              format=self.bzrdir_format)
 
236
        except errors.UninitializableFormat:
 
237
            raise tests.TestNotApplicable('cannot initialize this format')
 
238
        source.start_series()
 
239
        source.build_snapshot('A', None, [
 
240
            ('add', ('', 'root-id', 'directory', None))])
 
241
        source.build_snapshot('B', ['A'], [])
 
242
        source.build_snapshot('C', ['A'], [])
 
243
        source.finish_series()
 
244
        b = source.get_branch()
 
245
        # Note: We can't read lock the source branch. Some formats take a write
 
246
        # lock to 'set_push_location', which breaks
 
247
        self.addCleanup(b.lock_write().unlock)
 
248
        repo = bzrdir.create_repository()
 
249
        # This means 'push the source branch into this dir'
 
250
        bzrdir.push_branch(b)
 
251
        self.addCleanup(repo.lock_read().unlock)
 
252
        # We should have pushed 'C', but not 'B', since it isn't in the
 
253
        # ancestry
 
254
        self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
 
255
 
204
256
    def test_push_with_default_stacking_does_not_create_broken_branch(self):
205
257
        """Pushing a new standalone branch works even when there's a default
206
258
        stacking policy at the destination.