~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Ian Clatworthy
  • Date: 2010-03-30 20:13:52 UTC
  • mto: This revision was merged to the branch mainline in revision 5125.
  • Revision ID: ian.clatworthy@canonical.com-20100330201352-vw2gtujybyg3rvwc
whitespace fix in win32 installer

Show diffs side-by-side

added added

removed removed

Lines of Context:
1027
1027
 
1028
1028
        :seealso: add_inventory, for the contract.
1029
1029
        """
1030
 
        inv_lines = self._serialise_inventory_to_lines(inv)
 
1030
        inv_lines = self._serializer.write_inventory_to_lines(inv)
1031
1031
        return self._inventory_add_lines(revision_id, parents,
1032
1032
            inv_lines, check_content=False)
1033
1033
 
1895
1895
                rev = self._serializer.read_revision_from_string(text)
1896
1896
                yield (revid, rev)
1897
1897
 
1898
 
    @needs_read_lock
1899
 
    def get_revision_xml(self, revision_id):
1900
 
        # TODO: jam 20070210 This shouldn't be necessary since get_revision
1901
 
        #       would have already do it.
1902
 
        # TODO: jam 20070210 Just use _serializer.write_revision_to_string()
1903
 
        # TODO: this can't just be replaced by:
1904
 
        # return self._serializer.write_revision_to_string(
1905
 
        #     self.get_revision(revision_id))
1906
 
        # as cStringIO preservers the encoding unlike write_revision_to_string
1907
 
        # or some other call down the path.
1908
 
        rev = self.get_revision(revision_id)
1909
 
        rev_tmp = cStringIO.StringIO()
1910
 
        # the current serializer..
1911
 
        self._serializer.write_revision(rev, rev_tmp)
1912
 
        rev_tmp.seek(0)
1913
 
        return rev_tmp.getvalue()
1914
 
 
1915
1898
    def get_deltas_for_revisions(self, revisions, specific_fileids=None):
1916
1899
        """Produce a generator of revision deltas.
1917
1900
 
2430
2413
                result.revision_id, revision_id))
2431
2414
        return result
2432
2415
 
2433
 
    def _serialise_inventory(self, inv):
2434
 
        return self._serializer.write_inventory_to_string(inv)
2435
 
 
2436
 
    def _serialise_inventory_to_lines(self, inv):
2437
 
        return self._serializer.write_inventory_to_lines(inv)
2438
 
 
2439
2416
    def get_serializer_format(self):
2440
2417
        return self._serializer.format_num
2441
2418
 
2505
2482
            else:
2506
2483
                next_id = parents[0]
2507
2484
 
2508
 
    @needs_read_lock
2509
 
    def get_revision_inventory(self, revision_id):
2510
 
        """Return inventory of a past revision."""
2511
 
        # TODO: Unify this with get_inventory()
2512
 
        # bzr 0.0.6 and later imposes the constraint that the inventory_id
2513
 
        # must be the same as its revision, so this is trivial.
2514
 
        if revision_id is None:
2515
 
            # This does not make sense: if there is no revision,
2516
 
            # then it is the current tree inventory surely ?!
2517
 
            # and thus get_root_id() is something that looks at the last
2518
 
            # commit on the branch, and the get_root_id is an inventory check.
2519
 
            raise NotImplementedError
2520
 
            # return Inventory(self.get_root_id())
2521
 
        else:
2522
 
            return self.get_inventory(revision_id)
2523
 
 
2524
2485
    def is_shared(self):
2525
2486
        """Return True if this repository is flagged as a shared repository."""
2526
2487
        raise NotImplementedError(self.is_shared)
2560
2521
            return RevisionTree(self, Inventory(root_id=None),
2561
2522
                                _mod_revision.NULL_REVISION)
2562
2523
        else:
2563
 
            inv = self.get_revision_inventory(revision_id)
 
2524
            inv = self.get_inventory(revision_id)
2564
2525
            return RevisionTree(self, inv, revision_id)
2565
2526
 
2566
2527
    def revision_trees(self, revision_ids):
3072
3033
    # Is the format experimental ?
3073
3034
    experimental = False
3074
3035
 
3075
 
    def __str__(self):
3076
 
        return "<%s>" % self.__class__.__name__
 
3036
    def __repr__(self):
 
3037
        return "%s()" % self.__class__.__name__
3077
3038
 
3078
3039
    def __eq__(self, other):
3079
3040
        # format objects are generally stateless
3411
3372
        :return: None.
3412
3373
        """
3413
3374
        ui.ui_factory.warn_experimental_format_fetch(self)
3414
 
        f = _mod_fetch.RepoFetcher(to_repository=self.target,
 
3375
        from bzrlib.fetch import RepoFetcher
 
3376
        # See <https://launchpad.net/bugs/456077> asking for a warning here
 
3377
        if self.source._format.network_name() != self.target._format.network_name():
 
3378
            ui.ui_factory.show_user_warning('cross_format_fetch',
 
3379
                from_format=self.source._format,
 
3380
                to_format=self.target._format)
 
3381
        f = RepoFetcher(to_repository=self.target,
3415
3382
                               from_repository=self.source,
3416
3383
                               last_revision=revision_id,
3417
3384
                               fetch_spec=fetch_spec,
3995
3962
        """See InterRepository.fetch()."""
3996
3963
        if fetch_spec is not None:
3997
3964
            raise AssertionError("Not implemented yet...")
3998
 
        # See <https://launchpad.net/bugs/456077> asking for a warning here
3999
 
        #
4000
 
        # nb this is only active for local-local fetches; other things using
4001
 
        # streaming.
4002
 
        ui.ui_factory.warn_cross_format_fetch(self.source._format,
4003
 
            self.target._format)
4004
3965
        ui.ui_factory.warn_experimental_format_fetch(self)
4005
3966
        if (not self.source.supports_rich_root()
4006
3967
            and self.target.supports_rich_root()):
4008
3969
            self._revision_id_to_root_id = {}
4009
3970
        else:
4010
3971
            self._converting_to_rich_root = False
 
3972
        # See <https://launchpad.net/bugs/456077> asking for a warning here
 
3973
        if self.source._format.network_name() != self.target._format.network_name():
 
3974
            ui.ui_factory.show_user_warning('cross_format_fetch',
 
3975
                from_format=self.source._format,
 
3976
                to_format=self.target._format)
4011
3977
        revision_ids = self.target.search_missing_revision_ids(self.source,
4012
3978
            revision_id, find_ghosts=find_ghosts).get_keys()
4013
3979
        if not revision_ids:
4296
4262
                    self._extract_and_insert_inventories(
4297
4263
                        substream, src_serializer)
4298
4264
            elif substream_type == 'inventory-deltas':
4299
 
                ui.ui_factory.warn_cross_format_fetch(src_format,
4300
 
                    self.target_repo._format)
4301
4265
                self._extract_and_insert_inventory_deltas(
4302
4266
                    substream, src_serializer)
4303
4267
            elif substream_type == 'chk_bytes':