~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: John Arbash Meinel
  • Date: 2010-05-11 10:45:26 UTC
  • mto: This revision was merged to the branch mainline in revision 5225.
  • Revision ID: john@arbash-meinel.com-20100511104526-zxnstcxta22hzw2n
Implement a compiled extension for parsing the text key out of a CHKInventory value.

Related to bug #562666. This seems to shave 5-10% out of the time spent doing a complete
branch of bzr.dev/launchpad/etc.

Show diffs side-by-side

added added

removed removed

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