~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Martin Pool
  • Date: 2005-09-19 07:52:30 UTC
  • Revision ID: mbp@sourcefrog.net-20050919075230-bd8a133ef1671044
- remove RevisionReference; just hold parent ids directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import bzrlib.errors
19
19
 
20
20
 
21
 
class RevisionReference(object):
22
 
    """
23
 
    Reference to a stored revision.
24
 
 
25
 
    Includes the revision_id and revision_sha1.
26
 
    """
27
 
    revision_id = None
28
 
    revision_sha1 = None
29
 
    def __init__(self, revision_id, revision_sha1=None):
30
 
        if revision_id == None \
31
 
           or isinstance(revision_id, basestring):
32
 
            self.revision_id = revision_id
33
 
        else:
34
 
            raise ValueError('bad revision_id %r' % revision_id)
35
 
 
36
 
        if revision_sha1 != None:
37
 
            if isinstance(revision_sha1, basestring) \
38
 
               and len(revision_sha1) == 40:
39
 
                self.revision_sha1 = revision_sha1
40
 
            else:
41
 
                raise ValueError('bad revision_sha1 %r' % revision_sha1)
42
 
                
43
 
 
44
 
 
45
21
class Revision(object):
46
22
    """Single revision on a branch.
47
23
 
65
41
    def __init__(self, **args):
66
42
        self.__dict__.update(args)
67
43
        self.parents = []
 
44
        self.parent_sha1s = []
68
45
 
69
46
 
70
47
    def __repr__(self):
128
105
                    continue
129
106
            if only_present:
130
107
                yield ancestor, distance
131
 
            new_ancestors.extend([p.revision_id for p in revision.parents])
 
108
            new_ancestors.extend(revision.parents)
132
109
        ancestors = new_ancestors
133
110
        distance += 1
134
111
 
234
211
    while len(active) > 0:
235
212
        new_active = []
236
213
        for line in active:
237
 
            parent_ids = [p.revision_id for p in 
238
 
                          rev_source.get_revision(line[-1]).parents]
239
 
            for parent in parent_ids:
 
214
            for parent in rev_source.get_revision(line[-1]).parents:
240
215
                line_copy = line[:]
241
216
                if parent == ancestor_id:
242
217
                    successful_lines.append(line_copy)