~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-04-19 02:27:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2426.
  • Revision ID: robertc@robertcollins.net-20070419022744-pfdqz42kp1wizh43
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

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