234
235
os.mkdir('lala.OTHER')
235
236
expected = ContentsConflict('lala', file_id='lala-id')
236
237
self.assertEqual(list(tree.conflicts()), [expected])
240
class TestNonFormatSpecificCode(TestCaseWithTransport):
241
"""This class contains tests of workingtree that are not format specific."""
243
def test__translate_ignore_rule(self):
244
tree = self.make_branch_and_tree('.')
245
# translation should return the regex, the number of groups in it,
246
# and the original rule in a tuple.
247
# there are three sorts of ignore rules:
248
# root only - regex is the rule itself without the leading ./
251
tree._translate_ignore_rule("./rootdirrule"))
252
# full path - regex is the rule itself
254
"(path\\/to\\/file$)",
255
tree._translate_ignore_rule("path/to/file"))
256
# basename only rule - regex is a rule that ignores everything up
257
# to the last / in the filename
259
"((?:.*/)?(?!.*/)basenamerule$)",
260
tree._translate_ignore_rule("basenamerule"))
262
def test__combine_ignore_rules(self):
263
tree = self.make_branch_and_tree('.')
264
# the combined ignore regexs need the outer group indices
265
# placed in a dictionary with the rules that were combined.
266
# an empty set of rules
267
compiled_rules = tree._combine_ignore_rules([])
268
# what type *is* the compiled regex to do an isinstance of ?
269
self.assertEqual(0, compiled_rules[0].groups)
270
self.assertEqual({}, compiled_rules[1])
271
# one of each type of rule.
272
compiled_rules = tree._combine_ignore_rules(
273
["rule1", "rule/two", "./three"])
274
self.assertEqual(3, compiled_rules[0].groups)
276
{0:"rule1",1:"rule/two",2:"./three"},
279
def test__get_ignore_rules_as_regex(self):
280
tree = self.make_branch_and_tree('.')
281
# test against the default rules.
282
reference_output = tree._combine_ignore_rules(bzrlib.DEFAULT_IGNORE)
283
regex_rules = tree._get_ignore_rules_as_regex()
284
self.assertEqual(len(reference_output[1]), regex_rules[0].groups)
285
self.assertEqual(reference_output[1], regex_rules[1])