~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
    def is_locked(self):
232
232
        return self.control_files.is_locked()
233
233
 
234
 
    def lock_write(self):
235
 
        self.control_files.lock_write()
 
234
    def lock_write(self, token=None):
 
235
        """Lock this repository for writing.
 
236
        
 
237
        :param token: if this is already locked, then lock_write will fail
 
238
            unless the token matches the existing lock.
 
239
        :returns: a token if this instance supports tokens, otherwise None.
 
240
        :raises TokenLockingNotSupported: when a token is given but this
 
241
            instance doesn't support using token locks.
 
242
        :raises MismatchedToken: if the specified token doesn't match the token
 
243
            of the existing lock.
 
244
 
 
245
        A token should be passed in if you know that you have locked the object
 
246
        some other way, and need to synchronise this object's state with that
 
247
        fact.
 
248
 
 
249
        XXX: this docstring is duplicated in many places, e.g. lockable_files.py
 
250
        """
 
251
        return self.control_files.lock_write(token=token)
236
252
 
237
253
    def lock_read(self):
238
254
        self.control_files.lock_read()
240
256
    def get_physical_lock_status(self):
241
257
        return self.control_files.get_physical_lock_status()
242
258
 
 
259
    def leave_lock_in_place(self):
 
260
        """Tell this repository not to release the physical lock when this
 
261
        object is unlocked.
 
262
        
 
263
        If lock_write doesn't return a token, then this method is not supported.
 
264
        """
 
265
        self.control_files.leave_in_place()
 
266
 
 
267
    def dont_leave_lock_in_place(self):
 
268
        """Tell this repository to release the physical lock when this
 
269
        object is unlocked, even if it didn't originally acquire it.
 
270
 
 
271
        If lock_write doesn't return a token, then this method is not supported.
 
272
        """
 
273
        self.control_files.dont_leave_in_place()
 
274
 
243
275
    @needs_read_lock
244
276
    def gather_stats(self, revid=None, committers=None):
245
277
        """Gather statistics from a revision id.
1341
1373
 
1342
1374
    @staticmethod
1343
1375
    def is_compatible(source, target):
1344
 
        if not isinstance(source, Repository):
1345
 
            return False
1346
 
        if not isinstance(target, Repository):
1347
 
            return False
1348
 
        if source._format.rich_root_data != target._format.rich_root_data:
 
1376
        if source.supports_rich_root() != target.supports_rich_root():
1349
1377
            return False
1350
1378
        if source._serializer != target._serializer:
1351
1379
            return False
1352
 
        else:
1353
 
            return True 
 
1380
        return True
1354
1381
 
1355
1382
    @needs_write_lock
1356
1383
    def copy_content(self, revision_id=None):
1586
1613
 
1587
1614
    @staticmethod
1588
1615
    def is_compatible(source, target):
1589
 
        if not isinstance(source, Repository):
1590
 
            return False
1591
 
        if not isinstance(target, Repository):
1592
 
            return False
1593
 
        if not source._format.rich_root_data and target._format.rich_root_data:
 
1616
        if not source.supports_rich_root() and target.supports_rich_root():
1594
1617
            return True
1595
1618
        else:
1596
1619
            return False