/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/repository.py

merge hpss changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
        :raises MismatchedToken: if the specified token doesn't match the token
243
243
            of the existing lock.
244
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
 
245
249
        XXX: this docstring is duplicated in many places, e.g. lockable_files.py
246
250
        """
247
251
        return self.control_files.lock_write(token=token)
339
343
        control = bzrdir.BzrDir.open(base)
340
344
        return control.open_repository()
341
345
 
342
 
    def copy_content_into(self, destination, revision_id=None, basis=None):
 
346
    def copy_content_into(self, destination, revision_id=None):
343
347
        """Make a complete copy of the content in self into destination.
344
348
        
345
349
        This is a destructive operation! Do not use it on existing 
346
350
        repositories.
347
351
        """
348
352
        revision_id = osutils.safe_revision_id(revision_id)
349
 
        return InterRepository.get(self, destination).copy_content(revision_id, basis)
 
353
        return InterRepository.get(self, destination).copy_content(revision_id)
350
354
 
351
355
    def fetch(self, source, revision_id=None, pb=None):
352
356
        """Fetch the content required to construct revision_id from source.
354
358
        If revision_id is None all content is copied.
355
359
        """
356
360
        revision_id = osutils.safe_revision_id(revision_id)
357
 
        return InterRepository.get(source, self).fetch(revision_id=revision_id,
358
 
                                                       pb=pb)
 
361
        inter = InterRepository.get(source, self)
 
362
        try:
 
363
            return inter.fetch(revision_id=revision_id, pb=pb)
 
364
        except NotImplementedError:
 
365
            raise errors.IncompatibleRepositories(source, self)
359
366
 
360
367
    def get_commit_builder(self, branch, parents, config, timestamp=None, 
361
368
                           timezone=None, committer=None, revprops=None, 
379
386
        self.control_files.unlock()
380
387
 
381
388
    @needs_read_lock
382
 
    def clone(self, a_bzrdir, revision_id=None, basis=None):
 
389
    def clone(self, a_bzrdir, revision_id=None):
383
390
        """Clone this repository into a_bzrdir using the current format.
384
391
 
385
392
        Currently no check is made that the format of this repository and
397
404
                dest_repo = self._format.initialize(a_bzrdir, shared=self.is_shared())
398
405
            except errors.UninitializableFormat:
399
406
                dest_repo = a_bzrdir.open_repository()
400
 
        self.copy_content_into(dest_repo, revision_id, basis)
 
407
        self.copy_content_into(dest_repo, revision_id)
401
408
        return dest_repo
402
409
 
403
410
    @needs_read_lock
1234
1241
    """Common base class for the new repositories using the metadir layout."""
1235
1242
 
1236
1243
    rich_root_data = False
1237
 
    support_tree_reference = False
 
1244
    supports_tree_reference = False
1238
1245
    _matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1239
1246
 
1240
1247
    def __init__(self):
1310
1317
    _optimisers = []
1311
1318
    """The available optimised InterRepository types."""
1312
1319
 
1313
 
    def copy_content(self, revision_id=None, basis=None):
 
1320
    def copy_content(self, revision_id=None):
1314
1321
        raise NotImplementedError(self.copy_content)
1315
1322
 
1316
1323
    def fetch(self, revision_id=None, pb=None):
1375
1382
        return True
1376
1383
 
1377
1384
    @needs_write_lock
1378
 
    def copy_content(self, revision_id=None, basis=None):
 
1385
    def copy_content(self, revision_id=None):
1379
1386
        """Make a complete copy of the content in self into destination.
1380
1387
        
1381
1388
        This is a destructive operation! Do not use it on existing 
1383
1390
 
1384
1391
        :param revision_id: Only copy the content needed to construct
1385
1392
                            revision_id and its parents.
1386
 
        :param basis: Copy the needed data preferentially from basis.
1387
1393
        """
1388
1394
        try:
1389
1395
            self.target.set_make_working_trees(self.source.make_working_trees())
1392
1398
        # TODO: jam 20070210 This is fairly internal, so we should probably
1393
1399
        #       just assert that revision_id is not unicode.
1394
1400
        revision_id = osutils.safe_revision_id(revision_id)
1395
 
        # grab the basis available data
1396
 
        if basis is not None:
1397
 
            self.target.fetch(basis, revision_id=revision_id)
1398
1401
        # but don't bother fetching if we have the needed data now.
1399
1402
        if (revision_id not in (None, _mod_revision.NULL_REVISION) and 
1400
1403
            self.target.has_revision(revision_id)):
1449
1452
            return False
1450
1453
    
1451
1454
    @needs_write_lock
