/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_ls.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:
20
20
 
21
21
from bzrlib import ignores
22
22
from bzrlib.tests import TestCaseWithTransport
 
23
from bzrlib.tests.matchers import ContainsNoVfsCalls
23
24
 
24
25
 
25
26
class TestLS(TestCaseWithTransport):
235
236
                       '%s/a\n'
236
237
                       % (self.test_dir, self.test_dir),
237
238
                       self.test_dir, recursive=False)
 
239
 
 
240
    def test_ls_directory(self):
 
241
        """Test --directory option"""
 
242
        self.wt = self.make_branch_and_tree('dir')
 
243
        self.build_tree(['dir/sub/', 'dir/sub/file'])
 
244
        self.wt.add(['sub', 'sub/file'])
 
245
        self.wt.commit('commit')
 
246
        self.ls_equals('sub/\nsub/file\n', '--directory=dir')
 
247
        self.ls_equals('sub/file\n', '-d dir sub')
 
248
 
 
249
 
 
250
class TestSmartServerLs(TestCaseWithTransport):
 
251
 
 
252
    def test_simple_ls(self):
 
253
        self.setup_smart_server_with_call_log()
 
254
        t = self.make_branch_and_tree('branch')
 
255
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
256
        t.add("foo")
 
257
        t.commit("message")
 
258
        self.reset_smart_call_log()
 
259
        out, err = self.run_bzr(['ls', self.get_url('branch')])
 
260
        # This figure represent the amount of work to perform this use case. It
 
261
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
262
        # being too low. If rpc_count increases, more network roundtrips have
 
263
        # become necessary for this use case. Please do not adjust this number
 
264
        # upwards without agreement from bzr's network support maintainers.
 
265
        self.assertLength(6, self.hpss_calls)
 
266
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)