~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: Danny van Heumen
  • Date: 2010-03-09 16:38:10 UTC
  • mto: (4634.139.5 2.0)
  • mto: This revision was merged to the branch mainline in revision 5160.
  • Revision ID: danny@dannyvanheumen.nl-20100309163810-ujn8hcx08f75nlf1
Refined test to make use of locking hooks and also validate if lock is truly a checkout-lock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 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
17
17
"""Server-side branch related request implmentations."""
18
18
 
19
19
 
20
 
from bzrlib import (
21
 
    bencode,
22
 
    errors,
23
 
    )
 
20
from bzrlib import errors
24
21
from bzrlib.bzrdir import BzrDir
25
22
from bzrlib.smart.request import (
26
23
    FailedSmartServerResponse,
108
105
 
109
106
class SmartServerBranchSetTagsBytes(SmartServerLockedBranchRequest):
110
107
 
111
 
    def __init__(self, backing_transport, root_client_path='/', jail_root=None):
 
108
    def __init__(self, backing_transport, root_client_path='/'):
112
109
        SmartServerLockedBranchRequest.__init__(
113
 
            self, backing_transport, root_client_path, jail_root)
 
110
            self, backing_transport, root_client_path)
114
111
        self.locked = False
115
112
        
116
113
    def do_with_locked_branch(self, branch):
197
194
        return SuccessfulSmartServerResponse(())
198
195
 
199
196
 
200
 
class SmartServerBranchRequestSetConfigOptionDict(SmartServerLockedBranchRequest):
201
 
    """Set an option in the branch configuration.
202
 
    
203
 
    New in 2.2.
204
 
    """
205
 
 
206
 
    def do_with_locked_branch(self, branch, value_dict, name, section):
207
 
        utf8_dict = bencode.bdecode(value_dict)
208
 
        value_dict = {}
209
 
        for key, value in utf8_dict.items():
210
 
            value_dict[key.decode('utf8')] = value.decode('utf8')
211
 
        if not section:
212
 
            section = None
213
 
        branch._get_config().set_option(value_dict, name, section)
214
 
        return SuccessfulSmartServerResponse(())
215
 
 
216
 
 
217
197
class SmartServerBranchRequestSetLastRevision(SmartServerSetTipRequest):
218
198
 
219
199
    def do_tip_change_with_locked_branch(self, branch, new_last_revision_id):
312
292
        if repo_token == '':
313
293
            repo_token = None
314
294
        try:
315
 
            repo_token = branch.repository.lock_write(
316
 
                token=repo_token).repository_token
 
295
            repo_token = branch.repository.lock_write(token=repo_token)
317
296
            try:
318
 
                branch_token = branch.lock_write(
319
 
                    token=branch_token).branch_token
 
297
                branch_token = branch.lock_write(token=branch_token)
320
298
            finally:
321
299
                # this leaves the repository with 1 lock
322
300
                branch.repository.unlock()