1452
 
    def copy_content(self, revision_id=None, basis=None):
 
1455
    def copy_content(self, revision_id=None):
1453
1456
        """See InterRepository.copy_content()."""
1454
1457
        # weave specific optimised path:
1455
1458
        # TODO: jam 20070210 Internal, should be an assert, not translate
1456
1459
        revision_id = osutils.safe_revision_id(revision_id)
1457
 
        if basis is not None:
1458
 
            # copy the basis in, then fetch remaining data.
1459
 
            basis.copy_content_into(self.target, revision_id)
1460
 
            # the basis copy_content_into could miss-set this.
 
1460
        try:
 
1461
            self.target.set_make_working_trees(self.source.make_working_trees())
 
1462
        except NotImplementedError:
 
1463
            pass
 
1464
        # FIXME do not peek!
 
1465
        if self.source.control_files._transport.listable():
 
1466
            pb = ui.ui_factory.nested_progress_bar()
1461
1467
            try:
1462
 
                self.target.set_make_working_trees(self.source.make_working_trees())
1463
 
            except NotImplementedError:
1464
 
                pass
 
1468
                self.target.weave_store.copy_all_ids(
 
1469
                    self.source.weave_store,
 
1470
                    pb=pb,
 
1471
                    from_transaction=self.source.get_transaction(),
 
1472
                    to_transaction=self.target.get_transaction())
 
1473
                pb.update('copying inventory', 0, 1)
 
1474
                self.target.control_weaves.copy_multi(
 
1475
                    self.source.control_weaves, ['inventory'],
 
1476
                    from_transaction=self.source.get_transaction(),
 
1477
                    to_transaction=self.target.get_transaction())
 
1478
                self.target._revision_store.text_store.copy_all_ids(
 
1479
                    self.source._revision_store.text_store,
 
1480
                    pb=pb)
 
1481
            finally:
 
1482
                pb.finished()
 
1483
        else:
1465
1484
            self.target.fetch(self.source, revision_id=revision_id)
1466
 
        else:
1467
 
            try:
1468
 
                self.target.set_make_working_trees(self.source.make_working_trees())
1469
 
            except NotImplementedError:
1470
 
                pass
1471
 
            # FIXME do not peek!
1472
 
            if self.source.control_files._transport.listable():
1473
 
                pb = ui.ui_factory.nested_progress_bar()
1474
 
                try:
1475
 
                    self.target.weave_store.copy_all_ids(
1476
 
                        self.source.weave_store,
1477
 
                        pb=pb,
1478
 
                        from_transaction=self.source.get_transaction(),
1479
 
                        to_transaction=self.target.get_transaction())
1480
 
                    pb.update('copying inventory', 0, 1)
1481
 
                    self.target.control_weaves.copy_multi(
1482
 
                        self.source.control_weaves, ['inventory'],
1483
 
                        from_transaction=self.source.get_transaction(),
1484
 
                        to_transaction=self.target.get_transaction())
1485
 
                    self.target._revision_store.text_store.copy_all_ids(
1486
 
                        self.source._revision_store.text_store,
1487
 
                        pb=pb)
1488
 
                finally:
1489
 
                    pb.finished()
1490
 
            else:
1491
 
                self.target.fetch(self.source, revision_id=revision_id)
1492
1485
 
1493
1486
    @needs_write_lock
1494
1487
    def fetch(self, revision_id=None, pb=None):
1640
1633
        return f.count_copied, f.failed_revisions
1641
1634
 
1642
1635
    @needs_write_lock
1643
 
    def copy_content(self, revision_id=None, basis=None):
 
1636
    def copy_content(self, revision_id=None):
1644
1637
        """Make a complete copy of the content in self into destination.
1645
1638
        
1646
1639
        This is a destructive operation! Do not use it on existing 
1648
1641
 
1649
1642
        :param revision_id: Only copy the content needed to construct
1650
1643
                            revision_id and its parents.
1651
 
        :param basis: Copy the needed data preferentially from basis.
1652
1644
        """
1653
1645
        try:
1654
1646
            self.target.set_make_working_trees(self.source.make_working_trees())
1656
1648
            pass
1657
1649
        # TODO: jam 20070210 Internal, assert, don't translate
1658
1650
        revision_id = osutils.safe_revision_id(revision_id)
1659
 
        # grab the basis available data
1660
 
        if basis is not None:
1661
 
            self.target.fetch(basis, revision_id=revision_id)
1662
1651
        # but don't bother fetching if we have the needed data now.
1663
1652
        if (revision_id not in (None, _mod_revision.NULL_REVISION) and 
1664
1653
            self.target.has_revision(revision_id)):