~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2017-01-17 13:48:10 UTC
  • mfrom: (6615.3.6 merges)
  • mto: This revision was merged to the branch mainline in revision 6620.
  • Revision ID: v.ladeuil+lp@free.fr-20170117134810-j9p3lidfy6pfyfsc
Merge 2.7, resolving conflicts

Show diffs side-by-side

added added

removed removed

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