/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/workingtree_implementations/test_unversion.py

  • Committer: John Arbash Meinel
  • Date: 2007-10-23 21:48:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2930.
  • Revision ID: john@arbash-meinel.com-20071023214830-5mlzu2mjcmnx7znz
Add another direct test in unversion, because the other test
did not trigger the 'delete a file in another directory' bug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests of the WorkingTree.unversion API."""
18
18
 
19
 
from bzrlib import errors
 
19
from bzrlib import (
 
20
    errors,
 
21
    osutils,
 
22
    )
20
23
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
21
24
 
22
25
 
137
140
                          ('dir2/f3', 'f3-id'),
138
141
                         ], paths)
139
142
 
 
143
    def test_unversion_after_conflicted_merge(self):
 
144
        # Test for bug #114615
 
145
        tree_a = self.make_branch_and_tree('A')
 
146
        self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
 
147
        tree_a.add(['a', 'a/m', 'a/n'], ['a-id', 'm-id', 'n-id'])
 
148
        tree_a.commit('init')
 
149
 
 
150
        tree_a.lock_read()
 
151
        try:
 
152
            root_id = tree_a.inventory.root.file_id
 
153
        finally:
 
154
            tree_a.unlock()
 
155
 
 
156
        tree_b = tree_a.bzrdir.sprout('B').open_workingtree()
 
157
        self.build_tree(['B/xyz/'])
 
158
        tree_b.add(['xyz'], ['xyz-id'])
 
159
        tree_b.rename_one('a/m', 'xyz/m')
 
160
        tree_b.unversion(['a-id'])
 
161
        tree_b.commit('delete in B')
 
162
 
 
163
        paths = [(path, ie.file_id)
 
164
                 for path, ie in tree_b.iter_entries_by_dir()]
 
165
        self.assertEqual([('', root_id),
 
166
                          ('xyz', 'xyz-id'),
 
167
                          ('xyz/m', 'm-id'),
 
168
                         ], paths)
 
169
 
 
170
        self.build_tree_contents([('A/a/n', 'new contents for n\n')])
 
171
        tree_a.commit('change n in A')
 
172
 
 
173
        # Merging from A should introduce conflicts because 'n' was modified
 
174
        # and removed, so 'a' needs to be restored. We also have a conflict
 
175
        # because 'a' is still an existing directory
 
176
        num_conflicts = tree_b.merge_from_branch(tree_a.branch)
 
177
        self.assertEqual(4, num_conflicts)
 
178
        paths = [(path, ie.file_id)
 
179
                 for path, ie in tree_b.iter_entries_by_dir()]
 
180
        self.assertEqual([('', root_id),
 
181
                          ('a', 'a-id'),
 
182
                          ('xyz', 'xyz-id'),
 
183
                          ('a/n.OTHER', 'n-id'),
 
184
                          ('xyz/m', 'm-id'),
 
185
                         ], paths)
 
186
        tree_b.unversion(['a-id'])
 
187
        paths = [(path, ie.file_id)
 
188
                 for path, ie in tree_b.iter_entries_by_dir()]
 
189
        self.assertEqual([('', root_id),
 
190
                          ('xyz', 'xyz-id'),
 
191
                          ('xyz/m', 'm-id'),
 
192
                         ], paths)