~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-06 20:42:40 UTC
  • mto: This revision was merged to the branch mainline in revision 4088.
  • Revision ID: john@arbash-meinel.com-20090306204240-mzjavv31z3gu1x7i
Fix a small bug in setup.py when an extension fails to build

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
21
21
from bzrlib.lazy_import import lazy_import
22
22
lazy_import(globals(), """
23
23
from bzrlib import deprecated_graph
24
 
from bzrlib import bugtracker
25
24
""")
26
25
from bzrlib import (
27
26
    errors,
28
27
    symbol_versioning,
29
28
    )
30
29
from bzrlib.osutils import contains_whitespace
 
30
from bzrlib.progress import DummyProgress
31
31
 
32
32
NULL_REVISION="null:"
33
33
CURRENT_REVISION="current:"
53
53
 
54
54
    def __init__(self, revision_id, properties=None, **args):
55
55
        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
 
56
        self.properties = properties or {}
 
57
        self._check_properties()
62
58
        self.parent_ids = []
63
59
        self.parent_sha1s = []
64
60
        """Not used anymore - legacy from for 4."""
70
66
    def __eq__(self, other):
71
67
        if not isinstance(other, Revision):
72
68
            return False
 
69
        # FIXME: rbc 20050930 parent_ids are not being compared
73
70
        return (
74
71
                self.inventory_sha1 == other.inventory_sha1
75
72
                and self.revision_id == other.revision_id
77
74
                and self.message == other.message
78
75
                and self.timezone == other.timezone
79
76
                and self.committer == other.committer
80
 
                and self.properties == other.properties
81
 
                and self.parent_ids == other.parent_ids)
 
77
                and self.properties == other.properties)
82
78
 
83
79
    def __ne__(self, other):
84
80
        return not self.__eq__(other)
90
86
                raise ValueError("invalid property name %r" % name)
91
87
            if not isinstance(value, basestring):
92
88
                raise ValueError("invalid property value %r for %r" %
93
 
                                 (value, name))
 
89
                                 (name, value))
94
90
 
95
91
    def get_history(self, repository):
96
92
        """Return the canonical line-of-history for this revision.
113
109
 
114
110
    def get_summary(self):
115
111
        """Get the first line of the log message for this revision.
116
 
 
117
 
        Return an empty string if message is None.
118
112
        """
119
 
        if self.message:
120
 
            return self.message.lstrip().split('\n', 1)[0]
121
 
        else:
122
 
            return ''
 
113
        return self.message.lstrip().split('\n', 1)[0]
123
114
 
124
115
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((1, 13, 0)))
125
116
    def get_apparent_author(self):
130
121
        If the revision properties contain any author names,
131
122
        return the first. Otherwise return the committer name.
132
123
        """
133
 
        authors = self.get_apparent_authors()
134
 
        if authors:
135
 
            return authors[0]
136
 
        else:
137
 
            return None
 
124
        return self.get_apparent_authors()[0]
138
125
 
139
126
    def get_apparent_authors(self):
140
127
        """Return the apparent authors of this revision.
146
133
        """
147
134
        authors = self.properties.get('authors', None)
148
135
        if authors is None:
149
 
            author = self.properties.get('author', self.committer)
 
136
            author = self.properties.get('author', None)
150
137
            if author is None:
151
 
                return []
 
138
                return [self.committer]
152
139
            return [author]
153
140
        else:
154
141
            return authors.split("\n")
155
142
 
156
 
    def iter_bugs(self):
157
 
        """Iterate over the bugs associated with this revision."""
158
 
        bug_property = self.properties.get('bugs', None)
159
 
        if bug_property is None:
160
 
            return
161
 
        for line in bug_property.splitlines():
162
 
            try:
163
 
                url, status = line.split(None, 2)
164
 
            except ValueError:
165
 
                raise errors.InvalidLineInBugsProperty(line)
166
 
            if status not in bugtracker.ALLOWED_BUG_STATUSES:
167
 
                raise errors.InvalidBugStatus(status)
168
 
            yield url, status
169
 
 
170
143
 
171
144
def iter_ancestors(revision_id, revision_source, only_present=False):
172
145
    ancestors = (revision_id,)
218
191
def is_reserved_id(revision_id):
219
192
    """Determine whether a revision id is reserved
220
193
 
221
 
    :return: True if the revision is reserved, False otherwise
 
194
    :return: True if the revision is is reserved, False otherwise
222
195
    """
223
196
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
224
197