/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:
20
20
# perhaps show them in log -v and allow them as options to the commit command.
21
21
 
22
22
 
23
 
from .lazy_import import lazy_import
 
23
from bzrlib.lazy_import import lazy_import
24
24
lazy_import(globals(), """
25
 
from breezy import bugtracker
 
25
from bzrlib import bugtracker
26
26
""")
27
 
from . import (
 
27
from bzrlib import (
28
28
    errors,
29
 
    osutils,
30
 
    )
31
 
from .sixish import (
32
 
    text_type,
33
 
    )
 
29
    symbol_versioning,
 
30
    )
 
31
from bzrlib.osutils import contains_whitespace
34
32
 
35
 
NULL_REVISION = b"null:"
36
 
CURRENT_REVISION = b"current:"
 
33
NULL_REVISION="null:"
 
34
CURRENT_REVISION="current:"
37
35
 
38
36
 
39
37
class Revision(object):
88
86
 
89
87
    def _check_properties(self):
90
88
        """Verify that all revision properties are OK."""
91
 
        for name, value in self.properties.items():
92
 
            # GZ 2017-06-10: What sort of string are properties exactly?
93
 
            not_text = not isinstance(name, (text_type, str))
94
 
            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):
95
91
                raise ValueError("invalid property name %r" % name)
96
 
            if not isinstance(value, (text_type, bytes)):
 
92
            if not isinstance(value, basestring):
97
93
                raise ValueError("invalid property value %r for %r" %
98
94
                                 (value, name))
99
95
 
152
148
            try:
153
149
                url, status = line.split(None, 2)
154
150
            except ValueError:
155
 
                raise bugtracker.InvalidLineInBugsProperty(line)
 
151
                raise errors.InvalidLineInBugsProperty(line)
156
152
            if status not in bugtracker.ALLOWED_BUG_STATUSES:
157
 
                raise bugtracker.InvalidBugStatus(status)
 
153
                raise errors.InvalidBugStatus(status)
158
154
            yield url, status
159
155
 
160
156
 
168
164
                yield ancestor, distance
169
165
            try:
170
166
                revision = revision_source.get_revision(ancestor)
171
 
            except errors.NoSuchRevision as e:
 
167
            except errors.NoSuchRevision, e:
172
168
                if e.revision == revision_id:
173
169
                    raise
174
170
                else:
210
206
 
211
207
    :return: True if the revision is reserved, False otherwise
212
208
    """
213
 
    return isinstance(revision_id, bytes) and revision_id.endswith(b':')
 
209
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
214
210
 
215
211
 
216
212
def check_not_reserved_id(revision_id):
222
218
def ensure_null(revision_id):
223
219
    """Ensure only NULL_REVISION is used to represent the null revision"""
224
220
    if revision_id is None:
225
 
        raise ValueError(
226
 
            'NULL_REVISION should be used for the null'
227
 
            ' revision instead of None.')
228
 
    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
229
227
 
230
228
 
231
229
def is_null(revision_id):
232
230
    if revision_id is None:
233
 
        raise ValueError('NULL_REVISION should be used for the null'
234
 
                         ' revision instead of None.')
235
 
    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)