/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/tests/blackbox/test_add.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-17 19:08:25 UTC
  • mto: This revision was merged to the branch mainline in revision 4460.
  • Revision ID: john@arbash-meinel.com-20090617190825-ktfk82li57rf2im6
It seems that fetch() no longer returns the number of revisions fetched.
It still does for *some* InterRepository fetch paths, but the generic one does not.
It is also not easy to get it to, since the Source and Sink are the ones
that would know how many keys were transmitted, and they are potentially 'remote'
objects.

This was also only tested to occur as a by-product in a random 'test_commit' test.
I assume if we really wanted the assurance, we would have a per_repo or interrepo
test for it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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 (
23
 
    osutils,
24
 
    tests,
 
22
from bzrlib import osutils
 
23
from bzrlib.tests import (
 
24
    condition_isinstance,
 
25
    split_suite_by_condition,
 
26
    multiply_tests,
 
27
    SymlinkFeature
25
28
    )
 
29
from bzrlib.tests.blackbox import ExternalBase
 
30
from bzrlib.tests.test_win32utils import NeedsGlobExpansionFeature
26
31
 
27
32
 
28
33
def load_tests(standard_tests, module, loader):
29
34
    """Parameterize tests for view-aware vs not."""
30
 
    to_adapt, result = tests.split_suite_by_condition(
31
 
        standard_tests, tests.condition_isinstance(TestAdd))
 
35
    to_adapt, result = split_suite_by_condition(
 
36
        standard_tests, condition_isinstance(TestAdd))
32
37
    scenarios = [
33
38
        ('pre-views', {'branch_tree_format': 'pack-0.92'}),
34
39
        ('view-aware', {'branch_tree_format': 'development6-rich-root'}),
35
40
        ]
36
 
    return tests.multiply_tests(to_adapt, scenarios, result)
37
 
 
38
 
 
39
 
class TestAdd(tests.TestCaseWithTransport):
 
41
    return multiply_tests(to_adapt, scenarios, result)
 
42
 
 
43
 
 
44
class TestAdd(ExternalBase):
40
45
 
41
46
    def make_branch_and_tree(self, dir):
42
 
        return super(TestAdd, self).make_branch_and_tree(
43
 
            dir, format=self.branch_tree_format)
 
47
        return ExternalBase.make_branch_and_tree(self, dir,
 
48
            format=self.branch_tree_format)
44
49
 
45
50
    def test_add_reports(self):
46
51
        """add command prints the names of added files."""
50
55
        out = self.run_bzr('add')[0]
51
56
        # the ordering is not defined at the moment
52
57
        results = sorted(out.rstrip('\n').split('\n'))
53
 
        self.assertEquals(['adding .bzrignore',
 
58
        self.assertEquals(['If you wish to add ignored files, '
 
59
                           'please add them explicitly by name. '
 
60
                           '("bzr ignored" gives a list)',
 
61
                           'adding .bzrignore',
54
62
                           'adding dir',
55
63
                           'adding dir/sub.txt',
56
 
                           'adding top.txt'],
 
64
                           'adding top.txt',
 
65
                           'ignored 1 file(s).'],
57
66
                          results)
58
67
        out = self.run_bzr('add -v')[0]
59
68
        results = sorted(out.rstrip('\n').split('\n'))
60
 
        self.assertEquals(['ignored CVS matching "CVS"'],
 
69
        self.assertEquals(['If you wish to add ignored files, '\
 
70
                           'please add them explicitly by name. ("bzr ignored" gives a list)',
 
71
                           'ignored CVS matching "CVS"'],
61
72
                          results)
62
73
 
63
74
    def test_add_quiet_is(self):
111
122
 
112
123
        eq = self.assertEqual
113
124
        ass = self.assertTrue
 
125
        chdir = os.chdir
114
126
 
115
127
        t = self.make_branch_and_tree('.')
116
128
        b = t.branch
125
137
 
126
138
        # add with no arguments in a subdirectory gets only files below that
127
139
        # subdirectory
128
 
        self.run_bzr('add', working_dir='src')
129
 
        self.assertEquals('README\n',
130
 
                          self.run_bzr('unknowns', working_dir='src')[0])
 
140
        chdir('src')
 
141
        self.run_bzr('add')
 
142
        self.assertEquals(self.run_bzr('unknowns')[0], 'README\n')
131
143
        # reopen to see the new changes
132
 
        t = t.bzrdir.open_workingtree('src')
 
144
        t = t.bzrdir.open_workingtree()
133
145
        versioned = [path for path, entry in t.iter_entries_by_dir()]
134
 
        self.assertEquals(versioned, ['', 'src', 'src/foo.c'])
 
146
        self.assertEquals(versioned,
 
147
            ['', 'src', 'src/foo.c'])
135
148
 
136
149
        # add from the parent directory should pick up all file names
 
150
        chdir('..')
137
151
        self.run_bzr('add')
138
152
        self.assertEquals(self.run_bzr('unknowns')[0], '')
139
153
        self.run_bzr('check')
203
217
        err = self.run_bzr('add .bzr/crescent', retcode=3)[1]
204
218
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
205
219
 
 
220
    def test_add_with_wildcards(self):
 
221
        self.requireFeature(NeedsGlobExpansionFeature)
 
222
        self.make_branch_and_tree('.')
 
223
        self.build_tree(['a1', 'a2', 'b', 'c33'])
 
224
        self.run_bzr(['add', 'a?', 'c*'])
 
225
        self.assertEquals(self.run_bzr('unknowns')[0], 'b\n')
 
226
 
 
227
    def test_add_with_wildcards_unicode(self):
 
228
        self.requireFeature(NeedsGlobExpansionFeature)
 
229
        self.make_branch_and_tree('.')
 
230
        self.build_tree([u'\u1234A', u'\u1235A', u'\u1235AA', 'cc'])
 
231
        self.run_bzr(['add', u'\u1234?', u'\u1235*'])
 
232
        self.assertEquals(self.run_bzr('unknowns')[0], 'cc\n')
 
233
 
206
234
    def test_add_via_symlink(self):
207
 
        self.requireFeature(tests.SymlinkFeature)
 
235
        self.requireFeature(SymlinkFeature)
208
236
        self.make_branch_and_tree('source')
209
237
        self.build_tree(['source/top.txt'])
210
238
        os.symlink('source', 'link')
212
240
        self.assertEquals(out, 'adding top.txt\n')
213
241
 
214
242
    def test_add_symlink_to_abspath(self):
215
 
        self.requireFeature(tests.SymlinkFeature)
 
243
        self.requireFeature(SymlinkFeature)
216
244
        self.make_branch_and_tree('tree')
217
245
        os.symlink(osutils.abspath('target'), 'tree/link')
218
246
        out = self.run_bzr(['add', 'tree/link'])[0]