/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-20 02:17:05 UTC
  • mfrom: (7518.1.2 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200720021705-5f11tmo1hdqjxm6x
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/387628

Show diffs side-by-side

added added

removed removed

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