~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.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) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012 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
1269
1269
        self.reset_smart_call_log()
1270
1270
        verb = 'Branch.set_parent_location'
1271
1271
        self.disable_verb(verb)
1272
 
        branch.set_parent('http://foo/')
1273
 
        self.assertLength(12, self.hpss_calls)
 
1272
        branch.lock_write()
 
1273
        try:
 
1274
            branch.set_parent('http://foo/')
 
1275
        finally:
 
1276
            branch.unlock()
 
1277
        self.assertLength(13, self.hpss_calls)
1274
1278
 
1275
1279
 
1276
1280
class TestBranchGetTagsBytes(RemoteBranchTestCase):
2047
2051
            'Branch.get_config_file', ('memory:///', ),
2048
2052
            'success', ('ok', ), "# line 1\n")
2049
2053
        client.add_expected_call(
 
2054
            'Branch.get_config_file', ('memory:///', ),
 
2055
            'success', ('ok', ), "# line 1\n")
 
2056
        client.add_expected_call(
2050
2057
            'Branch.put_config_file', ('memory:///', 'branch token',
2051
2058
            'repo token'),
2052
2059
            'success', ('ok',))
2064
2071
            [('call', 'Branch.get_stacked_on_url', ('memory:///',)),
2065
2072
             ('call', 'Branch.lock_write', ('memory:///', '', '')),
2066
2073
             ('call_expecting_body', 'Branch.get_config_file', ('memory:///',)),
 
2074
             ('call_expecting_body', 'Branch.get_config_file', ('memory:///',)),
2067
2075
             ('call_with_body_bytes_expecting_body', 'Branch.put_config_file',
2068
2076
                 ('memory:///', 'branch token', 'repo token'),
2069
2077
                 '# line 1\nemail = The Dude <lebowski@example.com>\n'),
4134
4142
        self.bound_location = self.checkout.branch.get_bound_location()
4135
4143
 
4136
4144
    def assertUpdateSucceeds(self, new_location):
4137
 
        self.checkout.branch.set_bound_location(new_location)
4138
 
        self.checkout.update()
 
4145
        self.checkout.lock_write()
 
4146
        try:
 
4147
            self.checkout.branch.set_bound_location(new_location)
 
4148
            self.checkout.update()
 
4149
        finally:
 
4150
            self.checkout.unlock()
4139
4151
        self.assertEquals(self.last_revid, self.checkout.last_revision())
4140
4152
 
4141
4153
    def test_without_final_slash(self):