/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_merger.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) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 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
22
22
from bzrlib import (
23
23
    errors,
24
24
    merge as _mod_merge,
25
 
    option,
26
 
    progress,
27
25
    )
28
26
from bzrlib.tests import (
29
27
    multiply_tests,
39
37
    result = loader.suiteClass()
40
38
    scenarios = [
41
39
        (name, {'merge_type': merger})
42
 
        for name, merger in option._merge_type_registry.items()]
 
40
        for name, merger in _mod_merge.merge_type_registry.items()]
43
41
    return multiply_tests(standard_tests, scenarios, result)
44
42
 
45
43
 
176
174
        transform.finalize()
177
175
        return (limbodir, deletiondir)
178
176
 
179
 
    def test_merge_with_existing_limbo(self):
180
 
        wt = self.make_branch_and_tree('this')
181
 
        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
182
 
        os.mkdir(limbodir)
 
177
    def test_merge_with_existing_limbo_empty(self):
 
178
        """Empty limbo dir is just cleaned up - see bug 427773"""
 
179
        wt = self.make_branch_and_tree('this')
 
180
        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
 
181
        os.mkdir(limbodir)
 
182
        self.do_merge(wt, wt)
 
183
 
 
184
    def test_merge_with_existing_limbo_non_empty(self):
 
185
        wt = self.make_branch_and_tree('this')
 
186
        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
 
187
        os.mkdir(limbodir)
 
188
        os.mkdir(os.path.join(limbodir, 'something'))
183
189
        self.assertRaises(errors.ExistingLimbo, self.do_merge, wt, wt)
184
190
        self.assertRaises(errors.LockError, wt.unlock)
185
191
 
186
 
    def test_merge_with_pending_deletion(self):
187
 
        wt = self.make_branch_and_tree('this')
188
 
        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
189
 
        os.mkdir(deletiondir)
 
192
    def test_merge_with_pending_deletion_empty(self):
 
193
        wt = self.make_branch_and_tree('this')
 
194
        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
 
195
        os.mkdir(deletiondir)
 
196
        self.do_merge(wt, wt)
 
197
 
 
198
    def test_merge_with_pending_deletion_non_empty(self):
 
199
        """Also see bug 427773"""
 
200
        wt = self.make_branch_and_tree('this')
 
201
        (limbodir, deletiondir) =  self.get_limbodir_deletiondir(wt)
 
202
        os.mkdir(deletiondir)
 
203
        os.mkdir(os.path.join(deletiondir, 'something'))
190
204
        self.assertRaises(errors.ExistingPendingDeletion, self.do_merge, wt, wt)
191
205
        self.assertRaises(errors.LockError, wt.unlock)
192
206