~bzr-pqm/bzr/bzr.dev

6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2005-2009, 2011, 2012, 2016 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1185.50.22 by John Arbash Meinel
Forgot to add the test.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1185.50.22 by John Arbash Meinel
Forgot to add the test.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1185.50.22 by John Arbash Meinel
Forgot to add the test.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.50.22 by John Arbash Meinel
Forgot to add the test.
16
3388.2.1 by Martin Pool
Deprecate LockableFiles.get_utf8
17
from bzrlib.tests import TestNotApplicable
4523.1.4 by Martin Pool
Rename remaining *_implementations tests
18
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
19
import bzrlib.xml6
1185.50.22 by John Arbash Meinel
Forgot to add the test.
20
1532 by Robert Collins
Merge in John Meinels integration branch.
21
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
22
class TestBasisInventory(TestCaseWithWorkingTree):
1185.50.22 by John Arbash Meinel
Forgot to add the test.
23
24
    def test_create(self):
2255.2.20 by Robert Collins
Bypass irrelevant basis_inventory tests for dirstate.
25
        # This test is not applicable to DirState based trees: the basis is
26
        # not separate is mandatory.
27
        if isinstance(self.workingtree_format,
3907.2.3 by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced
28
            bzrlib.workingtree_4.DirStateWorkingTreeFormat):
3388.2.1 by Martin Pool
Deprecate LockableFiles.get_utf8
29
            raise TestNotApplicable("not applicable to %r"
30
                % (self.workingtree_format,))
1638.1.2 by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name.
31
        # TODO: jam 20051218 this probably should add more than just
32
        #                    a couple files to the inventory
33
1185.50.22 by John Arbash Meinel
Forgot to add the test.
34
        # Make sure the basis file is created by a commit
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
35
        t = self.make_branch_and_tree('.')
36
        b = t.branch
6437.20.3 by Wouter van Heyst
mechanically replace file().write() pattern with a with-keyword version
37
        with open('a', 'wb') as f: f.write('a\n')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
38
        t.add('a')
39
        t.commit('a', rev_id='r1')
40
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
41
        self.assertTrue(t._transport.has('basis-inventory-cache'))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
42
6405.2.9 by Jelmer Vernooij
More test fixes.
43
        basis_inv = t.basis_tree().root_inventory
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
44
        self.assertEqual('r1', basis_inv.revision_id)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
45
1185.65.17 by Robert Collins
Merge from integration, mode-changes are broken.
46
        store_inv = b.repository.get_inventory('r1')
4617.5.1 by Robert Collins
Stop poking under the hood for inventory equality in working tree inventory tests.
47
        self.assertEqual([], store_inv._make_delta(basis_inv))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
48
6437.20.3 by Wouter van Heyst
mechanically replace file().write() pattern with a with-keyword version
49
        with open('b', 'wb') as f: f.write('b\n')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
50
        t.add('b')
51
        t.commit('b', rev_id='r2')
52
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
53
        self.assertTrue(t._transport.has('basis-inventory-cache'))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
54
1638.1.2 by Robert Collins
Change the basis-inventory file to not have the revision-id in the file name.
55
        basis_inv_txt = t.read_basis_inventory()
2100.3.15 by Aaron Bentley
get test suite passing
56
        basis_inv = bzrlib.xml7.serializer_v7.read_inventory_from_string(basis_inv_txt)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
57
        self.assertEqual('r2', basis_inv.revision_id)
1185.65.17 by Robert Collins
Merge from integration, mode-changes are broken.
58
        store_inv = b.repository.get_inventory('r2')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
59
4617.5.1 by Robert Collins
Stop poking under the hood for inventory equality in working tree inventory tests.
60
        self.assertEqual([], store_inv._make_delta(basis_inv))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
61
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
62
    def test_wrong_format(self):
63
        """WorkingTree.basis safely ignores junk basis inventories"""
2255.2.20 by Robert Collins
Bypass irrelevant basis_inventory tests for dirstate.
64
        # This test is not applicable to DirState based trees: the basis is
65
        # not separate and ignorable.
66
        if isinstance(self.workingtree_format,
3907.2.3 by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced
67
            bzrlib.workingtree_4.DirStateWorkingTreeFormat):
3388.2.1 by Martin Pool
Deprecate LockableFiles.get_utf8
68
            raise TestNotApplicable("not applicable to %r"
69
                % (self.workingtree_format,))
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
70
        t = self.make_branch_and_tree('.')
71
        b = t.branch
6437.20.3 by Wouter van Heyst
mechanically replace file().write() pattern with a with-keyword version
72
        with open('a', 'wb') as f: f.write('a\n')
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
73
        t.add('a')
74
        t.commit('a', rev_id='r1')
3407.2.5 by Martin Pool
Deprecate LockableFiles.put_utf8
75
        t._transport.put_bytes('basis-inventory-cache', 'booga')
76
        t.basis_tree()
77
        t._transport.put_bytes('basis-inventory-cache', '<xml/>')
78
        t.basis_tree()
79
        t._transport.put_bytes('basis-inventory-cache', '<inventory />')
80
        t.basis_tree()
81
        t._transport.put_bytes('basis-inventory-cache',
82
            '<inventory format="pi"/>')
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
83
        t.basis_tree()