~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Shannon Weyrick
  • Date: 2011-11-16 20:59:10 UTC
  • mto: This revision was merged to the branch mainline in revision 6268.
  • Revision ID: weyrick@mozek.us-20111116205910-1xbpqbimbw3fvfqw
A version of the patch, based on suggestions from John Meinel, which detects an empty page differently to avoid false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
24
class TestRemerge(TestCaseWithTransport):
25
25
 
26
26
    def make_file(self, name, contents):
27
 
        with open(name, 'wb') as f:
 
27
        f = open(name, 'wb')
 
28
        try:
28
29
            f.write(contents)
 
30
        finally:
 
31
            f.close()
29
32
 
30
33
    def create_conflicts(self):
31
34
        """Create a conflicted tree"""
32
35
        os.mkdir('base')
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')
 
36
        os.chdir('base')
 
37
        self.make_file('hello', "hi world")
 
38
        self.make_file('answer', "42")
 
39
        self.run_bzr('init')
 
40
        self.run_bzr('add')
 
41
        self.run_bzr('commit -m base')
 
42
        self.run_bzr('branch . ../other')
 
43
        self.run_bzr('branch . ../this')
 
44
        os.chdir('../other')
 
45
        self.make_file('hello', "Hello.")
 
46
        self.make_file('answer', "Is anyone there?")
 
47
        self.run_bzr('commit -m other')
 
48
        os.chdir('../this')
 
49
        self.make_file('hello', "Hello, world")
 
50
        self.run_bzr('mv answer question')
 
51
        self.make_file('question', "What do you get when you multiply six"
 
52
                                   "times nine?")
 
53
        self.run_bzr('commit -m this')
48
54
 
49
55
    def test_remerge(self):
50
56
        """Remerge command works as expected"""
51
57
        self.create_conflicts()
52
 
        self.run_bzr('merge ../other --show-base',
53
 
                     retcode=1, working_dir='this')
54
 
        conflict_text = open('this/hello').read()
 
58
        self.run_bzr('merge ../other --show-base', retcode=1)
 
59
        conflict_text = open('hello').read()
55
60
        self.assertTrue('|||||||' in conflict_text)
56
61
        self.assertTrue('hi world' in conflict_text)
57
62
 
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()
 
63
        self.run_bzr_error(['conflicts encountered'], 'remerge', retcode=1)
 
64
        conflict_text = open('hello').read()
62
65
        self.assertFalse('|||||||' in conflict_text)
63
66
        self.assertFalse('hi world' in conflict_text)
64
67
 
65
 
        os.unlink('this/hello.OTHER')
66
 
        os.unlink('this/question.OTHER')
 
68
        os.unlink('hello.OTHER')
 
69
        os.unlink('question.OTHER')
67
70
 
68
71
        self.run_bzr_error(['jello is not versioned'],
69
 
                     'remerge jello --merge-type weave', working_dir='this')
 
72
                     'remerge jello --merge-type weave')
70
73
        self.run_bzr_error(['conflicts encountered'],
71
74
                           'remerge hello --merge-type weave',
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]
 
75
                           retcode=1)
 
76
 
 
77
        self.assertPathExists('hello.OTHER')
 
78
        self.assertPathDoesNotExist('question.OTHER')
 
79
 
 
80
        file_id = self.run_bzr('file-id hello')[0]
78
81
        self.run_bzr_error(['hello.THIS is not versioned'],
79
 
                           'file-id hello.THIS', working_dir='this')
 
82
                           'file-id hello.THIS')
80
83
 
81
84
        self.run_bzr_error(['conflicts encountered'],
82
 
                           'remerge --merge-type weave',
83
 
                           retcode=1, working_dir='this')
 
85
                           'remerge --merge-type weave', retcode=1)
84
86
 
85
 
        self.assertPathExists('this/hello.OTHER')
86
 
        self.assertTrue('this/hello.BASE')
87
 
        with open('this/hello') as f:
88
 
            conflict_text = f.read()
 
87
        self.assertPathExists('hello.OTHER')
 
88
        self.assertTrue('hello.BASE')
89
89
        self.assertFalse('|||||||' in conflict_text)
90
90
        self.assertFalse('hi world' in conflict_text)
91
91
 
92
92
        self.run_bzr_error(['Showing base is not supported.*Weave'],
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')
 
93
                           'remerge . --merge-type weave --show-base')
 
94
        self.run_bzr_error(['Can\'t reprocess and show base'],
 
95
                           'remerge . --show-base --reprocess')
98
96
        self.run_bzr_error(['conflicts encountered'],
99
97
                           'remerge . --merge-type weave --reprocess',
100
 
                           retcode=1, working_dir='this')
 
98
                           retcode=1)
101
99
        self.run_bzr_error(['conflicts encountered'],
102
100
                           'remerge hello --show-base',
103
 
                           retcode=1, working_dir='this')
 
101
                           retcode=1)
104
102
        self.run_bzr_error(['conflicts encountered'],
105
 
                           'remerge hello --reprocess',
106
 
                           retcode=1, working_dir='this')
 
103
                           'remerge hello --reprocess', retcode=1)
107
104
 
108
 
        self.run_bzr('resolve --all', working_dir='this')
109
 
        self.run_bzr('commit -m done', working_dir='this')
 
105
        self.run_bzr('resolve --all')
 
106
        self.run_bzr('commit -m done')
110
107
 
111
108
        self.run_bzr_error(['remerge only works after normal merges',
112
109
                            'Not cherrypicking or multi-merges'],
113
 
                           'remerge', working_dir='this')
 
110
                           'remerge')
114
111
 
115
112
    def test_conflicts(self):
116
113
        self.create_conflicts()
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')
 
114
        self.run_bzr('merge ../other', retcode=1)
 
115
        wt = WorkingTree.open('.')
 
116
        self.assertEqual(2, len(wt.conflicts()))
 
117
        self.run_bzr('remerge', retcode=1)
 
118
        wt = WorkingTree.open('.')
 
119
        self.assertEqual(2, len(wt.conflicts()))
 
120
        self.run_bzr('remerge hello', retcode=1)
125
121
        self.assertEqual(2, len(wt.conflicts()))