~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-26 06:24:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2376.
  • Revision ID: andrew.bennetts@canonical.com-20070326062401-k3nbefzje5332jaf
Deal with review comments from Robert:

  * Add my name to the NEWS file
  * Move the test case to a new module in branch_implementations
  * Remove revision_history cruft from identitymap and test_identitymap
  * Improve some docstrings

Also, this fixes a bug where revision_history was not returning a copy of the
cached data, allowing the cache to be corrupted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.bzrdir import BzrDir
29
29
from bzrlib.lockdir import LockDir
30
30
from bzrlib.mutabletree import needs_tree_write_lock
 
31
from bzrlib.symbol_versioning import zero_thirteen
31
32
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
32
33
from bzrlib.transport import get_transport
33
34
from bzrlib.workingtree import (
93
94
        """See WorkingTreeFormat.get_format_string()."""
94
95
        return "Sample tree format."
95
96
 
96
 
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
97
 
                   accelerator_tree=None, hardlink=False):
 
97
    def initialize(self, a_bzrdir, revision_id=None):
98
98
        """Sample branches cannot be created."""
99
99
        t = a_bzrdir.get_workingtree_transport(self)
100
100
        t.put_bytes('format', self.get_format_string())
216
216
        control.create_repository()
217
217
        control.create_branch()
218
218
        tree = workingtree.WorkingTreeFormat3().initialize(control)
219
 
        tree._transport.delete("pending-merges")
 
219
        tree._control_files._transport.delete("pending-merges")
220
220
        self.assertEqual([], tree.get_parent_ids())
221
221
 
222
222
 
250
250
        self.assertEqual(list(tree.conflicts()), [expected])
251
251
 
252
252
 
 
253
class TestNonFormatSpecificCode(TestCaseWithTransport):
 
254
    """This class contains tests of workingtree that are not format specific."""
 
255
 
 
256
    def test_gen_file_id(self):
 
257
        file_id = self.applyDeprecated(zero_thirteen, workingtree.gen_file_id,
 
258
                                      'filename')
 
259
        self.assertStartsWith(file_id, 'filename-')
 
260
 
 
261
    def test_gen_root_id(self):
 
262
        file_id = self.applyDeprecated(zero_thirteen, workingtree.gen_root_id)
 
263
        self.assertStartsWith(file_id, 'tree_root-')
 
264
        
 
265
 
253
266
class InstrumentedTree(object):
254
267
    """A instrumented tree to check the needs_tree_write_lock decorator."""
255
268
 
296
309
        self.assertEqual(['t', 'u', 't', 'u'], tree._locks)
297
310
 
298
311
 
299
 
class TestRevert(TestCaseWithTransport):
300
 
 
301
 
    def test_revert_conflicts_recursive(self):
302
 
        this_tree = self.make_branch_and_tree('this-tree')
303
 
        self.build_tree_contents([('this-tree/foo/',),
304
 
                                  ('this-tree/foo/bar', 'bar')])
305
 
        this_tree.add(['foo', 'foo/bar'])
306
 
        this_tree.commit('created foo/bar')
307
 
        other_tree = this_tree.bzrdir.sprout('other-tree').open_workingtree()
308
 
        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
309
 
        other_tree.commit('changed bar')
310
 
        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
311
 
        this_tree.commit('changed qux')
312
 
        this_tree.merge_from_branch(other_tree.branch)
313
 
        self.assertEqual(1, len(this_tree.conflicts()))
314
 
        this_tree.revert(['foo'])
315
 
        self.assertEqual(0, len(this_tree.conflicts()))
316
 
 
317
 
 
318
312
class TestAutoResolve(TestCaseWithTransport):
319
313
 
320
314
    def test_auto_resolve(self):
362
356
        file_conflict = conflicts.TextConflict('file', None, 'hello-id')
363
357
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
364
358
        tree.auto_resolve()
365
 
 
366
 
 
367
 
class TestFindTrees(TestCaseWithTransport):
368
 
 
369
 
    def test_find_trees(self):
370
 
        self.make_branch_and_tree('foo')
371
 
        self.make_branch_and_tree('foo/bar')
372
 
        # Sticking a tree inside a control dir is heinous, so let's skip it
373
 
        self.make_branch_and_tree('foo/.bzr/baz')
374
 
        self.make_branch('qux')
375
 
        trees = workingtree.WorkingTree.find_trees('.')
376
 
        self.assertEqual(2, len(list(trees)))