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