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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-14 19:47:11 UTC
  • mfrom: (7027.4.12 python3-blackbox)
  • Revision ID: breezy.the.bot@gmail.com-20180714194711-h73vd0gzphiab6vf
Change run_bzr to use StringIOWithEncoding for stderr and stdout on python 3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-blackbox/+merge/349090

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
    :param blob: A git blob
102
102
    :return: Inventory delta for this file
103
103
    """
 
104
    if not isinstance(path, bytes):
 
105
        raise TypeError(path)
 
106
    decoded_path = path.decode('utf-8')
104
107
    (base_mode, mode) = modes
105
108
    (base_hexsha, hexsha) = hexshas
106
109
    if mapping.is_special_file(path):
108
111
    if base_hexsha == hexsha and base_mode == mode:
109
112
        # If nothing has changed since the base revision, we're done
110
113
        return []
111
 
    file_id = lookup_file_id(osutils.safe_unicode(path))
 
114
    file_id = lookup_file_id(decoded_path)
112
115
    if stat.S_ISLNK(mode):
113
116
        cls = InventoryLink
114
117
    else:
117
120
    if ie.kind == "file":
118
121
        ie.executable = mode_is_executable(mode)
119
122
    if base_hexsha == hexsha and mode_kind(base_mode) == mode_kind(mode):
120
 
        base_exec = base_bzr_tree.is_executable(path)
 
123
        base_exec = base_bzr_tree.is_executable(decoded_path)
121
124
        if ie.kind == "symlink":
122
 
            ie.symlink_target = base_bzr_tree.get_symlink_target(path)
 
125
            ie.symlink_target = base_bzr_tree.get_symlink_target(decoded_path)
123
126
        else:
124
 
            ie.text_size = base_bzr_tree.get_file_size(path)
125
 
            ie.text_sha1 = base_bzr_tree.get_file_sha1(path)
 
127
            ie.text_size = base_bzr_tree.get_file_size(decoded_path)
 
128
            ie.text_sha1 = base_bzr_tree.get_file_sha1(decoded_path)
126
129
        if ie.kind == "symlink" or ie.executable == base_exec:
127
 
            ie.revision = base_bzr_tree.get_file_revision(path)
 
130
            ie.revision = base_bzr_tree.get_file_revision(decoded_path)
128
131
        else:
129
132
            blob = lookup_object(hexsha)
130
133
    else:
139
142
    parent_keys = []
140
143
    for ptree in parent_bzr_trees:
141
144
        try:
142
 
            ppath = ptree.id2path(file_id)
143
 
        except errors.NoSuchId:
 
145
            ppaths = base_bzr_tree.find_related_paths_across_trees([decoded_path], trees=[ptree])
 
146
        except errors.PathsNotVersionedError:
144
147
            continue
 
148
        ppath = ppaths.pop()
145
149
        pkind = ptree.kind(ppath, file_id)
146
150
        if (pkind == ie.kind and
147
151
            ((pkind == "symlink" and ptree.get_symlink_target(ppath, file_id) == ie.symlink_target) or
167
171
                tuple(parent_keys), ie.text_sha1, chunks)])
168
172
    invdelta = []
169
173
    if base_hexsha is not None:
170
 
        old_path = path.decode("utf-8") # Renames are not supported yet
 
174
        old_path = decoded_path # Renames are not supported yet
171
175
        if stat.S_ISDIR(base_mode):
172
176
            invdelta.extend(remove_disappeared_children(base_bzr_tree, old_path,
173
177
                lookup_object(base_hexsha), [], lookup_object))
174
178
    else:
175
179
        old_path = None
176
 
    new_path = path.decode("utf-8")
177
 
    invdelta.append((old_path, new_path, file_id, ie))
 
180
    invdelta.append((old_path, decoded_path, file_id, ie))
178
181
    if base_hexsha != hexsha:
179
182
        store_updater.add_object(blob, (ie.file_id, ie.revision), path)
180
183
    return invdelta