/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: Martin Pool
  • Date: 2007-09-25 08:14:12 UTC
  • mto: This revision was merged to the branch mainline in revision 2895.
  • Revision ID: mbp@sourcefrog.net-20070925081412-ta60zj5qxfuokev3
Remove most calls to safe_file_id and safe_revision_id.

The deprecation period for passing unicode objects as revision ids is now over.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
            self._committer = committer
97
97
 
98
98
        self.new_inventory = Inventory(None)
99
 
        self._new_revision_id = osutils.safe_revision_id(revision_id)
 
99
        self._new_revision_id = revision_id
100
100
        self.parents = parents
101
101
        self.repository = repository
102
102
 
395
395
 
396
396
        returns the sha1 of the serialized inventory.
397
397
        """
398
 
        revision_id = osutils.safe_revision_id(revision_id)
399
398
        _mod_revision.check_not_reserved_id(revision_id)
400
399
        assert inv.revision_id is None or inv.revision_id == revision_id, \
401
400
            "Mismatch between inventory revision" \
428
427
                       If supplied its signature_needed method will be used
429
428
                       to determine if a signature should be made.
430
429
        """
431
 
        revision_id = osutils.safe_revision_id(revision_id)
432
430
        # TODO: jam 20070210 Shouldn't we check rev.revision_id and
433
431
        #       rev.parent_ids?
434
432
        _mod_revision.check_not_reserved_id(revision_id)
659
657
 
660
658
        revision_id: only return revision ids included by revision_id.
661
659
        """
662
 
        revision_id = osutils.safe_revision_id(revision_id)
663
660
        return InterRepository.get(other, self).missing_revision_ids(revision_id)
664
661
 
665
662
    @staticmethod
678
675
        This is a destructive operation! Do not use it on existing 
679
676
        repositories.
680
677
        """
681
 
        revision_id = osutils.safe_revision_id(revision_id)
682
678
        return InterRepository.get(self, destination).copy_content(revision_id)
683
679
 
684
680
    def commit_write_group(self):
706
702
 
707
703
        If revision_id is None all content is copied.
708
704
        """
709
 
        revision_id = osutils.safe_revision_id(revision_id)
710
705
        inter = InterRepository.get(source, self)
711
706
        try:
712
707
            return inter.fetch(revision_id=revision_id, pb=pb)
730
725
        :param revprops: Optional dictionary of revision properties.
731
726
        :param revision_id: Optional revision id.
732
727
        """
733
 
        revision_id = osutils.safe_revision_id(revision_id)
734
728
        result = self._commit_builder_class(self, parents, config,
735
729
            timestamp, timezone, committer, revprops, revision_id)
736
730
        self.start_write_group()
816
810
        """True if this repository has a copy of the revision."""
817
811
        if 'evil' in debug.debug_flags:
818
812
            mutter_callsite(2, "has_revision is a LBYL symptom.")
819
 
        revision_id = osutils.safe_revision_id(revision_id)
820
813
        return self._revision_store.has_revision_id(revision_id,
821
814
                                                    self.get_transaction())
822
815
 
844
837
    @needs_read_lock
845
838
    def _get_revisions(self, revision_ids):
846
839
        """Core work logic to get many revisions without sanity checks."""
847
 
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
848
840
        for rev_id in revision_ids:
849
841
            if not rev_id or not isinstance(rev_id, basestring):
850
842
                raise errors.InvalidRevisionId(revision_id=rev_id, branch=self)
861
853
        # TODO: jam 20070210 This shouldn't be necessary since get_revision
862
854
        #       would have already do it.
863
855
        # TODO: jam 20070210 Just use _serializer.write_revision_to_string()
864
 
        revision_id = osutils.safe_revision_id(revision_id)
865
856
        rev = self.get_revision(revision_id)
866
857
        rev_tmp = StringIO()
867
858
        # the current serializer..
902
893
 
903
894
    @needs_write_lock
904
895
    def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
905
 
        revision_id = osutils.safe_revision_id(revision_id)
906
896
        signature = gpg_strategy.sign(plaintext)
