~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Aaron Bentley
  • Date: 2007-08-15 11:24:06 UTC
  • mfrom: (2702 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2703.
  • Revision ID: aaron.bentley@utoronto.ca-20070815112406-lyv23omlm0wgsu42
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
249
249
        self._lock_count = 0
250
250
        self._leave_lock = False
251
251
 
252
 
    def has_same_location(self, other):
253
 
        return (self.__class__ == other.__class__ and
254
 
                self.bzrdir.transport.base == other.bzrdir.transport.base)
255
 
        
 
252
    def abort_write_group(self):
 
253
        """Complete a write group on the decorated repository.
 
254
        
 
255
        Smart methods peform operations in a single step so this api
 
256
        is not really applicable except as a compatibility thunk
 
257
        for older plugins that don't use e.g. the CommitBuilder
 
258
        facility.
 
259
        """
 
260
        self._ensure_real()
 
261
        return self._real_repository.abort_write_group()
 
262
 
 
263
    def commit_write_group(self):
 
264
        """Complete a write group on the decorated repository.
 
265
        
 
266
        Smart methods peform operations in a single step so this api
 
267
        is not really applicable except as a compatibility thunk
 
268
        for older plugins that don't use e.g. the CommitBuilder
 
269
        facility.
 
270
        """
 
271
        self._ensure_real()
 
272
        return self._real_repository.commit_write_group()
 
273
 
256
274
    def _ensure_real(self):
257
275
        """Ensure that there is a _real_repository set.
258
276
 
303
321
        assert response[0] in ('yes', 'no'), 'unexpected response code %s' % (response,)
304
322
        return response[0] == 'yes'
305
323
 
 
324
    def has_same_location(self, other):
 
325
        return (self.__class__ == other.__class__ and
 
326
                self.bzrdir.transport.base == other.bzrdir.transport.base)
 
327
        
306
328
    def get_graph(self, other_repository=None):
307
329
        """Return the graph for this repository format"""
308
330
        return self._real_repository.get_graph(other_repository)
341
363
        """See Repository.get_physical_lock_status()."""
342
364
        return False
343
365
 
 
366
    def is_in_write_group(self):
 
367
        """Return True if there is an open write group.
 
368
 
 
369
        write groups are only applicable locally for the smart server..
 
370
        """
 
371
        if self._real_repository:
 
372
            return self._real_repository.is_in_write_group()
 
373
 
 
374
    def is_locked(self):
 
375
        return self._lock_count >= 1
 
376
 
344
377
    def is_shared(self):
345
378
        """See Repository.is_shared()."""
346
379
        path = self.bzrdir._path_for_remote_call(self._client)
412
445
        elif self._lock_mode == 'r':
413
446
            self._real_repository.lock_read()
414
447
 
 
448
    def start_write_group(self):
 
449
        """Start a write group on the decorated repository.
 
450
        
 
451
        Smart methods peform operations in a single step so this api
 
452
        is not really applicable except as a compatibility thunk
 
453
        for older plugins that don't use e.g. the CommitBuilder
 
454
        facility.
 
455
        """
 
456
        self._ensure_real()
 
457
        return self._real_repository.start_write_group()
 
458
 
415
459
    def _unlock(self, token):
416
460
        path = self.bzrdir._path_for_remote_call(self._client)
417
461
        response = self._client.call('Repository.unlock', path, token)
423
467
            raise errors.UnexpectedSmartServerResponse(response)
424
468
 
425
469
    def unlock(self):
 
470
        if self._lock_count == 1 and self._lock_mode == 'w':
 
471
            # don't unlock if inside a write group.
 
472
            if self.is_in_write_group():
 
473
                raise errors.BzrError(
 
474
                    'Must end write groups before releasing write locks.')
426
475
        self._lock_count -= 1
427
476
        if not self._lock_count:
428
477
            mode = self._lock_mode