~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Robert Collins
  • Date: 2009-03-26 23:16:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4216.
  • Revision ID: robertc@robertcollins.net-20090326231606-rh98suac20x246pk
Review caught a bogus change to test_last_modified_revision_after_commit_link_unchanged_ric.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005, 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
# 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.
20
20
 
21
21
from bzrlib.lazy_import import lazy_import
22
22
lazy_import(globals(), """
 
23
from bzrlib import deprecated_graph
23
24
from bzrlib import bugtracker
24
25
""")
25
26
from bzrlib import (
27
28
    symbol_versioning,
28
29
    )
29
30
from bzrlib.osutils import contains_whitespace
 
31
from bzrlib.progress import DummyProgress
30
32
 
31
33
NULL_REVISION="null:"
32
34
CURRENT_REVISION="current:"
52
54
 
53
55
    def __init__(self, revision_id, properties=None, **args):
54
56
        self.revision_id = revision_id
55
 
        if properties is None:
56
 
            self.properties = {}
57
 
        else:
58
 
            self.properties = properties
59
 
            self._check_properties()
60
 
        self.committer = None
 
57
        self.properties = properties or {}
 
58
        self._check_properties()
61
59
        self.parent_ids = []
62
60
        self.parent_sha1s = []
63
61
        """Not used anymore - legacy from for 4."""
69
67
    def __eq__(self, other):
70
68
        if not isinstance(other, Revision):
71
69
            return False
 
70
        # FIXME: rbc 20050930 parent_ids are not being compared
72
71
        return (
73
72
                self.inventory_sha1 == other.inventory_sha1
74
73
                and self.revision_id == other.revision_id
76
75
                and self.message == other.message
77
76
                and self.timezone == other.timezone
78
77
                and self.committer == other.committer
79
 
                and self.properties == other.properties
80
 
                and self.parent_ids == other.parent_ids)
 
78
                and self.properties == other.properties)
81
79
 
82
80
    def __ne__(self, other):
83
81
        return not self.__eq__(other)
89
87
                raise ValueError("invalid property name %r" % name)
90
88
            if not isinstance(value, basestring):
91
89
                raise ValueError("invalid property value %r for %r" %
92
 
                                 (value, name))
 
90
                                 (name, value))
93
91
 
94
92
    def get_history(self, repository):
95
93
        """Return the canonical line-of-history for this revision.
112
110
 
113
111
    def get_summary(self):
114
112
        """Get the first line of the log message for this revision.
115
 
 
116
 
        Return an empty string if message is None.
117
 
        """
118
 
        if self.message:
119
 
            return self.message.lstrip().split('\n', 1)[0]
120
 
        else:
121
 
            return ''
 
113
        """
 
114
        return self.message.lstrip().split('\n', 1)[0]
 
115
 
 
116
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
 
117
    def get_apparent_author(self):
 
118
        """Return the apparent author of this revision.
 
119
 
 
120
        This method is deprecated in favour of get_apparent_authors.
 
121
 
 
122
        If the revision properties contain any author names,
 
123
        return the first. Otherwise return the committer name.
 
124
        """
 
125
        return self.get_apparent_authors()[0]
122
126
 
123
127
    def get_apparent_authors(self):
124
128
        """Return the apparent authors of this revision.
130
134
        """
131
135
        authors = self.properties.get('authors', None)
132
136
        if authors is None:
133
 
            author = self.properties.get('author', self.committer)
 
137
            author = self.properties.get('author', None)
134
138
            if author is None:
135
 
                return []
 
139
                return [self.committer]
136
140
            return [author]
137
141
        else:
138
142
            return authors.split("\n")
202
206
def is_reserved_id(revision_id):
203
207
    """Determine whether a revision id is reserved
204
208
 
205
 
    :return: True if the revision is reserved, False otherwise
 
209
    :return: True if the revision is is reserved, False otherwise
206
210
    """
207
211
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
208
212