/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) 2011, 2016 Canonical Ltd
5741.1.3 by Jelmer Vernooij
Move fetch tests.
2
#
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.
7
#
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.
12
#
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17
"""Tests for InterBranch.fetch."""
18
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
19
from breezy.revision import NULL_REVISION
20
from breezy.tests.per_interbranch import (
5741.1.3 by Jelmer Vernooij
Move fetch tests.
21
    TestCaseWithInterBranch,
22
    )
23
24
25
class TestInterBranchFetch(TestCaseWithInterBranch):
26
27
    def test_fetch_revisions(self):
28
        """Test fetch-revision operation."""
29
        wt = self.make_from_branch_and_tree('b1')
30
        b1 = wt.branch
31
        self.build_tree_contents([('b1/foo', 'hello')])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
32
        wt.add(['foo'])
5741.1.3 by Jelmer Vernooij
Move fetch tests.
33
        wt.commit('lala!', rev_id='revision-1', allow_pointless=False)
34
35
        b2 = self.make_to_branch('b2')
36
        b2.fetch(b1)
37
38
        # fetch does not update the last revision
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
39
        self.assertEqual(NULL_REVISION, b2.last_revision())
5741.1.3 by Jelmer Vernooij
Move fetch tests.
40
41
        rev = b2.repository.get_revision('revision-1')
42
        tree = b2.repository.revision_tree('revision-1')
43
        tree.lock_read()
44
        self.addCleanup(tree.unlock)
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
45
        self.assertEqual(
46
                tree.get_file_text(tree.path2id('foo'), 'foo'),
47
                'hello')
5741.1.3 by Jelmer Vernooij
Move fetch tests.
48
5852.1.2 by Jelmer Vernooij
Add test for InterBranch.fetch(limit=).
49
    def test_fetch_revisions_limit(self):
50
        """Test fetch-revision operation."""
5852.1.9 by Jelmer Vernooij
Use branch builder.
51
        builder = self.make_branch_builder('b1',
52
            format=self.branch_format_from._matchingbzrdir)
53
        builder.start_series()
5852.1.11 by Jelmer Vernooij
Review feedback from Andrew: use NotImplementedError instead of UnsupportedOperation, use simpler build_commit rather than build_snapshot.
54
        builder.build_commit(rev_id='revision-1')
55
        builder.build_commit(rev_id='revision-2')
56
        builder.build_commit(rev_id='revision-3')
5852.1.9 by Jelmer Vernooij
Use branch builder.
57
        builder.finish_series()
58
        b1 = builder.get_branch()
5852.1.2 by Jelmer Vernooij
Add test for InterBranch.fetch(limit=).
59
        b2 = self.make_to_branch('b2')
60
        b2.fetch(b1, limit=1)
61
62
        # fetch does not update the last revision
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
63
        self.assertEqual(NULL_REVISION, b2.last_revision())
5852.1.2 by Jelmer Vernooij
Add test for InterBranch.fetch(limit=).
64
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
65
        self.assertEqual(
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
66
            {'revision-1'},
5852.1.2 by Jelmer Vernooij
Add test for InterBranch.fetch(limit=).
67
            b2.repository.has_revisions(
68
                ['revision-1', 'revision-2', 'revision-3']))
5852.1.5 by Andrew Bennetts, Jelmer Vernooij
Support limit= for fetching between Bazaar branches.
69
70
    def test_fetch_revisions_limit_incremental(self):
71
        """Test incremental fetch-revision operation with limit."""
72
        wt = self.make_from_branch_and_tree('b1')
73
        b1 = wt.branch
74
        self.build_tree_contents([('b1/foo', 'hello')])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
75
        wt.add(['foo'])
5852.1.5 by Andrew Bennetts, Jelmer Vernooij
Support limit= for fetching between Bazaar branches.
76
        wt.commit('lala!', rev_id='revision-1', allow_pointless=False)
77
78
        b2 = self.make_to_branch('b2')
79
        b2.fetch(b1, limit=1)
80
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
81
        self.assertEqual(
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
82
            {'revision-1'},
5852.1.5 by Andrew Bennetts, Jelmer Vernooij
Support limit= for fetching between Bazaar branches.
83
            b2.repository.has_revisions(
84
                ['revision-1', 'revision-2', 'revision-3']))
85
86
        wt.commit('hmm', rev_id='revision-2')
87
        wt.commit('hmmm', rev_id='revision-3')
88
89
        b2.fetch(b1, limit=1)
90
91
        # fetch does not update the last revision
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
92
        self.assertEqual(NULL_REVISION, b2.last_revision())
5852.1.5 by Andrew Bennetts, Jelmer Vernooij
Support limit= for fetching between Bazaar branches.
93
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
94
        self.assertEqual(
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
95
            {'revision-1', 'revision-2'},
5852.1.5 by Andrew Bennetts, Jelmer Vernooij
Support limit= for fetching between Bazaar branches.
96
            b2.repository.has_revisions(
97
                ['revision-1', 'revision-2', 'revision-3']))