1
# Copyright (C) 2005 by 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
"""Testament - a summary of a revision for signing.
19
A testament can be defined as "something that serves as tangible
20
proof or evidence." In bzr we use them to allow people to certify
21
particular revisions as authentic.
23
We sign a testament rather than the revision XML itself for several reasons.
24
The most important is that the form in which the revision is stored
25
internally is designed for that purpose, and contains information which need
26
not be attested to by the signer. For example the inventory contains the
27
last-changed revision for a file, but this is not necessarily something the
30
Having unnecessary fields signed makes the signatures brittle when the same
31
revision is stored in different branches or when the format is upgraded.
33
Handling upgrades is another motivation for using testaments separate from
34
the stored revision. We would like to be able to compare a signature
35
generated from an old-format tree to newer tree, or vice versa. This could
36
be done by comparing the revisions but that makes it unclear about exactly
37
what is being compared or not.
39
Different signing keys might indicate different levels of trust; we can in
40
the future extend this to allow signatures indicating not just that a
41
particular version is authentic but that it has other properties.
44
class Testament(object):
45
"""Reduced summary of a revision.
49
- produced from a revision
51
- loaded from a stream
52
- compared to a revision
56
def from_revision(cls, branch, revision_id):
57
"""Produce a new testament from a historical revision"""
59
rev = branch.get_revision(revision_id)
60
t.revision_id = revision_id
61
t.committer = rev.committer
62
t.timezone = rev.timezone or 0
63
t.timestamp = rev.timestamp
64
t.message = rev.message