907
897
        self._revision_store.add_revision_signature_text(revision_id,
908
898
                                                         signature,
919
909
        assert self._serializer.support_altered_by_hack, \
920
910
            ("fileids_altered_by_revision_ids only supported for branches " 
921
911
             "which store inventory as unnested xml, not on %r" % self)
922
 
        selected_revision_ids = set(osutils.safe_revision_id(r)
923
 
                                    for r in revision_ids)
 
912
        selected_revision_ids = set(revision_ids)
924
913
        w = self.get_inventory_weave()
925
914
        result = {}
926
915
 
1070
1059
        """Get Inventory object by hash."""
1071
1060
        # TODO: jam 20070210 Technically we don't need to sanitize, since all
1072
1061
        #       called functions must sanitize.
1073
 
        revision_id = osutils.safe_revision_id(revision_id)
1074
1062
        return self.deserialise_inventory(
1075
1063
            revision_id, self.get_inventory_xml(revision_id))
1076
1064
 
1080
1068
        :param revision_id: The expected revision id of the inventory.
1081
1069
        :param xml: A serialised inventory.
1082
1070
        """
1083
 
        revision_id = osutils.safe_revision_id(revision_id)
1084
1071
        result = self._serializer.read_inventory_from_string(xml)
1085
1072
        result.root.revision = revision_id
1086
1073
        return result
1097
1084
    @needs_read_lock
1098
1085
    def get_inventory_xml(self, revision_id):
1099
1086
        """Get inventory XML as a file object."""
1100
 
        revision_id = osutils.safe_revision_id(revision_id)
1101
1087
        try:
1102
1088
            assert isinstance(revision_id, str), type(revision_id)
1103
1089
            iw = self.get_inventory_weave()
1110
1096
        """Return the sha1 hash of the inventory entry
1111
1097
        """
1112
1098
        # TODO: jam 20070210 Shouldn't this be deprecated / removed?
1113
 
        revision_id = osutils.safe_revision_id(revision_id)
1114
1099
        return self.get_revision(revision_id).inventory_sha1
1115
1100
 
1116
1101
    @needs_read_lock
1142
1127
            pending = set(self.all_revision_ids())
1143
1128
            required = set([])
1144
1129
        else:
1145
 
            pending = set(osutils.safe_revision_id(r) for r in revision_ids)
 
1130
            pending = set(revision_ids)
1146
1131
            # special case NULL_REVISION
1147
1132
            if _mod_revision.NULL_REVISION in pending:
1148
1133
                pending.remove(_mod_revision.NULL_REVISION)
1181
1166
        :param revision_id: The revision id to start with.  All its lefthand
1182
1167
            ancestors will be traversed.
1183
1168
        """
1184
 
        revision_id = osutils.safe_revision_id(revision_id)
1185
1169
        if revision_id in (None, _mod_revision.NULL_REVISION):
1186
1170
            return
1187
1171
        next_id = revision_id
1245
1229
            return RevisionTree(self, Inventory(root_id=None), 
1246
1230
                                _mod_revision.NULL_REVISION)
1247
1231
        else:
1248
 
            revision_id = osutils.safe_revision_id(revision_id)
1249
1232
            inv = self.get_revision_inventory(revision_id)
1250
1233
            return RevisionTree(self, inv, revision_id)
1251
1234
 
1273
1256
        """
1274
1257
        if _mod_revision.is_null(revision_id):
1275
1258
            return [None]
1276
 
        revision_id = osutils.safe_revision_id(revision_id)
1277
1259
        if not self.has_revision(revision_id):
1278
1260
            raise errors.NoSuchRevision(self, revision_id)
1279
1261
        w = self.get_inventory_weave()
1299
1281
        - it writes to stdout, it assumes that that is valid etc. Fix
1300
1282
        by creating a new more flexible convenience function.
1301
1283
        """
1302
 
        revision_id = osutils.safe_revision_id(revision_id)
1303
1284
        tree = self.revision_tree(revision_id)
1304
1285
        # use inventory as it was in that revision
1305
1286
        file_id = tree.inventory.path2id(file)
1314
1295
        return self.control_files.get_transaction()
1315
1296
 
1316
1297
    def revision_parents(self, revision_id):
1317
 
        revision_id = osutils.safe_revision_id(revision_id)
1318
1298
        return self.get_inventory_weave().parent_names(revision_id)
1319
1299
 
1320
1300
    def get_parents(self, revision_ids):
1365
1345
 
1366
1346
    @needs_write_lock
1367
1347
    def sign_revision(self, revision_id, gpg_strategy):
1368
 
        revision_id = osutils.safe_revision_id(revision_id)
1369
1348
        plaintext = Testament.from_revision(self, revision_id).as_short_text()
1370
1349
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1371
1350
 
1372
1351
    @needs_read_lock
1373
1352
    def has_signature_for_revision_id(self, revision_id):
1374
1353
        """Query for a revision signature for revision_id in the repository."""
1375
 
        revision_id = osutils.safe_revision_id(revision_id)
1376
1354
        return self._revision_store.has_signature(revision_id,
1377
1355
                                                  self.get_transaction())
1378
1356
 
1379
1357
    @needs_read_lock
1380
1358
    def get_signature_text(self, revision_id):
1381
1359
        """Return the text for a signature."""
1382
 
        revision_id = osutils.safe_revision_id(revision_id)
1383
1360
        return self._revision_store.get_signature_text(revision_id,
1384
1361
                                                       self.get_transaction())
1385
1362
 
1395
1372
        if not revision_ids:
1396
1373
            raise ValueError("revision_ids must be non-empty in %s.check" 
1397
1374
                    % (self,))
1398
 
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
1399
1375
        return self._check(revision_ids)
1400
1376
 
1401
1377
    def _check(self, revision_ids):
1851
1827
        if revision_id is not None:
1852
1828
            # TODO: jam 20070210 InterRepository is internal enough that it
1853
1829
            #       should assume revision_ids are already utf-8
1854
 
            revision_id = osutils.safe_revision_id(revision_id)
1855
1830
            source_ids = self.source.get_ancestry(revision_id)
1856
1831
            assert source_ids[0] is None
1857
1832
            source_ids.pop(0)
1905
1880
            self.target.set_make_working_trees(self.source.make_working_trees())
1906
1881
        except NotImplementedError:
1907
1882
            pass
1908
 
        # TODO: jam 20070210 This is fairly internal, so we should probably
1909
 
        #       just assert that revision_id is not unicode.
1910
 
        revision_id = osutils.safe_revision_id(revision_id)
1911
1883
        # but don't bother fetching if we have the needed data now.
1912
1884
        if (revision_id not in (None, _mod_revision.NULL_REVISION) and 
1913
1885
            self.target.has_revision(revision_id)):
1919
1891
        """See InterRepository.fetch()."""
1920
1892
        from bzrlib.fetch import GenericRepoFetcher
1921
1893
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
1922
 
               self.source, self.source._format, self.target, 
 
1894
               self.source, self.source._format, self.target,
1923
1895
               self.target._format)
