~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2009, 2010 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
227
227
                                in wt.inventory.iter_entries()])
228
228
 
229
229
 
 
230
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
 
231
 
 
232
    def make_tree_with_text_conflict(self):
 
233
        tb = self.make_branch_and_tree('base')
 
234
        self.build_tree_contents([('base/file', 'content in base')])
 
235
        tb.add('file')
 
236
        tb.commit('Adding file')
 
237
 
 
238
        t1 = tb.bzrdir.sprout('t1').open_workingtree()
 
239
 
 
240
        self.build_tree_contents([('base/file', 'content changed in base')])
 
241
        tb.commit('Changing file in base')
 
242
 
 
243
        self.build_tree_contents([('t1/file', 'content in t1')])
 
244
        t1.commit('Changing file in t1')
 
245
        t1.merge_from_branch(tb.branch)
 
246
        return t1
 
247
 
 
248
    def test_cant_add_generated_files_implicitly(self):
 
249
        t = self.make_tree_with_text_conflict()
 
250
        added, ignored = t.smart_add([t.basedir])
 
251
        self.assertEqual(([], {}), (added, ignored))
 
252
 
 
253
    def test_can_add_generated_files_explicitly(self):
 
254
        fnames = ['file.%s' % s  for s in ('BASE', 'THIS', 'OTHER')]
 
255
        t = self.make_tree_with_text_conflict()
 
256
        added, ignored = t.smart_add([t.basedir + '/%s' % f for f in fnames])
 
257
        self.assertEqual((fnames, {}), (added, ignored))
 
258
 
 
259
 
230
260
class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree):
231
261
 
232
262
    _test_needs_features = [tests.UnicodeFilenameFeature]
239
269
 
240
270
    def test_accessible_explicit(self):
241
271
        osutils.normalized_filename = osutils._accessible_normalized_filename
242
 
        self.wt.smart_add([u'a\u030a'])
 
272
        if isinstance(self.workingtree_format, workingtree.WorkingTreeFormat2):
 
273
            self.expectFailure(
 
274
                'With WorkingTreeFormat2, smart_add requires'
 
275
                ' normalized unicode filenames',
 
276
                self.assertRaises, errors.NoSuchFile,
 
277
                self.wt.smart_add, [u'a\u030a'])
 
278
        else:
 
279
            self.wt.smart_add([u'a\u030a'])
243
280
        self.wt.lock_read()
244
281
        self.addCleanup(self.wt.unlock)
245
282
        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
248
285
 
249
286
    def test_accessible_implicit(self):
250
287
        osutils.normalized_filename = osutils._accessible_normalized_filename
251
 
        self.wt.smart_add([])
 
288
        if isinstance(self.workingtree_format, workingtree.WorkingTreeFormat2):
 
289
            self.expectFailure(
 
290
                'With WorkingTreeFormat2, smart_add requires'
 
291
                ' normalized unicode filenames',
 
292
                self.assertRaises, errors.NoSuchFile,
 
293
                self.wt.smart_add, [])
 
294
        else:
 
295
            self.wt.smart_add([])
252
296
        self.wt.lock_read()
253
297
        self.addCleanup(self.wt.unlock)
254
298
        self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
255
 
                         [(path, ie.kind) for path,ie in
256
 
                          self.wt.inventory.iter_entries()])
 
299
                         [(path, ie.kind) for path,ie
 
300
                          in self.wt.inventory.iter_entries()])
257
301
 
258
302
    def test_inaccessible_explicit(self):
259
303
        osutils.normalized_filename = osutils._inaccessible_normalized_filename