~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-26 21:33:20 UTC
  • mfrom: (3015.2.15 pack.read-locks)
  • Revision ID: pqm@pqm.ubuntu.com-20071126213320-adxxra3gsie5inhw
(robertc) Many fixes to support packs on the smart server and as the
        default format. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
412
412
 
413
413
    def get_physical_lock_status(self):
414
414
        """See Repository.get_physical_lock_status()."""
415
 
        return False
 
415
        # should be an API call to the server.
 
416
        self._ensure_real()
 
417
        return self._real_repository.get_physical_lock_status()
416
418
 
417
419
    def is_in_write_group(self):
418
420
        """Return True if there is an open write group.
465
467
    def lock_write(self, token=None):
466
468
        if not self._lock_mode:
467
469
            self._lock_token = self._remote_lock_write(token)
468
 
            assert self._lock_token, 'Remote server did not return a token!'
 
470
            # if self._lock_token is None, then this is something like packs or
 
471
            # svn where we don't get to lock the repo, or a weave style repository
 
472
            # where we cannot lock it over the wire and attempts to do so will
 
473
            # fail.
469
474
            if self._real_repository is not None:
470
475
                self._real_repository.lock_write(token=self._lock_token)
471
476
            if token is not None:
478
483
            raise errors.ReadOnlyError(self)
479
484
        else:
480
485
            self._lock_count += 1
481
 
        return self._lock_token
 
486
        return self._lock_token or None
482
487
 
483
488
    def leave_lock_in_place(self):
 
489
        if not self._lock_token:
 
490
            raise NotImplementedError(self.leave_lock_in_place)
484
491
        self._leave_lock = True
485
492
 
486
493
    def dont_leave_lock_in_place(self):
 
494
        if not self._lock_token:
 
495
            raise NotImplementedError(self.dont_leave_lock_in_place)
487
496
        self._leave_lock = False
488
497
 
489
498
    def _set_real_repository(self, repository):
514
523
 
515
524
    def _unlock(self, token):
516
525
        path = self.bzrdir._path_for_remote_call(self._client)
 
526
        if not token:
 
527
            # with no token the remote repository is not persistently locked.
 
528
            return
517
529
        response = self._client.call('Repository.unlock', path, token)
518
530
        if response == ('ok',):
519
531
            return
542
554
            if old_mode == 'w':
543
555
                # Only write-locked repositories need to make a remote method
544
556
                # call to perfom the unlock.
545
 
                assert self._lock_token, \
546
 
                    '%s is locked, but has no token' \
547
 
                    % self
548
557
                old_token = self._lock_token
549
558
                self._lock_token = None
550
559
                if not self._leave_lock:
604
613
        builder = self._real_repository.get_commit_builder(branch, parents,
605
614
                config, timestamp=timestamp, timezone=timezone,
606
615
                committer=committer, revprops=revprops, revision_id=revision_id)
607
 
        # Make the builder use this RemoteRepository rather than the real one.
608
 
        builder.repository = self
609
616
        return builder
610
617
 
611
618
    @needs_write_lock
1055
1062
            self.repository.unlock()
1056
1063
        path = self.bzrdir._path_for_remote_call(self._client)
1057
1064
        response = self._client.call('Branch.lock_write', path, branch_token,
1058
 
                                     repo_token)
 
1065
                                     repo_token or '')
1059
1066
        if response[0] == 'ok':
1060
1067
            ok, branch_token, repo_token = response
1061
1068
            return branch_token, repo_token
1108
1115
                if token != self._lock_token:
1109
1116
                    raise errors.TokenMismatch(token, self._lock_token)
1110
1117
            self._lock_count += 1
1111
 
        return self._lock_token
 
1118
        return self._lock_token or None
1112
1119
 
1113
1120
    def _unlock(self, branch_token, repo_token):
1114
1121
        path = self.bzrdir._path_for_remote_call(self._client)
1115
1122
        response = self._client.call('Branch.unlock', path, branch_token,
1116
 
                                     repo_token)
 
1123
                                     repo_token or '')
1117
1124
        if response == ('ok',):
1118
1125
            return
1119
1126
        elif response[0] == 'TokenMismatch':
1129
1136
            mode = self._lock_mode
1130
1137
            self._lock_mode = None
1131
1138
            if self._real_branch is not None:
1132
 
                if not self._leave_lock:
 
1139
                if (not self._leave_lock and mode == 'w' and
 
1140
                    self._repo_lock_token):
1133
1141
                    # If this RemoteBranch will remove the physical lock for the
1134
1142
                    # repository, make sure the _real_branch doesn't do it
1135
1143
                    # first.  (Because the _real_branch's repository is set to
1153
1161
        return self._real_branch.break_lock()
1154
1162
 
1155
1163
    def leave_lock_in_place(self):
 
1164
        if not self._lock_token:
 
1165
            raise NotImplementedError(self.leave_lock_in_place)
1156
1166
        self._leave_lock = True
1157
1167
 
1158
1168
    def dont_leave_lock_in_place(self):
 
1169
        if not self._lock_token:
 
1170
            raise NotImplementedError(self.dont_leave_lock_in_place)
1159
1171
        self._leave_lock = False
1160
1172
 
1161
1173
    def last_revision_info(self):