~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-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
2481
2481
        self.control_files = _control_files
2482
2482
        self._transport = _control_files._transport
2483
2483
        self.repository = _repository
 
2484
        self.conf_store = None
2484
2485
        Branch.__init__(self, possible_transports)
2485
2486
 
2486
2487
    def __str__(self):
2502
2503
        return _mod_config.TransportConfig(self._transport, 'branch.conf')
2503
2504
 
2504
2505
    def _get_config_store(self):
2505
 
        return _mod_config.BranchStore(self)
 
2506
        if self.conf_store is None:
 
2507
            self.conf_store =  _mod_config.BranchStore(self)
 
2508
        return self.conf_store
2506
2509
 
2507
2510
    def is_locked(self):
2508
2511
        return self.control_files.is_locked()
2557
2560
 
2558
2561
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2559
2562
    def unlock(self):
 
2563
        if self.conf_store is not None:
 
2564
            self.conf_store.save_changes()
2560
2565
        try:
2561
2566
            self.control_files.unlock()
2562
2567
        finally:
3245
3250
 
3246
3251
        # Copy source data into target
3247
3252
        new_branch._write_last_revision_info(*branch.last_revision_info())
3248
 
        new_branch.set_parent(branch.get_parent())
3249
 
        new_branch.set_bound_location(branch.get_bound_location())
3250
 
        new_branch.set_push_location(branch.get_push_location())
 
3253
        new_branch.lock_write()
 
3254
        try:
 
3255
            new_branch.set_parent(branch.get_parent())
 
3256
            new_branch.set_bound_location(branch.get_bound_location())
 
3257
            new_branch.set_push_location(branch.get_push_location())
 
3258
        finally:
 
3259
            new_branch.unlock()
3251
3260
 
3252
3261
        # New branch has no tags by default
3253
3262
        new_branch.tags._set_tag_dict({})
3259
3268
 
3260
3269
        # Clean up old files
3261
3270
        new_branch._transport.delete('revision-history')
 
3271
        branch.lock_write()
3262
3272
        try:
3263
 
            branch.set_parent(None)
3264
 
        except errors.NoSuchFile:
3265
 
            pass
3266
 
        branch.set_bound_location(None)
 
3273
            try:
 
3274
                branch.set_parent(None)
 
3275
            except errors.NoSuchFile:
 
3276
                pass
 
3277
            branch.set_bound_location(None)
 
3278
        finally:
 
3279
            branch.unlock()
3267
3280
 
3268
3281
 
3269
3282
class Converter6to7(object):