~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_reconfigure.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 14:26:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105142658-vek3v6pzlxb751s2
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. 

@only_raises is evil and gave a hard time since any exception during
save_changes() was swallowed.

Possible improvements: 

- add some needs_write_lock decorators to crucial
  methods (_set_config_location ?) but keep locking the branch at higher levels

- decorate branch.unlock to call stack.save if last_lock() it True
  outside of @only_raises scope (evil decorator)

- add @needs_write_lock to stack.set and stack.remove (will probably get
  rid of most testing issues) we probably need a specialized decorator
  that can relay to the store and from there to the branch or whatever is
  needed. This will also helps bzr config to get it right. The
  get_mutable_section trick should not be needed anymore either.

- decorate branch.unlock to call stack.save if last_lock() it True outside
  of @only_raises scope (evil decorator)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2007-2012 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
242
242
        branch_2 = tree_2.branch
243
243
        # now reconfigure to be stacked
244
244
        out, err = self.run_bzr('reconfigure --stacked-on b1 b2')
245
 
        self.assertContainsRe(out,
246
 
            '^.*/b2/ is now stacked on ../b1\n$')
 
245
        self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
247
246
        self.assertEquals('', err)
248
247
        # can also give the absolute URL of the branch, and it gets stored 
249
248
        # as a relative path if possible
250
249
        out, err = self.run_bzr('reconfigure --stacked-on %s b2'
251
 
            % (self.get_url('b1'),))
252
 
        self.assertContainsRe(out,
253
 
            '^.*/b2/ is now stacked on ../b1\n$')
 
250
                                % (self.get_url('b1'),))
 
251
        self.assertContainsRe(out, '^.*/b2/ is now stacked on ../b1\n$')
254
252
        self.assertEquals('', err)
 
253
        b2 = bzrdir.BzrDir.open('b2').open_branch()
255
254
        # It should be given a relative URL to the destination, if possible,
256
255
        # because that's most likely to work across different transports
257
 
        self.assertEquals(branch_2.get_stacked_on_url(),
258
 
            '../b1')
 
256
        self.assertEquals('../b1', b2.get_stacked_on_url())
259
257
        # commit, and it should be stored into b2's repo
260
258
        self.build_tree_contents([('foo', 'new foo')])
261
259
        tree_2.commit('update foo')
264
262
        self.assertContainsRe(out,
265
263
            '^.*/b2/ is now not stacked\n$')
266
264
        self.assertEquals('', err)
267
 
        self.assertRaises(errors.NotStacked,
268
 
            branch_2.get_stacked_on_url)
 
265
        b2 = bzrdir.BzrDir.open('b2').open_branch()
 
266
        self.assertRaises(errors.NotStacked, b2.get_stacked_on_url)
269
267
 
270
268
    # XXX: Needs a test for reconfiguring stacking and shape at the same time;
271
269
    # no branch at location; stacked-on is not a branch; quiet mode.