/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/foreign.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-17 00:47:52 UTC
  • mfrom: (7182 work)
  • mto: This revision was merged to the branch mainline in revision 7305.
  • Revision ID: jelmer@jelmer.uk-20181117004752-6ywampe5pfywlby4
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from .branch import (
23
23
    Branch,
24
24
    )
25
 
from .commands import Command, Option
26
25
from .repository import Repository
27
26
from .revision import Revision
28
 
from .sixish import (
29
 
    text_type,
30
 
    )
31
27
from .lazy_import import lazy_import
32
28
lazy_import(globals(), """
33
29
from breezy import (
34
30
    errors,
35
31
    registry,
36
 
    transform,
37
32
    )
38
 
from breezy.i18n import gettext
39
33
""")
40
34
 
 
35
 
41
36
class VcsMapping(object):
42
37
    """Describes the mapping between the semantics of Bazaar and a foreign VCS.
43
38
 
115
110
    """
116
111
 
117
112
    def __init__(self, foreign_revid, mapping, *args, **kwargs):
118
 
        if not "inventory_sha1" in kwargs:
 
113
        if "inventory_sha1" not in kwargs:
119
114
            kwargs["inventory_sha1"] = b""
120
115
        super(ForeignRevision, self).__init__(*args, **kwargs)
121
116
        self.foreign_revid = foreign_revid
144
139
        :param foreign_revid: Foreign revision id.
145
140
        :return: Dictionary mapping string keys to string values.
146
141
        """
147
 
        return { }
 
142
        return {}
148
143
 
149
144
    def serialize_foreign_revid(self, foreign_revid):
150
145
        """Serialize a foreign revision id for this VCS.
171
166
        :param foreign_vcs: ForeignVCS instance
172
167
        :param help: Description of the foreign VCS
173
168
        """
174
 
        if b":" in key or b"-" in key:
 
169
        if ":" in key or "-" in key:
175
170
            raise ValueError("vcs name can not contain : or -")
176
171
        registry.Registry.register(self, key, foreign_vcs, help)
177
172
 
185
180
        if b":" not in revid or b"-" not in revid:
186
181
            raise errors.InvalidRevisionId(revid, None)
187
182
        try:
188
 
            foreign_vcs = self.get(revid.split(b"-")[0])
 
183
            foreign_vcs = self.get(revid.split(b"-")[0].decode('ascii'))
189
184
        except KeyError:
190
185
            raise errors.InvalidRevisionId(revid, None)
191
186
        return foreign_vcs.mapping_registry.revision_id_bzr_to_foreign(revid)
235
230
    def __init__(self, mapping):
236
231
        self.mapping = mapping
237
232
        super(ForeignBranch, self).__init__()
238