/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/selftest/versioning.py

  • Committer: Martin Pool
  • Date: 2005-06-28 03:02:31 UTC
  • Revision ID: mbp@sourcefrog.net-20050628030231-d311e4ebcd467ef4
Merge John's import-speedup branch:

                                                                                         
  777 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:20:32 -0500
      revision-id: john@arbash-meinel.com-20050627032031-e82a50db3863b18e
      bzr selftest was not using the correct bzr

  776 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:20:22 -0500
      revision-id: john@arbash-meinel.com-20050627032021-c9f21fde989ddaee
      Add was using an old mutter

  775 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:02:33 -0500
      revision-id: john@arbash-meinel.com-20050627030233-9165cfe98fc63298
      Cleaned up to be less different

  774 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:54:53 -0500
      revision-id: john@arbash-meinel.com-20050627025452-4260d0e744edef43
      Allow BZR_PLUGIN_PATH='' to negate plugin loading.

  773 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:49:34 -0500
      revision-id: john@arbash-meinel.com-20050627024933-b7158f67b7b9eae5
      Finished the previous cleanup (allowing load_plugins to be called twice)

  772 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:45:08 -0500
      revision-id: john@arbash-meinel.com-20050627024508-723b1df510d196fc
      Work on making the tests pass. versioning.py is calling run_cmd directly, but plugins have been loaded.

  771 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:32:29 -0500
      revision-id: john@arbash-meinel.com-20050627023228-79972744d7c53e15
      Got it down a little bit more by removing import of tree and inventory.

  770 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:26:05 -0500
      revision-id: john@arbash-meinel.com-20050627022604-350b9773ef622f95
      Reducing the number of import from bzrlib/__init__.py and bzrlib/branch.py

  769 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:32:25 -0500
      revision-id: john@arbash-meinel.com-20050627013225-32dd044f10d23948
      Updated revision.py and xml.py to include SubElement.

  768 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:03:56 -0500
      revision-id: john@arbash-meinel.com-20050627010356-ee66919e1c377faf
      Minor typo

  767 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:03:13 -0500
      revision-id: john@arbash-meinel.com-20050627010312-40d024007eb85051
      Caching the import

  766 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:51:47 -0500
      revision-id: john@arbash-meinel.com-20050627005147-5281c99e48ed1834
      Created wrapper functions for lazy import of ElementTree

  765 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:46:37 -0500
      revision-id: john@arbash-meinel.com-20050627004636-bf432902004a94c5
      Removed all of the test imports of cElementTree

  764 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:43:59 -0500
      revision-id: john@arbash-meinel.com-20050627004358-d137fbe9570dd71b
      Trying to make bzr startup faster.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests of simple versioning operations"""
19
19
 
20
 
# TODO: test adding a file whose directory is not versioned
21
 
# TODO: test trying to commit within a directory that is not yet added
22
 
 
23
 
 
24
 
import os
25
 
from bzrlib.selftest import InTempDir, BzrTestBase
26
 
from bzrlib.branch import Branch
27
 
 
 
20
 
 
21
from bzrlib.selftest import InTempDir
28
22
 
29
23
class Mkdir(InTempDir):
30
24
    def runTest(self): 
31
25
        """Basic 'bzr mkdir' operation"""
32
26
        from bzrlib.commands import run_bzr
 
27
        import os
33
28
 
34
 
        run_bzr(['init'])
35
 
        run_bzr(['mkdir', 'foo'])
 
29
        run_bzr(['bzr', 'init'])
 
30
        run_bzr(['bzr', 'mkdir', 'foo'])
36
31
        self.assert_(os.path.isdir('foo'))
37
32
 
38
 
        self.assertRaises(OSError, run_bzr, ['mkdir', 'foo'])
 
33
        self.assertRaises(OSError, run_bzr, ['bzr', 'mkdir', 'foo'])
39
34
 
40
 
        from bzrlib.diff import compare_trees
 
35
        from bzrlib.diff import compare_trees, TreeDelta
41
36
        from bzrlib.branch import Branch
42
37
        b = Branch('.')
43
38
        
44
39
        delta = compare_trees(b.basis_tree(), b.working_tree())
45
40
 
46
 
        self.log('delta.added = %r' % delta.added)
47
 
 
48
41
        self.assertEquals(len(delta.added), 1)
49
42
        self.assertEquals(delta.added[0][0], 'foo')
50
43
        self.failIf(delta.modified)
59
52
        branch add doesn't do that.
60
53
        """
