~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_smart_add.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009-2012, 2016 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
25
25
    ignores,
26
26
    osutils,
27
27
    tests,
 
28
    trace,
28
29
    )
29
30
from bzrlib.tests import (
 
31
    features,
 
32
    per_workingtree,
30
33
    test_smart_add,
31
 
    per_workingtree,
32
34
    )
33
35
 
34
36
 
90
92
        for path in paths:
91
93
            self.assertNotEqual(wt.path2id(path), None)
92
94
 
 
95
    def test_skip_nested_trees(self):
 
96
        """Test smart-adding a nested tree ignors it and warns."""
 
97
        wt = self.make_branch_and_tree('.')
 
98
        nested_wt = self.make_branch_and_tree('nested')
 
99
        warnings = []
 
100
        def warning(*args):
 
101
            warnings.append(args[0] % args[1:])
 
102
        self.overrideAttr(trace, 'warning', warning)
 
103
        wt.smart_add((u".",))
 
104
        self.assertIs(wt.path2id("nested"), None)
 
105
        self.assertEqual(
 
106
            ['skipping nested tree %r' % nested_wt.basedir], warnings)
 
107
 
93
108
    def test_add_dot_from_subdir(self):
94
109
        """Test adding . from a subdir of the tree."""
95
110
        paths = ("original/", "original/file1", "original/file2")
120
135
 
121
136
        self.build_tree(build_paths)
122
137
        wt = self.make_branch_and_tree('.')
 
138
        if wt.user_url != wt.branch.user_url:
 
139
            # Lightweight checkout, make sure we have a repo location.
 
140
            wt.branch.bzrdir.root_transport.mkdir('original')
123
141
        child_tree = self.make_branch_and_tree('original/child')
124
142
        wt.smart_add((".",))
125
143
        for path in paths:
149
167
        self.build_tree(tree_shape)
150
168
        wt.smart_add(add_paths)
151
169
        for path in expected_paths:
152
 
            self.assertNotEqual(wt.path2id(path), None, "No id added for %s" % path)
 
170
            self.assertNotEqual(wt.path2id(path), None,
 
171
                "No id added for %s" % path)
153
172
 
154
173
    def test_add_non_existant(self):
155
174
        """Test smart-adding a file that does not exist."""
288
307
 
289
308
class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree):
290
309
 
291
 
    _test_needs_features = [tests.UnicodeFilenameFeature]
 
310
    _test_needs_features = [features.UnicodeFilenameFeature]
292
311
 
293
312
    def setUp(self):
294
313
        super(TestSmartAddTreeUnicode, self).setUp()