/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-2011, 2013, 2016 Canonical Ltd
1850.3.4 by John Arbash Meinel
Add copyright to test_uncommit.py
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1850.3.4 by John Arbash Meinel
Add copyright to test_uncommit.py
16
17
"""Test the uncommit command."""
1558.1.12 by Aaron Bentley
Got uncommit working properly with checkouts
18
19
import os
20
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
21
from breezy import uncommit
6670.4.3 by Jelmer Vernooij
Fix more imports.
22
from breezy.bzr.bzrdir import BzrDirMetaFormat1
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy.errors import BoundBranchOutOfDate
24
from breezy.tests import TestCaseWithTransport
25
from breezy.tests.script import (
5416.1.9 by Martin Pool
Add a test that uncommit confirms its action
26
    run_script,
27
    ScriptRunner,
28
    )
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
29
30
31
class TestUncommit(TestCaseWithTransport):
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
32
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
33
    def create_simple_tree(self):
34
        wt = self.make_branch_and_tree('tree')
35
        self.build_tree(['tree/a', 'tree/b', 'tree/c'])
36
        wt.add(['a', 'b', 'c'])
6855.4.1 by Jelmer Vernooij
Yet more bees.
37
        wt.commit('initial commit', rev_id=b'a1')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
38
6855.4.1 by Jelmer Vernooij
Yet more bees.
39
        self.build_tree_contents([('tree/a', b'new contents of a\n')])
40
        wt.commit('second commit', rev_id=b'a2')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
41
42
        return wt
43
0.3.11 by John Arbash Meinel
Updated to latest bzr.dev code, and added tests.
44
    def test_uncommit(self):
45
        """Test uncommit functionality."""
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
46
        wt = self.create_simple_tree()
47
48
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
49
        out, err = self.run_bzr('uncommit --dry-run --force')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
50
        self.assertContainsRe(out, 'Dry-run')
51
        self.assertNotContainsRe(out, 'initial commit')
52
        self.assertContainsRe(out, 'second commit')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
53
54
        # Nothing has changed
6973.14.7 by Jelmer Vernooij
Bees bees bees.
55
        self.assertEqual([b'a2'], wt.get_parent_ids())
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
56
57
        # Uncommit, don't prompt
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
58
        out, err = self.run_bzr('uncommit --force')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
59
        self.assertNotContainsRe(out, 'initial commit')
60
        self.assertContainsRe(out, 'second commit')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
61
62
        # This should look like we are back in revno 1
6973.14.7 by Jelmer Vernooij
Bees bees bees.
63
        self.assertEqual([b'a1'], wt.get_parent_ids())
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
64
        out, err = self.run_bzr('status')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
65
        self.assertEqual(out, 'modified:\n  a\n')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
66
5416.1.9 by Martin Pool
Add a test that uncommit confirms its action
67
    def test_uncommit_interactive(self):
68
        """Uncommit seeks confirmation, and doesn't proceed without it."""
69
        wt = self.create_simple_tree()
70
        os.chdir('tree')
6973.14.7 by Jelmer Vernooij
Bees bees bees.
71
        run_script(self, """
6622.1.29 by Jelmer Vernooij
Fix some more tests.
72
        $ brz uncommit
5416.1.12 by Martin Pool
Tweak uncommit doctest for python 2.4
73
        ...
5416.1.9 by Martin Pool
Add a test that uncommit confirms its action
74
        The above revision(s) will be removed.
6182.2.15 by Benoît Pierre
Fix uncommit tests.
75
        2>Uncommit these revisions? ([y]es, [n]o): no
5416.1.9 by Martin Pool
Add a test that uncommit confirms its action
76
        <n
77
        Canceled
78
        """)
6973.14.7 by Jelmer Vernooij
Bees bees bees.
79
        self.assertEqual([b'a2'], wt.get_parent_ids())
5416.1.9 by Martin Pool
Add a test that uncommit confirms its action
80
2948.2.1 by John Arbash Meinel
Fix 'bzr uncommit' when there is no revision history.
81
    def test_uncommit_no_history(self):
82
        wt = self.make_branch_and_tree('tree')
83
        out, err = self.run_bzr('uncommit --force', retcode=1)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
