/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-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Foreign branch utilities."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
 
21
 
19
22
from .branch import (
20
23
    Branch,
21
24
    )
 
25
from .commands import Command, Option
22
26
from .repository import Repository
23
27
from .revision import Revision
24
 
from . import (
 
28
from .sixish import (
 
29
    text_type,
 
30
    )
 
31
from .lazy_import import lazy_import
 
32
lazy_import(globals(), """
 
33
from breezy import (
25
34
    errors,
26
35
    registry,
 
36
    transform,
27
37
    )
28
 
 
 
38
from breezy.i18n import gettext
 
39
""")
29
40
 
30
41
class VcsMapping(object):
31
42
    """Describes the mapping between the semantics of Bazaar and a foreign VCS.
77
88
        The factory must be a callable that takes one parameter: the key.
78
89
        It must produce an instance of VcsMapping when called.
79
90
        """
80
 
        if b":" in key:
 
91
        if ":" in key:
81
92
            raise ValueError("mapping name can not contain colon (:)")
82
93
        registry.Registry.register(self, key, factory, help)
83
94
 
104
115
    """
105
116
 
106
117
    def __init__(self, foreign_revid, mapping, *args, **kwargs):
107
 
        if "inventory_sha1" not in kwargs:
108
 
            kwargs["inventory_sha1"] = b""
 
118
        if not "inventory_sha1" in kwargs:
 
119
            kwargs["inventory_sha1"] = ""
109
120
        super(ForeignRevision, self).__init__(*args, **kwargs)
110
121
        self.foreign_revid = foreign_revid
111
122
        self.mapping = mapping
133
144
        :param foreign_revid: Foreign revision id.
134
145
        :return: Dictionary mapping string keys to string values.
135
146
        """
136
 
        return {}
 
147
        return { }
137
148
 
138
149
    def serialize_foreign_revid(self, foreign_revid):
139
150
        """Serialize a foreign revision id for this VCS.
140
151
 
141
152
        :param foreign_revid: Foreign revision id
142
 
        :return: Bytestring with serialized revid, will not contain any
 
153
        :return: Bytestring with serialized revid, will not contain any 
143
154
            newlines.
144
155
        """
145
156
        raise NotImplementedError(self.serialize_foreign_revid)
171
182
        :param revid: The bzr revision id
172
183
        :return: tuple with foreign revid and vcs mapping
173
184
        """
174
 
        if b":" not in revid or b"-" not in revid:
 
185
        if not ":" in revid or not "-" in revid:
175
186
            raise errors.InvalidRevisionId(revid, None)
176
187
        try:
177
 
            foreign_vcs = self.get(revid.split(b"-")[0].decode('ascii'))
 
188
            foreign_vcs = self.get(revid.split("-")[0])
178
189
        except KeyError:
179
190
            raise errors.InvalidRevisionId(revid, None)
180
191
        return foreign_vcs.mapping_registry.revision_id_bzr_to_foreign(revid)
224
235
    def __init__(self, mapping):
225
236
        self.mapping = mapping
226
237
        super(ForeignBranch, self).__init__()
 
238