61
54
        from bzrlib.branch import Branch
 
55
        import os
62
56
        from bzrlib.errors import NotVersionedError
63
57
 
64
58
        b = Branch('.', init=True)
70
64
                          b.add,
71
65
                          'foo/hello')
72
66
        
73
 
        
74
 
class SubdirCommit(BzrTestBase):
75
 
    def runTest(self):
76
 
        """Test committing a subdirectory, and committing within a directory."""
77
 
        run_bzr = self.run_bzr
78
 
        eq = self.assertEqual
79
 
 
80
 
        self.build_tree(['a/', 'b/'])
81
 
        
82
 
        run_bzr('init')
83
 
        b = Branch('.')
84
 
        
85
 
        for fn in ('a/one', 'b/two', 'top'):
86
 
            file(fn, 'w').write('old contents')
87
 
            
88
 
        run_bzr('add')
89
 
        run_bzr('commit', '-m', 'first revision')
90
 
        
91
 
        for fn in ('a/one', 'b/two', 'top'):
92
 
            file(fn, 'w').write('new contents')
93
 
            
94
 
        run_bzr('commit', 'a', '-m', 'commit a only')
95
 
        
96
 
        old = b.revision_tree(b.lookup_revision(1))
97
 
        new = b.revision_tree(b.lookup_revision(2))
98
 
        
99
 
        eq(new.get_file_by_path('b/two').read(), 'old contents')
100
 
        eq(new.get_file_by_path('top').read(), 'old contents')
101
 
        eq(new.get_file_by_path('a/one').read(), 'new contents')
102
 
        
103
 
        os.chdir('a')
104
 
        # commit from here should do nothing
105
 
        run_bzr('commit', '.', '-m', 'commit subdir only', '--unchanged')
106
 
        v3 = b.revision_tree(b.lookup_revision(3))
107
 
        eq(v3.get_file_by_path('b/two').read(), 'old contents')
108
 
        eq(v3.get_file_by_path('top').read(), 'old contents')
109
 
        eq(v3.get_file_by_path('a/one').read(), 'new contents')
110
 
                
111
 
        # commit in subdirectory commits whole tree
112
 
        run_bzr('commit', '-m', 'commit whole tree from subdir')
113
 
        v4 = b.revision_tree(b.lookup_revision(4))
114
 
        eq(v4.get_file_by_path('b/two').read(), 'new contents')        
115
 
        eq(v4.get_file_by_path('top').read(), 'new contents')
116
 
        
117
 
        # TODO: factor out some kind of assert_tree_state() method
118
 
        
119
 
        
120
 
        
121
 
class SubdirAdd(InTempDir):
122
 
    def runTest(self):
123
 
        """Add in subdirectory should add only things from there down"""
124
 
        
125
 
        from bzrlib.branch import Branch
126
 
        from bzrlib.commands import run_bzr
127
 
        
128
 
        eq = self.assertEqual
129
 
        ass = self.assert_
130
 
        chdir = os.chdir
131
 
        
132
 
        b = Branch('.', init=True)
133
 
        self.build_tree(['src/', 'README'])
134
 
        
135
 
        eq(sorted(b.unknowns()),
136
 
           ['README', 'src'])
137
 
        
138
 
        eq(run_bzr(['add', 'src']), 0)
139
 
        
140
 
        self.build_tree(['src/foo.c'])
141
 
        
142
 
        chdir('src')
143
 
        eq(run_bzr(['add']), 0)
144
 
        
145
 
        eq(sorted(b.unknowns()), 
146
 
           ['README'])
147
 
        eq(len(b.inventory), 3)
148
 
                
149
 
        chdir('..')
150
 
        eq(run_bzr(['add']), 0)
151
 
        eq(list(b.unknowns()), [])
152