~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_whitebox.py

  • Committer: Martin Pool
  • Date: 2006-02-01 12:24:35 UTC
  • mfrom: (1534.4.32 branch-formats)
  • mto: This revision was merged to the branch mainline in revision 1553.
  • Revision ID: mbp@sourcefrog.net-20060201122435-53f3efb1b5749fe1
[merge] branch-formats branch, and reconcile changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
import unittest
3
3
 
4
 
from bzrlib.tests import TestCaseInTempDir, TestCase
 
4
from bzrlib.tests import TestCaseWithTransport, TestCase
5
5
from bzrlib.branch import ScratchBranch, Branch
6
6
from bzrlib.errors import PathNotChild
7
7
from bzrlib.osutils import relpath, pathjoin, abspath, realpath
8
8
 
9
9
 
10
 
class TestBranch(TestCaseInTempDir):
11
 
 
12
 
    def test_no_changes(self):
13
 
        from bzrlib.errors import PointlessCommit
14
 
        
15
 
        b = Branch.initialize(u'.')
16
 
 
17
 
        self.build_tree(['hello.txt'])
18
 
 
19
 
        self.assertRaises(PointlessCommit,
20
 
                          b.working_tree().commit,
21
 
                          'commit without adding',
22
 
                          allow_pointless=False)
23
 
 
24
 
        b.working_tree().commit('commit pointless tree',
25
 
                 allow_pointless=True)
26
 
 
27
 
        b.working_tree().add('hello.txt')
28
 
        
29
 
        b.working_tree().commit('commit first added file',
30
 
                 allow_pointless=False)
31
 
        
32
 
        self.assertRaises(PointlessCommit,
33
 
                          b.working_tree().commit,
34
 
                          'commit after adding file',
35
 
                          allow_pointless=False)
36
 
        
37
 
        b.working_tree().commit('commit pointless revision with one file',
38
 
                 allow_pointless=True)
39
 
 
40
 
 
41
 
class MoreTests(TestCaseInTempDir):
42
 
 
43
 
    def test_rename_dirs(self):
44
 
        """Test renaming directories and the files within them."""
45
 
        b = Branch.initialize(u'.')
46
 
        self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
47
 
        b.working_tree().add(['dir', 'dir/sub', 'dir/sub/file'])
48
 
 
49
 
        b.working_tree().commit('create initial state')
50
 
 
51
 
        # TODO: lift out to a test helper that checks the shape of
52
 
        # an inventory
53
 
        
54
 
        revid = b.revision_history()[0]
55
 
        self.log('first revision_id is {%s}' % revid)
56
 
        
57
 
        inv = b.repository.get_revision_inventory(revid)
58
 
        self.log('contents of inventory: %r' % inv.entries())
59
 
 
60
 
        self.check_inventory_shape(inv,
61
 
                                   ['dir', 'dir/sub', 'dir/sub/file'])
62
 
 
63
 
        b.working_tree().rename_one('dir', 'newdir')
64
 
 
65
 
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
66
 
                                   ['newdir', 'newdir/sub', 'newdir/sub/file'])
67
 
 
68
 
        b.working_tree().rename_one('newdir/sub', 'newdir/newsub')
69
 
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
70
 
                                   ['newdir', 'newdir/newsub',
71
 
                                    'newdir/newsub/file'])
 
10
class MoreTests(TestCaseWithTransport):
72
11
 
73
12
    def test_relpath(self):
74
13
        """test for branch path lookups