/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_interbranch/test_pull.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-03-24 03:28:54 UTC
  • mfrom: (6883.21.3 noroundtrippin)
  • Revision ID: breezy.the.bot@gmail.com-20180324032854-sc5g279k6b2vttbg
Allow InterBranch formats to raise NoRoundtrippingSupport.

Merged from https://code.launchpad.net/~jelmer/brz/noroundtrippin/+merge/340877

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        # become the revision-history.
37
37
        parent = self.make_from_branch_and_tree('parent')
38
38
        parent.commit('1st post', allow_pointless=True)
39
 
        mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
39
        try:
 
40
            mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
41
        except errors.NoRoundtrippingSupport:
 
42
            raise TestNotApplicable(
 
43
                'lossless push between %r and %r not supported' %
 
44
                (self.branch_format_from, self.branch_format_to))
40
45
        mine.commit('my change', allow_pointless=True)
41
 
        parent.merge_from_branch(mine.branch)
 
46
        try:
 
47
            parent.merge_from_branch(mine.branch)
 
48
        except errors.NoRoundtrippingSupport:
 
49
            raise TestNotApplicable(
 
50
                'lossless push between %r and %r not supported' %
 
51
                (self.branch_format_from, self.branch_format_to))
42
52
        p2 = parent.commit('merge my change')
43
53
        mine.pull(parent.branch)
44
54
        self.assertEqual(p2, mine.branch.last_revision())
50
60
        # directly accessible.
51
61
        parent = self.make_from_branch_and_tree('parent')
52
62
        parent.commit('1st post', allow_pointless=True)
53
 
        mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
63
        try:
 
64
            mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
65
        except errors.NoRoundtrippingSupport:
 
66
            raise TestNotApplicable(
 
67
                'lossless push between %r and %r not supported' %
 
68
                (self.branch_format_from, self.branch_format_to))
54
69
        mine.commit('my change', allow_pointless=True)
55
70
        other = self.sprout_to(parent.controldir, 'other').open_workingtree()
56
71
        other.merge_from_branch(mine.branch)
57
72
        other.commit('merge my change')
58
 
        parent.merge_from_branch(other.branch)
 
73
        try:
 
74
            parent.merge_from_branch(other.branch)
 
75
        except errors.NoRoundtrippingSupport:
 
76
            raise TestNotApplicable(
 
77
                'lossless push between %r and %r not supported' %
 
78
                (self.branch_format_from, self.branch_format_to))
59
79
        p2 = parent.commit('merge other')
60
80
        mine.pull(parent.branch)
61
81
        self.assertEqual(p2, mine.branch.last_revision())
65
85
        master_tree = self.make_from_branch_and_tree('master')
66
86
        master_tree.commit('master')
67
87
        checkout = master_tree.branch.create_checkout('checkout')
68
 
        other = self.sprout_to(master_tree.branch.controldir, 'other').open_workingtree()
 
88
        try:
 
89
            other = self.sprout_to(master_tree.branch.controldir, 'other').open_workingtree()
 
90
        except errors.NoRoundtrippingSupport:
 
91
            raise TestNotApplicable(
 
92
                'lossless push between %r and %r not supported' %
 
93
                (self.branch_format_from, self.branch_format_to))
69
94
        rev2 = other.commit('other commit')
70
95
        # now pull, which should update both checkout and master.
71
 
        checkout.branch.pull(other.branch)
 
96
        try:
 
97
            checkout.branch.pull(other.branch)
 
98
        except errors.NoRoundtrippingSupport:
 
99
            raise TestNotApplicable(
 
100
                'lossless push between %r and %r not supported' %
 
101
                (self.branch_format_from, self.branch_format_to))
72
102
        self.assertEqual(rev2, checkout.branch.last_revision())
73
103
        self.assertEqual(rev2, master_tree.branch.last_revision())
74
104
 
90
120
    def test_pull_returns_result(self):
91
121
        parent = self.make_from_branch_and_tree('parent')
92
122
        p1 = parent.commit('1st post')
93
 
        mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
123
        try:
 
124
            mine = self.sprout_to(parent.controldir, 'mine').open_workingtree()
 
125
        except errors.NoRoundtrippingSupport:
 
126
            raise TestNotApplicable(
 
127
                'lossless push between %r and %r not supported' %
 
128
                (self.branch_format_from, self.branch_format_to))
94
129
        m1 = mine.commit('my change')
95
 
        result = parent.branch.pull(mine.branch)
 
130
        try:
 
131
            result = parent.branch.pull(mine.branch)
 
132
        except errors.NoRoundtrippingSupport:
 
133
            raise TestNotApplicable(
 
134
                'lossless push between %r and %r not supported' %
 
135
                (self.branch_format_from, self.branch_format_to))
96
136
        self.assertIsNot(None, result)
97
137
        self.assertIs(mine.branch, result.source_branch)
98
138
        self.assertIs(parent.branch, result.target_branch)
107
147
    def test_pull_overwrite(self):
108
148
        tree_a = self.make_from_branch_and_tree('tree_a')
109
149
        tree_a.commit('message 1')
110
 
        tree_b = self.sprout_to(tree_a.controldir, 'tree_b').open_workingtree()
 
150
        try:
 
151
            tree_b = self.sprout_to(tree_a.controldir, 'tree_b').open_workingtree()
 
152
        except errors.NoRoundtrippingSupport:
 
153
            raise TestNotApplicable(
 
154
                'lossless push between %r and %r not supported' %
 
155
                (self.branch_format_from, self.branch_format_to))
 
156
 
111
157
        rev2a = tree_a.commit('message 2a')
112
158
        rev2b = tree_b.commit('message 2b')
113
 
        self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
159
        try:
 
160
            self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
161
        except errors.NoRoundtrippingSupport:
 
162
            raise TestNotApplicable(
 
163
                'lossless push between %r and %r not supported' %
 
164
                (self.branch_format_from, self.branch_format_to))
114
165
        self.assertRaises(errors.DivergedBranches,
115
166
                          tree_a.branch.pull, tree_b.branch,
116
167
                          overwrite=False, stop_revision=rev2b)