/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_missing.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 14:26:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105142658-vek3v6pzlxb751s2
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. 

@only_raises is evil and gave a hard time since any exception during
save_changes() was swallowed.

Possible improvements: 

- add some needs_write_lock decorators to crucial
  methods (_set_config_location ?) but keep locking the branch at higher levels

- decorate branch.unlock to call stack.save if last_lock() it True
  outside of @only_raises scope (evil decorator)

- add @needs_write_lock to stack.set and stack.remove (will probably get
  rid of most testing issues) we probably need a specialized decorator
  that can relay to the store and from there to the branch or whatever is
  needed. This will also helps bzr config to get it right. The
  get_mutable_section trick should not be needed anymore either.

- decorate branch.unlock to call stack.save if last_lock() it True outside
  of @only_raises scope (evil decorator)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2008 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
49
49
        self.assertEqual('', err)
50
50
 
51
51
    def test_missing(self):
52
 
        missing = "You are missing 1 revision(s):"
 
52
        missing = "You are missing 1 revision:"
53
53
 
54
54
        # create a source branch
55
55
        a_tree = self.make_branch_and_tree('a')
92
92
 
93
93
        # compare again, but now we have the 'merge' commit extra
94
94
        lines = self.run_bzr('missing ../b', retcode=1)[0].splitlines()
95
 
        self.assertEqual("You have 1 extra revision(s):", lines[0])
 
95
        self.assertEqual("You have 1 extra revision:", lines[0])
96
96
        self.assertEqual(8, len(lines))
97
97
        lines2 = self.run_bzr('missing ../b --mine-only', retcode=1)[0]
98
98
        lines2 = lines2.splitlines()
99
99
        self.assertEqual(lines, lines2)
100
100
        lines3 = self.run_bzr('missing ../b --theirs-only', retcode=0)[0]
101
 
        self.assertEqualDiff('Other branch is up to date.\n', lines3)
 
101
        self.assertEqualDiff('Other branch has no new revisions.\n', lines3)
102
102
 
103
103
        # relative to a, missing the 'merge' commit
104
104
        os.chdir('../b')
109
109
        lines2 = lines2.splitlines()
110
110
        self.assertEqual(lines, lines2)
111
111
        lines3 = self.run_bzr('missing ../a --mine-only', retcode=0)[0]
112
 
        self.assertEqualDiff('This branch is up to date.\n', lines3)
 
112
        self.assertEqualDiff('This branch has no new revisions.\n', lines3)
113
113
        lines4 = self.run_bzr('missing ../a --short', retcode=1)[0]
114
114
        lines4 = lines4.splitlines()
115
115
        self.assertEqual(4, len(lines4))
 
116
        lines4a = self.run_bzr('missing ../a -S', retcode=1)[0]
 
117
        lines4a = lines4a.splitlines()
 
118
        self.assertEqual(lines4, lines4a)
116
119
        lines5 = self.run_bzr('missing ../a --line', retcode=1)[0]
117
120
        lines5 = lines5.splitlines()
118
121
        self.assertEqual(2, len(lines5))
128
131
        self.assertEqual("  a", lines8[-1])
129
132
 
130
133
        os.chdir('../a')
131
 
        self.assertEqualDiff('Other branch is up to date.\n',
 
134
        self.assertEqualDiff('Other branch has no new revisions.\n',
132
135
                             self.run_bzr('missing ../b --theirs-only')[0])
133
136
 
134
137
        # after a pull we're back on track
139
142
        self.assertEqualDiff('Branches are up to date.\n',
140
143
                             self.run_bzr('missing ../a')[0])
141
144
        # If you supply mine or theirs you only know one side is up to date
142
 
        self.assertEqualDiff('This branch is up to date.\n',
 
145
        self.assertEqualDiff('This branch has no new revisions.\n',
143
146
                             self.run_bzr('missing ../a --mine-only')[0])
144
 
        self.assertEqualDiff('Other branch is up to date.\n',
 
147
        self.assertEqualDiff('Other branch has no new revisions.\n',
145
148
                             self.run_bzr('missing ../a --theirs-only')[0])
146
149
 
147
150
    def test_missing_filtered(self):
200
203
                          'Branches are up to date.\n' % location,
201
204
                          lines)
202
205
        self.assertEquals('', err)
 
206
 
 
207
    def test_missing_directory(self):
 
208
        """Test --directory option"""
 
209
 
 
210
        # create a source branch
 
211
        a_tree = self.make_branch_and_tree('a')
 
212
        self.build_tree_contents([('a/a', 'initial\n')])
 
213
        a_tree.add('a')
 
214
        a_tree.commit(message='initial')
 
215
 
 
216
        # clone and add a differing revision
 
217
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
 
218
        self.build_tree_contents([('b/a', 'initial\nmore\n')])
 
219
        b_tree.commit(message='more')
 
220
 
 
221
        out2, err2 = self.run_bzr('missing --directory a b', retcode=1)
 
222
        os.chdir('a')
 
223
        out1, err1 = self.run_bzr('missing ../b', retcode=1)
 
224
        self.assertEqualDiff(out1, out2)
 
225
        self.assertEqualDiff(err1, err2)