/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-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

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,
62
64
 
63
65
from .mapping import (
64
66
    DEFAULT_FILE_MODE,
65
 
    decode_git_path,
66
67
    mode_is_executable,
67
68
    mode_kind,
68
69
    warn_unusual_mode,
86
87
    """
87
88
    if not isinstance(path, bytes):
88
89
        raise TypeError(path)
89
 
    decoded_path = decode_git_path(path)
 
90
    decoded_path = path.decode('utf-8')
90
91
    (base_mode, mode) = modes
91
92
    (base_hexsha, hexsha) = hexshas
92
93
    if mapping.is_special_file(path):
99
100
        cls = InventoryLink
100
101
    else:
101
102
        cls = InventoryFile
102
 
    ie = cls(file_id, decode_git_path(name), parent_id)
 
103
    ie = cls(file_id, name.decode("utf-8"), parent_id)
103
104
    if ie.kind == "file":
104
105
        ie.executable = mode_is_executable(mode)
105
106
    if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode):
117
118
        blob = lookup_object(hexsha)
118
119
        if ie.kind == "symlink":
119
120
            ie.revision = None
120
 
            ie.symlink_target = decode_git_path(blob.data)
 
121
            ie.symlink_target = blob.data.decode("utf-8")
121
122
        else:
122
123
            ie.text_size = sum(map(len, blob.chunked))
123
124
            ie.text_sha1 = osutils.sha_strings(blob.chunked)
184
185
    (base_mode, mode) = modes
185
186
    if base_hexsha == hexsha and base_mode == mode:
186
187
        return [], {}
187
 
    path = decode_git_path(path)
 
188
    path = path.decode('utf-8')
188
189
    file_id = lookup_file_id(path)
189
190
    invdelta = []
190
 
    ie = TreeReference(file_id, decode_git_path(name), parent_id)
 
191
    ie = TreeReference(file_id, name.decode("utf-8"), parent_id)
191
192
    ie.revision = revision_id
192
193
    if base_hexsha is not None:
193
194
        old_path = path  # Renames are not supported yet
222
223
    for name, mode, hexsha in base_tree.iteritems():
223
224
        if name in existing_children:
224
225
            continue
225
 
        c_path = posixpath.join(path, decode_git_path(name))
 
226
        c_path = posixpath.join(path, name.decode("utf-8"))
226
227
        file_id = base_bzr_tree.path2id(c_path)
227
228
        if file_id is None:
228
229
            raise TypeError(file_id)
259
260
        return [], {}
260
261
    invdelta = []
261
262
    file_id = lookup_file_id(osutils.safe_unicode(path))
262
 
    ie = InventoryDirectory(file_id, decode_git_path(name), parent_id)
 
263
    # We just have to hope this is indeed utf-8:
 
264
    ie = InventoryDirectory(file_id, name.decode("utf-8"), parent_id)
263
265
    tree = lookup_object(hexsha)
264
266
    if base_hexsha is None:
265
267
        base_tree = None
266
268
        old_path = None  # Newly appeared here
267
269
    else:
268
270
        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)
 
271
        old_path = path.decode("utf-8")  # Renames aren't supported yet
 
272
    new_path = path.decode("utf-8")
271
273
    if base_tree is None or type(base_tree) is not Tree:
272
274
        ie.revision = revision_id
273
275
        invdelta.append((old_path, new_path, ie.file_id, ie))