/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/workingtree_implementations/test_executable.py

First attempt to merge .dev and resolve the conflicts (but tests are 
failing)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
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
18
18
 
19
19
import os
20
20
 
 
21
from bzrlib import (
 
22
    osutils,
 
23
    )
21
24
from bzrlib.inventory import InventoryFile
22
25
from bzrlib.transform import TreeTransform
23
26
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
41
44
 
42
45
    def check_exist(self, tree):
43
46
        """Just check that both files have the right executable bits set"""
44
 
        measured = []
45
 
        for cn, ie in tree.inventory.iter_entries():
46
 
            if isinstance(ie, InventoryFile):
47
 
                measured.append((cn, ie.executable))
48
 
        self.assertEqual([('a', True), ('b', False)], measured)
 
47
        tree.lock_read()
49
48
        self.failUnless(tree.is_executable(self.a_id),
50
49
                        "'a' lost the execute bit")
51
50
        self.failIf(tree.is_executable(self.b_id),
52
51
                    "'b' gained an execute bit")
 
52
        tree.unlock()
53
53
 
54
54
    def check_empty(self, tree, ignore_inv=False):
55
55
        """Check that the files are truly missing
57
57
                the inventory still shows them, so don't assert that
58
58
                the inventory is empty, just that the tree doesn't have them
59
59
        """
 
60
        tree.lock_read()
60
61
        if not ignore_inv:
61
62
            self.assertEqual(
62
63
                [('', tree.inventory.root)],
65
66
        self.failIf(tree.has_filename('a'))
66
67
        self.failIf(tree.has_id(self.b_id))
67
68
        self.failIf(tree.has_filename('b'))
 
69
        tree.unlock()
68
70
 
69
71
    def commit_and_branch(self):
70
72
        """Commit the current tree, and create a second tree"""
71
73
        self.wt.commit('adding a,b', rev_id='r1')
72
 
 
73
74
        # Now make sure that 'bzr branch' also preserves the
74
75
        # executable bit
75
76
        # TODO: Maybe this should be a blackbox test
126
127
 
127
128
        rev_tree = self.wt.branch.repository.revision_tree('r1')
128
129
        # Now revert back to the previous commit
129
 
        self.wt.revert([], rev_tree, backups=False)
 
130
        self.wt.revert(old_tree=rev_tree, backups=False)
130
131
 
131
132
        self.check_exist(self.wt)
132
133
 
157
158
        # so that the second branch can pull the changes
158
159
        # and make sure that the executable bit has been copied
159
160
        rev_tree = self.wt.branch.repository.revision_tree('r1')
160
 
        self.wt.revert([], rev_tree, backups=False)
 
161
        self.wt.revert(old_tree=rev_tree, backups=False)
161
162
        self.wt.commit('resurrected', rev_id='r3')
162
163
 
163
164
        self.check_exist(self.wt)
174
175
        """
175
176
        self.wt.commit('adding a,b', rev_id='r1')
176
177
        rev_tree = self.wt.branch.repository.revision_tree('r1')
177
 
        self.wt.revert([], rev_tree, backups=False)
 
178
        self.wt.revert(old_tree=rev_tree, backups=False)
178
179
        self.check_exist(self.wt)
179
180
 
 
181
    def test_commit_with_exec_from_basis(self):
 
182
        self.wt._is_executable_from_path_and_stat = \
 
183
            self.wt._is_executable_from_path_and_stat_from_basis
 
184
        rev_id1 = self.wt.commit('one')
 
185
        rev_tree1 = self.wt.branch.repository.revision_tree(rev_id1)
 
186
        a_executable = rev_tree1.inventory[self.a_id].executable
 
187
        b_executable = rev_tree1.inventory[self.b_id].executable
 
188
        self.assertIsNot(None, a_executable)
 
189
        self.assertTrue(a_executable)
 
190
        self.assertIsNot(None, b_executable)
 
191
        self.assertFalse(b_executable)
 
192
 
 
193
    def test_use_exec_from_basis(self):
 
194
        if osutils.supports_executable():
 
195
            self.assertEqual(self.wt._is_executable_from_path_and_stat_from_stat,
 
196
                             self.wt._is_executable_from_path_and_stat)
 
197
        else:
 
198
            self.assertEqual(self.wt._is_executable_from_path_and_stat_from_basis,
 
199
                             self.wt._is_executable_from_path_and_stat)