~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Robert Collins
  • Date: 2005-09-12 12:42:30 UTC
  • mfrom: (1092.2.9)
  • mto: (1092.2.15)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050912124229-abcadea71750e4ab
revision eq operators

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
    Includes the revision_id and revision_sha1.
26
26
    """
27
 
    revision_id = None
28
 
    revision_sha1 = None
 
27
 
 
28
    def __eq__(self, other):
 
29
        try:
 
30
            return self.revision_id == other.revision_id and \
 
31
                   self.revision_sha1 == other.revision_sha1
 
32
        except AttributeError:
 
33
            return False
 
34
 
29
35
    def __init__(self, revision_id, revision_sha1=None):
 
36
        self.revision_id = None
 
37
        self.revision_sha1 = None
30
38
        if revision_id == None \
31
39
           or isinstance(revision_id, basestring):
32
40
            self.revision_id = revision_id
54
62
    parents
55
63
        List of parent revisions, each is a RevisionReference.
56
64
    """
57
 
    inventory_id = None
58
 
    inventory_sha1 = None
59
 
    revision_id = None
60
 
    timestamp = None
61
 
    message = None
62
 
    timezone = None
63
 
    committer = None
64
65
    
65
 
    def __init__(self, **args):
66
 
        self.__dict__.update(args)
67
 
        self.parents = []
 
66
    def __init__(self, inventory_id=None, inventory_sha1=None, 
 
67
                       revision_id=None, timestamp=None,
 
68
                       message=None, timezone=None,
 
69
                       committer=None, parents=None):
 
70
        self.inventory_id = inventory_id
 
71
        self.inventory_sha1 = inventory_sha1
 
72
        self.revision_id = revision_id
 
73
        self.timestamp = timestamp
 
74
        self.message = message
 
75
        self.timezone = timezone
 
76
        self.committer = committer
 
77
        if parents is not None:
 
78
            self.parents = parents
 
79
        else:
 
80
            self.parents = []
68
81
 
 
82
    def __eq__(self, other):
 
83
        try:
 
84
            return self.inventory_id == other.inventory_id and \
 
85
                   self.inventory_sha1 == other.inventory_sha1 and \
 
86
                   self.revision_id == other.revision_id and \
 
87
                   self.timestamp == other.timestamp and \
 
88
                   self.message == other.message and \
 
89
                   self.timezone == other.timezone and \
 
90
                   self.committer == other.committer and \
 
91
                   self.parents == other.parents 
 
92
        except AttributeError:
 
93
            return False
69
94
 
70
95
    def __repr__(self):
71
96
        return "<Revision id %s>" % self.revision_id
72
 
 
73
97
        
74
98
    def to_element(self):
75
99
        from bzrlib.xml import Element, SubElement