~michael-ellerman/bzr/mpe

« back to all changes in this revision

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

[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Black-box tests for bzr missing.
2
 
"""
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
# -*- coding: utf-8 -*-
 
3
# vim: encoding=utf-8
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
"""Black-box tests for bzr missing."""
3
20
 
4
21
import os
5
22
 
10
27
class TestMissing(TestCaseInTempDir):
11
28
 
12
29
    def test_missing(self):
 
30
        def bzr(*args, **kwargs):
 
31
            return self.run_bzr(*args, **kwargs)[0]
13
32
        missing = "You are missing 1 revision(s):"
14
33
 
15
34
        # create a source branch
16
35
        os.mkdir('a')
17
36
        os.chdir('a')
18
 
        self.capture('init')
 
37
        bzr('init')
19
38
        open('a', 'wb').write('initial\n')
20
 
        self.capture('add a')
21
 
        self.capture('commit -m inital')
 
39
        bzr('add', 'a')
 
40
        bzr('commit', '-m', 'inital')
22
41
 
23
42
        # clone and add a differing revision
24
 
        self.capture('branch . ../b')
 
43
        bzr('branch', '.', '../b')
25
44
        os.chdir('../b')
26
45
        open('a', 'ab').write('more\n')
27
 
        self.capture('commit -m more')
 
46
        bzr('commit', '-m', 'more')
28
47
 
29
48
        # run missing in a against b
30
49
        os.chdir('../a')
51
70
        branch_b.unlock()
52
71
 
53
72
        # get extra revision from b
54
 
        self.capture('merge ../b')
55
 
        self.capture('commit -m merge')
 
73
        bzr('merge', '../b')
 
74
        bzr('commit', '-m', 'merge')
56
75
 
57
76
        # compare again, but now we have the 'merge' commit extra
58
 
        lines = self.capture('missing ../b', retcode=1).splitlines()
 
77
        lines = bzr('missing', '../b', retcode=1).splitlines()
59
78
        self.assertEqual("You have 1 extra revision(s):", lines[0])
60
79
        self.assertEqual(8, len(lines))
61
 
        lines2 = self.capture('missing ../b --mine-only', retcode=1)
 
80
        lines2 = bzr('missing', '../b', '--mine-only', retcode=1)
62
81
        lines2 = lines2.splitlines()
63
82
        self.assertEqual(lines, lines2)
64
 
        lines3 = self.capture('missing ../b --theirs-only', retcode=1)
 
83
        lines3 = bzr('missing', '../b', '--theirs-only', retcode=1)
65
84
        lines3 = lines3.splitlines()
66
85
        self.assertEqual(0, len(lines3))
67
86
 
68
87
        # relative to a, missing the 'merge' commit 
69
88
        os.chdir('../b')
70
 
        lines = self.capture('missing ../a', retcode=1).splitlines()
 
89
        lines = bzr('missing', '../a', retcode=1).splitlines()
71
90
        self.assertEqual(missing, lines[0])
72
91
        self.assertEqual(8, len(lines))
73
 
        lines2 = self.capture('missing ../a --theirs-only', retcode=1)
 
92
        lines2 = bzr('missing', '../a', '--theirs-only', retcode=1)
74
93
        lines2 = lines2.splitlines()
75
94
        self.assertEqual(lines, lines2)
76
 
        lines3 = self.capture('missing ../a --mine-only', retcode=1)
 
95
        lines3 = bzr('missing', '../a', '--mine-only', retcode=1)
77
96
        lines3 = lines3.splitlines()
78
97
        self.assertEqual(0, len(lines3))
79
 
        lines4 = self.capture('missing ../a --short', retcode=1)
 
98
        lines4 = bzr('missing', '../a', '--short', retcode=1)
80
99
        lines4 = lines4.splitlines()
81
100
        self.assertEqual(4, len(lines4))
82
 
        lines5 = self.capture('missing ../a --line', retcode=1)
 
101
        lines5 = bzr('missing', '../a', '--line', retcode=1)
83
102
        lines5 = lines5.splitlines()
84
103
        self.assertEqual(2, len(lines5))
85
 
        lines6 = self.capture('missing ../a --reverse', retcode=1)
 
104
        lines6 = bzr('missing', '../a', '--reverse', retcode=1)
86
105
        lines6 = lines6.splitlines()
87
106
        self.assertEqual(lines6, lines)
88
 
        lines7 = self.capture('missing ../a --show-ids', retcode=1)
 
107
        lines7 = bzr('missing', '../a', '--show-ids', retcode=1)
89
108
        lines7 = lines7.splitlines()
90
109
        self.assertEqual(11, len(lines7))
91
 
        lines8 = self.capture('missing ../a --verbose', retcode=1)
 
110
        lines8 = bzr('missing', '../a', '--verbose', retcode=1)
92
111
        lines8 = lines8.splitlines()
93
112
        self.assertEqual("modified:", lines8[-2])
94
113
        self.assertEqual("  a", lines8[-1])
95
114
 
96
115
        
97
116
        # after a pull we're back on track
98
 
        self.capture('pull')
 
117
        bzr('pull')
99
118
        self.assertEqual("Branches are up to date.\n", 
100
 
                         self.capture('missing ../a'))
 
119
                         bzr('missing', '../a'))
101
120