~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-25 22:58:41 UTC
  • mfrom: (1185.81.31 bzr.patience)
  • Revision ID: pqm@pqm.ubuntu.com-20060525225841-625f0ece2f64af43
Use patience for two-way merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 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."""
 
1
"""Black-box tests for bzr missing.
 
2
"""
20
3
 
21
4
import os
22
5
 
23
 
from bzrlib import osutils
24
 
 
25
6
from bzrlib.branch import Branch
26
 
from bzrlib.tests import TestCaseWithTransport
27
 
 
28
 
 
29
 
class TestMissing(TestCaseWithTransport):
 
7
from bzrlib.tests import TestCaseInTempDir
 
8
 
 
9
 
 
10
class TestMissing(TestCaseInTempDir):
30
11
 
31
12
    def test_missing(self):
32
 
        def bzr(*args, **kwargs):
33
 
            return self.run_bzr(*args, **kwargs)[0]
34
13
        missing = "You are missing 1 revision(s):"
35
14
 
36
15
        # create a source branch
37
16
        os.mkdir('a')
38
17
        os.chdir('a')
39
 
        bzr('init')
 
18
        self.capture('init')
40
19
        open('a', 'wb').write('initial\n')
41
 
        bzr('add a')
42
 
        bzr('commit -m inital')
 
20
        self.capture('add a')
 
21
        self.capture('commit -m inital')
43
22
 
44
23
        # clone and add a differing revision
45
 
        bzr('branch . ../b')
 
24
        self.capture('branch . ../b')
46
25
        os.chdir('../b')
47
26
        open('a', 'ab').write('more\n')
48
 
        bzr('commit -m more')
 
27
        self.capture('commit -m more')
49
28
 
50
29
        # run missing in a against b
51
30
        os.chdir('../a')
58
37
        branch_a.lock_write()
59
38
        branch_b = Branch.open('../b')
60
39
        branch_b.lock_write()
61
 
        out,err = self.run_bzr('missing ../b', retcode=1)
 
40
        out,err = self.run_bzr('missing', '../b', retcode=1)
62
41
        lines = out.splitlines()
63
42
        # we're missing the extra revision here
64
43
        self.assertEqual(missing, lines[0])
72
51
        branch_b.unlock()
73
52
 
74
53
        # get extra revision from b
75
 
        bzr('merge ../b')
76
 
        bzr('commit -m merge')
 
54
        self.capture('merge ../b')
 
55
        self.capture('commit -m merge')
77
56
 
78
57
        # compare again, but now we have the 'merge' commit extra
79
 
        lines = bzr('missing ../b', retcode=1).splitlines()
 
58
        lines = self.capture('missing ../b', retcode=1).splitlines()
80
59
        self.assertEqual("You have 1 extra revision(s):", lines[0])
81
60
        self.assertEqual(8, len(lines))
82
 
        lines2 = bzr('missing ../b --mine-only', retcode=1)
 
61
        lines2 = self.capture('missing ../b --mine-only', retcode=1)
83
62
        lines2 = lines2.splitlines()
84
63
        self.assertEqual(lines, lines2)
85
 
        lines3 = bzr('missing ../b --theirs-only', retcode=1)
 
64
        lines3 = self.capture('missing ../b --theirs-only', retcode=1)
86
65
        lines3 = lines3.splitlines()
87
66
        self.assertEqual(0, len(lines3))
88
67
 
89
68
        # relative to a, missing the 'merge' commit 
90
69
        os.chdir('../b')
91
 
        lines = bzr('missing ../a', retcode=1).splitlines()
 
70
        lines = self.capture('missing ../a', retcode=1).splitlines()
92
71
        self.assertEqual(missing, lines[0])
93
72
        self.assertEqual(8, len(lines))
94
 
        lines2 = bzr('missing ../a --theirs-only', retcode=1)
 
73
        lines2 = self.capture('missing ../a --theirs-only', retcode=1)
95
74
        lines2 = lines2.splitlines()
96
75
        self.assertEqual(lines, lines2)
97
 
        lines3 = bzr('missing ../a --mine-only', retcode=1)
 
76
        lines3 = self.capture('missing ../a --mine-only', retcode=1)
98
77
        lines3 = lines3.splitlines()
99
78
        self.assertEqual(0, len(lines3))
100
 
        lines4 = bzr('missing ../a --short', retcode=1)
 
79
        lines4 = self.capture('missing ../a --short', retcode=1)
101
80
        lines4 = lines4.splitlines()
102
81
        self.assertEqual(4, len(lines4))
103
 
        lines5 = bzr('missing ../a --line', retcode=1)
 
82
        lines5 = self.capture('missing ../a --line', retcode=1)
104
83
        lines5 = lines5.splitlines()
105
84
        self.assertEqual(2, len(lines5))
106
 
        lines6 = bzr('missing ../a --reverse', retcode=1)
 
85
        lines6 = self.capture('missing ../a --reverse', retcode=1)
107
86
        lines6 = lines6.splitlines()
108
87
        self.assertEqual(lines6, lines)
109
 
        lines7 = bzr('missing ../a --show-ids', retcode=1)
 
88
        lines7 = self.capture('missing ../a --show-ids', retcode=1)
110
89
        lines7 = lines7.splitlines()
111
90
        self.assertEqual(11, len(lines7))
112
 
        lines8 = bzr('missing ../a --verbose', retcode=1)
 
91
        lines8 = self.capture('missing ../a --verbose', retcode=1)
113
92
        lines8 = lines8.splitlines()
114
93
        self.assertEqual("modified:", lines8[-2])
115
94
        self.assertEqual("  a", lines8[-1])
116
95
 
 
96
        
117
97
        # after a pull we're back on track
118
 
        bzr('pull')
119
 
        self.assertEqual("Branches are up to date.\n", bzr('missing ../a'))
120
 
 
121
 
    def test_missing_check_last_location(self):
122
 
        # check that last location shown as filepath not file URL
123
 
 
124
 
        # create a source branch
125
 
        os.mkdir('a')
126
 
        os.chdir('a')
127
 
        wt = self.make_branch_and_tree('.')
128
 
        b = wt.branch
129
 
        self.build_tree(['foo'])
130
 
        wt.add('foo')
131
 
        wt.commit('initial')
132
 
 
133
 
        location = osutils.getcwd() + '/'
134
 
 
135
 
        # clone
136
 
        b.bzrdir.sprout('../b')
137
 
 
138
 
        # check last location
139
 
        lines, err = self.run_bzr('missing', working_dir='../b')
140
 
        self.assertEquals('Using last location: %s\n'
141
 
                          'Branches are up to date.\n' % location,
142
 
                          lines)
143
 
        self.assertEquals('', err)
 
98
        self.capture('pull')
 
99
        self.assertEqual("Branches are up to date.\n", 
 
100
                         self.capture('missing ../a'))
 
101