1
# Copyright (C) 2005, 2006 by Canonical Ltd
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.
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.
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
20
from bzrlib.tests.blackbox import ExternalBase
21
from bzrlib.workingtree import WorkingTree
24
class TestRemerge(ExternalBase):
26
def make_file(self, name, contents):
31
def create_conflicts(self):
32
"""Create a conflicted tree"""
35
self.make_file('hello', "hi world")
36
self.make_file('answer', "42")
39
self.run_bzr('commit', '-m', 'base')
40
self.run_bzr('branch', '.', '../other')
41
self.run_bzr('branch', '.', '../this')
43
self.make_file('hello', "Hello.")
44
self.make_file('answer', "Is anyone there?")
45
self.run_bzr('commit', '-m', 'other')
47
self.make_file('hello', "Hello, world")
48
self.run_bzr('mv', 'answer', 'question')
49
self.make_file('question', "What do you get when you multiply six"
51
self.run_bzr('commit', '-m', 'this')
53
def test_remerge(self):
54
"""Remerge command works as expected"""
55
self.create_conflicts()
56
self.run_bzr('merge', '../other', '--show-base', retcode=1)
57
conflict_text = open('hello').read()
58
self.assertTrue('|||||||' in conflict_text)
59
self.assertTrue('hi world' in conflict_text)
61
self.run_bzr('remerge', retcode=1)
62
conflict_text = open('hello').read()
63
self.assertFalse('|||||||' in conflict_text)
64
self.assertFalse('hi world' in conflict_text)
66
os.unlink('hello.OTHER')
67
os.unlink('question.OTHER')
69
self.run_bzr('remerge', 'jello', '--merge-type', 'weave', retcode=3)
70
self.run_bzr('remerge', 'hello', '--merge-type', 'weave', retcode=1)
72
self.failUnlessExists('hello.OTHER')
73
self.failIfExists('question.OTHER')
75
file_id = self.run_bzr('file-id', 'hello')[0]
76
self.run_bzr('file-id', 'hello.THIS', retcode=3)
78
self.run_bzr('remerge', '--merge-type', 'weave', retcode=1)
80
self.failUnlessExists('hello.OTHER')
81
self.failIfExists('hello.BASE')
82
self.assertFalse('|||||||' in conflict_text)
83
self.assertFalse('hi world' in conflict_text)
85
self.run_bzr_error(['Showing base is not supported.*Weave'],
86
'remerge', '.', '--merge-type', 'weave', '--show-base',
88
self.run_bzr_error(['Can\'t reprocess and show base'],
89
'remerge', '.', '--show-base', '--reprocess',
91
self.run_bzr_error(['conflicts encountered'],
92
'remerge', '.', '--merge-type', 'weave', '--reprocess',
94
self.run_bzr_error(['conflicts encountered'],
95
'remerge', 'hello', '--show-base',
97
self.run_bzr_error(['conflicts encountered'],
98
'remerge', 'hello', '--reprocess', retcode=1)
100
self.run_bzr('resolve', '--all')
101
self.run_bzr('commit', '-m', 'done')
103
self.run_bzr_error(['remerge only works after normal merges',
104
'Not cherrypicking or multi-merges'],