/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_workingtree.py

  • Committer: Alexander Belchenko
  • Date: 2008-04-03 20:51:42 UTC
  • mfrom: (3331 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3337.
  • Revision ID: bialix@ukr.net-20080403205142-7b3q6eh1zhojuy0d
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
from cStringIO import StringIO
 
20
import errno
20
21
import os
21
22
import sys
22
23
 
825
826
            expected_kind = names[i]
826
827
            self.assertEqual(expected_kind, actual_kind)
827
828
 
 
829
    def test_stored_kind_with_missing(self):
 
830
        tree = self.make_branch_and_tree('tree')
 
831
        tree.lock_write()
 
832
        self.addCleanup(tree.unlock)
 
833
        self.build_tree(['tree/a', 'tree/b/'])
 
834
        tree.add(['a', 'b'], ['a-id', 'b-id'])
 
835
        os.unlink('tree/a')
 
836
        os.rmdir('tree/b')
 
837
        self.assertEqual('file', tree.stored_kind('a-id'))
 
838
        self.assertEqual('directory', tree.stored_kind('b-id'))
 
839
 
828
840
    def test_missing_file_sha1(self):
829
841
        """If a file is missing, its sha1 should be reported as None."""
830
842
        tree = self.make_branch_and_tree('.')
863
875
        if tree.__class__ == WorkingTree2:
864
876
            raise TestSkipped('WorkingTree2 is not supported')
865
877
        self.assertEqual(case_sensitive, tree.case_sensitive)
 
878
 
 
879
    def test_all_file_ids_with_missing(self):
 
880
        tree = self.make_branch_and_tree('tree')
 
881
        tree.lock_write()
 
882
        self.addCleanup(tree.unlock)
 
883
        self.build_tree(['tree/a', 'tree/b'])
 
884
        tree.add(['a', 'b'], ['a-id', 'b-id'])
 
885
        os.unlink('tree/a')
 
886
        self.assertEqual(set(['a-id', 'b-id', tree.get_root_id()]),
 
887
                         tree.all_file_ids())
 
888
 
 
889
    def test_sprout_hardlink(self):
 
890
        source = self.make_branch_and_tree('source')
 
891
        self.build_tree(['source/file'])
 
892
        source.add('file')
 
893
        source.commit('added file')
 
894
        def fake_link(source, target):
 
895
            raise OSError(errno.EPERM, 'Operation not permitted')
 
896
        real_os_link = os.link
 
897
        os.link = fake_link
 
898
        try:
 
899
            # Hard-link support is optional, so supplying hardlink=True may
 
900
            # or may not raise an exception.  But if it does, it must be
 
901
            # HardLinkNotSupported
 
902
            try:
 
903
                source.bzrdir.sprout('target', accelerator_tree=source,
 
904
                                     hardlink=True)
 
905
            except errors.HardLinkNotSupported:
 
906
                pass
 
907
        finally:
 
908
            os.link = real_os_link