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