1
"""Black-box tests for bzr missing.
6
from bzrlib.branch import Branch
7
from bzrlib.tests import TestCaseInTempDir
10
class TestMissing(TestCaseInTempDir):
12
def test_missing(self):
13
missing = "You are missing 1 revision(s):"
15
# create a source branch
19
open('a', 'wb').write('initial\n')
21
self.capture('commit -m inital')
23
# clone and add a differing revision
24
self.capture('branch . ../b')
26
open('a', 'ab').write('more\n')
27
self.capture('commit -m more')
29
# run missing in a against b
31
# this should not require missing to take out a write lock on a
32
# or b. So we take a write lock on both to test that at the same
33
# time. This may let the test pass while the default branch is an
34
# os-locking branch, but it will trigger failures with lockdir based
36
branch_a = Branch.open('.')
38
branch_b = Branch.open('../b')
40
out,err = self.run_bzr('missing', '../b', retcode=1)
41
lines = out.splitlines()
42
# we're missing the extra revision here
43
self.assertEqual(missing, lines[0])
44
# and we expect 8 lines of output which we trust at the moment to be
46
self.assertEqual(8, len(lines))
47
# we do not expect any error output.
48
self.assertEqual('', err)
49
# unlock the branches for the rest of the test
53
# get extra revision from b
54
self.capture('merge ../b')
55
self.capture('commit -m merge')
57
# compare again, but now we have the 'merge' commit extra
58
lines = self.capture('missing ../b', retcode=1).splitlines()
59
self.assertEqual("You have 1 extra revision(s):", lines[0])
60
self.assertEqual(8, len(lines))
61
lines2 = self.capture('missing ../b --mine-only', retcode=1)
62
lines2 = lines2.splitlines()
63
self.assertEqual(lines, lines2)
64
lines3 = self.capture('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 = self.capture('missing ../a', retcode=1).splitlines()
71
self.assertEqual(missing, lines[0])
72
self.assertEqual(8, len(lines))
73
lines2 = self.capture('missing ../a --theirs-only', retcode=1)
74
lines2 = lines2.splitlines()
75
self.assertEqual(lines, lines2)
76
lines3 = self.capture('missing ../a --mine-only', retcode=1)
77
lines3 = lines3.splitlines()
78
self.assertEqual(0, len(lines3))
79
lines4 = self.capture('missing ../a --short', retcode=1)
80
lines4 = lines4.splitlines()
81
self.assertEqual(4, len(lines4))
82
lines5 = self.capture('missing ../a --line', retcode=1)
83
lines5 = lines5.splitlines()
84
self.assertEqual(2, len(lines5))
85
lines6 = self.capture('missing ../a --reverse', retcode=1)
86
lines6 = lines6.splitlines()
87
self.assertEqual(lines6, lines)
88
lines7 = self.capture('missing ../a --show-ids', retcode=1)
89
lines7 = lines7.splitlines()
90
self.assertEqual(11, len(lines7))
91
lines8 = self.capture('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
self.capture('missing ../a'))