/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Merge updated set_parents api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 Canonical Ltd
2
 
 
 
2
#
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.
7
 
 
 
7
#
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.
12
 
 
 
12
#
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, NotVersionedError,
24
 
                           ExistingLimbo, ImmortalLimbo, LockError)
 
23
                           ReusingTransform, CantMoveRoot, 
 
24
                           PathsNotVersionedError, ExistingLimbo,
 
25
                           ImmortalLimbo, LockError)
25
26
from bzrlib.osutils import file_kind, has_symlinks, pathjoin
26
27
from bzrlib.merge import Merge3Merger
27
28
from bzrlib.tests import TestCaseInTempDir, TestSkipped, TestCase
28
29
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths, 
29
30
                              resolve_conflicts, cook_conflicts, 
30
31
                              find_interesting, build_tree, get_backup_name)
 
32
import bzrlib.urlutils as urlutils
31
33
 
32
34
class TestTreeTransform(TestCaseInTempDir):
 
35
 
33
36
    def setUp(self):
34
37
        super(TestTreeTransform, self).setUp()
35
38
        self.wt = BzrDir.create_standalone_workingtree('.')
41
44
        return transform, transform.trans_id_tree_file_id(self.wt.get_root_id())
42
45
 
43
46
    def test_existing_limbo(self):
44
 
        limbo_name = self.wt._control_files.controlfilename('limbo')
 
47
        limbo_name = urlutils.local_path_from_url(
 
48
            self.wt._control_files.controlfilename('limbo'))
45
49
        transform, root = self.get_transform()
46
50
        os.mkdir(pathjoin(limbo_name, 'hehe'))
47
51
        self.assertRaises(ImmortalLimbo, transform.apply)
57
61
        transform, root = self.get_transform() 
58
62
        self.assertIs(transform.get_tree_parent(root), ROOT_PARENT)
59
63
        imaginary_id = transform.trans_id_tree_path('imaginary')
 
64
        imaginary_id2 = transform.trans_id_tree_path('imaginary/')
 
65
        self.assertEqual(imaginary_id, imaginary_id2)
60
66
        self.assertEqual(transform.get_tree_parent(imaginary_id), root)
61
67
        self.assertEqual(transform.final_kind(root), 'directory')
62
68
        self.assertEqual(transform.final_file_id(root), self.wt.get_root_id())
487
493
        create.apply()
488
494
        self.assertEqual(find_interesting(wt, wt, ['vfile']),
489
495
                         set(['myfile-id']))
490
 
        self.assertRaises(NotVersionedError, find_interesting, wt, wt,
 
496
        self.assertRaises(PathsNotVersionedError, find_interesting, wt, wt,
491
497
                          ['uvfile'])
492
498
 
 
499
    def test_set_executability_order(self):
 
500
        """Ensure that executability behaves the same, no matter what order.
 
501
        
 
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)
 
507
        """
 
508
        transform, root = self.get_transform()
 
509
        wt = transform._tree
 
510
        transform.new_file('set_on_creation', root, 'Set on creation', 'soc',
 
511
                           True)
 
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)
 
516
        transform.apply()
 
517
        self.assertTrue(wt.is_executable('soc'))
 
518
        self.assertTrue(wt.is_executable('sac'))
 
519
 
493
520
 
494
521
class TransformGroup(object):
495
522
    def __init__(self, dirname):