~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree_4.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2011 Canonical Ltd
 
1
# Copyright (C) 2007-2012, 2016 Canonical Ltd
2
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
29
29
    workingtree_4,
30
30
    )
31
31
from bzrlib.lockdir import LockDir
32
 
from bzrlib.tests import TestCaseWithTransport, TestSkipped
 
32
from bzrlib.tests import TestCaseWithTransport, TestSkipped, features
33
33
from bzrlib.tree import InterTree
34
34
 
35
35
 
88
88
        self.assertIsDirectory('.bzr/checkout', t)
89
89
        self.assertIsDirectory('.bzr/checkout/lock', t)
90
90
        our_lock = LockDir(t, '.bzr/checkout/lock')
91
 
        self.assertEquals(our_lock.peek(), None)
 
91
        self.assertEqual(our_lock.peek(), None)
92
92
        tree.lock_write()
93
93
        self.assertTrue(our_lock.peek())
94
94
        tree.unlock()
95
 
        self.assertEquals(our_lock.peek(), None)
 
95
        self.assertEqual(our_lock.peek(), None)
96
96
 
97
97
    def make_workingtree(self, relpath=''):
98
98
        url = self.get_url(relpath)
212
212
        rev1 = subtree.commit('commit in subdir')
213
213
        rev1_tree = subtree.basis_tree()
214
214
        rev1_tree.lock_read()
215
 
        rev1_tree.inventory
 
215
        rev1_tree.root_inventory
216
216
        self.addCleanup(rev1_tree.unlock)
217
217
        rev2 = subtree.commit('second commit in subdir', allow_pointless=True)
218
218
        rev2_tree = subtree.basis_tree()
219
219
        rev2_tree.lock_read()
220
 
        rev2_tree.inventory
 
220
        rev2_tree.root_inventory
221
221
        self.addCleanup(rev2_tree.unlock)
222
222
 
223
223
        tree.branch.pull(subtree.branch)
516
516
 
517
517
    def test_unique_root_id_per_tree(self):
518
518
        # each time you initialize a new tree, it gets a different root id
519
 
        format_name = 'dirstate-with-subtree'
 
519
        format_name = 'development-subtree'
520
520
        tree1 = self.make_branch_and_tree('tree1',
521
521
            format=format_name)
522
522
        tree2 = self.make_branch_and_tree('tree2',
552
552
        tree = self.make_branch_and_tree('tag', format='dirstate-tags')
553
553
        self.assertEqual(inventory.ROOT_ID, tree.get_root_id())
554
554
        tree = self.make_branch_and_tree('subtree',
555
 
                                         format='dirstate-with-subtree')
 
555
                                         format='development-subtree')
556
556
        self.assertNotEqual(inventory.ROOT_ID, tree.get_root_id())
557
557
 
558
558
    def test_non_subtree_with_nested_trees(self):
559
559
        # prior to dirstate, st/diff/commit ignored nested trees.
560
 
        # dirstate, as opposed to dirstate-with-subtree, should
 
560
        # dirstate, as opposed to development-subtree, should
561
561
        # behave the same way.
562
562
        tree = self.make_branch_and_tree('.', format='dirstate')
563
563
        self.assertFalse(tree.supports_tree_reference())
603
603
        tree.unlock()
604
604
 
605
605
    def test_with_subtree_supports_tree_references(self):
606
 
        # dirstate-with-subtree should support tree-references.
607
 
        tree = self.make_branch_and_tree('.', format='dirstate-with-subtree')
 
606
        # development-subtree should support tree-references.
 
607
        tree = self.make_branch_and_tree('.', format='development-subtree')
608
608
        self.assertTrue(tree.supports_tree_reference())
609
609
        # having checked this is on, the tree interface, and intertree
610
610
        # interface tests, will proceed to test the subtree support of
673
673
                              tree_iter_changes, ['bar', 'foo'])
674
674
        self.assertEqual(e.paths, ['foo'])
675
675
 
 
676
    def test_iter_changes_unversioned_non_ascii(self):
 
677
        """Unversioned non-ascii paths should be reported as unicode"""
 
678
        self.requireFeature(features.UnicodeFilenameFeature)
 
679
        tree = self.make_branch_and_tree('.')
 
680
        self.build_tree_contents([('f', '')])
 
681
        tree.add(['f'], ['f-id'])
 
682
        def tree_iter_changes(tree, files):
 
683
            return list(tree.iter_changes(tree.basis_tree(),
 
684
                specific_files=files, require_versioned=True))
 
685
        tree.lock_read()
 
686
        self.addCleanup(tree.unlock)
 
687
        e = self.assertRaises(errors.PathsNotVersionedError,
 
688
            tree_iter_changes, tree, [u'\xa7', u'\u03c0'])
 
689
        self.assertEqual(e.paths, [u'\xa7', u'\u03c0'])
 
690
 
676
691
    def get_tree_with_cachable_file_foo(self):
677
692
        tree = self.make_branch_and_tree('.')
678
693
        tree.lock_write()
851
866
        self.addCleanup(tree.unlock)
852
867
        # Force access to the in memory inventory to trigger bug #494221: try
853
868
        # maintaining the in-memory inventory
854
 
        inv = tree.inventory
 
869
        inv = tree.root_inventory
855
870
        self.assertTrue(inv.has_id('a-id'))
856
871
        self.assertTrue(inv.has_id('b-id'))
857
872
        tree.unversion(['a-id', 'b-id'])