~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2005-10-30 18:39:32 UTC
  • mto: (1185.33.1)
  • mto: This revision was merged to the branch mainline in revision 1509.
  • Revision ID: jelmer@samba.org-20051030183932-9188295b602ce28c
Move some more generic methods from NativeBranch to Branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
        The delta is relative to its mainline predecessor, or the
310
310
        empty tree for revision 1.
311
311
        """
312
 
        raise NotImplementedError('get_revision_delta is abstract')
 
312
        assert isinstance(revno, int)
 
313
        rh = self.revision_history()
 
314
        if not (1 <= revno <= len(rh)):
 
315
            raise InvalidRevisionNumber(revno)
 
316
 
 
317
        # revno is 1-based; list is 0-based
 
318
 
 
319
        new_tree = self.revision_tree(rh[revno-1])
 
320
        if revno == 1:
 
321
            old_tree = EmptyTree()
 
322
        else:
 
323
            old_tree = self.revision_tree(rh[revno-2])
 
324
 
 
325
        return compare_trees(old_tree, new_tree)
313
326
 
314
327
    def get_revision_sha1(self, revision_id):
315
328
        """Hash the stored value of a revision, and return it."""
323
336
        """
324
337
        raise NotImplementedError('get_ancestry is abstract')
325
338
 
326
 
    def get_inventory_weave(self):
327
 
        raise NotImplementedError('get_inventory_weave is abstract')
328
 
 
329
339
    def get_inventory(self, revision_id):
330
340
        """Get Inventory object by hash."""
331
341
        raise NotImplementedError('get_inventory is abstract')
1056
1066
        assert r.revision_id == revision_id
1057
1067
        return r
1058
1068
 
1059
 
    def get_revision_delta(self, revno):
1060
 
        """See Branch.get_revision_delta."""
1061
 
        assert isinstance(revno, int)
1062
 
        rh = self.revision_history()
1063
 
        if not (1 <= revno <= len(rh)):
1064
 
            raise InvalidRevisionNumber(revno)
1065
 
 
1066
 
        # revno is 1-based; list is 0-based
1067
 
 
1068
 
        new_tree = self.revision_tree(rh[revno-1])
1069
 
        if revno == 1:
1070
 
            old_tree = EmptyTree()
1071
 
        else:
1072
 
            old_tree = self.revision_tree(rh[revno-2])
1073
 
 
1074
 
        return compare_trees(old_tree, new_tree)
1075
 
 
1076
1069
    def get_revision_sha1(self, revision_id):
1077
1070
        """See Branch.get_revision_sha1."""
1078
1071
        # In the future, revision entries will be signed. At that
1087
1080
        """See Branch.get_ancestry."""
1088
1081
        if revision_id is None:
1089
1082
            return [None]
1090
 
        w = self.get_inventory_weave()
 
1083
        w = self._get_inventory_weave()
1091
1084
        return [None] + map(w.idx_to_name,
1092
1085
                            w.inclusions([w.lookup(revision_id)]))
1093
1086
 
1094
 
    def get_inventory_weave(self):
1095
 
        """See Branch.get_inventory_weave."""
 
1087
    def _get_inventory_weave(self):
1096
1088
        return self.control_weaves.get_weave('inventory',
1097
1089
                                             self.get_transaction())
1098
1090
 
1105
1097
        """See Branch.get_inventory_xml."""
1106
1098
        try:
1107
1099
            assert isinstance(revision_id, basestring), type(revision_id)
1108
 
            iw = self.get_inventory_weave()
 
1100
            iw = self._get_inventory_weave()
1109
1101
            return iw.get_text(iw.lookup(revision_id))
1110
1102
        except IndexError:
1111
1103
            raise bzrlib.errors.HistoryMissing(self, 'inventory', revision_id)