/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
17
from breezy.tests import TestNotApplicable
18
from breezy.tests.per_workingtree import TestCaseWithWorkingTree
6670.4.3 by Jelmer Vernooij
Fix more imports.
19
import breezy.bzr.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,
7143.15.2 by Jelmer Vernooij
Run autopep8.
28
                      breezy.bzr.workingtree_4.DirStateWorkingTreeFormat):
3388.2.1 by Martin Pool
Deprecate LockableFiles.get_utf8
29
            raise TestNotApplicable("not applicable to %r"
7143.15.2 by Jelmer Vernooij
Run autopep8.
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('.')
6876.5.1 by Jelmer Vernooij
Avoid passing in revision ids if possible.
36
        if getattr(t, 'root_inventory', None) is None:
37
            raise TestNotApplicable("not applicable to %r"
7143.15.2 by Jelmer Vernooij
Run autopep8.
38
                                    % (self.workingtree_format,))
6876.5.1 by Jelmer Vernooij
Avoid passing in revision ids if possible.
39
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
40
        b = t.branch
7143.15.2 by Jelmer Vernooij
Run autopep8.
41
        with open('a', 'wb') as f:
42
            f.write(b'a\n')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
43
        t.add('a')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
44
        r1 = t.commit('a')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
45
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
46
        self.assertTrue(t._transport.has('basis-inventory-cache'))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
47
6405.2.9 by Jelmer Vernooij
More test fixes.
48
        basis_inv = t.basis_tree().root_inventory
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
49
        self.assertEqual(r1, basis_inv.revision_id)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
50
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
51
        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.
52
        self.assertEqual([], store_inv._make_delta(basis_inv))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
53
7143.15.2 by Jelmer Vernooij
Run autopep8.
54
        with open('b', 'wb') as f:
55
            f.write(b'b\n')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
56
        t.add('b')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
57
        r2 = t.commit('b')
1185.50.22 by John Arbash Meinel
Forgot to add the test.
58
3407.2.14 by Martin Pool
Remove more cases of getting transport via control_files
59
        self.assertTrue(t._transport.has('basis-inventory-cache'))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
60
7467.2.1 by Jelmer Vernooij
Replace write_inventory_to_string with write_inventory_to_chunks.
61
        basis_inv_lines = t.read_basis_inventory()
62
        basis_inv = breezy.bzr.xml7.serializer_v7.read_inventory_from_lines(
63
            basis_inv_lines)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
64
        self.assertEqual(r2, basis_inv.revision_id)
65
        store_inv = b.repository.get_inventory(r2)
1185.50.22 by John Arbash Meinel
Forgot to add the test.
66
4617.5.1 by Robert Collins
Stop poking under the hood for inventory equality in working tree inventory tests.
67
        self.assertEqual([], store_inv._make_delta(basis_inv))
1185.50.22 by John Arbash Meinel
Forgot to add the test.
68
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
69
    def test_wrong_format(self):
70
        """WorkingTree.basis safely ignores junk basis inventories"""
2255.2.20 by Robert Collins
Bypass irrelevant basis_inventory tests for dirstate.
71
        # This test is not applicable to DirState based trees: the basis is
72
        # not separate and ignorable.
73
        if isinstance(self.workingtree_format,
7143.15.2 by Jelmer Vernooij
Run autopep8.
74
                      breezy.bzr.workingtree_4.DirStateWorkingTreeFormat):
3388.2.1 by Martin Pool
Deprecate LockableFiles.get_utf8
75
            raise TestNotApplicable("not applicable to %r"
7143.15.2 by Jelmer Vernooij
Run autopep8.
76
                                    % (self.workingtree_format,))
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
77
        t = self.make_branch_and_tree('.')
6876.5.1 by Jelmer Vernooij
Avoid passing in revision ids if possible.
78
        if getattr(t, 'root_inventory', None) is None:
79
            raise TestNotApplicable("not applicable to %r"
7143.15.2 by Jelmer Vernooij
Run autopep8.
80
                                    % (self.workingtree_format,))
6876.5.1 by Jelmer Vernooij
Avoid passing in revision ids if possible.
81
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
82
        b = t.branch
7143.15.2 by Jelmer Vernooij
Run autopep8.
83
        with open('a', 'wb') as f:
84
            f.write(b'a\n')
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
85
        t.add('a')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
86
        t.commit('a')
6982 by Jelmer Vernooij
Merge lp:~jelmer/brz/python3-xml
87
        t._transport.put_bytes('basis-inventory-cache', b'booga')
88
        t.basis_tree()
89
        t._transport.put_bytes('basis-inventory-cache', b'<xml/>')
90
        t.basis_tree()
91
        t._transport.put_bytes('basis-inventory-cache', b'<inventory />')
3407.2.5 by Martin Pool
Deprecate LockableFiles.put_utf8
92
        t.basis_tree()
93
        t._transport.put_bytes('basis-inventory-cache',
7143.15.2 by Jelmer Vernooij
Run autopep8.
94
                               b'<inventory format="pi"/>')
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
95
        t.basis_tree()