/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.436.30 by Jelmer Vernooij
Add test demonstrating issues rebasing revisions with multiple parents. (maybe same cause as #126743).
1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
0.436.177 by Jelmer Vernooij
Remove trailing whitespace.
2
#
0.436.19 by Jelmer Vernooij
- Add blackbox tests
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
0.436.131 by Jelmer Vernooij
Change license back to GPLv2+
5
# the Free Software Foundation; either version 2 of the License, or
0.436.19 by Jelmer Vernooij
- Add blackbox tests
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
16
0.436.178 by Jelmer Vernooij
Finish rename to 'bzr-rewrite'.
17
"""Couple of blackbox tests for the rewrite plugin."""
0.436.19 by Jelmer Vernooij
- Add blackbox tests
18
0.436.157 by Jelmer Vernooij
use absolute imports everywhere.
19
import os
20
7406.3.2 by Jelmer Vernooij
Update for breezy.
21
from ....branch import Branch
22
from ....tests.blackbox import ExternalBase
0.436.19 by Jelmer Vernooij
- Add blackbox tests
23
24
class TestRebaseSimple(ExternalBase):
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
25
0.436.19 by Jelmer Vernooij
- Add blackbox tests
26
    def make_file(self, name, contents):
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
27
        with open(name, 'w' + ('b' if isinstance(contents, bytes) else '')) as f:
0.436.19 by Jelmer Vernooij
- Add blackbox tests
28
            f.write(contents)
29
30
    def setUp(self):
31
        super(TestRebaseSimple, self).setUp()
32
        os.mkdir('main')
33
        os.chdir('main')
34
        self.run_bzr('init')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
35
        self.make_file('hello', b"hi world")
0.436.19 by Jelmer Vernooij
- Add blackbox tests
36
        self.run_bzr('add')
37
        self.run_bzr('commit -m bla')
38
        self.run_bzr('branch . ../feature')
39
0.436.214 by Jelmer Vernooij
Cope with no upstream branch being set.
40
    def test_no_upstream_branch(self):
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
41
        self.run_bzr_error(['brz: ERROR: No upstream branch specified.\n'],
0.436.214 by Jelmer Vernooij
Cope with no upstream branch being set.
42
                           'rebase')
43
0.436.19 by Jelmer Vernooij
- Add blackbox tests
44
    def test_notneeded(self):
45
        os.chdir('../feature')
7406.3.5 by Jelmer Vernooij
Fix formatting.
46
        self.assertEquals(
47
            'No revisions to rebase.\n',
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
48
            self.run_bzr('rebase ../main')[0])
0.436.19 by Jelmer Vernooij
- Add blackbox tests
49
0.436.215 by Jelmer Vernooij
Fix traceback when using --merge option.
50
    def test_custom_merge_type(self):
51
        self.make_file('hello', '42')
52
        self.run_bzr('commit -m that')
53
        os.chdir('../feature')
54
        self.make_file('hoi', "my data")
55
        self.run_bzr('add')
56
        self.run_bzr('commit -m this')
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
57
        self.assertEquals('', self.run_bzr('rebase --lca ../main')[0])
58
        self.assertEquals('3\n', self.run_bzr('revno')[0])
0.436.215 by Jelmer Vernooij
Fix traceback when using --merge option.
59
0.436.92 by Jelmer Vernooij
Handle case where base branch is descendant of current branch.
60
    def test_notneeded_feature_ahead(self):
61
        os.chdir('../feature')
62
        self.make_file('barbla', "bloe")
63
        self.run_bzr('add')
64
        self.run_bzr('commit -m bloe')
7406.3.5 by Jelmer Vernooij
Fix formatting.
65
        self.assertEquals(
66
            'No revisions to rebase.\n',
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
67
            self.run_bzr('rebase ../main')[0])
0.436.92 by Jelmer Vernooij
Handle case where base branch is descendant of current branch.
68
69
    def test_notneeded_main_ahead(self):
70
        self.make_file('barbla', "bloe")
71
        self.run_bzr('add')
72
        self.run_bzr('commit -m bloe')
73
        os.chdir('../feature')
7406.3.5 by Jelmer Vernooij
Fix formatting.
74
        self.assertEquals(
75
            "Base branch is descendant of current branch. Pulling instead.\n",
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
76
            self.run_bzr('rebase ../main')[0])
0.436.243 by Jelmer Vernooij
Avoid deprecated methods, use Tree API only.
77
        self.assertEquals(Branch.open("../feature").last_revision_info(),
78
                          Branch.open("../main").last_revision_info())
0.436.92 by Jelmer Vernooij
Handle case where base branch is descendant of current branch.
79
0.436.84 by Jelmer Vernooij
Support rebasing pending merges.
80
    def test_no_pending_merges(self):
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
81
        self.run_bzr_error(['brz: ERROR: No pending merges present.\n'],
0.436.147 by Jelmer Vernooij
Fix tests against bzr.dev.
82
                           ['rebase', '--pending-merges'])
0.436.84 by Jelmer Vernooij
Support rebasing pending merges.
83
84
    def test_pending_merges(self):
0.441.3 by Robert Collins
Update rebase to 1.6b3 API changes.
85
        os.chdir('..')
86
        self.build_tree_contents([('main/hello', '42')])
87
        self.run_bzr('add', working_dir='main')
88
        self.run_bzr('commit -m that main')
89
        self.build_tree_contents([('feature/hoi', 'my data')])
90
        self.run_bzr('add', working_dir='feature')
91
        self.run_bzr('commit -m this feature')
7406.3.5 by Jelmer Vernooij
Fix formatting.
92
        self.assertEqual(
93
            ('', ' M  hello\nAll changes applied successfully.\n'),
0.441.3 by Robert Collins
Update rebase to 1.6b3 API changes.
94
            self.run_bzr('merge ../main', working_dir='feature'))
95
        out, err = self.run_bzr('rebase --pending-merges', working_dir='feature')
96
        self.assertEqual('', out)
97
        self.assertContainsRe(err, 'modified hello')
7406.3.5 by Jelmer Vernooij
Fix formatting.
98
        self.assertEqual(
99
            ('3\n', ''),
0.441.3 by Robert Collins
Update rebase to 1.6b3 API changes.
100
            self.run_bzr('revno', working_dir='feature'))
0.436.84 by Jelmer Vernooij
Support rebasing pending merges.
101
0.436.19 by Jelmer Vernooij
- Add blackbox tests
102
    def test_simple_success(self):
103
        self.make_file('hello', '42')
104
        self.run_bzr('commit -m that')
105
        os.chdir('../feature')
106
        self.make_file('hoi', "my data")
107
        self.run_bzr('add')
108
        self.run_bzr('commit -m this')
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
109
        self.assertEquals('', self.run_bzr('rebase ../main')[0])
110
        self.assertEquals('3\n', self.run_bzr('revno')[0])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
111
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
112
    def test_range(self):
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
113
        # commit mainline rev 2
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
114
        self.make_file('hello', '42')
115
        self.run_bzr('commit -m that')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
116
        # commit feature rev 2
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
117
        os.chdir('../feature')
118
        self.make_file('hoi', "my data")
119
        self.run_bzr('add')
120
        self.run_bzr('commit -m this')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
121
        # commit feature rev 3
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
122
        self.make_file('hooi', "your data")
123
        self.run_bzr('add')
124
        self.run_bzr('commit -m that')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
125
        # commit feature rev 4
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
126
        self.make_file('hoooi', "someone else's data")
127
        self.run_bzr('add')
128
        self.run_bzr('commit -m these')
0.436.181 by Jelmer Vernooij
Merge patch from Max to treat a stop revision as inclusive, not exclusive.
129
        # pick up just rev 2 and 3 and discard 4 from feature
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
130
        self.assertEquals('', self.run_bzr('rebase -r2..3 ../main')[0])
0.436.182 by Jelmer Vernooij
Fix test.
131
        # our rev 2 is now rev3 and 3 is now rev4:
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
132
        self.assertEquals('4\n', self.run_bzr('revno')[0])
0.436.182 by Jelmer Vernooij
Fix test.
133
        # content added from our old revisions 4 should be gone.
0.436.236 by Jelmer Vernooij
Avoid deprecated failIfExists.
134
        self.assertPathDoesNotExist('hoooi')
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
135
136
    def test_range_open_end(self):
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
137
        # commit mainline rev 2
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
138
        self.make_file('hello', '42')
139
        self.run_bzr('commit -m that')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
140
        # commit feature rev 2
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
141
        os.chdir('../feature')
142
        self.make_file('hoi', "my data")
143
        self.run_bzr('add')
144
        self.run_bzr('commit -m this')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
145
        # commit feature rev 3
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
146
        self.make_file('hooi', "your data")
147
        self.run_bzr('add')
148
        self.run_bzr('commit -m that')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
149
        # commit feature rev 4
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
150
        self.make_file('hoooi', "someone else's data")
151
        self.run_bzr('add')
152
        self.run_bzr('commit -m these')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
153
        # rebase only rev 4 onto main
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
154
        self.assertEquals('', self.run_bzr('rebase -r4.. ../main')[0])
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
155
        # should only get rev 3 (our old 2 and 3 are gone)
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
156
        self.assertEquals('3\n', self.run_bzr('revno')[0])
0.436.236 by Jelmer Vernooij
Avoid deprecated failIfExists.
157
        self.assertPathDoesNotExist('hoi')
158
        self.assertPathDoesNotExist('hooi')
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
159
        branch = Branch.open(".")
7406.3.5 by Jelmer Vernooij
Fix formatting.
160
        self.assertEquals(
161
            "these",
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
162
            branch.repository.get_revision(branch.last_revision()).message)
0.436.236 by Jelmer Vernooij
Avoid deprecated failIfExists.
163
        self.assertPathExists('hoooi')
0.436.42 by Jelmer Vernooij
Support the -r argument to rebase.
164
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
165
    def test_conflicting(self):
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
166
        # commit mainline rev 2
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
167
        self.make_file('hello', '42')
168
        self.run_bzr('commit -m that')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
169
        # commit feature rev 2 changing hello differently
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
170
        os.chdir('../feature')
171
        self.make_file('hello', "other data")
172
        self.run_bzr('commit -m this')
0.441.4 by Robert Collins
* Fixed O(history) access during plan creation (Robert Collins, lp:#249823).
173
        self.run_bzr_error([
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
174
            'Text conflict in hello\n1 conflicts encountered.\nbrz: ERROR: A conflict occurred replaying a commit. Resolve the conflict and run \'brz rebase-continue\' or run \'brz rebase-abort\'.',
0.436.147 by Jelmer Vernooij
Fix tests against bzr.dev.
175
            ], ['rebase', '../main'])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
176
177
    def test_conflicting_abort(self):
178
        self.make_file('hello', '42')
179
        self.run_bzr('commit -m that')
180
        os.chdir('../feature')
181
        self.make_file('hello', "other data")
182
        self.run_bzr('commit -m this')
183
        old_log = self.run_bzr('log')[0]
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
184
        self.run_bzr_error(['Text conflict in hello\n1 conflicts encountered.\nbrz: ERROR: A conflict occurred replaying a commit. Resolve the conflict and run \'brz rebase-continue\' or run \'brz rebase-abort\'.\n'], ['rebase', '../main'])
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
185
        self.assertEquals('', self.run_bzr('rebase-abort')[0])
186
        self.assertEquals(old_log, self.run_bzr('log')[0])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
187
188
    def test_conflicting_continue(self):
189
        self.make_file('hello', '42')
190
        self.run_bzr('commit -m that')
191
        os.chdir('../feature')
192
        self.make_file('hello', "other data")
193
        self.run_bzr('commit -m this')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
194
        self.run_bzr_error(['Text conflict in hello\n1 conflicts encountered.\nbrz: ERROR: A conflict occurred replaying a commit. Resolve the conflict and run \'brz rebase-continue\' or run \'brz rebase-abort\'.\n'], ['rebase', '../main'])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
195
        self.run_bzr('resolved hello')
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
196
        self.assertEquals('', self.run_bzr('rebase-continue')[0])
197
        self.assertEquals('3\n', self.run_bzr('revno')[0])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
198
199
    def test_continue_nothing(self):
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
200
        self.run_bzr_error(['brz: ERROR: No rebase to continue'],
0.436.147 by Jelmer Vernooij
Fix tests against bzr.dev.
201
                           ['rebase-continue'])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
202
203
    def test_abort_nothing(self):
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
204
        self.run_bzr_error(['brz: ERROR: No rebase to abort'],
0.436.147 by Jelmer Vernooij
Fix tests against bzr.dev.
205
                           ['rebase-abort'])
0.436.20 by Jelmer Vernooij
Some more blackbox tests.
206
0.436.21 by Jelmer Vernooij
Tests.
207
    def test_todo_nothing(self):
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
208
        self.run_bzr_error(['brz: ERROR: No rebase in progress'],
0.436.147 by Jelmer Vernooij
Fix tests against bzr.dev.
209
                           ['rebase-todo'])
0.437.2 by James Westby
Lookup the onto revision in the upstream branch.
210
211
    def test_onto(self):
212
        self.make_file('hello', '42')
213
        self.run_bzr('add')
214
        self.run_bzr('commit -m that')
215
        self.make_file('other', '43')
216
        self.run_bzr('add')
217
        self.run_bzr('commit -m that_other')
218
        os.chdir('../feature')
219
        self.make_file('hoi', "my data")
220
        self.run_bzr('add')
221
        self.run_bzr('commit -m this')
7406.3.5 by Jelmer Vernooij
Fix formatting.
222
        self.assertEquals(
223
            '', self.run_bzr('rebase --onto -2 ../main')[0])
224
        self.assertEquals(
225
            '3\n', self.run_bzr('revno')[0])
0.437.2 by James Westby
Lookup the onto revision in the upstream branch.
226
0.436.51 by Jelmer Vernooij
Give proper warning when there is no common base.
227
    def test_unrelated(self):
228
        os.chdir('..')
229
        os.mkdir('unrelated')
230
        os.chdir('unrelated')
231
        self.run_bzr('init')
232
        self.make_file('hello', "hi world")
233
        self.run_bzr('add')
234
        self.run_bzr('commit -m x')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
235
        self.run_bzr_error(['brz: ERROR: Branches have no common ancestor, and no merge base.*'],
0.436.147 by Jelmer Vernooij
Fix tests against bzr.dev.
236
                           ['rebase', '../main'])
0.436.51 by Jelmer Vernooij
Give proper warning when there is no common base.
237
0.437.4 by James Westby
Import rebase_todo as it is needed for --verbose.
238
    def test_verbose(self):
239
        self.make_file('hello', '42')
240
        self.run_bzr('commit -m that')
241
        os.chdir('../feature')
242
        self.make_file('hoi', "my data")
243
        self.run_bzr('add')
244
        self.run_bzr('commit -m this')
245
        out, err = self.run_bzr('rebase -v ../main')
0.436.30 by Jelmer Vernooij
Add test demonstrating issues rebasing revisions with multiple parents. (maybe same cause as #126743).
246
        self.assertContainsRe(err, '1 revisions will be rebased:')
0.437.4 by James Westby
Import rebase_todo as it is needed for --verbose.
247
        self.assertEqual('', out)
7406.3.5 by Jelmer Vernooij
Fix formatting.
248
        self.assertEqual('3\n', self.run_bzr('revno')[0])
0.437.4 by James Westby
Import rebase_todo as it is needed for --verbose.
249
0.436.30 by Jelmer Vernooij
Add test demonstrating issues rebasing revisions with multiple parents. (maybe same cause as #126743).
250
    def test_useless_merge(self):
251
        self.make_file('bar', '42')
252
        self.run_bzr('add')
253
        self.run_bzr('commit -m that')
254
        os.chdir('../feature')
255
        self.make_file('hello', "my data")
256
        self.run_bzr('commit -m this')
257
        self.run_bzr('merge')
258
        self.run_bzr('commit -m merge')
259
        self.run_bzr('rebase')
0.436.63 by Jelmer Vernooij
Fix replay command, add test.
260
0.443.7 by Max Bowsher
Adjust the expectations of tests I inherited from lifeless to match what I
261
    def strip_last_revid_part(self, revid):
262
        """Assume revid is a revid in the default form, and strip the part
263
        which would be random.
264
        """
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
265
        return revid[:revid.rindex(b'-')]
0.443.7 by Max Bowsher
Adjust the expectations of tests I inherited from lifeless to match what I
266
0.443.1 by Robert Collins
Fix rebasing of merge commits.
267
    def test_always_rebase_merges(self):
268
        trunk = self.make_branch_and_tree('trunk')
269
        trunk.commit('base')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
270
        feature2 = trunk.controldir.sprout('feature2').open_workingtree()
0.443.1 by Robert Collins
Fix rebasing of merge commits.
271
        revid2 = feature2.commit('change')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
272
        feature = trunk.controldir.sprout('feature').open_workingtree()
0.443.1 by Robert Collins
Fix rebasing of merge commits.
273
        feature.commit('change')
274
        feature.merge_from_branch(feature2.branch)
275
        feature.commit('merge')
276
        feature.commit('change2')
277
        trunk.commit('additional upstream change')
278
        self.run_bzr('rebase --always-rebase-merges ../trunk', working_dir='feature')
279
        # second revision back should be a merge of feature2
280
        repo = feature.branch.repository
281
        repo.lock_read()
282
        self.addCleanup(repo.unlock)
283
        tip = feature.last_revision()
284
        merge_id = repo.get_graph().get_parent_map([tip])[tip][0]
285
        merge_parents = repo.get_graph().get_parent_map([merge_id])[merge_id]
0.443.7 by Max Bowsher
Adjust the expectations of tests I inherited from lifeless to match what I
286
        self.assertEqual(self.strip_last_revid_part(revid2),
287
                         self.strip_last_revid_part(merge_parents[1]))
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
288
0.443.1 by Robert Collins
Fix rebasing of merge commits.
289
    def test_rebase_merge(self):
290
        trunk = self.make_branch_and_tree('trunk')
291
        trunk.commit('base')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
292
        feature2 = trunk.controldir.sprout('feature2').open_workingtree()
0.443.1 by Robert Collins
Fix rebasing of merge commits.
293
        revid2 = feature2.commit('change')
7406.3.3 by Jelmer Vernooij
Fix python3 compatibility.
294
        feature = trunk.controldir.sprout('feature').open_workingtree()
0.443.1 by Robert Collins
Fix rebasing of merge commits.
295
        feature.commit('change')
296
        feature.merge_from_branch(feature2.branch)
297
        feature.commit('merge')
298
        feature.commit('change2')
299
        trunk.commit('additional upstream change')
300
        self.run_bzr('rebase ../trunk', working_dir='feature')
301
        # second revision back should be a merge of feature2
302
        repo = feature.branch.repository
303
        repo.lock_read()
304
        self.addCleanup(repo.unlock)
305
        tip = feature.last_revision()
306
        merge_id = repo.get_graph().get_parent_map([tip])[tip][0]
307
        merge_parents = repo.get_graph().get_parent_map([merge_id])[merge_id]
0.443.7 by Max Bowsher
Adjust the expectations of tests I inherited from lifeless to match what I
308
        self.assertEqual(self.strip_last_revid_part(revid2),
309
                         self.strip_last_revid_part(merge_parents[1]))
0.443.1 by Robert Collins
Fix rebasing of merge commits.
310
0.436.213 by Levi Bard
Allow branch to operate on to be specified explicitly.
311
    def test_directory(self):
312
        self.make_file('test_directory1', "testing non-current directories")
313
        self.run_bzr('add')
314
        self.run_bzr('commit -m blah')
315
        os.chdir('../feature')
316
        self.make_file('test_directory2', "testing non-current directories")
317
        self.run_bzr('add')
318
        self.run_bzr('commit -m blah')
319
        os.chdir('..')
7406.3.5 by Jelmer Vernooij
Fix formatting.
320
        self.assertEquals('', self.run_bzr('rebase -d feature main')[0])
0.436.217 by Jelmer Vernooij
avoid using deprecated utility functions.
321
0.436.187 by Jelmer Vernooij
Fix test names.
322
0.436.63 by Jelmer Vernooij
Fix replay command, add test.
323
class ReplayTests(ExternalBase):
0.436.187 by Jelmer Vernooij
Fix test names.
324
0.436.63 by Jelmer Vernooij
Fix replay command, add test.
325
    def test_replay(self):
326
        os.mkdir('main')
327
        os.chdir('main')
328
        self.run_bzr('init')
329
        open('bar', 'w').write('42')
330
        self.run_bzr('add')
331
        self.run_bzr('commit -m that')
332
        os.mkdir('../feature')
333
        os.chdir('../feature')
334
        self.run_bzr('init')
335
        branch = Branch.open('.')
336
        open('hello', 'w').write("my data")
337
        self.run_bzr('add')
338
        self.run_bzr('commit -m this')
0.436.243 by Jelmer Vernooij
Avoid deprecated methods, use Tree API only.
339
        self.assertEquals(1, branch.revno())
0.436.63 by Jelmer Vernooij
Fix replay command, add test.
340
        self.run_bzr('replay -r1 ../main')
0.436.243 by Jelmer Vernooij
Avoid deprecated methods, use Tree API only.
341
        self.assertEquals(2, branch.revno())
0.436.63 by Jelmer Vernooij
Fix replay command, add test.
342
        self.assertTrue(os.path.exists('bar'))
0.436.64 by Jelmer Vernooij
Support revision ranges to replay.
343
0.436.187 by Jelmer Vernooij
Fix test names.
344
    def test_replay_open_range(self):
0.436.64 by Jelmer Vernooij
Support revision ranges to replay.
345
        os.mkdir('main')
346
        os.chdir('main')
347
        self.run_bzr('init')
348
        open('bar', 'w').write('42')
349
        self.run_bzr('add')
350
        self.run_bzr('commit -m that')
351
        open('bar', 'w').write('84')
352
        self.run_bzr('commit -m blathat')
353
        os.mkdir('../feature')
354
        os.chdir('../feature')
355
        self.run_bzr('init')
356
        branch = Branch.open('.')
357
        open('hello', 'w').write("my data")
358
        self.run_bzr('add')
359
        self.run_bzr('commit -m this')
0.436.243 by Jelmer Vernooij
Avoid deprecated methods, use Tree API only.
360
        self.assertEquals(1, branch.revno())
0.436.64 by Jelmer Vernooij
Support revision ranges to replay.
361
        self.run_bzr('replay -r1.. ../main')
0.436.243 by Jelmer Vernooij
Avoid deprecated methods, use Tree API only.
362
        self.assertEquals(3, branch.revno())
0.436.64 by Jelmer Vernooij
Support revision ranges to replay.
363
        self.assertTrue(os.path.exists('bar'))