1
1
# Copyright (C) 2006 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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
20
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
21
21
UnversionedParent, ParentLoop)
22
22
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
23
ReusingTransform, CantMoveRoot,
24
PathsNotVersionedError, ExistingLimbo,
25
ImmortalLimbo, LockError)
23
ReusingTransform, CantMoveRoot, NotVersionedError,
24
ExistingLimbo, ImmortalLimbo, LockError)
26
25
from bzrlib.osutils import file_kind, has_symlinks, pathjoin
27
26
from bzrlib.merge import Merge3Merger
28
27
from bzrlib.tests import TestCaseInTempDir, TestSkipped, TestCase
29
28
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths,
30
29
resolve_conflicts, cook_conflicts,
31
30
find_interesting, build_tree, get_backup_name)
32
import bzrlib.urlutils as urlutils
34
32
class TestTreeTransform(TestCaseInTempDir):
37
34
super(TestTreeTransform, self).setUp()
38
35
self.wt = BzrDir.create_standalone_workingtree('.')
44
41
return transform, transform.trans_id_tree_file_id(self.wt.get_root_id())
46
43
def test_existing_limbo(self):
47
limbo_name = urlutils.local_path_from_url(
48
self.wt._control_files.controlfilename('limbo'))
44
limbo_name = self.wt._control_files.controlfilename('limbo')
49
45
transform, root = self.get_transform()
50
46
os.mkdir(pathjoin(limbo_name, 'hehe'))
51
47
self.assertRaises(ImmortalLimbo, transform.apply)
494
490
self.assertEqual(find_interesting(wt, wt, ['vfile']),
495
491
set(['myfile-id']))
496
self.assertRaises(PathsNotVersionedError, find_interesting, wt, wt,
492
self.assertRaises(NotVersionedError, find_interesting, wt, wt,
499
def test_set_executability_order(self):
500
"""Ensure that executability behaves the same, no matter what order.
502
- create file and set executability simultaneously
503
- create file and set executability afterward
504
- unsetting the executability of a file whose executability has not been
505
declared should throw an exception (this may happen when a
506
merge attempts to create a file with a duplicate ID)
508
transform, root = self.get_transform()
510
transform.new_file('set_on_creation', root, 'Set on creation', 'soc',
512
sac = transform.new_file('set_after_creation', root, 'Set after creation', 'sac')
513
transform.set_executability(True, sac)
514
uws = transform.new_file('unset_without_set', root, 'Unset badly', 'uws')
515
self.assertRaises(KeyError, transform.set_executability, None, uws)
517
self.assertTrue(wt.is_executable('soc'))
518
self.assertTrue(wt.is_executable('sac'))
521
496
class TransformGroup(object):
522
497
def __init__(self, dirname):