1
# Copyright (C) 2005 by Canonical Ltd
2
# -*- coding: utf-8 -*-
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.
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.
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
"""Black-box tests for bzr missing.
23
from bzrlib.branch import Branch
24
from bzrlib.tests import TestCaseInTempDir
26
class TestMissing(TestCaseInTempDir):
27
def test_missing(self):
28
def bzr(*args, **kwargs):
29
return self.run_bzr(*args, **kwargs)[0]
30
missing = "You are missing 1 revision(s):"
32
# create a source branch
36
open('a', 'wb').write('initial\n')
38
bzr('commit', '-m', 'inital')
40
# clone and add a differing revision
41
bzr('branch', '.', '../b')
43
open('a', 'ab').write('more\n')
44
bzr('commit', '-m', 'more')
48
lines = bzr('missing', '../b', retcode=1).splitlines()
49
# we're missing the extra revision here
50
self.assertEqual(missing, lines[0])
51
self.assertEqual(8, len(lines))
53
# get extra revision from b
55
bzr('commit', '-m', 'merge')
57
# compare again, but now we have the 'merge' commit extra
58
lines = bzr('missing', '../b', retcode=1).splitlines()
59
self.assertEqual("You have 1 extra revision(s):", lines[0])
60
self.assertEqual(8, len(lines))
61
lines2 = bzr('missing', '../b', '--mine-only', retcode=1)
62
lines2 = lines2.splitlines()
63
self.assertEqual(lines, lines2)
64
lines3 = bzr('missing', '../b', '--theirs-only', retcode=1)
65
lines3 = lines3.splitlines()
66
self.assertEqual(0, len(lines3))
68
# relative to a, missing the 'merge' commit
70
lines = bzr('missing', '../a', retcode=1).splitlines()
71
self.assertEqual(missing, lines[0])
72
self.assertEqual(8, len(lines))
73
lines2 = bzr('missing', '../a', '--theirs-only', retcode=1)
74
lines2 = lines2.splitlines()
75
self.assertEqual(lines, lines2)
76
lines3 = bzr('missing', '../a', '--mine-only', retcode=1)
77
lines3 = lines3.splitlines()
78
self.assertEqual(0, len(lines3))
79
lines4 = bzr('missing', '../a', '--short', retcode=1)
80
lines4 = lines4.splitlines()
81
self.assertEqual(4, len(lines4))
82
lines5 = bzr('missing', '../a', '--line', retcode=1)
83
lines5 = lines5.splitlines()
84
self.assertEqual(2, len(lines5))
85
lines6 = bzr('missing', '../a', '--reverse', retcode=1)
86
lines6 = lines6.splitlines()
87
self.assertEqual(lines6, lines)
88
lines7 = bzr('missing', '../a', '--show-ids', retcode=1)
89
lines7 = lines7.splitlines()
90
self.assertEqual(11, len(lines7))
91
lines8 = bzr('missing', '../a', '--verbose', retcode=1)
92
lines8 = lines8.splitlines()
93
self.assertEqual("modified:", lines8[-2])
94
self.assertEqual(" a", lines8[-1])
97
# after a pull we're back on track
99
self.assertEqual("Branches are up to date.\n",
100
bzr('missing', '../a'))