~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_conflicts.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-09 04:08:15 UTC
  • Revision ID: mbp@sourcefrog.net-20050309040815-13242001617e4a06
import from baz patch-364

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 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
 
import os
18
 
 
19
 
from bzrlib.workingtree import WorkingTree
20
 
from bzrlib.tests.blackbox import ExternalBase
21
 
 
22
 
class TestConflicts(ExternalBase):
23
 
    def setUp(self):
24
 
        super(ExternalBase, self).setUp()
25
 
        try:
26
 
            os.mkdir('a')
27
 
        except:
28
 
            raise os.getcwd()
29
 
        os.chdir('a')
30
 
        self.runbzr('init')
31
 
        file('myfile', 'wb').write('contentsa\n')
32
 
        file('my_other_file', 'wb').write('contentsa\n')
33
 
        self.runbzr('add')
34
 
        self.runbzr('commit -m new')
35
 
        os.chdir('..')
36
 
        self.runbzr('branch a b')
37
 
        os.chdir('b')
38
 
        file('myfile', 'wb').write('contentsb\n')
39
 
        file('my_other_file', 'wb').write('contentsb\n')
40
 
        self.runbzr('commit -m change')
41
 
        os.chdir('../a')
42
 
        file('myfile', 'wb').write('contentsa2\n')
43
 
        file('my_other_file', 'wb').write('contentsa2\n')
44
 
        self.runbzr('commit -m change')
45
 
        self.runbzr('merge ../b', retcode=1)
46
 
 
47
 
    def test_conflicts(self):
48
 
        conflicts = self.runbzr('conflicts', backtick=True)
49
 
        self.assertEqual(len(conflicts.splitlines()), 2)
50
 
 
51
 
    def test_resolve(self):
52
 
        self.runbzr('resolve', retcode=3)
53
 
        self.runbzr('resolve myfile')
54
 
        conflicts = self.runbzr('conflicts', backtick=True)
55
 
        self.assertEqual(len(conflicts.splitlines()), 1)
56
 
        self.runbzr('resolve my_other_file')
57
 
        conflicts = self.runbzr('conflicts', backtick=True)
58
 
        self.assertEqual(len(conflicts.splitlines()), 0)
59
 
 
60
 
    def test_resolve_all(self):
61
 
        self.runbzr('resolve --all')
62
 
        conflicts = self.runbzr('conflicts', backtick=True)
63
 
        self.assertEqual(len(conflicts.splitlines()), 0)
64
 
 
65
 
    def test_resolve_in_subdir(self):
66
 
        """resolve when run from subdirectory should handle relative paths"""
67
 
        orig_dir = os.getcwdu()
68
 
        try:
69
 
            os.mkdir("subdir")
70
 
            os.chdir("subdir")
71
 
            self.runbzr("resolve ../myfile")
72
 
            os.chdir("../../b")
73
 
            self.runbzr("resolve ../a/myfile")
74
 
            wt = WorkingTree.open_containing('.')[0]
75
 
            conflicts = wt.conflicts()
76
 
            if not conflicts.is_empty():
77
 
                self.fail("tree still contains conflicts: %r" % conflicts)
78
 
        finally:
79
 
            os.chdir(orig_dir)