~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-01-06 22:44:57 UTC
  • mfrom: (6436 +trunk)
  • mto: (6437.3.11 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120106224457-re0pcy0fz31xob77
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    PathsNotVersionedError,
38
38
    )
39
39
from bzrlib.inventory import Inventory
 
40
from bzrlib.mutabletree import MutableTree
40
41
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
41
42
from bzrlib.tests import (
42
43
    features,
451
452
            revision_id='a')
452
453
        self.assertEqual(['a'], made_tree.get_parent_ids())
453
454
 
 
455
    def test_post_build_tree_hook(self):
 
456
        calls = []
 
457
        def track_post_build_tree(tree):
 
458
            calls.append(tree.last_revision())
 
459
        source = self.make_branch_and_tree('source')
 
460
        source.commit('a', rev_id='a', allow_pointless=True)
 
461
        source.commit('b', rev_id='b', allow_pointless=True)
 
462
        self.build_tree(['new/'])
 
463
        made_control = self.bzrdir_format.initialize('new')
 
464
        source.branch.repository.clone(made_control)
 
465
        source.branch.clone(made_control)
 
466
        MutableTree.hooks.install_named_hook("post_build_tree",
 
467
            track_post_build_tree, "Test")
 
468
        made_tree = self.workingtree_format.initialize(made_control,
 
469
            revision_id='a')
 
470
        self.assertEqual(['a'], calls)
 
471
 
454
472
    def test_update_sets_last_revision(self):
455
473
        # working tree formats from the meta-dir format and newer support
456
474
        # setting the last revision on a tree independently of that on the
960
978
        tree = tree.bzrdir.open_workingtree()
961
979
        self.assertFalse(tree.case_sensitive)
962
980
 
 
981
    def test_supports_executable(self):
 
982
        self.build_tree(['filename'])
 
983
        tree = self.make_branch_and_tree('.')
 
984
        tree.add('filename')
 
985
        self.assertIsInstance(tree._supports_executable(), bool)
 
986
        if tree._supports_executable():
 
987
            tree.lock_read()
 
988
            try:
 
989
                self.assertFalse(tree.is_executable(tree.path2id('filename')))
 
990
            finally:
 
991
                tree.unlock()
 
992
            os.chmod('filename', 0755)
 
993
            self.addCleanup(tree.lock_read().unlock)
 
994
            self.assertTrue(tree.is_executable(tree.path2id('filename')))
 
995
        else:
 
996
            self.addCleanup(tree.lock_read().unlock)
 
997
            self.assertFalse(tree.is_executable(tree.path2id('filename')))
 
998
 
963
999
    def test_all_file_ids_with_missing(self):
964
1000
        tree = self.make_branch_and_tree('tree')
965
1001
        tree.lock_write()