/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 breezy/tests/per_workingtree/test_smart_add.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
            wt.unlock()
85
85
        # and the disk state should be the same - reopen to check.
86
86
        wt = wt.controldir.open_workingtree()
87
 
        self.assertEqual(wt.path2id('file'), None)
 
87
        self.assertFalse(wt.is_versioned('file'))
88
88
 
89
89
    def test_add_dot_from_root(self):
90
90
        """Test adding . from the root of the tree."""
93
93
        wt = self.make_branch_and_tree('.')
94
94
        wt.smart_add((u".",))
95
95
        for path in paths:
96
 
            self.assertNotEqual(wt.path2id(path), None)
 
96
            self.assertTrue(wt.is_versioned(path))
97
97
 
98
98
    def test_skip_nested_trees(self):
99
99
        """Test smart-adding a nested tree ignors it and warns."""
104
104
            warnings.append(args[0] % args[1:])
105
105
        self.overrideAttr(trace, 'warning', warning)
106
106
        wt.smart_add((u".",))
107
 
        self.assertIs(wt.path2id("nested"), None)
 
107
        self.assertFalse(wt.is_versioned("nested"))
108
108
        self.assertEqual(
109
109
            ['skipping nested tree %r' % nested_wt.basedir], warnings)
110
110
 
115
115
        wt = self.make_branch_and_tree('.')
116
116
        wt.smart_add((u".",))
117
117
        for path in paths:
118
 
            self.assertNotEqual(wt.path2id(path), None)
 
118
            self.assertTrue(wt.is_versioned(path))
119
119
 
120
120
    def test_add_tree_from_above_tree(self):
121
121
        """Test adding a tree from above the tree."""
126
126
        wt = self.make_branch_and_tree('branch')
127
127
        wt.smart_add(("branch",))
128
128
        for path in paths:
129
 
            self.assertNotEqual(wt.path2id(path), None)
 
129
            self.assertTrue(wt.is_versioned(path))
130
130
 
131
131
    def test_add_above_tree_preserves_tree(self):
132
132
        """Test nested trees are not affect by an add above them."""
138
138
 
139
139
        self.build_tree(build_paths)
140
140
        wt = self.make_branch_and_tree('.')
141
 
        if wt.user_url != wt.branch.user_url:
 
141
        if wt.controldir.user_url != wt.branch.controldir.user_url:
142
142
            # Lightweight checkout, make sure we have a repo location.
143
143
            wt.branch.controldir.root_transport.mkdir('original')
144
144
        child_tree = self.make_branch_and_tree('original/child')
145
145
        wt.smart_add((".",))
146
146
        for path in paths:
147
 
            self.assertNotEqual((path, wt.path2id(path)),
148
 
                                (path, None))
 
147
            self.assertNotEqual((path, wt.is_versioned(path)),
 
148
                                (path, False))
149
149
        for path in full_child_paths:
150
 
            self.assertEqual((path, wt.path2id(path)),
151
 
                             (path, None))
 
150
            self.assertEqual((path, wt.is_versioned(path)),
 
151
                             (path, False))
152
152
        for path in child_paths:
153
 
            self.assertEqual(child_tree.path2id(path), None)
 
153
            self.assertFalse(child_tree.is_versioned(path))
154
154
 
155
155
    def test_add_paths(self):
156
156
        """Test smart-adding a list of paths."""
159
159
        wt = self.make_branch_and_tree('.')
160
160
        wt.smart_add(paths)
161
161
        for path in paths:
162
 
            self.assertNotEqual(wt.path2id(path), None)
 
162
            self.assertTrue(wt.is_versioned(path))
163
163
 
164
164
    def test_add_ignored_nested_paths(self):
165
165
        """Test smart-adding a list of paths which includes ignored ones."""
170
170
        self.build_tree(tree_shape)
171
171
        wt.smart_add(add_paths)
172
172
        for path in expected_paths:
173
 
            self.assertNotEqual(wt.path2id(path), None,
174
 
                "No id added for %s" % path)
 
173
            self.assertTrue(wt.is_versioned(path), "No id added for %s" % path)
175
174
 
176
175
    def test_add_non_existant(self):
177
176
        """Test smart-adding a file that does not exist."""
186
185
        self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
187
186
                        'inertiatic/foo.pyc'])
188
187
        added, ignored = wt.smart_add(u'.')
189
 
        self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'),
190
 
                          added)
 
188
        if wt.has_versioned_directories():
 
189
            self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'),
 
190
                              added)
 
191
        else:
 
192
            self.assertSubset(('inertiatic/esp', 'inertiatic/CVS'),
 
193
                              added)
191
194
        self.assertSubset(('*.py[co]',), ignored)
192
195
        self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[co]'])
193
196
 
206
209
        wt.smart_add(['file1', 'file2', 'dir1', 'dir2'])
207
210
 
208
211
        for path in added_paths:
209
 
            self.assertNotEqual(None, wt.path2id(path.rstrip('/')),
 
212
            self.assertTrue(wt.is_versioned(path.rstrip('/')),
210
213
                    'Failed to add path: %s' % (path,))
211
214
        for path in not_added:
212
 
            self.assertEqual(None, wt.path2id(path.rstrip('/')),
 
215
            self.assertFalse(wt.is_versioned(path.rstrip('/')),
213
216
                    'Accidentally added path: %s' % (path,))
214
217
 
215
218
    def test_add_file_in_unknown_dir(self):