84
        self.assertEqual('', err)
85
        self.assertEqual('No revisions to uncommit.\n', out)
2948.2.1 by John Arbash Meinel
Fix 'bzr uncommit' when there is no revision history.
86
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
87
    def test_uncommit_checkout(self):
88
        wt = self.create_simple_tree()
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
89
        checkout_tree = wt.branch.create_checkout('checkout')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
90
6973.13.2 by Jelmer Vernooij
Fix some more tests.
91
        self.assertEqual([b'a2'], checkout_tree.get_parent_ids())
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
92
93
        os.chdir('checkout')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
94
        out, err = self.run_bzr('uncommit --dry-run --force')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
95
        self.assertContainsRe(out, 'Dry-run')
96
        self.assertNotContainsRe(out, 'initial commit')
97
        self.assertContainsRe(out, 'second commit')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
98
6973.13.2 by Jelmer Vernooij
Fix some more tests.
99
        self.assertEqual([b'a2'], checkout_tree.get_parent_ids())
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
100
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
101
        out, err = self.run_bzr('uncommit --force')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
102
        self.assertNotContainsRe(out, 'initial commit')
103
        self.assertContainsRe(out, 'second commit')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
104
105
        # uncommit in a checkout should uncommit the parent branch
106
        # (but doesn't effect the other working tree)
6973.13.2 by Jelmer Vernooij
Fix some more tests.
107
        self.assertEqual([b'a1'], checkout_tree.get_parent_ids())
7045.1.14 by Jelmer Vernooij
More fixes.
108
        self.assertEqual(b'a1', wt.branch.last_revision())
6973.13.2 by Jelmer Vernooij
Fix some more tests.
109
        self.assertEqual([b'a2'], wt.get_parent_ids())
1558.9.1 by Aaron Bentley
Fix uncommit to handle bound branches, and to do locking
110
111
    def test_uncommit_bound(self):
112
        os.mkdir('a')
113
        a = BzrDirMetaFormat1().initialize('a')
114
        a.create_repository()
115
        a.create_branch()
1908.6.1 by Robert Collins
Change all callers of set_last_revision to use set_parent_trees.
116
        t_a = a.create_workingtree()
117
        t_a.commit('commit 1')
118
        t_a.commit('commit 2')
119
        t_a.commit('commit 3')
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
120
        b = t_a.branch.create_checkout('b').branch
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
121
        uncommit.uncommit(b)
6165.4.4 by Jelmer Vernooij
Avoid .revision_history().
122
        self.assertEqual(b.last_revision_info()[0], 2)
123
        self.assertEqual(t_a.branch.last_revision_info()[0], 2)
4031.3.1 by Frank Aspell
Fixing various typos
124
        # update A's tree to not have the uncommitted revision referenced.
1908.6.1 by Robert Collins
Change all callers of set_last_revision to use set_parent_trees.
125
        t_a.update()
126
        t_a.commit('commit 3b')
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
127
        self.assertRaises(BoundBranchOutOfDate, uncommit.uncommit, b)
1908.6.1 by Robert Collins
Change all callers of set_last_revision to use set_parent_trees.
128
        b.pull(t_a.branch)
1850.3.1 by John Arbash Meinel
cleanup the uncommit tests
129
        uncommit.uncommit(b)
1558.9.1 by Aaron Bentley
Fix uncommit to handle bound branches, and to do locking
130
3280.4.1 by John Arbash Meinel
Add uncommit --local.
131
    def test_uncommit_bound_local(self):
132
        t_a = self.make_branch_and_tree('a')
133
        rev_id1 = t_a.commit('commit 1')
134
        rev_id2 = t_a.commit('commit 2')
135
        rev_id3 = t_a.commit('commit 3')
136
        b = t_a.branch.create_checkout('b').branch
137
138
        out, err = self.run_bzr(['uncommit', '--local', 'b', '--force'])
139
        self.assertEqual(rev_id3, t_a.last_revision())
140
        self.assertEqual((3, rev_id3), t_a.branch.last_revision_info())
141
        self.assertEqual((2, rev_id2), b.last_revision_info())
