/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_switch.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-12 18:05:15 UTC
  • mto: (4371.4.5 vila-better-heads)
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090612180515-t0cwbjsnve094oik
Add a failing test for handling nodes that are in the same linear chain.

It fails because the ancestry skipping causes us to miss the fact that the two nodes
are actually directly related. We could check at the beginning, as the 
code used to do, but I think that will be incomplete for the more-than-two
heads cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007 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
19
19
 
20
20
import os
21
21
 
22
 
from bzrlib import (
23
 
    branch,
24
 
    errors,
25
 
    merge as _mod_merge,
26
 
    switch,
27
 
    tests,
28
 
)
 
22
from bzrlib import branch, errors, switch, tests
29
23
 
30
24
 
31
25
class TestSwitch(tests.TestCaseWithTransport):
106
100
        self.assertContainsRe(str(err),
107
101
            "Pending merges must be committed or reverted before using switch")
108
102
 
109
 
    def test_switch_with_revision(self):
110
 
        """Test switch when a revision is given."""
111
 
        # Create a tree with 2 revisions
112
 
        tree = self.make_branch_and_tree('branch-1')
113
 
        self.build_tree(['branch-1/file-1'])
114
 
        tree.add('file-1')
115
 
        tree.commit(rev_id='rev1', message='rev1')
116
 
        self.build_tree(['branch-1/file-2'])
117
 
        tree.add('file-2')
118
 
        tree.commit(rev_id='rev2', message='rev2')
119
 
        # Check it out and switch to revision 1
120
 
        checkout = tree.branch.create_checkout('checkout',
121
 
            lightweight=self.lightweight)
122
 
        switch.switch(checkout.bzrdir, tree.branch, revision_id="rev1")
123
 
        self.failUnlessExists('checkout/file-1')
124
 
        self.failIfExists('checkout/file-2')
125
 
 
126
 
    def test_switch_changing_root_id(self):
127
 
        tree = self._setup_tree()
128
 
        tree2 = self.make_branch_and_tree('tree-2')
129
 
        tree2.set_root_id('custom-root-id')
130
 
        self.build_tree(['tree-2/file-2'])
131
 
        tree2.add(['file-2'])
132
 
        tree2.commit('rev1b')
133
 
        checkout = tree.branch.create_checkout('checkout',
134
 
            lightweight=self.lightweight)
135
 
        switch.switch(checkout.bzrdir, tree2.branch)
136
 
        self.assertEqual('custom-root-id', tree2.get_root_id())
137
 
 
138
 
    def test_switch_configurable_file_merger(self):
139
 
        class DummyMerger(_mod_merge.ConfigurableFileMerger):
140
 
            name_prefix = 'file'
141
 
 
142
 
        _mod_merge.Merger.hooks.install_named_hook(
143
 
            'merge_file_content', DummyMerger,
144
 
            'test factory')
145
 
        foo = self.make_branch('foo')
146
 
        checkout = foo.create_checkout('checkout', lightweight=True)
147
 
        self.build_tree_contents([('checkout/file', 'a')])
148
 
        checkout.add('file')
149
 
        checkout.commit('a')
150
 
        bar = foo.bzrdir.sprout('bar').open_workingtree()
151
 
        self.build_tree_contents([('bar/file', 'b')])
152
 
        bar.commit('b')
153
 
        self.build_tree_contents([('checkout/file', 'c')])
154
 
        switch.switch(checkout.bzrdir, bar.branch)
155
 
 
156
103
 
157
104
class TestSwitchHeavyweight(TestSwitch):
158
105