/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
from .lazy_import import lazy_import
 
23
from bzrlib.lazy_import import lazy_import
22
24
lazy_import(globals(), """
23
 
from breezy import bugtracker
 
25
from bzrlib import bugtracker
24
26
""")
25
 
from . import (
 
27
from bzrlib import (
26
28
    errors,
27
 
    osutils,
 
29
    symbol_versioning,
28
30
    )
 
31
from bzrlib.osutils import contains_whitespace
29
32
 
30
 
NULL_REVISION = b"null:"
31
 
CURRENT_REVISION = b"current:"
 
33
NULL_REVISION="null:"
 
34
CURRENT_REVISION="current:"
32
35
 
33
36
 
34
37
class Revision(object):
69
72
        if not isinstance(other, Revision):
70
73
            return False
71
74
        return (
72
 
            self.inventory_sha1 == other.inventory_sha1
73
 
            and self.revision_id == other.revision_id
74
 
            and self.timestamp == other.timestamp
75
 
            and self.message == other.message
76
 
            and self.timezone == other.timezone
77
 
            and self.committer == other.committer
78
 
            and self.properties == other.properties
79
 
            and self.parent_ids == other.parent_ids)
 
75
                self.inventory_sha1 == other.inventory_sha1
 
76
                and self.revision_id == other.revision_id
 
77
                and self.timestamp == other.timestamp
 
78
                and self.message == other.message
 
79
                and self.timezone == other.timezone
 
80
                and self.committer == other.committer
 
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)
83
86
 
84
87
    def _check_properties(self):
85
88
        """Verify that all revision properties are OK."""
86
 
        for name, value in self.properties.items():
87
 
            # GZ 2017-06-10: What sort of string are properties exactly?
88
 
            not_text = not isinstance(name, str)
89
 
            if not_text or osutils.contains_whitespace(name):
 
89
        for name, value in self.properties.iteritems():
 
90
            if not isinstance(name, basestring) or contains_whitespace(name):
90
91
                raise ValueError("invalid property name %r" % name)
91
 
            if not isinstance(value, (str, bytes)):
 
92
            if not isinstance(value, basestring):
92
93
                raise ValueError("invalid property value %r for %r" %
93
94
                                 (value, name))
94
95
 
102
103
        reversed_result = []
103
104
        while current_revision is not None:
104
105
            reversed_result.append(current_revision.revision_id)
105
 
            if not len(current_revision.parent_ids):
 
106
            if not len (current_revision.parent_ids):
106
107
                reversed_result.append(None)
107
108
                current_revision = None
108
109
            else:
142
143
        """Iterate over the bugs associated with this revision."""
143
144
        bug_property = self.properties.get('bugs', None)
144
145
        if bug_property is None:
145
 
            return iter([])
146
 
        return bugtracker.decode_bug_urls(bug_property)
 
146
            return
 
147
        for line in bug_property.splitlines():
 
148
            try:
 
149
                url, status = line.split(None, 2)
 
150
            except ValueError:
 
151
                raise errors.InvalidLineInBugsProperty(line)
 
152
            if status not in bugtracker.ALLOWED_BUG_STATUSES:
 
153
                raise errors.InvalidBugStatus(status)
 
154
            yield url, status
147
155
 
148
156
 
149
157
def iter_ancestors(revision_id, revision_source, only_present=False):
156
164
                yield ancestor, distance
157
165
            try:
158
166
                revision = revision_source.get_revision(ancestor)
159
 
            except errors.NoSuchRevision as e:
 
167
            except errors.NoSuchRevision, e:
160
168
                if e.revision == revision_id:
161
169
                    raise
162
170
                else:
177
185
    """
178
186
    found_ancestors = {}
179
187
    anc_iter = enumerate(iter_ancestors(revision_id, revision_source,
180
 
                                        only_present=True))
 
188
                         only_present=True))
181
189
    for anc_order, (anc_id, anc_distance) in anc_iter:
182
190
        if anc_id not in found_ancestors:
183
191
            found_ancestors[anc_id] = (anc_order, anc_distance)
198
206
 
199
207
    :return: True if the revision is reserved, False otherwise
200
208
    """
201
 
    return isinstance(revision_id, bytes) and revision_id.endswith(b':')
 
209
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
202
210
 
203
211
 
204
212
def check_not_reserved_id(revision_id):
210
218
def ensure_null(revision_id):
211
219
    """Ensure only NULL_REVISION is used to represent the null revision"""
212
220
    if revision_id is None:
213
 
        raise ValueError(
214
 
            'NULL_REVISION should be used for the null'
215
 
            ' revision instead of None.')
216
 
    return revision_id
 
221
        symbol_versioning.warn('NULL_REVISION should be used for the null'
 
222
            ' revision instead of None, as of bzr 0.91.',
 
223
            DeprecationWarning, stacklevel=2)
 
224
        return NULL_REVISION
 
225
    else:
 
226
        return revision_id
217
227
 
218
228
 
219
229
def is_null(revision_id):
220
230
    if revision_id is None:
221
 
        raise ValueError('NULL_REVISION should be used for the null'
222
 
                         ' revision instead of None.')
223
 
    return (revision_id == NULL_REVISION)
 
231
        symbol_versioning.warn('NULL_REVISION should be used for the null'
 
232
            ' revision instead of None, as of bzr 0.90.',
 
233
            DeprecationWarning, stacklevel=2)
 
234
    return revision_id in (None, NULL_REVISION)