~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-01 09:01:06 UTC
  • mto: This revision was merged to the branch mainline in revision 5951.
  • Revision ID: v.ladeuil+lp@free.fr-20110601090106-j6576yr7gv1xs1fs
Forget weakref for branch <-> config.

Show diffs side-by-side

added added

removed removed

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