/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/git/fetch.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 20:02:36 UTC
  • mto: (7490.7.7 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200322200236-fsbl91ktcn6fcbdd
Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Fetching from git into bzr."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from dulwich.objects import (
20
22
    Commit,
21
23
    Tag,
49
51
    NULL_REVISION,
50
52
    )
51
53
from ..bzr.inventorytree import InventoryRevisionTree
 
54
from ..sixish import text_type
52
55
from ..bzr.testament import (
53
56
    StrictTestament3,
54
57
    )
62
65
 
63
66
from .mapping import (
64
67
    DEFAULT_FILE_MODE,
65
 
    decode_git_path,
66
68
    mode_is_executable,
67
69
    mode_kind,
68
70
    warn_unusual_mode,
86
88
    """
87
89
    if not isinstance(path, bytes):
88
90
        raise TypeError(path)
89
 
    decoded_path = decode_git_path(path)
 
91
    decoded_path = path.decode('utf-8')
90
92
    (base_mode, mode) = modes
91
93
    (base_hexsha, hexsha) = hexshas
92
94
    if mapping.is_special_file(path):
99
101
        cls = InventoryLink
100
102
    else:
101
103
        cls = InventoryFile
102
 
    ie = cls(file_id, decode_git_path(name), parent_id)
 
104
    ie = cls(file_id, name.decode("utf-8"), parent_id)
103
105
    if ie.kind == "file":
104
106
        ie.executable = mode_is_executable(mode)
105
107
    if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode):
117
119
        blob = lookup_object(hexsha)
118
120
        if ie.kind == "symlink":
119
121
            ie.revision = None
120
 
            ie.symlink_target = decode_git_path(blob.data)
 
122
            ie.symlink_target = blob.data.decode("utf-8")
121
123
        else:
122
124
            ie.text_size = sum(map(len, blob.chunked))
123
125
            ie.text_sha1 = osutils.sha_strings(blob.chunked)
184
186
    (base_mode, mode) = modes
185
187
    if base_hexsha == hexsha and base_mode == mode:
186
188
        return [], {}
187
 
    path = decode_git_path(path)
 
189
    path = path.decode('utf-8')
188
190
    file_id = lookup_file_id(path)
189
191
    invdelta = []
190
 
    ie = TreeReference(file_id, decode_git_path(name), parent_id)
 
192
    ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
191
193
    ie.revision = revision_id
192
194
    if base_hexsha is not None:
193
195
        old_path = path  # Renames are not supported yet
216
218
    :param lookup_object: Lookup a git object by its SHA1
217
219
    :return: Inventory delta, as list
218
220
    """
219
 
    if not isinstance(path, str):
 
221
    if not isinstance(path, text_type):
220
222
        raise TypeError(path)
221
223
    ret = []
222
224
    for name, mode, hexsha in base_tree.iteritems():
223
225
        if name in existing_children:
224
226
            continue
225
 
        c_path = posixpath.join(path, decode_git_path(name))
 
227
        c_path = posixpath.join(path, name.decode("utf-8"))
226
228
        file_id = base_bzr_tree.path2id(c_path)
227
229
        if file_id is None:
228
230
            raise TypeError(file_id)
259
261
        return [], {}
260
262
    invdelta = []
261
263
    file_id = lookup_file_id(osutils.safe_unicode(path))
262
 
    ie = InventoryDirectory(file_id, decode_git_path(name), parent_id)
 
264
    # We just have to hope this is indeed utf-8:
 
265
    ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id)
263
266
    tree = lookup_object(hexsha)
264
267
    if base_hexsha is None:
265
268
        base_tree = None
266
269
        old_path = None  # Newly appeared here
267
270
    else:
268
271
        base_tree = lookup_object(base_hexsha)
269
 
        old_path = decode_git_path(path)  # Renames aren't supported yet
270
 
    new_path = decode_git_path(path)
 
272
        old_path = path.decode("utf-8")  # Renames aren't supported yet
 
273
    new_path = path.decode("utf-8")
271
274
    if base_tree is None or type(base_tree) is not Tree:
272
275
        ie.revision = revision_id
273
276
        invdelta.append((old_path, new_path, ie.file_id, ie))