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
17
# TODO: Some kind of command-line display of revision properties:
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
25
26
from bzrlib import (
49
50
Dictionary of revision properties. These are attached to the
50
revision as extra metadata. The name must be a single
51
revision as extra metadata. The name must be a single
51
52
word; the value can be an arbitrary string.
54
55
def __init__(self, revision_id, properties=None, **args):
55
56
self.revision_id = revision_id
56
57
self.properties = properties or {}
85
86
if not isinstance(name, basestring) or contains_whitespace(name):
86
87
raise ValueError("invalid property name %r" % name)
87
88
if not isinstance(value, basestring):
88
raise ValueError("invalid property value %r for %r" %
89
raise ValueError("invalid property value %r for %r" %
91
92
def get_history(self, repository):
113
114
return self.message.lstrip().split('\n', 1)[0]
116
@symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
115
117
def get_apparent_author(self):
116
118
"""Return the apparent author of this revision.
118
If the revision properties contain the author name,
119
return it. Otherwise return the committer name.
121
return self.properties.get('author', self.committer)
120
This method is deprecated in favour of get_apparent_authors.
122
If the revision properties contain any author names,
123
return the first. Otherwise return the committer name.
125
return self.get_apparent_authors()[0]
127
def get_apparent_authors(self):
128
"""Return the apparent authors of this revision.
130
If the revision properties contain the names of the authors,
131
return them. Otherwise return the committer name.
133
The return value will be a list containing at least one element.
135
authors = self.properties.get('authors', None)
137
author = self.properties.get('author', None)
139
return [self.committer]
142
return authors.split("\n")
145
"""Iterate over the bugs associated with this revision."""
146
bug_property = self.properties.get('bugs', None)
147
if bug_property is None:
149
for line in bug_property.splitlines():
151
url, status = line.split(None, 2)
153
raise errors.InvalidLineInBugsProperty(line)
154
if status not in bugtracker.ALLOWED_BUG_STATUSES:
155
raise errors.InvalidBugStatus(status)
124
159
def iter_ancestors(revision_id, revision_source, only_present=False):
157
192
if anc_id not in found_ancestors:
158
193
found_ancestors[anc_id] = (anc_order, anc_distance)
159
194
return found_ancestors
162
197
def __get_closest(intersection):
163
198
intersection.sort()
165
200
for entry in intersection:
166
201
if entry[0] == intersection[0][0]:
167
202
matches.append(entry[2])