/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: 2020-05-06 02:13:25 UTC
  • mfrom: (7490.7.21 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200506021325-awbmmqu1zyorz7sj
Merge 3.1 branch.

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
 
 
19
17
# TODO: Some kind of command-line display of revision properties:
20
18
# perhaps show them in log -v and allow them as options to the commit command.
21
19
 
28
26
    errors,
29
27
    osutils,
30
28
    )
31
 
from .sixish import (
32
 
    text_type,
33
 
    )
34
29
 
35
 
NULL_REVISION=b"null:"
36
 
CURRENT_REVISION=b"current:"
 
30
NULL_REVISION = b"null:"
 
31
CURRENT_REVISION = b"current:"
37
32
 
38
33
 
39
34
class Revision(object):
74
69
        if not isinstance(other, Revision):
75
70
            return False
76
71
        return (
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)
 
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)
85
80
 
86
81
    def __ne__(self, other):
87
82
        return not self.__eq__(other)
90
85
        """Verify that all revision properties are OK."""
91
86
        for name, value in self.properties.items():
92
87
            # GZ 2017-06-10: What sort of string are properties exactly?
93
 
            not_text = not isinstance(name, (text_type, str))
 
88
            not_text = not isinstance(name, str)
94
89
            if not_text or osutils.contains_whitespace(name):
95
90
                raise ValueError("invalid property name %r" % name)
96
 
            if not isinstance(value, (text_type, bytes)):
 
91
            if not isinstance(value, (str, bytes)):
97
92
                raise ValueError("invalid property value %r for %r" %
98
93
                                 (value, name))
99
94
 
107
102
        reversed_result = []
108
103
        while current_revision is not None:
109
104
            reversed_result.append(current_revision.revision_id)
110
 
            if not len (current_revision.parent_ids):
 
105
            if not len(current_revision.parent_ids):
111
106
                reversed_result.append(None)
112
107
                current_revision = None
113
108
            else:
147
142
        """Iterate over the bugs associated with this revision."""
148
143
        bug_property = self.properties.get('bugs', None)
149
144
        if bug_property is None:
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
 
145
            return iter([])
 
146
        return bugtracker.decode_bug_urls(bug_property)
159
147
 
160
148
 
161
149
def iter_ancestors(revision_id, revision_source, only_present=False):
189
177
    """
190
178
    found_ancestors = {}
191
179
    anc_iter = enumerate(iter_ancestors(revision_id, revision_source,
192
 
                         only_present=True))
 
180
                                        only_present=True))
193
181
    for anc_order, (anc_id, anc_distance) in anc_iter:
194
182
        if anc_id not in found_ancestors:
195
183
            found_ancestors[anc_id] = (anc_order, anc_distance)