~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-27 05:35:00 UTC
  • mfrom: (4570 +trunk)
  • mto: (4634.6.29 2.0)
  • mto: This revision was merged to the branch mainline in revision 4680.
  • Revision ID: andrew.bennetts@canonical.com-20090727053500-q76zsn2dx33jhmj5
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
# TODO: Some kind of command-line display of revision properties:
18
18
# perhaps show them in log -v and allow them as options to the commit command.
21
21
from bzrlib.lazy_import import lazy_import
22
22
lazy_import(globals(), """
23
23
from bzrlib import deprecated_graph
 
24
from bzrlib import bugtracker
24
25
""")
25
26
from bzrlib import (
26
27
    errors,
55
56
        self.revision_id = revision_id
56
57
        self.properties = properties or {}
57
58
        self._check_properties()
 
59
        self.committer = None
58
60
        self.parent_ids = []
59
61
        self.parent_sha1s = []
60
62
        """Not used anymore - legacy from for 4."""
66
68
    def __eq__(self, other):
67
69
        if not isinstance(other, Revision):
68
70
            return False
69
 
        # FIXME: rbc 20050930 parent_ids are not being compared
70
71
        return (
71
72
                self.inventory_sha1 == other.inventory_sha1
72
73
                and self.revision_id == other.revision_id
74
75
                and self.message == other.message
75
76
                and self.timezone == other.timezone
76
77
                and self.committer == other.committer
77
 
                and self.properties == other.properties)
 
78
                and self.properties == other.properties
 
79
                and self.parent_ids == other.parent_ids)
78
80
 
79
81
    def __ne__(self, other):
80
82
        return not self.__eq__(other)
109
111
 
110
112
    def get_summary(self):
111
113
        """Get the first line of the log message for this revision.
 
114
 
 
115
        Return an empty string if message is None.
112
116
        """
113
 
        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 ''
114
121
 
115
122
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
116
123
    def get_apparent_author(self):
121
128
        If the revision properties contain any author names,
122
129
        return the first. Otherwise return the committer name.
123
130
        """
124
 
        return self.get_apparent_authors()[0]
 
131
        authors = self.get_apparent_authors()
 
132
        if authors:
 
133
            return authors[0]
 
134
        else:
 
135
            return None
125
136
 
126
137
    def get_apparent_authors(self):
127
138
        """Return the apparent authors of this revision.
133
144
        """
134
145
        authors = self.properties.get('authors', None)
135
146
        if authors is None:
136
 
            author = self.properties.get('author', None)
 
147
            author = self.properties.get('author', self.committer)
137
148
            if author is None:
138
 
                return [self.committer]
 
149
                return []
139
150
            return [author]
140
151
        else:
141
152
            return authors.split("\n")
142
153
 
 
154
    def iter_bugs(self):
 
155
        """Iterate over the bugs associated with this revision."""
 
156
        bug_property = self.properties.get('bugs', None)
 
157
        if bug_property is None:
 
158
            return
 
159
        for line in bug_property.splitlines():
 
160
            try:
 
161
                url, status = line.split(None, 2)
 
162
            except ValueError:
 
163
                raise errors.InvalidLineInBugsProperty(line)
 
164
            if status not in bugtracker.ALLOWED_BUG_STATUSES:
 
165
                raise errors.InvalidBugStatus(status)
 
166
            yield url, status
 
167
 
143
168
 
144
169
def iter_ancestors(revision_id, revision_source, only_present=False):
145
170
    ancestors = (revision_id,)
191
216
def is_reserved_id(revision_id):
192
217
    """Determine whether a revision id is reserved
193
218
 
194
 
    :return: True if the revision is is reserved, False otherwise
 
219
    :return: True if the revision is reserved, False otherwise
195
220
    """
196
221
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
197
222