142
1850.3.2 by John Arbash Meinel
Change uncommit -r 10 so that it uncommits *to* 10, rather than removing 10
143
    def test_uncommit_revision(self):
144
        wt = self.create_simple_tree()
145
146
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
147
        out, err = self.run_bzr('uncommit -r1 --force')
1850.3.2 by John Arbash Meinel
Change uncommit -r 10 so that it uncommits *to* 10, rather than removing 10
148
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
149
        self.assertNotContainsRe(out, 'initial commit')
150
        self.assertContainsRe(out, 'second commit')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
151
        self.assertEqual([b'a1'], wt.get_parent_ids())
152
        self.assertEqual(b'a1', wt.branch.last_revision())
1850.3.2 by John Arbash Meinel
Change uncommit -r 10 so that it uncommits *to* 10, rather than removing 10
153
154
    def test_uncommit_neg_1(self):
155
        wt = self.create_simple_tree()
156
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
157
        out, err = self.run_bzr('uncommit -r -1', retcode=1)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
158
        self.assertEqual('No revisions to uncommit.\n', out)
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
159
160
    def test_uncommit_merges(self):
161
        wt = self.create_simple_tree()
162
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
163
        tree2 = wt.controldir.sprout('tree2').open_workingtree()
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
164
6855.4.1 by Jelmer Vernooij
Yet more bees.
165
        tree2.commit('unchanged', rev_id=b'b3')
166
        tree2.commit('unchanged', rev_id=b'b4')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
167
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
168
        wt.merge_from_branch(tree2.branch)
6855.4.1 by Jelmer Vernooij
Yet more bees.
169
        wt.commit('merge b4', rev_id=b'a3')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
170
6973.13.2 by Jelmer Vernooij
Fix some more tests.
171
        self.assertEqual([b'a3'], wt.get_parent_ids())
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
172
173
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
174
        out, err = self.run_bzr('uncommit --force')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
175
6973.13.2 by Jelmer Vernooij
Fix some more tests.
176
        self.assertEqual([b'a2', b'b4'], wt.get_parent_ids())
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
177
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
178
    def test_uncommit_pending_merge(self):
179
        wt = self.create_simple_tree()
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
180
        tree2 = wt.controldir.sprout('tree2').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
181
        tree2.commit('unchanged', rev_id=b'b3')
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
182
183
        wt.branch.fetch(tree2.branch)
6973.13.2 by Jelmer Vernooij
Fix some more tests.
184
        wt.set_pending_merges([b'b3'])
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
185
186
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
187
        out, err = self.run_bzr('uncommit --force')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
188
        self.assertEqual([b'a1', b'b3'], wt.get_parent_ids())
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
189
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
190
    def test_uncommit_multiple_merge(self):
191
        wt = self.create_simple_tree()
192
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
193
        tree2 = wt.controldir.sprout('tree2').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
194
        tree2.commit('unchanged', rev_id=b'b3')
1908.6.7 by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly.
195
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
196
        tree3 = wt.controldir.sprout('tree3').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
197
        tree3.commit('unchanged', rev_id=b'c3')
3462.1.4 by John Arbash Meinel
fix up the uncommit tests now that set_parent_ids is filtering out ancestors.
198
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
199
        wt.merge_from_branch(tree2.branch)
6855.4.1 by Jelmer Vernooij
Yet more bees.
200
        wt.commit('merge b3', rev_id=b'a3')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
201
3462.1.4 by John Arbash Meinel
fix up the uncommit tests now that set_parent_ids is filtering out ancestors.
202
        wt.merge_from_branch(tree3.branch)
6855.4.1 by Jelmer Vernooij
Yet more bees.
203
        wt.commit('merge c3', rev_id=b'a4')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
204
6973.13.2 by Jelmer Vernooij
Fix some more tests.
205
        self.assertEqual([b'a4'], wt.get_parent_ids())
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
206
207
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
208
        out, err = self.run_bzr('uncommit --force -r 2')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
209
6973.13.2 by Jelmer Vernooij
Fix some more tests.
210
        self.assertEqual([b'a2', b'b3', b'c3'], wt.get_parent_ids())
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
211
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
212
    def test_uncommit_merge_plus_pending(self):
213
        wt = self.create_simple_tree()
