/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert Collins
  • Date: 2007-11-05 19:40:28 UTC
  • mfrom: (2963 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2967.
  • Revision ID: robertc@robertcollins.net-20071105194028-5gc6rdajk96maaq1
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
        self._lock_token = None
259
259
        self._lock_count = 0
260
260
        self._leave_lock = False
261
 
        # for tests
262
 
        self._reconcile_does_inventory_gc = True
263
 
        self._reconcile_fixes_text_parents = True
 
261
        # For tests:
 
262
        # These depend on the actual remote format, so force them off for
 
263
        # maximum compatibility. XXX: In future these should depend on the
 
264
        # remote repository instance, but this is irrelevant until we perform
 
265
        # reconcile via an RPC call.
 
266
        self._reconcile_does_inventory_gc = False
 
267
        self._reconcile_fixes_text_parents = False
 
268
        self._reconcile_backsup_inventory = False
264
269
        self.base = self.bzrdir.transport.base
265
270
 
266
271
    def __str__(self):
492
497
            raise errors.UnexpectedSmartServerResponse(response)
493
498
 
494
499
    def unlock(self):
495
 
        if self._lock_count == 1 and self._lock_mode == 'w':
496
 
            # don't unlock if inside a write group.
497
 
            if self.is_in_write_group():
498
 
                raise errors.BzrError(
499
 
                    'Must end write groups before releasing write locks.')
500
500
        self._lock_count -= 1
501
 
        if not self._lock_count:
502
 
            mode = self._lock_mode
503
 
            self._lock_mode = None
 
501
        if self._lock_count > 0:
 
502
            return
 
503
        old_mode = self._lock_mode
 
504
        self._lock_mode = None
 
505
        try:
 
506
            # The real repository is responsible at present for raising an
 
507
            # exception if it's in an unfinished write group.  However, it
 
508
            # normally will *not* actually remove the lock from disk - that's
 
509
            # done by the server on receiving the Repository.unlock call.
 
510
            # This is just to let the _real_repository stay up to date.
504
511
            if self._real_repository is not None:
505
512
                self._real_repository.unlock()
506
 
            if mode != 'w':
 
513
        finally:
 
514
            # The rpc-level lock should be released even if there was a
 
515
            # problem releasing the vfs-based lock.
 
516
            if old_mode == 'w':
507
517
                # Only write-locked repositories need to make a remote method
508
518
                # call to perfom the unlock.
509
 
                return
510
 
            assert self._lock_token, 'Locked, but no token!'
511
 
            token = self._lock_token
512
 
            self._lock_token = None
513
 
            if not self._leave_lock:
514
 
                self._unlock(token)
 
519
                assert self._lock_token, \
 
520
                    '%s is locked, but has no token' \
 
521
                    % self
 
522
                old_token = self._lock_token
 
523
                self._lock_token = None
 
524
                if not self._leave_lock:
 
525
                    self._unlock(old_token)
515
526
 
516
527
    def break_lock(self):
517
528
        # should hand off to the network