/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

  • Committer: Aaron Bentley
  • Date: 2007-04-02 17:18:11 UTC
  • mfrom: (2392 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2393.
  • Revision ID: abentley@panoramicfeedback.com-20070402171811-bz7y2b2h1m1k4n7x
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
311
311
        control = bzrdir.BzrDir.open(base)
312
312
        return control.open_repository()
313
313
 
314
 
    def copy_content_into(self, destination, revision_id=None, basis=None):
 
314
    def copy_content_into(self, destination, revision_id=None):
315
315
        """Make a complete copy of the content in self into destination.
316
316
        
317
317
        This is a destructive operation! Do not use it on existing 
318
318
        repositories.
319
319
        """
320
320
        revision_id = osutils.safe_revision_id(revision_id)
321
 
        return InterRepository.get(self, destination).copy_content(revision_id, basis)
 
321
        return InterRepository.get(self, destination).copy_content(revision_id)
322
322
 
323
323
    def fetch(self, source, revision_id=None, pb=None):
324
324
        """Fetch the content required to construct revision_id from source.
326
326
        If revision_id is None all content is copied.
327
327
        """
328
328
        revision_id = osutils.safe_revision_id(revision_id)
329
 
        return InterRepository.get(source, self).fetch(revision_id=revision_id,
330
 
                                                       pb=pb)
 
329
        inter = InterRepository.get(source, self)
 
330
        try:
 
331
            return inter.fetch(revision_id=revision_id, pb=pb)
 
332
        except NotImplementedError:
 
333
            raise errors.IncompatibleRepositories(source, self)
331
334
 
332
335
    def get_commit_builder(self, branch, parents, config, timestamp=None, 
333
336
                           timezone=None, committer=None, revprops=None, 
351
354
        self.control_files.unlock()
352
355
 
353
356
    @needs_read_lock
354
 
    def clone(self, a_bzrdir, revision_id=None, basis=None):
 
357
    def clone(self, a_bzrdir, revision_id=None):
355
358
        """Clone this repository into a_bzrdir using the current format.
356
359
 
357
360
        Currently no check is made that the format of this repository and
369
372
                dest_repo = self._format.initialize(a_bzrdir, shared=self.is_shared())
370
373
            except errors.UninitializableFormat:
371
374
                dest_repo = a_bzrdir.open_repository()
372
 
        self.copy_content_into(dest_repo, revision_id, basis)
 
375
        self.copy_content_into(dest_repo, revision_id)
373
376
        return dest_repo
374
377
 
375
378
    @needs_read_lock
1204
1207
    """Common base class for the new repositories using the metadir layout."""
1205
1208
 
1206
1209
    rich_root_data = False
 
1210
    supports_tree_reference = False
1207
1211
    _matchingbzrdir = bzrdir.BzrDirMetaFormat1()
1208
1212
 
1209
1213
    def __init__(self):
1279
1283
    _optimisers = []
1280
1284
    """The available optimised InterRepository types."""
1281
1285
 
1282
 
    def copy_content(self, revision_id=None, basis=None):
 
1286
    def copy_content(self, revision_id=None):
1283
1287
        raise NotImplementedError(self.copy_content)
1284
1288
 
1285
1289
    def fetch(self, revision_id=None, pb=None):
1349
1353
            return True 
1350
1354
 
1351
1355
    @needs_write_lock
1352
 
    def copy_content(self, revision_id=None, basis=None):
 
1356
    def copy_content(self, revision_id=None):
1353
1357
        """Make a complete copy of the content in self into destination.
1354
1358
        
1355
1359
        This is a destructive operation! Do not use it on existing 
1357
1361
 
1358
1362
        :param revision_id: Only copy the content needed to construct
1359
1363
                            revision_id and its parents.
1360
 
        :param basis: Copy the needed data preferentially from basis.
1361
1364
        """
1362
1365
        try:
1363
1366
            self.target.set_make_working_trees(self.source.make_working_trees())
1366
1369
        # TODO: jam 20070210 This is fairly internal, so we should probably
1367
1370
        #       just assert that revision_id is not unicode.
1368
1371
        revision_id = osutils.safe_revision_id(revision_id)
1369
 
        # grab the basis available data
1370
 
        if basis is not None:
1371
 
            self.target.fetch(basis, revision_id=revision_id)
1372
1372
        # but don't bother fetching if we have the needed data now.
1373
1373
        if (revision_id not in (None, _mod_revision.NULL_REVISION) and 
1374
1374
            self.target.has_revision(revision_id)):
1423
1423
            return False
1424
1424
    
1425
1425
    @needs_write_lock
1426
 
    def copy_content(self, revision_id=None, basis=None):
 
1426
    def copy_content(self, revision_id=None):
1427
1427
        """See InterRepository.copy_content()."""
1428
1428
        # weave specific optimised path:
1429
1429
        # TODO: jam 20070210 Internal, should be an assert, not translate
1430
1430
        revision_id = osutils.safe_revision_id(revision_id)
1431
 
        if basis is not None:
1432
 
            # copy the basis in, then fetch remaining data.
1433
 
            basis.copy_content_into(self.target, revision_id)
1434
 
            # the basis copy_content_into could miss-set this.
 
1431
        try:
 
1432
            self.target.set_make_working_trees(self.source.make_working_trees())
 
1433
        except NotImplementedError:
 
1434
            pass
 
1435
        # FIXME do not peek!
 
1436
        if self.source.control_files._transport.listable():
 
1437
            pb = ui.ui_factory.nested_progress_bar()
1435
1438
            try:
1436
 
                self.target.set_make_working_trees(self.source.make_working_trees())
1437
 
            except NotImplementedError:
1438
 
                pass
 
1439
                self.target.weave_store.copy_all_ids(
 
1440
                    self.source.weave_store,
 
1441
                    pb=pb,
 
1442
                    from_transaction=self.source.get_transaction(),
 
1443
                    to_transaction=self.target.get_transaction())
 
1444
                pb.update('copying inventory', 0, 1)
 
1445
                self.target.control_weaves.copy_multi(
 
1446
                    self.source.control_weaves, ['inventory'],
 
1447
                    from_transaction=self.source.get_transaction(),
 
1448
                    to_transaction=self.target.get_transaction())
 
1449
                self.target._revision_store.text_store.copy_all_ids(
 
1450
                    self.source._revision_store.text_store,
 
1451
                    pb=pb)
 
1452
            finally:
 
1453
                pb.finished()
 
1454
        else:
1439
1455
            self.target.fetch(self.source, revision_id=revision_id)
1440
 
        else:
1441
 
            try:
1442
 
                self.target.set_make_working_trees(self.source.make_working_trees())
1443
 
            except NotImplementedError:
1444
 
                pass
1445
 
            # FIXME do not peek!
1446
 
            if self.source.control_files._transport.listable():
1447
 
                pb = ui.ui_factory.nested_progress_bar()
1448
 
                try:
1449
 
                    self.target.weave_store.copy_all_ids(
1450
 
                        self.source.weave_store,
1451
 
                        pb=pb,
1452
 
                        from_transaction=self.source.get_transaction(),
1453
 
                        to_transaction=self.target.get_transaction())
1454
 
                    pb.update('copying inventory', 0, 1)
1455
 
                    self.target.control_weaves.copy_multi(
1456
 
                        self.source.control_weaves, ['inventory'],
1457
 
                        from_transaction=self.source.get_transaction(),
1458
 
                        to_transaction=self.target.get_transaction())
1459
 
                    self.target._revision_store.text_store.copy_all_ids(
1460
 
                        self.source._revision_store.text_store,
1461
 
                        pb=pb)
1462
 
                finally:
1463
 
                    pb.finished()
1464
 
            else:
1465
 
                self.target.fetch(self.source, revision_id=revision_id)
1466
1456
 
1467
1457
    @needs_write_lock
1468
1458
    def fetch(self, revision_id=None, pb=None):
1618
1608
        return f.count_copied, f.failed_revisions
1619
1609
 
1620
1610
    @needs_write_lock
1621
 
    def copy_content(self, revision_id=None, basis=None):
 
1611
    def copy_content(self, revision_id=None):
1622
1612
        """Make a complete copy of the content in self into destination.
1623
1613
        
1624
1614
        This is a destructive operation! Do not use it on existing 
1626
1616
 
1627
1617
        :param revision_id: Only copy the content needed to construct
1628
1618
                            revision_id and its parents.
1629
 
        :param basis: Copy the needed data preferentially from basis.
1630
1619
        """
1631
1620
        try:
1632
1621
            self.target.set_make_working_trees(self.source.make_working_trees())
1634
1623
            pass
1635
1624
        # TODO: jam 20070210 Internal, assert, don't translate
1636
1625
        revision_id = osutils.safe_revision_id(revision_id)
1637
 
        # grab the basis available data
1638
 
        if basis is not None:
1639
 
            self.target.fetch(basis, revision_id=revision_id)
1640
1626
        # but don't bother fetching if we have the needed data now.
1641
1627
        if (revision_id not in (None, _mod_revision.NULL_REVISION) and 
1642
1628
            self.target.has_revision(revision_id)):