214
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
215
        tree2 = wt.controldir.sprout('tree2').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
216
        tree2.commit('unchanged', rev_id=b'b3')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
217
        tree3 = wt.controldir.sprout('tree3').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
218
        tree3.commit('unchanged', rev_id=b'c3')
3462.1.4 by John Arbash Meinel
fix up the uncommit tests now that set_parent_ids is filtering out ancestors.
219
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
220
        wt.branch.fetch(tree2.branch)
6973.13.2 by Jelmer Vernooij
Fix some more tests.
221
        wt.set_pending_merges([b'b3'])
6855.4.1 by Jelmer Vernooij
Yet more bees.
222
        wt.commit('merge b3', rev_id=b'a3')
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
223
3462.1.4 by John Arbash Meinel
fix up the uncommit tests now that set_parent_ids is filtering out ancestors.
224
        wt.merge_from_branch(tree3.branch)
225
6973.13.2 by Jelmer Vernooij
Fix some more tests.
226
        self.assertEqual([b'a3', b'c3'], wt.get_parent_ids())
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
227
228
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
229
        out, err = self.run_bzr('uncommit --force -r 2')
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
230
6973.13.2 by Jelmer Vernooij
Fix some more tests.
231
        self.assertEqual([b'a2', b'b3', b'c3'], wt.get_parent_ids())
1956.1.1 by John Arbash Meinel
Fix bug #57660: 'bzr uncommit' should preserve pending merges
232
3629.1.1 by John Arbash Meinel
Change 'bzr uncommit' to display the revision ids and log them.
233
    def test_uncommit_shows_log_with_revision_id(self):
234
        wt = self.create_simple_tree()
235
5010.1.2 by Martin Pool
Uncommit sends some output to stdout; change it to a script test
236
        script = ScriptRunner()
237
        script.run_script(self, """
238
$ cd tree
7195.5.1 by Martin
Fix remaining whitespace lint in codebase
239
$ brz uncommit --force
5010.1.3 by Martin Pool
uncommit tests aren't isolated; shouldn't check committer/date
240
    2 ...
5010.1.2 by Martin Pool
Uncommit sends some output to stdout; change it to a script test
241
      second commit
242
...
243
The above revision(s) will be removed.
244
You can restore the old tip by running:
6622.1.29 by Jelmer Vernooij
Fix some more tests.
245
  brz pull . -r revid:a2
5010.1.2 by Martin Pool
Uncommit sends some output to stdout; change it to a script test
246
""")
3629.1.1 by John Arbash Meinel
Change 'bzr uncommit' to display the revision ids and log them.
247
7290.3.1 by Jelmer Vernooij
Display "-d $LOCATION" in example bzr pull command output by 'brz uncommit'
248
    def test_uncommit_shows_pull_with_location(self):
249
        wt = self.create_simple_tree()
250
251
        script = ScriptRunner()
252
        script.run_script(self, """
253
$ brz uncommit --force tree
254
    2 ...
255
      second commit
256
...
257
The above revision(s) will be removed.
258
You can restore the old tip by running:
7290.3.2 by Jelmer Vernooij
Fix location.
259
  brz pull -d tree tree -r revid:a2
7290.3.1 by Jelmer Vernooij
Display "-d $LOCATION" in example bzr pull command output by 'brz uncommit'
260
""")
261
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
262
    def test_uncommit_octopus_merge(self):
263
        # Check that uncommit keeps the pending merges in the same order
3462.1.4 by John Arbash Meinel
fix up the uncommit tests now that set_parent_ids is filtering out ancestors.
264
        # though it will also filter out ones in the ancestry
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
265
        wt = self.create_simple_tree()
266
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
267
        tree2 = wt.controldir.sprout('tree2').open_workingtree()
268
        tree3 = wt.controldir.sprout('tree3').open_workingtree()
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
269
6855.4.1 by Jelmer Vernooij
Yet more bees.
270
        tree2.commit('unchanged', rev_id=b'b3')
271
        tree3.commit('unchanged', rev_id=b'c3')
3629.1.1 by John Arbash Meinel
Change 'bzr uncommit' to display the revision ids and log them.
272
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
273
        wt.merge_from_branch(tree2.branch)
