~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/version_info_formats/format_rio.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""A generator which creates a rio stanza of the current tree info"""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
 
from bzrlib import hooks
22
 
from bzrlib.revision import (
23
 
    NULL_REVISION,
24
 
    )
25
19
from bzrlib.rio import RioWriter, Stanza
26
20
 
27
21
from bzrlib.version_info_formats import (
36
30
    def generate(self, to_file):
37
31
        info = Stanza()
38
32
        revision_id = self._get_revision_id()
39
 
        if revision_id != NULL_REVISION:
 
33
        if revision_id is not None:
40
34
            info.add('revision-id', revision_id)
41
35
            rev = self._branch.repository.get_revision(revision_id)
42
36
            info.add('date', create_date_str(rev.timestamp, rev.timezone))
43
 
            revno = self._get_revno_str(revision_id)
44
 
            for hook in RioVersionInfoBuilder.hooks['revision']:
45
 
                hook(rev, info)
 
37
            revno = str(self._branch.revision_id_to_revno(revision_id))
46
38
        else:
47
39
            revno = '0'
48
40
 
62
54
                info.add('clean', 'False')
63
55
 
64
56
        if self._include_history:
 
57
            self._extract_revision_history()
65
58
            log = Stanza()
66
59
            for (revision_id, message,
67
 
                 timestamp, timezone) in self._iter_revision_history():
 
60
                 timestamp, timezone) in self._revision_history_info:
68
61
                log.add('id', revision_id)
69
62
                log.add('message', message)
70
63
                log.add('date', create_date_str(timestamp, timezone))
81
74
        writer.write_stanza(info)
82
75
 
83
76
 
84
 
class RioVersionInfoBuilderHooks(hooks.Hooks):
85
 
    """Hooks for rio-formatted version-info output."""
86
 
 
87
 
    def __init__(self):
88
 
        super(RioVersionInfoBuilderHooks, self).__init__(
89
 
            "bzrlib.version_info_formats.format_rio", "RioVersionInfoBuilder.hooks")
90
 
        self.add_hook('revision',
91
 
            "Invoked when adding information about a revision to the"
92
 
            " RIO stanza that is printed. revision is called with a"
93
 
            " revision object and a RIO stanza.", (1, 15))
94
 
 
95
 
 
96
 
RioVersionInfoBuilder.hooks = RioVersionInfoBuilderHooks()