/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 breezy/revision.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

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
 
26
28
    errors,
27
29
    osutils,
28
30
    )
 
31
from .sixish import (
 
32
    text_type,
 
33
    )
29
34
 
30
 
NULL_REVISION = b"null:"
31
 
CURRENT_REVISION = b"current:"
 
35
NULL_REVISION=b"null:"
 
36
CURRENT_REVISION=b"current:"
32
37
 
33
38
 
34
39
class Revision(object):
69
74
        if not isinstance(other, Revision):
70
75
            return False
71
76
        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)
 
77
                self.inventory_sha1 == other.inventory_sha1
 
78
                and self.revision_id == other.revision_id
 
79
                and self.timestamp == other.timestamp
 
80
                and self.message == other.message
 
81
                and self.timezone == other.timezone
 
82
                and self.committer == other.committer
 
83
                and self.properties == other.properties
 
84
                and self.parent_ids == other.parent_ids)
80
85
 
81
86
    def __ne__(self, other):
82
87
        return not self.__eq__(other)
85
90
        """Verify that all revision properties are OK."""
86
91
        for name, value in self.properties.items():
87
92
            # GZ 2017-06-10: What sort of string are properties exactly?
88
 
            not_text = not isinstance(name, str)
 
93
            not_text = not isinstance(name, (text_type, str))
89
94
            if not_text or osutils.contains_whitespace(name):
90
95
                raise ValueError("invalid property name %r" % name)
91
 
            if not isinstance(value, (str, bytes)):
 
96
            if not isinstance(value, (text_type, bytes)):
92
97
                raise ValueError("invalid property value %r for %r" %
93
98
                                 (value, name))
94
99
 
102
107
        reversed_result = []
103
108
        while current_revision is not None:
104
109
            reversed_result.append(current_revision.revision_id)
105
 
            if not len(current_revision.parent_ids):
 
110
            if not len (current_revision.parent_ids):
106
111
                reversed_result.append(None)
107
112
                current_revision = None
108
113
            else:
142
147
        """Iterate over the bugs associated with this revision."""
143
148
        bug_property = self.properties.get('bugs', None)
144
149
        if bug_property is None:
145
 
            return iter([])
146
 
        return bugtracker.decode_bug_urls(bug_property)
 
150
            return
 
151
        for line in bug_property.splitlines():
 
152
            try:
 
153
                url, status = line.split(None, 2)
 
154
            except ValueError:
 
155
                raise bugtracker.InvalidLineInBugsProperty(line)
 
156
            if status not in bugtracker.ALLOWED_BUG_STATUSES:
 
157
                raise bugtracker.InvalidBugStatus(status)
 
158
            yield url, status
147
159
 
148
160
 
149
161
def iter_ancestors(revision_id, revision_source, only_present=False):
177
189
    """
178
190
    found_ancestors = {}
179
191
    anc_iter = enumerate(iter_ancestors(revision_id, revision_source,
180
 
                                        only_present=True))
 
192
                         only_present=True))
181
193
    for anc_order, (anc_id, anc_distance) in anc_iter:
182
194
        if anc_id not in found_ancestors:
183
195
            found_ancestors[anc_id] = (anc_order, anc_distance)