4721.3.2 by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites.
274
        wt.merge_from_branch(tree3.branch, force=True)
6855.4.1 by Jelmer Vernooij
Yet more bees.
275
        wt.commit('merge b3, c3', rev_id=b'a3')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
276
6855.4.1 by Jelmer Vernooij
Yet more bees.
277
        tree2.commit('unchanged', rev_id=b'b4')
278
        tree3.commit('unchanged', rev_id=b'c4')
1908.6.7 by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly.
279
1979.2.1 by Robert Collins
(robertc) adds a convenience method "merge_from_branch" to WorkingTree.
280
        wt.merge_from_branch(tree3.branch)
4721.3.2 by Vincent Ladeuil
Simplify mutable_tree.has_changes() and update call sites.
281
        wt.merge_from_branch(tree2.branch, force=True)
6855.4.1 by Jelmer Vernooij
Yet more bees.
282
        wt.commit('merge b4, c4', rev_id=b'a4')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
283
6973.13.2 by Jelmer Vernooij
Fix some more tests.
284
        self.assertEqual([b'a4'], wt.get_parent_ids())
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
285
286
        os.chdir('tree')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
287
        out, err = self.run_bzr('uncommit --force -r 2')
1850.3.5 by John Arbash Meinel
Fix bug 31426, have uncommit keep track of pending merges.
288
6973.13.2 by Jelmer Vernooij
Fix some more tests.
289
        self.assertEqual([b'a2', b'c4', b'b4'], wt.get_parent_ids())
3101.1.1 by Aaron Bentley
Uncommit doesn't throw when it encounters un-encodable characters
290
291
    def test_uncommit_nonascii(self):
292
        tree = self.make_branch_and_tree('tree')
293
        tree.commit(u'\u1234 message')
3101.1.2 by Aaron Bentley
Improve uncommit test
294
        out, err = self.run_bzr('uncommit --force tree', encoding='ascii')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
295
        self.assertContainsRe(out, r'\? message')
6091.1.4 by Jelmer Vernooij
More tests.
296
297
    def test_uncommit_removes_tags(self):
298
        tree = self.make_branch_and_tree('tree')
299
        revid = tree.commit('message')
300
        tree.branch.tags.set_tag("atag", revid)
301
        out, err = self.run_bzr('uncommit --force tree')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
302
        self.assertEqual({}, tree.branch.tags.get_tag_dict())
6091.1.4 by Jelmer Vernooij
More tests.
303
304
    def test_uncommit_keep_tags(self):
305
        tree = self.make_branch_and_tree('tree')
306
        revid = tree.commit('message')
307
        tree.branch.tags.set_tag("atag", revid)
308
        out, err = self.run_bzr('uncommit --keep-tags --force tree')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
309
        self.assertEqual({"atag": revid}, tree.branch.tags.get_tag_dict())
6345.2.3 by Jelmer Vernooij
Add hpss call count test for 'bzr uncommit'.
310
311
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
312
class TestInconsistentDelta(TestCaseWithTransport):
313
    # See https://bugs.launchpad.net/bzr/+bug/855155
314
    # See https://bugs.launchpad.net/bzr/+bug/1100385
6622.1.29 by Jelmer Vernooij
Fix some more tests.
315
    # brz uncommit may result in error
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
316
    # 'An inconsistent delta was supplied involving'
317
318
    def test_inconsistent_delta(self):
319
        # Script taken from https://bugs.launchpad.net/bzr/+bug/855155/comments/26
320
        wt = self.make_branch_and_tree('test')
321
        self.build_tree(['test/a/', 'test/a/b', 'test/a/c'])
322
        wt.add(['a', 'a/b', 'a/c'])
6855.4.1 by Jelmer Vernooij
Yet more bees.
323
        wt.commit('initial commit', rev_id=b'a1')
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
324
        wt.remove(['a/b', 'a/c'])
6855.4.1 by Jelmer Vernooij
Yet more bees.
325
        wt.commit('remove b and c', rev_id=b'a2')
6015.45.2 by Brian de Alwis, John Arbash Meinel
Backport the fix for bug #855155 to bzr-2.4
326
        self.run_bzr("uncommit --force test")