1
# (C) 2005,2006 Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
# Authors: Robert Collins <robert.collins@canonical.com>
4
4
# This program is free software; you can redistribute it and/or modify
23
from bzrlib.branch import Branch
24
import bzrlib.bzrdir as bzrdir
25
from bzrlib.bzrdir import BzrDir
26
import bzrlib.errors as errors
22
from bzrlib import branch, bzrdir, errors, urlutils, workingtree
27
23
from bzrlib.errors import (NotBranchError, NotVersionedError,
28
24
UnsupportedOperation)
29
25
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
30
26
from bzrlib.tests import TestSkipped
31
27
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
32
28
from bzrlib.trace import mutter
33
import bzrlib.workingtree as workingtree
34
29
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
31
from bzrlib.conflicts import ConflictList
38
33
class TestWorkingTree(TestCaseWithWorkingTree):
78
73
branch = self.make_branch_and_tree('.').branch
79
74
wt, relpath = WorkingTree.open_containing()
80
75
self.assertEqual('', relpath)
81
self.assertEqual(wt.basedir + '/', branch.base)
76
self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
82
77
wt, relpath = WorkingTree.open_containing(u'.')
83
78
self.assertEqual('', relpath)
84
self.assertEqual(wt.basedir + '/', branch.base)
79
self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
85
80
wt, relpath = WorkingTree.open_containing('./foo')
86
81
self.assertEqual('foo', relpath)
87
self.assertEqual(wt.basedir + '/', branch.base)
82
self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
88
83
wt, relpath = WorkingTree.open_containing('file://' + getcwd() + '/foo')
89
84
self.assertEqual('foo', relpath)
90
self.assertEqual(wt.basedir + '/', branch.base)
85
self.assertEqual(wt.basedir + '/', urlutils.local_path_from_url(branch.base))
92
87
def test_basic_relpath(self):
93
88
# for comprehensive relpath tests, see whitebox.py.
186
181
def test_initialize(self):
187
182
# initialize should create a working tree and branch in an existing dir
188
183
t = self.make_branch_and_tree('.')
184
b = branch.Branch.open('.')
190
185
self.assertEqual(t.branch.base, b.base)
191
186
t2 = WorkingTree.open('.')
192
187
self.assertEqual(t.basedir, t2.basedir)
400
395
self.build_tree(['checkout/', 'tree/file'])
401
396
checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
402
bzrlib.branch.BranchReferenceFormat().initialize(checkout, main_branch)
397
branch.BranchReferenceFormat().initialize(checkout, main_branch)
403
398
old_tree = self.workingtree_format.initialize(checkout)
404
399
# now commit to 'tree'
431
426
self.build_tree(['checkout/', 'tree/file'])
432
427
checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
433
bzrlib.branch.BranchReferenceFormat().initialize(checkout, main_branch)
428
branch.BranchReferenceFormat().initialize(checkout, main_branch)
434
429
old_tree = self.workingtree_format.initialize(checkout)
435
430
# now commit to 'tree'
538
533
tree.commit("blah", allow_pointless=False)
539
534
base = tree.basis_tree()
540
BzrDir.open("mine").sprout("other")
535
bzrdir.BzrDir.open("mine").sprout("other")
541
536
file('other/bloo', 'wb').write('two')
542
537
othertree = WorkingTree.open('other')
543
538
othertree.commit('blah', allow_pointless=False)
551
546
self.assertEqual(len(tree.conflicts()), 1)
553
548
def test_clear_merge_conflicts(self):
554
from bzrlib.conflicts import ConflictList
555
549
tree = self.make_merge_conflicts()
556
550
self.assertEqual(len(tree.conflicts()), 1)