~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-26 21:11:03 UTC
  • mfrom: (2447.1.7 bundle_empty_properties)
  • Revision ID: pqm@pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
(John Arbash Meinel) Fix bug #109613 by teaching Bundle how to properly read/write revision properties with no value.

Show diffs side-by-side

added added

removed removed

Lines of Context:
939
939
        except KeyError:
940
940
            raise RevisionNotPresent(version_id, self.filename)
941
941
 
942
 
    def get_ancestry(self, versions, topo_sorted=True):
 
942
    def get_ancestry(self, versions):
943
943
        """See VersionedFile.get_ancestry."""
944
944
        if isinstance(versions, basestring):
945
945
            versions = [versions]
946
946
        if not versions:
947
947
            return []
948
948
        versions = [osutils.safe_revision_id(v) for v in versions]
949
 
        return self._index.get_ancestry(versions, topo_sorted)
 
949
        return self._index.get_ancestry(versions)
950
950
 
951
951
    def get_ancestry_with_ghosts(self, versions):
952
952
        """See VersionedFile.get_ancestry_with_ghosts."""
967
967
        from bzrlib.weave import Weave
968
968
 
969
969
        w = Weave(self.filename)
970
 
        ancestry = set(self.get_ancestry(version_ids, topo_sorted=False))
 
970
        ancestry = self.get_ancestry(version_ids)
971
971
        sorted_graph = topo_sort(self._index.get_graph())
972
972
        version_list = [vid for vid in sorted_graph if vid in ancestry]
973
973
        
982
982
        """See VersionedFile.plan_merge."""
983
983
        ver_a = osutils.safe_revision_id(ver_a)
984
984
        ver_b = osutils.safe_revision_id(ver_b)
985
 
        ancestors_b = set(self.get_ancestry(ver_b, topo_sorted=False))
 
985
        ancestors_b = set(self.get_ancestry(ver_b))
986
986
        def status_a(revision, text):
987
987
            if revision in ancestors_b:
988
988
                return 'killed-b', text
989
989
            else:
990
990
                return 'new-a', text
991
991
        
992
 
        ancestors_a = set(self.get_ancestry(ver_a, topo_sorted=False))
 
992
        ancestors_a = set(self.get_ancestry(ver_a))
993
993
        def status_b(revision, text):
994
994
            if revision in ancestors_a:
995
995
                return 'killed-a', text
1185
1185
                # or a different failure, and raise. RBC 20060407
1186
1186
                continue
1187
1187
 
1188
 
            try:
1189
 
                parents = []
1190
 
                for value in rec[4:-1]:
1191
 
                    if value[0] == '.':
1192
 
                        # uncompressed reference
1193
 
                        parent_id = value[1:]
1194
 
                    else:
1195
 
                        parent_id = history[int(value)]
1196
 
                    parents.append(parent_id)
1197
 
            except (IndexError, ValueError), e:
1198
 
                # The parent could not be decoded to get its parent row. This
1199
 
                # at a minimum will cause this row to have wrong parents, or
1200
 
                # even to apply a delta to the wrong base and decode
1201
 
                # incorrectly. its therefore not usable, and because we have
1202
 
                # encountered a situation where a new knit index had this
1203
 
                # corrupt we can't asssume that no other rows referring to the
1204
 
                # index of this record actually mean the subsequent uncorrupt
1205
 
                # one, so we error.
1206
 
                raise errors.KnitCorrupt(self._filename,
1207
 
                    "line %r: %s" % (rec, e))
 
1188
            parents = []
 
1189
            for value in rec[4:-1]:
 
1190
                if value[0] == '.':
 
1191
                    # uncompressed reference
 
1192
                    parent_id = value[1:]
 
1193
                else:
 
1194
                    parent_id = history[int(value)]
 
1195
                parents.append(parent_id)
1208
1196
 
1209
1197
            version_id, options, pos, size = rec[:4]
1210
1198
            version_id = version_id
1229
1217
    def get_graph(self):
1230
1218
        return [(vid, idx[4]) for vid, idx in self._cache.iteritems()]
1231
1219
 
1232
 
    def get_ancestry(self, versions, topo_sorted=True):
 
1220
    def get_ancestry(self, versions):
1233
1221
        """See VersionedFile.get_ancestry."""
1234
1222
        # get a graph of all the mentioned versions:
1235
1223
        graph = {}
1245
1233
            # if not completed and not a ghost
1246
1234
            pending.update([p for p in parents if p not in graph])
1247
1235
            graph[version] = parents
1248
 
        if not topo_sorted:
1249
 
            return graph.keys()
1250
1236
        return topo_sort(graph.items())
1251
1237
 
1252
1238
    def get_ancestry_with_ghosts(self, versions):