1
"""Black-box tests for bzr missing.
6
from bzrlib.branch import Branch
7
from bzrlib.tests import TestCaseInTempDir
9
class TestMissing(TestCaseInTempDir):
10
def test_missing(self):
11
missing = "You are missing 1 revision(s):"
13
# create a source branch
17
open('a', 'wb').write('initial\n')
19
self.capture('commit -m inital')
21
# clone and add a differing revision
22
self.capture('branch . ../b')
24
open('a', 'ab').write('more\n')
25
self.capture('commit -m more')
29
lines = self.capture('missing ../b', retcode=1).splitlines()
30
# we're missing the extra revision here
31
self.assertEqual(missing, lines[0])
32
self.assertEqual(8, len(lines))
34
# get extra revision from b
35
self.capture('merge ../b')
36
self.capture('commit -m merge')
38
# compare again, but now we have the 'merge' commit extra
39
lines = self.capture('missing ../b', retcode=1).splitlines()
40
self.assertEqual("You have 1 extra revision(s):", lines[0])
41
self.assertEqual(8, len(lines))
42
lines2 = self.capture('missing ../b --mine-only', retcode=1)
43
lines2 = lines2.splitlines()
44
self.assertEqual(lines, lines2)
45
lines3 = self.capture('missing ../b --theirs-only', retcode=1)
46
lines3 = lines3.splitlines()
47
self.assertEqual(0, len(lines3))
49
# relative to a, missing the 'merge' commit
51
lines = self.capture('missing ../a', retcode=1).splitlines()
52
self.assertEqual(missing, lines[0])
53
self.assertEqual(8, len(lines))
54
lines2 = self.capture('missing ../a --theirs-only', retcode=1)
55
lines2 = lines2.splitlines()
56
self.assertEqual(lines, lines2)
57
lines3 = self.capture('missing ../a --mine-only', retcode=1)
58
lines3 = lines3.splitlines()
59
self.assertEqual(0, len(lines3))
60
lines4 = self.capture('missing ../a --short', retcode=1)
61
lines4 = lines4.splitlines()
62
self.assertEqual(4, len(lines4))
63
lines5 = self.capture('missing ../a --line', retcode=1)
64
lines5 = lines5.splitlines()
65
self.assertEqual(2, len(lines5))
66
lines6 = self.capture('missing ../a --reverse', retcode=1)
67
lines6 = lines6.splitlines()
68
self.assertEqual(lines6, lines)
69
lines7 = self.capture('missing ../a --show-ids', retcode=1)
70
lines7 = lines7.splitlines()
71
self.assertEqual(11, len(lines7))
72
lines8 = self.capture('missing ../a --verbose', retcode=1)
73
lines8 = lines8.splitlines()
74
self.assertEqual("modified:", lines8[-2])
75
self.assertEqual(" a", lines8[-1])
78
# after a pull we're back on track
80
self.assertEqual("Branches are up to date.\n",
81
self.capture('missing ../a'))