1
# Copyright (C) 2006 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
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
17
"""A generator which creates a rio stanza of the current tree info"""
19
from bzrlib.rio import RioWriter, Stanza
21
from bzrlib.version_info_formats import (
27
class RioVersionInfoBuilder(VersionInfoBuilder):
28
"""This writes a rio stream out."""
30
def generate(self, to_file):
32
revision_id = self._get_revision_id()
33
if revision_id is not None:
34
info.add('revision-id', revision_id)
35
rev = self._branch.repository.get_revision(revision_id)
36
info.add('date', create_date_str(rev.timestamp, rev.timezone))
37
revno = str(self._branch.revision_id_to_revno(revision_id))
41
info.add('build-date', create_date_str())
42
info.add('revno', revno)
44
if self._branch.nick is not None:
45
info.add('branch-nick', self._branch.nick)
47
if self._check or self._include_file_revs:
48
self._extract_file_revisions()
52
info.add('clean', 'True')
54
info.add('clean', 'False')
56
if self._include_history:
57
self._extract_revision_history()
59
for (revision_id, message,
60
timestamp, timezone) in self._revision_history_info:
61
log.add('id', revision_id)
62
log.add('message', message)
63
log.add('date', create_date_str(timestamp, timezone))
64
info.add('revisions', log.to_unicode())
66
if self._include_file_revs:
68
for path in sorted(self._file_revisions.keys()):
69
files.add('path', path)
70
files.add('revision', self._file_revisions[path])
71
info.add('file-revisions', files.to_unicode())
73
writer = RioWriter(to_file=to_file)
74
writer.write_stanza(info)