/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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.
1
# Copyright (C) 2005, 2006 by Canonical Ltd
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
18
import os
19
20
from bzrlib.tests.blackbox import ExternalBase
21
from bzrlib.workingtree import WorkingTree
22
23
24
class TestRemerge(ExternalBase):
25
26
    def make_file(self, name, contents):
27
        f = open(name, 'wb')
28
        f.write(contents)
29
        f.close()
30
31
    def create_conflicts(self):
32
        """Create a conflicted tree"""
33
        os.mkdir('base')
34
        os.chdir('base')
35
        self.make_file('hello', "hi world")
36
        self.make_file('answer', "42")
37
        self.run_bzr('init')
38
        self.run_bzr('add')
39
        self.run_bzr('commit', '-m', 'base')
40
        self.run_bzr('branch', '.', '../other')
41
        self.run_bzr('branch', '.', '../this')
42
        os.chdir('../other')
43
        self.make_file('hello', "Hello.")
44
        self.make_file('answer', "Is anyone there?")
45
        self.run_bzr('commit', '-m', 'other')
46
        os.chdir('../this')
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"
50
                                   "times nine?")
51
        self.run_bzr('commit', '-m', 'this')
52
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)
60
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
61
        self.run_bzr_error(['conflicts encountered'], 'remerge', retcode=1)
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
        conflict_text = open('hello').read()
63
        self.assertFalse('|||||||' in conflict_text)
64
        self.assertFalse('hi world' in conflict_text)
65
66
        os.unlink('hello.OTHER')
67
        os.unlink('question.OTHER')
68
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
69
        self.run_bzr_error(['jello is not versioned'],
70
                     'remerge', 'jello', '--merge-type', 'weave')
71
        self.run_bzr_error(['conflicts encountered'],
72
                           'remerge', 'hello', '--merge-type', 'weave',
73
                           retcode=1)
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.
74
75
        self.failUnlessExists('hello.OTHER')
76
        self.failIfExists('question.OTHER')
77
78
        file_id = self.run_bzr('file-id', 'hello')[0]
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
79
        self.run_bzr_error(['\'hello.THIS\' is not a versioned file'],
80
                           'file-id', 'hello.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.
81
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
82
        self.run_bzr_error(['conflicts encountered'],
83
                           'remerge', '--merge-type', 'weave', retcode=1)
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
85
        self.failUnlessExists('hello.OTHER')
86
        self.failIfExists('hello.BASE')
87
        self.assertFalse('|||||||' in conflict_text)
88
        self.assertFalse('hi world' in conflict_text)
89
90
        self.run_bzr_error(['Showing base is not supported.*Weave'],
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
91
                           'remerge', '.', '--merge-type', 'weave', '--show-base')
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.
92
        self.run_bzr_error(['Can\'t reprocess and show base'],
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
93
                           'remerge', '.', '--show-base', '--reprocess')
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.
94
        self.run_bzr_error(['conflicts encountered'],
95
                           'remerge', '.', '--merge-type', 'weave', '--reprocess',
96
                           retcode=1)
97
        self.run_bzr_error(['conflicts encountered'],
98
                           'remerge', 'hello', '--show-base',
99
                           retcode=1)
100
        self.run_bzr_error(['conflicts encountered'],
101
                           'remerge', 'hello', '--reprocess', retcode=1)
102
103
        self.run_bzr('resolve', '--all')
104
        self.run_bzr('commit', '-m', 'done')
105
106
        self.run_bzr_error(['remerge only works after normal merges',
107
                            'Not cherrypicking or multi-merges'],
1711.2.72 by John Arbash Meinel
Update test_remerge with new api, and minor fixes.
108
                           'remerge')