~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_add.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-26 23:30:56 UTC
  • mfrom: (2044.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060926233056-203e713964b2cd51
(Robert Collins) Forward merge from 0.11rc2 NEWS and performance-regression fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        """add command prints the names of added files."""
29
29
        self.runbzr('init')
30
30
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
 
31
        self.build_tree_contents([('.bzrignore', 'CVS\n')])
31
32
        out = self.run_bzr_captured(['add'], retcode=0)[0]
32
33
        # the ordering is not defined at the moment
33
34
        results = sorted(out.rstrip('\n').split('\n'))
34
35
        self.assertEquals(['If you wish to add some of these files, please'\
35
36
                           ' add them by name.',
 
37
                           'added .bzrignore',
36
38
                           'added dir',
37
39
                           'added dir/sub.txt',
38
40
                           'added top.txt',
93
95
    def test_subdir_add(self):
94
96
        """Add in subdirectory should add only things from there down"""
95
97
        from bzrlib.workingtree import WorkingTree
96
 
        
 
98
 
97
99
        eq = self.assertEqual
98
 
        ass = self.assert_
 
100
        ass = self.assertTrue
99
101
        chdir = os.chdir
100
102
        
101
103
        t = self.make_branch_and_tree('.')
119
121
        self.run_bzr('add')
120
122
        self.assertEquals(self.capture('unknowns'), '')
121
123
        self.run_bzr('check')
 
124
 
 
125
    def test_add_missing(self):
 
126
        """bzr add foo where foo is missing should error."""
 
127
        self.make_branch_and_tree('.')
 
128
        self.run_bzr('add', 'missing-file', retcode=3)
 
129
 
 
130
    def test_add_from(self):
 
131
        base_tree = self.make_branch_and_tree('base')
 
132
        self.build_tree(['base/a', 'base/b/', 'base/b/c'])
 
133
        base_tree.add(['a', 'b', 'b/c'])
 
134
        base_tree.commit('foo')
 
135
 
 
136
        new_tree = self.make_branch_and_tree('new')
 
137
        self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd'])
 
138
 
 
139
        os.chdir('new')
 
140
        out, err = self.run_bzr('add', '--file-ids-from', '../base')
 
141
        self.assertEqual('', err)
 
142
        self.assertEqualDiff('added a w/ file id from a\n'
 
143
                             'added b w/ file id from b\n'
 
144
                             'added b/c w/ file id from b/c\n',
 
145
                             out)
 
146
 
 
147
        new_tree.read_working_inventory()
 
148
        self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a'))
 
149
        self.assertEqual(base_tree.path2id('b'), new_tree.path2id('b'))
 
150
        self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('b/c'))
 
151
 
 
152
    def test_add_from_subdir(self):
 
153
        base_tree = self.make_branch_and_tree('base')
 
154
        self.build_tree(['base/a', 'base/b/', 'base/b/c', 'base/b/d'])
 
155
        base_tree.add(['a', 'b', 'b/c', 'b/d'])
 
156
        base_tree.commit('foo')
 
157
 
 
158
        new_tree = self.make_branch_and_tree('new')
 
159
        self.build_tree(['new/c', 'new/d'])
 
160
 
 
161
        os.chdir('new')
 
162
        out, err = self.run_bzr('add', '--file-ids-from', '../base/b')
 
163
        self.assertEqual('', err)
 
164
        self.assertEqualDiff('added c w/ file id from b/c\n'
 
165
                             'added d w/ file id from b/d\n',
 
166
                             out)
 
167
 
 
168
        new_tree.read_working_inventory()
 
169
        self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('c'))
 
170
        self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d'))
 
171
 
 
172
    def test_add_dry_run(self):
 
173
        # ensure that --dry-run actually don't add anything
 
174
        base_tree = self.make_branch_and_tree('.')
 
175
        self.build_tree(['spam'])
 
176
        out = self.run_bzr_captured(['add', '--dry-run'], retcode=0)[0]
 
177
        self.assertEquals('added spam\n', out)
 
178
        out = self.run_bzr_captured(['added'], retcode=0)[0]
 
179
        self.assertEquals('', out)