~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 14:15:25 UTC
  • mto: (6471.1.4 iter-child-entries)
  • mto: This revision was merged to the branch mainline in revision 6472.
  • Revision ID: jelmer@samba.org-20120220141525-9azkfei62st8yc7w
Use inventories directly in fewer places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
# TODO: Some kind of command-line display of revision properties:
18
20
# perhaps show them in log -v and allow them as options to the commit command.
19
21
 
20
22
 
21
23
from bzrlib.lazy_import import lazy_import
22
24
lazy_import(globals(), """
23
 
from bzrlib import deprecated_graph
24
25
from bzrlib import bugtracker
25
26
""")
26
27
from bzrlib import (
28
29
    symbol_versioning,
29
30
    )
30
31
from bzrlib.osutils import contains_whitespace
31
 
from bzrlib.progress import DummyProgress
32
32
 
33
33
NULL_REVISION="null:"
34
34
CURRENT_REVISION="current:"
54
54
 
55
55
    def __init__(self, revision_id, properties=None, **args):
56
56
        self.revision_id = revision_id
57
 
        self.properties = properties or {}
58
 
        self._check_properties()
 
57
        if properties is None:
 
58
            self.properties = {}
 
59
        else:
 
60
            self.properties = properties
 
61
            self._check_properties()
59
62
        self.committer = None
60
63
        self.parent_ids = []
61
64
        self.parent_sha1s = []
68
71
    def __eq__(self, other):
69
72
        if not isinstance(other, Revision):
70
73
            return False
71
 
        # FIXME: rbc 20050930 parent_ids are not being compared
72
74
        return (
73
75
                self.inventory_sha1 == other.inventory_sha1
74
76
                and self.revision_id == other.revision_id
76
78
                and self.message == other.message
77
79
                and self.timezone == other.timezone
78
80
                and self.committer == other.committer
79
 
                and self.properties == other.properties)
 
81
                and self.properties == other.properties
 
82
                and self.parent_ids == other.parent_ids)
80
83
 
81
84
    def __ne__(self, other):
82
85
        return not self.__eq__(other)
88
91
                raise ValueError("invalid property name %r" % name)
89
92
            if not isinstance(value, basestring):
90
93
                raise ValueError("invalid property value %r for %r" %
91
 
                                 (name, value))
 
94
                                 (value, name))
92
95
 
93
96
    def get_history(self, repository):
94
97
        """Return the canonical line-of-history for this revision.
111
114
 
112
115
    def get_summary(self):
113
116
        """Get the first line of the log message for this revision.
114
 
        """
115
 
        return self.message.lstrip().split('\n', 1)[0]
116
 
 
117
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
118
 
    def get_apparent_author(self):
119
 
        """Return the apparent author of this revision.
120
 
 
121
 
        This method is deprecated in favour of get_apparent_authors.
122
 
 
123
 
        If the revision properties contain any author names,
124
 
        return the first. Otherwise return the committer name.
125
 
        """
126
 
        authors = self.get_apparent_authors()
127
 
        if authors:
128
 
            return authors[0]
 
117
 
 
118
        Return an empty string if message is None.
 
119
        """
 
120
        if self.message:
 
121
            return self.message.lstrip().split('\n', 1)[0]
129
122
        else:
130
 
            return None
 
123
            return ''
131
124
 
132
125
    def get_apparent_authors(self):
133
126
        """Return the apparent authors of this revision.