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