/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/test_commit_merge.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) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009, 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
16
16
 
17
17
 
18
18
import os
19
 
import shutil
20
19
 
21
 
from bzrlib import check, osutils
22
 
from bzrlib.branch import Branch
23
 
from bzrlib.errors import PointlessCommit, BzrError
 
20
from bzrlib import (
 
21
    check,
 
22
    osutils,
 
23
    revision as _mod_revision,
 
24
    )
 
25
from bzrlib.errors import PointlessCommit
24
26
from bzrlib.tests import (
 
27
    TestCaseWithTransport,
 
28
    )
 
29
from bzrlib.tests.features import (
25
30
    SymlinkFeature,
26
 
    TestCaseWithTransport,
27
31
    )
28
 
from bzrlib.tests.test_revision import make_branches
29
32
 
30
33
 
31
34
class TestCommitMerge(TestCaseWithTransport):
56
59
        wty.commit('merge from x', rev_id='y@u-0-2', allow_pointless=False)
57
60
 
58
61
        self.assertEquals(by.revno(), 3)
59
 
        self.assertEquals(list(by.revision_history()),
60
 
                          [base_rev, 'y@u-0-1', 'y@u-0-2'])
 
62
        graph = wty.branch.repository.get_graph()
 
63
        self.addCleanup(wty.lock_read().unlock)
 
64
        self.assertEquals(list(
 
65
            graph.iter_lefthand_ancestry(by.last_revision(),
 
66
                [_mod_revision.NULL_REVISION])),
 
67
            ['y@u-0-2', 'y@u-0-1', base_rev])
61
68
        rev = by.repository.get_revision('y@u-0-2')
62
69
        self.assertEquals(rev.parent_ids,
63
70
                          ['y@u-0-1', 'x@u-0-1'])
92
99
 
93
100
        wty.commit('merge from x', rev_id='y@u-0-2', allow_pointless=False)
94
101
        tree = by.repository.revision_tree('y@u-0-2')
95
 
        inv = tree.inventory
96
 
        self.assertEquals(inv['ecks-id'].revision, 'x@u-0-1')
97
 
        self.assertEquals(inv['why-id'].revision, 'y@u-0-1')
 
102
        self.assertEquals(tree.get_file_revision('ecks-id'), 'x@u-0-1')
 
103
        self.assertEquals(tree.get_file_revision('why-id'), 'y@u-0-1')
98
104
 
99
105
        check.check_dwim(bx.base, False, True, True)
100
106
        check.check_dwim(by.base, False, True, True)