1
# Copyright (C) 2007 Canonical Ltd
1
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
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()])
230
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree):
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')])
236
tb.commit('Adding file')
238
t1 = tb.bzrdir.sprout('t1').open_workingtree()
240
self.build_tree_contents([('base/file', 'content changed in base')])
241
tb.commit('Changing file in base')
243
self.build_tree_contents([('t1/file', 'content in t1')])
244
t1.commit('Changing file in t1')
245
t1.merge_from_branch(tb.branch)
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))
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))
230
260
class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree):
232
262
_test_needs_features = [tests.UnicodeFilenameFeature]
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):
274
'With WorkingTreeFormat2, smart_add requires'
275
' normalized unicode filenames',
276
self.assertRaises, errors.NoSuchFile,
277
self.wt.smart_add, [u'a\u030a'])
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')],
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):
290
'With WorkingTreeFormat2, smart_add requires'
291
' normalized unicode filenames',
292
self.assertRaises, errors.NoSuchFile,
293
self.wt.smart_add, [])
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()])
258
302
def test_inaccessible_explicit(self):
259
303
osutils.normalized_filename = osutils._inaccessible_normalized_filename