22
22
from bzrlib.branch import Branch
23
import bzrlib.bzrdir as bzrdir
23
from bzrlib import bzrdir, conflicts, errors, workingtree
24
24
from bzrlib.bzrdir import BzrDir
25
from bzrlib.conflicts import *
26
import bzrlib.errors as errors
27
25
from bzrlib.errors import NotBranchError, NotVersionedError
28
26
from bzrlib.lockdir import LockDir
29
27
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
30
28
from bzrlib.tests import TestCaseWithTransport, TestSkipped
31
29
from bzrlib.trace import mutter
32
30
from bzrlib.transport import get_transport
33
import bzrlib.workingtree as workingtree
34
31
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
206
203
self.assertEquals(our_lock.peek(), None)
205
def test_missing_pending_merges(self):
206
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
207
control.create_repository()
208
control.create_branch()
209
tree = workingtree.WorkingTreeFormat3().initialize(control)
210
tree._control_files._transport.delete("pending-merges")
211
self.assertEqual([], tree.pending_merges())
209
214
class TestFormat2WorkingTree(TestCaseWithTransport):
210
215
"""Tests that are specific to format 2 trees."""
219
224
self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts,
221
226
file('lala.BASE', 'wb').write('labase')
222
expected = ContentsConflict('lala')
227
expected = conflicts.ContentsConflict('lala')
223
228
self.assertEqual(list(tree.conflicts()), [expected])
224
229
file('lala', 'wb').write('la')
225
230
tree.add('lala', 'lala-id')
226
expected = ContentsConflict('lala', file_id='lala-id')
231
expected = conflicts.ContentsConflict('lala', file_id='lala-id')
227
232
self.assertEqual(list(tree.conflicts()), [expected])
228
233
file('lala.THIS', 'wb').write('lathis')
229
234
file('lala.OTHER', 'wb').write('laother')
230
235
# When "text conflict"s happen, stem, THIS and OTHER are text
231
expected = TextConflict('lala', file_id='lala-id')
236
expected = conflicts.TextConflict('lala', file_id='lala-id')
232
237
self.assertEqual(list(tree.conflicts()), [expected])
233
238
os.unlink('lala.OTHER')
234
239
os.mkdir('lala.OTHER')
235
expected = ContentsConflict('lala', file_id='lala-id')
240
expected = conflicts.ContentsConflict('lala', file_id='lala-id')
236
241
self.assertEqual(list(tree.conflicts()), [expected])
310
315
def test__get_ignore_rules_as_regex(self):
311
316
tree = self.make_branch_and_tree('.')
312
# test against the default rules.
313
reference_output = tree._combine_ignore_rules(bzrlib.DEFAULT_IGNORE)[0]
317
self.build_tree_contents([('.bzrignore', 'CVS\n.hg\n')])
318
reference_output = tree._combine_ignore_rules(['CVS', '.hg'])[0]
314
319
regex_rules = tree._get_ignore_rules_as_regex()[0]
315
320
self.assertEqual(len(reference_output[1]), regex_rules[0].groups)
316
321
self.assertEqual(reference_output[1], regex_rules[1])