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
from bzrlib.lazy_import import lazy_import
22
lazy_import(globals(), """
23
from bzrlib import deprecated_graph
24
from bzrlib import bugtracker
21
26
from bzrlib import (
45
50
Dictionary of revision properties. These are attached to the
46
revision as extra metadata. The name must be a single
51
revision as extra metadata. The name must be a single
47
52
word; the value can be an arbitrary string.
50
55
def __init__(self, revision_id, properties=None, **args):
51
56
self.revision_id = revision_id
52
57
self.properties = properties or {}
53
58
self._check_properties()
54
60
self.parent_ids = []
55
61
self.parent_sha1s = []
56
62
"""Not used anymore - legacy from for 4."""
81
87
if not isinstance(name, basestring) or contains_whitespace(name):
82
88
raise ValueError("invalid property name %r" % name)
83
89
if not isinstance(value, basestring):
84
raise ValueError("invalid property value %r for %r" %
90
raise ValueError("invalid property value %r for %r" %
87
93
def get_history(self, repository):
109
115
return self.message.lstrip().split('\n', 1)[0]
117
@symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
111
118
def get_apparent_author(self):
112
119
"""Return the apparent author of this revision.
114
If the revision properties contain the author name,
115
return it. Otherwise return the committer name.
117
return self.properties.get('author', self.committer)
121
This method is deprecated in favour of get_apparent_authors.
123
If the revision properties contain any author names,
124
return the first. Otherwise return the committer name.
126
authors = self.get_apparent_authors()
132
def get_apparent_authors(self):
133
"""Return the apparent authors of this revision.
135
If the revision properties contain the names of the authors,
136
return them. Otherwise return the committer name.
138
The return value will be a list containing at least one element.
140
authors = self.properties.get('authors', None)
142
author = self.properties.get('author', self.committer)
147
return authors.split("\n")
150
"""Iterate over the bugs associated with this revision."""
151
bug_property = self.properties.get('bugs', None)
152
if bug_property is None:
154
for line in bug_property.splitlines():
156
url, status = line.split(None, 2)
158
raise errors.InvalidLineInBugsProperty(line)
159
if status not in bugtracker.ALLOWED_BUG_STATUSES:
160
raise errors.InvalidBugStatus(status)
120
164
def iter_ancestors(revision_id, revision_source, only_present=False):
153
197
if anc_id not in found_ancestors:
154
198
found_ancestors[anc_id] = (anc_order, anc_distance)
155
199
return found_ancestors
158
202
def __get_closest(intersection):
159
203
intersection.sort()
161
205
for entry in intersection:
162
206
if entry[0] == intersection[0][0]:
163
207
matches.append(entry[2])
167
211
def is_reserved_id(revision_id):
168
212
"""Determine whether a revision id is reserved
170
:return: True if the revision is is reserved, False otherwise
214
:return: True if the revision is reserved, False otherwise
172
216
return isinstance(revision_id, basestring) and revision_id.endswith(':')