/usr/lib/python2.7/dist-packages/bzrlib/version_info_formats/format_rio.py is in python-bzrlib 2.7.0-2ubuntu3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # Copyright (C) 2006, 2009, 2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""A generator which creates a rio stanza of the current tree info"""
from __future__ import absolute_import
from bzrlib import hooks
from bzrlib.revision import (
NULL_REVISION,
)
from bzrlib.rio import RioWriter, Stanza
from bzrlib.version_info_formats import (
create_date_str,
VersionInfoBuilder,
)
class RioVersionInfoBuilder(VersionInfoBuilder):
"""This writes a rio stream out."""
def generate(self, to_file):
info = Stanza()
revision_id = self._get_revision_id()
if revision_id != NULL_REVISION:
info.add('revision-id', revision_id)
rev = self._branch.repository.get_revision(revision_id)
info.add('date', create_date_str(rev.timestamp, rev.timezone))
revno = self._get_revno_str(revision_id)
for hook in RioVersionInfoBuilder.hooks['revision']:
hook(rev, info)
else:
revno = '0'
info.add('build-date', create_date_str())
info.add('revno', revno)
if self._branch.nick is not None:
info.add('branch-nick', self._branch.nick)
if self._check or self._include_file_revs:
self._extract_file_revisions()
if self._check:
if self._clean:
info.add('clean', 'True')
else:
info.add('clean', 'False')
if self._include_history:
log = Stanza()
for (revision_id, message,
timestamp, timezone) in self._iter_revision_history():
log.add('id', revision_id)
log.add('message', message)
log.add('date', create_date_str(timestamp, timezone))
info.add('revisions', log.to_unicode())
if self._include_file_revs:
files = Stanza()
for path in sorted(self._file_revisions.keys()):
files.add('path', path)
files.add('revision', self._file_revisions[path])
info.add('file-revisions', files.to_unicode())
writer = RioWriter(to_file=to_file)
writer.write_stanza(info)
class RioVersionInfoBuilderHooks(hooks.Hooks):
"""Hooks for rio-formatted version-info output."""
def __init__(self):
super(RioVersionInfoBuilderHooks, self).__init__(
"bzrlib.version_info_formats.format_rio", "RioVersionInfoBuilder.hooks")
self.add_hook('revision',
"Invoked when adding information about a revision to the"
" RIO stanza that is printed. revision is called with a"
" revision object and a RIO stanza.", (1, 15))
RioVersionInfoBuilder.hooks = RioVersionInfoBuilderHooks()
|