~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-08-13 07:56:06 UTC
  • mfrom: (5050.17.4 2.2)
  • mto: (5050.17.6 2.2)
  • mto: This revision was merged to the branch mainline in revision 5379.
  • Revision ID: mbp@sourcefrog.net-20100813075606-8zgmov3ezwans2zo
merge bzr 2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
23
23
    errors,
24
24
    )
25
25
from bzrlib.revision import NULL_REVISION
26
 
from bzrlib.smart import server
27
 
from bzrlib.tests import TestNotApplicable, KnownFailure, transport_util
 
26
from bzrlib.tests import TestNotApplicable, transport_util
28
27
from bzrlib.tests.per_branch import TestCaseWithBranch
29
 
from bzrlib.transport import get_transport
30
28
 
31
29
 
32
30
unstackable_format_errors = (
207
205
        self.assertRaises(errors.NotStacked,
208
206
            new_branch.get_stacked_on_url)
209
207
 
 
208
    def test_unstack_already_locked(self):
 
209
        """Removing the stacked-on branch with an already write-locked branch
 
210
        works.
 
211
 
 
212
        This was bug 551525.
 
213
        """
 
214
        try:
 
215
            stacked_bzrdir = self.make_stacked_bzrdir()
 
216
        except unstackable_format_errors, e:
 
217
            raise TestNotApplicable(e)
 
218
        stacked_branch = stacked_bzrdir.open_branch()
 
219
        stacked_branch.lock_write()
 
220
        stacked_branch.set_stacked_on_url(None)
 
221
        stacked_branch.unlock()
 
222
 
 
223
    def test_unstack_already_multiple_locked(self):
 
224
        """Unstacking a branch preserves the lock count (even though it
 
225
        replaces the br.repository object).
 
226
 
 
227
        This is a more extreme variation of test_unstack_already_locked.
 
228
        """
 
229
        try:
 
230
            stacked_bzrdir = self.make_stacked_bzrdir()
 
231
        except unstackable_format_errors, e:
 
232
            raise TestNotApplicable(e)
 
233
        stacked_branch = stacked_bzrdir.open_branch()
 
234
        stacked_branch.lock_write()
 
235
        stacked_branch.lock_write()
 
236
        stacked_branch.lock_write()
 
237
        stacked_branch.set_stacked_on_url(None)
 
238
        stacked_branch.unlock()
 
239
        stacked_branch.unlock()
 
240
        stacked_branch.unlock()
 
241
 
210
242
    def make_stacked_bzrdir(self, in_directory=None):
211
243
        """Create a stacked branch and return its bzrdir.
212
244
 
222
254
        tree = self.make_branch_and_tree(prefix + 'stacked-on')
223
255
        tree.commit('Added foo')
224
256
        stacked_bzrdir = tree.branch.bzrdir.sprout(
225
 
            prefix + 'stacked', tree.branch.last_revision(), stacked=True)
 
257
            self.get_url(prefix + 'stacked'), tree.branch.last_revision(),
 
258
            stacked=True)
226
259
        return stacked_bzrdir
227
260
 
228
261
    def test_clone_from_stacked_branch_preserve_stacking(self):
250
283
        except unstackable_format_errors, e:
251
284
            raise TestNotApplicable(e)
252
285
        stacked_bzrdir.open_branch().set_stacked_on_url('../stacked-on')
253
 
        cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
 
286
        cloned_bzrdir = stacked_bzrdir.clone(
 
287
            self.get_url('cloned'), preserve_stacking=True)
254
288
        self.assertEqual(
255
289
            '../dir/stacked-on',
256
290
            cloned_bzrdir.open_branch().get_stacked_on_url())