~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-06 20:45:48 UTC
  • mfrom: (4728.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091006204548-bjnc3z4k256ppimz
MutableTree.has_changes() does not require a tree parameter anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        self.revision_id = revision_id
57
57
        self.properties = properties or {}
58
58
        self._check_properties()
 
59
        self.committer = None
59
60
        self.parent_ids = []
60
61
        self.parent_sha1s = []
61
62
        """Not used anymore - legacy from for 4."""
67
68
    def __eq__(self, other):
68
69
        if not isinstance(other, Revision):
69
70
            return False
70
 
        # FIXME: rbc 20050930 parent_ids are not being compared
71
71
        return (
72
72
                self.inventory_sha1 == other.inventory_sha1
73
73
                and self.revision_id == other.revision_id
75
75
                and self.message == other.message
76
76
                and self.timezone == other.timezone
77
77
                and self.committer == other.committer
78
 
                and self.properties == other.properties)
 
78
                and self.properties == other.properties
 
79
                and self.parent_ids == other.parent_ids)
79
80
 
80
81
    def __ne__(self, other):
81
82
        return not self.__eq__(other)
87
88
                raise ValueError("invalid property name %r" % name)
88
89
            if not isinstance(value, basestring):
89
90
                raise ValueError("invalid property value %r for %r" %
90
 
                                 (name, value))
 
91
                                 (value, name))
91
92
 
92
93
    def get_history(self, repository):
93
94
        """Return the canonical line-of-history for this revision.
110
111
 
111
112
    def get_summary(self):
112
113
        """Get the first line of the log message for this revision.
 
114
 
 
115
        Return an empty string if message is None.
113
116
        """
114
 
        return self.message.lstrip().split('\n', 1)[0]
 
117
        if self.message:
 
118
            return self.message.lstrip().split('\n', 1)[0]
 
119
        else:
 
120
            return ''
115
121
 
116
122
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
117
123
    def get_apparent_author(self):
122
128
        If the revision properties contain any author names,
123
129
        return the first. Otherwise return the committer name.
124
130
        """
125
 
        return self.get_apparent_authors()[0]
 
131
        authors = self.get_apparent_authors()
 
132
        if authors:
 
133
            return authors[0]
 
134
        else:
 
135
            return None
126
136
 
127
137
    def get_apparent_authors(self):
128
138
        """Return the apparent authors of this revision.
134
144
        """
135
145
        authors = self.properties.get('authors', None)
136
146
        if authors is None:
137
 
            author = self.properties.get('author', None)
 
147
            author = self.properties.get('author', self.committer)
138
148
            if author is None:
139
 
                return [self.committer]
 
149
                return []
140
150
            return [author]
141
151
        else:
142
152
            return authors.split("\n")
206
216
def is_reserved_id(revision_id):
207
217
    """Determine whether a revision id is reserved
208
218
 
209
 
    :return: True if the revision is is reserved, False otherwise
 
219
    :return: True if the revision is reserved, False otherwise
210
220
    """
211
221
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
212
222