~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-01 12:31:04 UTC
  • mfrom: (5743.6.34 config-locks)
  • Revision ID: pqm@pqm.ubuntu.com-20110601123104-ldhru7h1z82ee5xv
(jameinel) Forget weakref for branch <-> config (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2415
2415
    def __init__(self, branch):
2416
2416
        super(BranchStore, self).__init__(branch.control_transport,
2417
2417
                                          'branch.conf')
2418
 
        # We don't want to create a cycle here when the BranchStore becomes
2419
 
        # part of an object (roughly a Stack, directly or indirectly) that is
2420
 
        # an attribute of the branch object itself. Since the BranchStore
2421
 
        # cannot exist without a branch, it's safe to make it a weakref.
2422
 
        self.branch_ref = weakref.ref(branch)
2423
 
 
2424
 
    def _get_branch(self):
2425
 
        b = self.branch_ref()
2426
 
        if b is None:
2427
 
            # Programmer error, a branch store can't exist if the branch it
2428
 
            # refers to is dead.
2429
 
            raise AssertionError('Dead branch ref in %r' % (self,))
2430
 
        return b
 
2418
        self.branch = branch
2431
2419
 
2432
2420
    def lock_write(self, token=None):
2433
 
        return self._get_branch().lock_write(token)
 
2421
        return self.branch.lock_write(token)
2434
2422
 
2435
2423
    def unlock(self):
2436
 
        return self._get_branch().unlock()
 
2424
        return self.branch.unlock()
2437
2425
 
2438
2426
    @needs_write_lock
2439
2427
    def save(self):