29
27
class TestMissing(TestCaseWithTransport):
29
def test_missing_quiet(self):
30
# <https://bugs.launchpad.net/bzr/+bug/284748>
31
# create a source branch
33
# XXX: This still needs a test that missing is quiet when there are
35
a_tree = self.make_branch_and_tree('.')
36
self.build_tree_contents([('a', 'initial\n')])
38
a_tree.commit(message='initial')
40
out, err = self.run_bzr('missing -q .')
41
self.assertEqual('', out)
42
self.assertEqual('', err)
31
44
def test_missing(self):
32
def bzr(*args, **kwargs):
33
return self.run_bzr(*args, **kwargs)[0]
34
45
missing = "You are missing 1 revision(s):"
36
47
# create a source branch
40
open('a', 'wb').write('initial\n')
42
bzr('commit', '-m', 'inital')
48
a_tree = self.make_branch_and_tree('a')
49
self.build_tree_contents([('a/a', 'initial\n')])
51
a_tree.commit(message='initial')
44
53
# clone and add a differing revision
45
bzr('branch', '.', '../b')
47
open('a', 'ab').write('more\n')
48
bzr('commit', '-m', 'more')
54
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
55
self.build_tree_contents([('b/a', 'initial\nmore\n')])
56
b_tree.commit(message='more')
50
58
# run missing in a against b
52
59
# this should not require missing to take out a write lock on a
53
60
# or b. So we take a write lock on both to test that at the same
54
61
# time. This may let the test pass while the default branch is an
55
62
# os-locking branch, but it will trigger failures with lockdir based
57
branch_a = Branch.open('.')
59
branch_b = Branch.open('../b')
61
out,err = self.run_bzr('missing', '../b', retcode=1)
64
a_branch = a_tree.branch
66
b_branch = b_tree.branch
69
out,err = self.run_bzr('missing ../b', retcode=1)
62
70
lines = out.splitlines()
63
71
# we're missing the extra revision here
64
72
self.assertEqual(missing, lines[0])
68
76
# we do not expect any error output.
69
77
self.assertEqual('', err)
70
78
# unlock the branches for the rest of the test
74
82
# get extra revision from b
76
bzr('commit', '-m', 'merge')
83
a_tree.merge_from_branch(b_branch)
84
a_tree.commit(message='merge')
78
86
# compare again, but now we have the 'merge' commit extra
79
lines = bzr('missing', '../b', retcode=1).splitlines()
87
lines = self.run_bzr('missing ../b', retcode=1)[0].splitlines()
80
88
self.assertEqual("You have 1 extra revision(s):", lines[0])
81
89
self.assertEqual(8, len(lines))
82
lines2 = bzr('missing', '../b', '--mine-only', retcode=1)
90
lines2 = self.run_bzr('missing ../b --mine-only', retcode=1)[0]
83
91
lines2 = lines2.splitlines()
84
92
self.assertEqual(lines, lines2)
85
lines3 = bzr('missing', '../b', '--theirs-only', retcode=1)
86
lines3 = lines3.splitlines()
87
self.assertEqual(0, len(lines3))
93
lines3 = self.run_bzr('missing ../b --theirs-only', retcode=0)[0]
94
self.assertEqualDiff('Other branch is up to date.\n', lines3)
89
96
# relative to a, missing the 'merge' commit
91
lines = bzr('missing', '../a', retcode=1).splitlines()
98
lines = self.run_bzr('missing ../a', retcode=1)[0].splitlines()
92
99
self.assertEqual(missing, lines[0])
93
100
self.assertEqual(8, len(lines))
94
lines2 = bzr('missing', '../a', '--theirs-only', retcode=1)
101
lines2 = self.run_bzr('missing ../a --theirs-only', retcode=1)[0]
95
102
lines2 = lines2.splitlines()
96
103
self.assertEqual(lines, lines2)
97
lines3 = bzr('missing', '../a', '--mine-only', retcode=1)
98
lines3 = lines3.splitlines()
99
self.assertEqual(0, len(lines3))
100
lines4 = bzr('missing', '../a', '--short', retcode=1)
104
lines3 = self.run_bzr('missing ../a --mine-only', retcode=0)[0]
105
self.assertEqualDiff('This branch is up to date.\n', lines3)
106
lines4 = self.run_bzr('missing ../a --short', retcode=1)[0]
101
107
lines4 = lines4.splitlines()
102
108
self.assertEqual(4, len(lines4))
103
lines5 = bzr('missing', '../a', '--line', retcode=1)
109
lines5 = self.run_bzr('missing ../a --line', retcode=1)[0]
104
110
lines5 = lines5.splitlines()
105
111
self.assertEqual(2, len(lines5))
106
lines6 = bzr('missing', '../a', '--reverse', retcode=1)
112
lines6 = self.run_bzr('missing ../a --reverse', retcode=1)[0]
107
113
lines6 = lines6.splitlines()
108
114
self.assertEqual(lines6, lines)
109
lines7 = bzr('missing', '../a', '--show-ids', retcode=1)
115
lines7 = self.run_bzr('missing ../a --show-ids', retcode=1)[0]
110
116
lines7 = lines7.splitlines()
111
117
self.assertEqual(11, len(lines7))
112
lines8 = bzr('missing', '../a', '--verbose', retcode=1)
118
lines8 = self.run_bzr('missing ../a --verbose', retcode=1)[0]
113
119
lines8 = lines8.splitlines()
114
120
self.assertEqual("modified:", lines8[-2])
115
121
self.assertEqual(" a", lines8[-1])
124
self.assertEqualDiff('Other branch is up to date.\n',
125
self.run_bzr('missing ../b --theirs-only')[0])
118
127
# after a pull we're back on track
120
self.assertEqual("Branches are up to date.\n",
121
bzr('missing', '../a'))
128
b_tree.pull(a_branch)
129
self.assertEqualDiff("Branches are up to date.\n",
130
self.run_bzr('missing ../b')[0])
132
self.assertEqualDiff('Branches are up to date.\n',
133
self.run_bzr('missing ../a')[0])
134
# If you supply mine or theirs you only know one side is up to date
135
self.assertEqualDiff('This branch is up to date.\n',
136
self.run_bzr('missing ../a --mine-only')[0])
137
self.assertEqualDiff('Other branch is up to date.\n',
138
self.run_bzr('missing ../a --theirs-only')[0])
123
140
def test_missing_check_last_location(self):
124
141
# check that last location shown as filepath not file URL
126
143
# create a source branch
129
wt = self.make_branch_and_tree('.')
144
wt = self.make_branch_and_tree('a')
131
self.build_tree(['foo'])
146
self.build_tree(['a/foo'])
133
148
wt.commit('initial')
135
151
location = osutils.getcwd() + '/'