6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
1 |
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
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
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
16 |
|
17 |
||
18 |
import os |
|
19 |
||
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
20 |
from bzrlib.tests import TestCaseWithTransport |
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
21 |
from bzrlib.workingtree import WorkingTree |
22 |
||
23 |
||
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
24 |
class TestRemerge(TestCaseWithTransport): |
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
25 |
|
26 |
def make_file(self, name, contents): |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
27 |
with open(name, 'wb') as f: |
1551.7.10
by Aaron Bentley
Remerge doesn't clear unrelated conflicts |
28 |
f.write(contents) |
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
29 |
|
30 |
def create_conflicts(self): |
|
31 |
"""Create a conflicted tree"""
|
|
32 |
os.mkdir('base') |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
33 |
self.make_file('base/hello', "hi world") |
34 |
self.make_file('base/answer', "42") |
|
35 |
self.run_bzr('init', working_dir='base') |
|
36 |
self.run_bzr('add', working_dir='base') |
|
37 |
self.run_bzr('commit -m base', working_dir='base') |
|
38 |
self.run_bzr('branch base other') |
|
39 |
self.run_bzr('branch base this') |
|
40 |
self.make_file('other/hello', "Hello.") |
|
41 |
self.make_file('other/answer', "Is anyone there?") |
|
42 |
self.run_bzr('commit -m other', working_dir='other') |
|
43 |
self.make_file('this/hello', "Hello, world") |
|
44 |
self.run_bzr('mv answer question', working_dir='this') |
|
45 |
self.make_file('this/question', |
|
46 |
"What do you get when you multiply sixtimes nine?") |
|
47 |
self.run_bzr('commit -m this', working_dir='this') |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
48 |
|
49 |
def test_remerge(self): |
|
50 |
"""Remerge command works as expected"""
|
|
51 |
self.create_conflicts() |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
52 |
self.run_bzr('merge ../other --show-base', |
53 |
retcode=1, working_dir='this') |
|
54 |
conflict_text = open('this/hello').read() |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
55 |
self.assertTrue('|||||||' in conflict_text) |
56 |
self.assertTrue('hi world' in conflict_text) |
|
57 |
||
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
58 |
self.run_bzr_error(['conflicts encountered'], 'remerge', |
59 |
retcode=1, working_dir='this') |
|
60 |
with open('this/hello') as f: |
|
61 |
conflict_text = f.read() |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
62 |
self.assertFalse('|||||||' in conflict_text) |
63 |
self.assertFalse('hi world' in conflict_text) |
|
64 |
||
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
65 |
os.unlink('this/hello.OTHER') |
66 |
os.unlink('this/question.OTHER') |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
67 |
|
1711.2.72
by John Arbash Meinel
Update test_remerge with new api, and minor fixes. |
68 |
self.run_bzr_error(['jello is not versioned'], |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
69 |
'remerge jello --merge-type weave', working_dir='this') |
1711.2.72
by John Arbash Meinel
Update test_remerge with new api, and minor fixes. |
70 |
self.run_bzr_error(['conflicts encountered'], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
71 |
'remerge hello --merge-type weave', |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
72 |
retcode=1, working_dir='this') |
73 |
||
74 |
self.assertPathExists('this/hello.OTHER') |
|
75 |
self.assertPathDoesNotExist('this/question.OTHER') |
|
76 |
||
77 |
file_id = self.run_bzr('file-id hello', working_dir='this')[0] |
|
2067.3.1
by Martin Pool
Clean up BzrNewError, other exception classes and users. |
78 |
self.run_bzr_error(['hello.THIS is not versioned'], |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
79 |
'file-id hello.THIS', working_dir='this') |
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
80 |
|
1711.2.72
by John Arbash Meinel
Update test_remerge with new api, and minor fixes. |
81 |
self.run_bzr_error(['conflicts encountered'], |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
82 |
'remerge --merge-type weave', |
83 |
retcode=1, working_dir='this') |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
84 |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
85 |
self.assertPathExists('this/hello.OTHER') |
86 |
self.assertTrue('this/hello.BASE') |
|
87 |
with open('this/hello') as f: |
|
88 |
conflict_text = f.read() |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
89 |
self.assertFalse('|||||||' in conflict_text) |
90 |
self.assertFalse('hi world' in conflict_text) |
|
91 |
||
92 |
self.run_bzr_error(['Showing base is not supported.*Weave'], |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
93 |
'remerge . --merge-type weave --show-base', |
94 |
working_dir='this') |
|
95 |
self.run_bzr_error(["Can't reprocess and show base"], |
|
96 |
'remerge . --show-base --reprocess', |
|
97 |
working_dir='this') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
98 |
self.run_bzr_error(['conflicts encountered'], |
99 |
'remerge . --merge-type weave --reprocess', |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
100 |
retcode=1, working_dir='this') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
101 |
self.run_bzr_error(['conflicts encountered'], |
102 |
'remerge hello --show-base', |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
103 |
retcode=1, working_dir='this') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
104 |
self.run_bzr_error(['conflicts encountered'], |
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
105 |
'remerge hello --reprocess', |
106 |
retcode=1, working_dir='this') |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
107 |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
108 |
self.run_bzr('resolve --all', working_dir='this') |
109 |
self.run_bzr('commit -m done', working_dir='this') |
|
1711.2.70
by John Arbash Meinel
Add run_bzr_errors alongside run_bzr, to make it easy to check the right error is occurring. |
110 |
|
111 |
self.run_bzr_error(['remerge only works after normal merges', |
|
112 |
'Not cherrypicking or multi-merges'], |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
113 |
'remerge', working_dir='this') |
1551.7.10
by Aaron Bentley
Remerge doesn't clear unrelated conflicts |
114 |
|
115 |
def test_conflicts(self): |
|
116 |
self.create_conflicts() |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
117 |
self.run_bzr('merge ../other', retcode=1, working_dir='this') |
118 |
wt = WorkingTree.open('this') |
|
119 |
self.assertEqual(2, len(wt.conflicts())) |
|
120 |
self.run_bzr('remerge', retcode=1, working_dir='this') |
|
121 |
wt = WorkingTree.open('this') |
|
122 |
self.assertEqual(2, len(wt.conflicts())) |
|
123 |
self.run_bzr('remerge hello', retcode=1, working_dir='this') |
|
124 |
wt = WorkingTree.open('this') |
|
1551.7.13
by Aaron Bentley
Switched from actual, expected to expected, actual, for John. |
125 |
self.assertEqual(2, len(wt.conflicts())) |