1924
 
        # TODO: jam 20070210 This should be an assert, not a translate
1925
 
        revision_id = osutils.safe_revision_id(revision_id)
1926
1896
        f = GenericRepoFetcher(to_repository=self.target,
1927
1897
                               from_repository=self.source,
1928
1898
                               last_revision=revision_id,
1969
1939
    def copy_content(self, revision_id=None):
1970
1940
        """See InterRepository.copy_content()."""
1971
1941
        # weave specific optimised path:
1972
 
        # TODO: jam 20070210 Internal, should be an assert, not translate
1973
 
        revision_id = osutils.safe_revision_id(revision_id)
1974
1942
        try:
1975
1943
            self.target.set_make_working_trees(self.source.make_working_trees())
1976
1944
        except NotImplementedError:
2003
1971
        from bzrlib.fetch import GenericRepoFetcher
2004
1972
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
2005
1973
               self.source, self.source._format, self.target, self.target._format)
2006
 
        # TODO: jam 20070210 This should be an assert, not a translate
2007
 
        revision_id = osutils.safe_revision_id(revision_id)
2008
1974
        f = GenericRepoFetcher(to_repository=self.target,
2009
1975
                               from_repository=self.source,
2010
1976
                               last_revision=revision_id,
2082
2048
        from bzrlib.fetch import KnitRepoFetcher
2083
2049
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
2084
2050
               self.source, self.source._format, self.target, self.target._format)
2085
 
        # TODO: jam 20070210 This should be an assert, not a translate
2086
 
        revision_id = osutils.safe_revision_id(revision_id)
2087
2051
        f = KnitRepoFetcher(to_repository=self.target,
2088
2052
                            from_repository=self.source,
2089
2053
                            last_revision=revision_id,
2138
2102
    def fetch(self, revision_id=None, pb=None):
2139
2103
        """See InterRepository.fetch()."""
2140
2104
        from bzrlib.fetch import Model1toKnit2Fetcher
2141
 
        # TODO: jam 20070210 This should be an assert, not a translate
2142
 
        revision_id = osutils.safe_revision_id(revision_id)
2143
2105
        f = Model1toKnit2Fetcher(to_repository=self.target,
2144
2106
                                 from_repository=self.source,
2145
2107
                                 last_revision=revision_id,
2160
2122
            self.target.set_make_working_trees(self.source.make_working_trees())
2161
2123
        except NotImplementedError:
2162
2124
            pass
2163
 
        # TODO: jam 20070210 Internal, assert, don't translate
2164
 
        revision_id = osutils.safe_revision_id(revision_id)
2165
2125
        # but don't bother fetching if we have the needed data now.
2166
2126
        if (revision_id not in (None, _mod_revision.NULL_REVISION) and 
2167
2127
            self.target.has_revision(revision_id)):
2194
2154
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
2195
2155
               self.source, self.source._format, self.target, 
2196
2156
               self.target._format)
2197
 
        # TODO: jam 20070210 This should be an assert, not a translate
2198
 
        revision_id = osutils.safe_revision_id(revision_id)
2199
2157
        f = Knit1to2Fetcher(to_repository=self.target,
2200
2158
                            from_repository=self.source,
2201
2159
                            last_revision=revision_id,