~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 04:32:32 UTC
  • mfrom: (1185.12.6)
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051004043231-40302a149769263b
merged my own changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    parent_ids
33
33
        List of parent revision_ids
34
34
    """
35
 
    inventory_id = None
36
 
    inventory_sha1 = None
37
 
    revision_id = None
38
 
    timestamp = None
39
 
    message = None
40
 
    timezone = None
41
 
    committer = None
42
35
    
43
 
    def __init__(self, **args):
 
36
    def __init__(self, revision_id, **args):
 
37
        self.revision_id = revision_id
44
38
        self.__dict__.update(args)
45
39
        self.parent_ids = []
46
40
        self.parent_sha1s = []
47
41
 
48
 
 
49
42
    def __repr__(self):
50
43
        return "<Revision id %s>" % self.revision_id
51
44
 
52
45
    def __eq__(self, other):
53
46
        if not isinstance(other, Revision):
54
47
            return False
55
 
        return (self.inventory_id == other.inventory_id
56
 
                and self.inventory_sha1 == other.inventory_sha1
 
48
        # FIXME: rbc 20050930 parent_ids are not being compared
 
49
        return (
 
50
                self.inventory_sha1 == other.inventory_sha1
57
51
                and self.revision_id == other.revision_id
58
52
                and self.timestamp == other.timestamp
59
53
                and self.message == other.message
64
58
        return not self.__eq__(other)
65
59
 
66
60
        
67
 
 
68
61
REVISION_ID_RE = None
69
62
 
70
63
def validate_revision_id(rid):
72
65
    global REVISION_ID_RE
73
66
    if not REVISION_ID_RE:
74
67
        import re
75
 
        REVISION_ID_RE = re.compile('[\w.-]+@[\w.-]+--?\d+--?[0-9a-f]+\Z')
 
68
        REVISION_ID_RE = re.compile('[\w:.-]+@[\w%.-]+--?[\w]+--?[0-9a-f]+\Z')
76
69
 
77
70
    if not REVISION_ID_RE.match(rid):
78
71
        raise ValueError("malformed revision-id %r" % rid)
211
204
    assert root not in ancestors[root]
212
205
    return root, ancestors, descendants
213
206
 
 
207
 
214
208
def combined_graph(revision_a, revision_b, revision_source):
215
209
    """Produce a combined ancestry graph.
216
210
    Return graph root, ancestors map, descendants map, set of common nodes"""
232
226
        descendants[node].update(node_dec)
233
227
    return root, ancestors, descendants, common
234
228
 
 
229
 
235
230
def common_ancestor(revision_a, revision_b, revision_source):
236
231
    try:
237
232
        root, ancestors, descendants, common = \
245
240
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
246
241
    return farthest
247
242
 
 
243
 
248
244
class MultipleRevisionSources(object):
249
245
    """Proxy that looks in multiple branches for revisions."""
250
246
    def __init__(self, *args):