~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-08-10 01:16:16 UTC
  • mto: (1904.1.2 0.9)
  • mto: This revision was merged to the branch mainline in revision 1913.
  • Revision ID: mbp@sourcefrog.net-20060810011616-d74881eba696e746
compare_trees is deprecated in 0.9 not 0.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
 
20
20
import os
21
21
 
 
22
from bzrlib import ignores
 
23
 
22
24
from bzrlib.tests.blackbox import ExternalBase
23
25
 
24
26
 
26
28
        
27
29
    def test_add_reports(self):
28
30
        """add command prints the names of added files."""
 
31
        ignores._set_user_ignores(['./.bazaar'])
 
32
 
29
33
        self.runbzr('init')
30
34
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
31
35
        self.build_tree_contents([('.bzrignore', 'CVS\n')])
38
42
                           'added dir',
39
43
                           'added dir/sub.txt',
40
44
                           'added top.txt',
41
 
                           'ignored 1 file(s).'],
 
45
                           'ignored 2 file(s).'],
42
46
                          results)
43
47
        out = self.run_bzr_captured(['add', '-v'], retcode=0)[0]
44
48
        results = sorted(out.rstrip('\n').split('\n'))
45
49
        self.assertEquals(['If you wish to add some of these files, please'\
46
50
                           ' add them by name.',
 
51
                           'ignored .bazaar matching "./.bazaar"',
47
52
                           'ignored CVS matching "CVS"'],
48
53
                          results)
49
54
 
61
66
 
62
67
        "bzr add" should add the parent(s) as necessary.
63
68
        """
 
69
        ignores._set_user_ignores(['./.bazaar'])
 
70
 
64
71
        self.runbzr('init')
65
72
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
66
73
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
84
91
 
85
92
        "bzr add" should do this happily.
86
93
        """
 
94
        ignores._set_user_ignores(['./.bazaar'])
 
95
 
87
96
        self.runbzr('init')
88
97
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
89
98
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
96
105
        """Add in subdirectory should add only things from there down"""
97
106
        from bzrlib.workingtree import WorkingTree
98
107
 
 
108
        ignores._set_user_ignores(['./.bazaar'])
99
109
        eq = self.assertEqual
100
110
        ass = self.assertTrue
101
111
        chdir = os.chdir
126
136
        """bzr add foo where foo is missing should error."""
127
137
        self.make_branch_and_tree('.')
128
138
        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)