/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/per_controldir/test_push.py

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for bzrdir implementations - push."""
18
18
 
19
 
from ...errors import LossyPushToSameVCS
 
19
from ...errors import (
 
20
    LossyPushToSameVCS,
 
21
    TagsNotSupported,
 
22
    )
 
23
from ...revision import NULL_REVISION
 
24
from .. import TestNotApplicable
20
25
 
21
26
from breezy.tests.per_controldir import (
22
27
    TestCaseWithControlDir,
39
44
        self.assertEqual(tree.branch, result.source_branch)
40
45
        self.assertEqual(dir.open_branch().base, result.target_branch.base)
41
46
        self.assertEqual(dir.open_branch().base,
42
 
            tree.branch.get_push_location())
 
47
                         tree.branch.get_push_location())
 
48
 
 
49
    def test_push_new_branch_fetch_tags(self):
 
50
        builder = self.make_branch_builder('from')
 
51
        builder.start_series()
 
52
        rev_1 = builder.build_snapshot(None, [
 
53
            ('add', ('', None, 'directory', '')),
 
54
            ('add', ('filename', None, 'file', b'content'))])
 
55
        rev_2 = builder.build_snapshot(
 
56
            [rev_1], [('modify', ('filename', b'new-content\n'))])
 
57
        rev_3 = builder.build_snapshot(
 
58
            [rev_1], [('modify', ('filename', b'new-new-content\n'))])
 
59
        builder.finish_series()
 
60
        branch = builder.get_branch()
 
61
        try:
 
62
            branch.tags.set_tag('atag', rev_2)
 
63
        except TagsNotSupported:
 
64
            raise TestNotApplicable('source format does not support tags')
 
65
 
 
66
        dir = self.make_repository('target').controldir
 
67
        branch.get_config().set_user_option('branch.fetch_tags', True)
 
68
        result = dir.push_branch(branch)
 
69
        self.assertEqual(
 
70
            set([rev_1, rev_2, rev_3]),
 
71
            set(result.source_branch.repository.all_revision_ids()))
 
72
        self.assertEqual(
 
73
            {'atag': rev_2}, result.source_branch.tags.get_tag_dict())
43
74
 
44
75
    def test_push_new_branch_lossy(self):
45
76
        tree, rev_1 = self.create_simple_tree()
53
84
        result = dir.push_branch(tree.branch)
54
85
        self.assertEqual(tree.branch.base, result.source_branch.base)
55
86
        self.assertEqual(dir.open_branch().base,
56
 
            result.target_branch.base)
 
87
                         result.target_branch.base)
57
88
 
58
89
    def test_push_incremental(self):
59
90
        tree, rev1 = self.create_simple_tree()
64
95
        rev_2 = tree.commit('two')
65
96
        result = dir.push_branch(tree.branch)
66
97
        self.assertEqual(tree.last_revision(),
67
 
            result.branch_push_result.new_revid)
 
98
                         result.branch_push_result.new_revid)
68
99
        self.assertEqual(2, result.branch_push_result.new_revno)
69
100
        self.assertEqual(tree.branch.base, result.source_branch.base)
70
101
        self.assertEqual(dir.open_branch().base, result.target_branch.base)