~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_executable.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2011, 2012, 2016 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
21
21
from bzrlib import (
22
22
    osutils,
23
23
    )
 
24
from bzrlib.inventory import InventoryFile
24
25
from bzrlib.transform import TreeTransform
25
26
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
26
27
 
43
44
    def check_exist(self, tree):
44
45
        """Just check that both files have the right executable bits set"""
45
46
        tree.lock_read()
46
 
        self.assertTrue(tree.is_executable(self.a_id),
 
47
        self.failUnless(tree.is_executable(self.a_id),
47
48
                        "'a' lost the execute bit")
48
 
        self.assertFalse(tree.is_executable(self.b_id),
 
49
        self.failIf(tree.is_executable(self.b_id),
49
50
                    "'b' gained an execute bit")
50
51
        tree.unlock()
51
52
 
58
59
        tree.lock_read()
59
60
        if not ignore_inv:
60
61
            self.assertEqual(
61
 
                [('', tree.root_inventory.root)],
62
 
                list(tree.root_inventory.iter_entries()))
63
 
        self.assertFalse(tree.has_id(self.a_id))
64
 
        self.assertFalse(tree.has_filename('a'))
65
 
        self.assertFalse(tree.has_id(self.b_id))
66
 
        self.assertFalse(tree.has_filename('b'))
 
62
                [('', tree.inventory.root)],
 
63
                list(tree.inventory.iter_entries()))
 
64
        self.failIf(tree.has_id(self.a_id))
 
65
        self.failIf(tree.has_filename('a'))
 
66
        self.failIf(tree.has_id(self.b_id))
 
67
        self.failIf(tree.has_filename('b'))
67
68
        tree.unlock()
68
69
 
69
70
    def commit_and_branch(self):
71
72
        self.wt.commit('adding a,b', rev_id='r1')
72
73
        # Now make sure that 'bzr branch' also preserves the
73
74
        # executable bit
74
 
        dir2 = self.wt.branch.bzrdir.sprout('b2', revision_id='r1')
 
75
        # TODO: Maybe this should be a blackbox test
 
76
        dir2 = self.wt.branch.bzrdir.clone('b2', revision_id='r1')
75
77
        wt2 = dir2.open_workingtree()
76
78
        self.assertEqual(['r1'], wt2.get_parent_ids())
77
79
        self.assertEqual('r1', wt2.branch.last_revision())
147
149
 
148
150
        # Make sure pull will delete the files
149
151
        wt2.pull(self.wt.branch)
150
 
        self.assertEqual(['r2'], wt2.get_parent_ids())
151
 
        self.assertEqual('r2', wt2.branch.last_revision())
 
152
        self.assertEquals(['r2'], wt2.get_parent_ids())
 
153
        self.assertEquals('r2', wt2.branch.last_revision())
152
154
        self.check_empty(wt2)
153
155
 
154
156
        # Now restore the files on the first branch and commit
161
163
        self.check_exist(self.wt)
162
164
 
163
165
        wt2.pull(self.wt.branch)
164
 
        self.assertEqual(['r3'], wt2.get_parent_ids())
165
 
        self.assertEqual('r3', wt2.branch.last_revision())
 
166
        self.assertEquals(['r3'], wt2.get_parent_ids())
 
167
        self.assertEquals('r3', wt2.branch.last_revision())
166
168
        self.check_exist(wt2)
167
169
 
168
170
    def test_08_no_op_revert(self):
180
182
            self.wt._is_executable_from_path_and_stat_from_basis
181
183
        rev_id1 = self.wt.commit('one')
182
184
        rev_tree1 = self.wt.branch.repository.revision_tree(rev_id1)
183
 
        a_executable = rev_tree1.root_inventory[self.a_id].executable
184
 
        b_executable = rev_tree1.root_inventory[self.b_id].executable
 
185
        a_executable = rev_tree1.inventory[self.a_id].executable
 
186
        b_executable = rev_tree1.inventory[self.b_id].executable
185
187
        self.assertIsNot(None, a_executable)
186
188
        self.assertTrue(a_executable)
187
189
        self.assertIsNot(None, b_executable)
188
190
        self.assertFalse(b_executable)
189
191
 
190
192
    def test_use_exec_from_basis(self):
191
 
        self.wt._supports_executable = lambda: False
192
 
        self.addCleanup(self.wt.lock_read().unlock)
193
 
        self.assertTrue(self.wt.is_executable(self.a_id))
194
 
        self.assertFalse(self.wt.is_executable(self.b_id))
 
193
        if osutils.supports_executable():
 
194
            self.assertEqual(self.wt._is_executable_from_path_and_stat_from_stat,
 
195
                             self.wt._is_executable_from_path_and_stat)
 
196
        else:
 
197
            self.assertEqual(self.wt._is_executable_from_path_and_stat_from_basis,
 
198
                             self.wt._is_executable_from_path_and_stat)