~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Jelmer Vernooij
  • Date: 2009-04-10 15:58:09 UTC
  • mto: This revision was merged to the branch mainline in revision 4284.
  • Revision ID: jelmer@samba.org-20090410155809-kdibzcjvp7pdb83f
Fix missing import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 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
28
28
    symbol_versioning,
29
29
    )
30
30
from bzrlib.osutils import contains_whitespace
 
31
from bzrlib.progress import DummyProgress
31
32
 
32
33
NULL_REVISION="null:"
33
34
CURRENT_REVISION="current:"
53
54
 
54
55
    def __init__(self, revision_id, properties=None, **args):
55
56
        self.revision_id = revision_id
56
 
        if properties is None:
57
 
            self.properties = {}
58
 
        else:
59
 
            self.properties = properties
60
 
            self._check_properties()
61
 
        self.committer = None
 
57
        self.properties = properties or {}
 
58
        self._check_properties()
62
59
        self.parent_ids = []
63
60
        self.parent_sha1s = []
64
61
        """Not used anymore - legacy from for 4."""
70
67
    def __eq__(self, other):
71
68
        if not isinstance(other, Revision):
72
69
            return False
 
70
        # FIXME: rbc 20050930 parent_ids are not being compared
73
71
        return (
74
72
                self.inventory_sha1 == other.inventory_sha1
75
73
                and self.revision_id == other.revision_id
77
75
                and self.message == other.message
78
76
                and self.timezone == other.timezone
79
77
                and self.committer == other.committer
80
 
                and self.properties == other.properties
81
 
                and self.parent_ids == other.parent_ids)
 
78
                and self.properties == other.properties)
82
79
 
83
80
    def __ne__(self, other):
84
81
        return not self.__eq__(other)
90
87
                raise ValueError("invalid property name %r" % name)
91
88
            if not isinstance(value, basestring):
92
89
                raise ValueError("invalid property value %r for %r" %
93
 
                                 (value, name))
 
90
                                 (name, value))
94
91
 
95
92
    def get_history(self, repository):
96
93
        """Return the canonical line-of-history for this revision.
113
110
 
114
111
    def get_summary(self):
115
112
        """Get the first line of the log message for this revision.
116
 
 
117
 
        Return an empty string if message is None.
118
113
        """
119
 
        if self.message:
120
 
            return self.message.lstrip().split('\n', 1)[0]
121
 
        else:
122
 
            return ''
 
114
        return self.message.lstrip().split('\n', 1)[0]
123
115
 
124
116
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
125
117
    def get_apparent_author(self):
130
122
        If the revision properties contain any author names,
131
123
        return the first. Otherwise return the committer name.
132
124
        """
133
 
        authors = self.get_apparent_authors()
134
 
        if authors:
135
 
            return authors[0]
136
 
        else:
137
 
            return None
 
125
        return self.get_apparent_authors()[0]
138
126
 
139
127
    def get_apparent_authors(self):
140
128
        """Return the apparent authors of this revision.
146
134
        """
147
135
        authors = self.properties.get('authors', None)
148
136
        if authors is None:
149
 
            author = self.properties.get('author', self.committer)
 
137
            author = self.properties.get('author', None)
150
138
            if author is None:
151
 
                return []
 
139
                return [self.committer]
152
140
            return [author]
153
141
        else:
154
142
            return authors.split("\n")