~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

(John Arbash Meinel) Update dirstate._iter_changes to return unicode for all paths (bug #92608)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1643
1643
            output. An unversioned file is defined as one with (False, False)
1644
1644
            for the versioned pair.
1645
1645
        """
1646
 
        utf8_decode = cache_utf8._utf8_decode_with_None
 
1646
        utf8_decode_or_none = cache_utf8._utf8_decode_with_None
1647
1647
        _minikind_to_kind = dirstate.DirState._minikind_to_kind
1648
1648
        # NB: show_status depends on being able to pass in non-versioned files
1649
1649
        # and report them as unknown
1983
1983
            # TODO: the pending list should be lexically sorted?  the
1984
1984
            # interface doesn't require it.
1985
1985
            current_root = search_specific_files.pop()
 
1986
            current_root_unicode = current_root.decode('utf8')
1986
1987
            searched_specific_files.add(current_root)
1987
1988
            # process the entries for this containing directory: the rest will be
1988
1989
            # found by their parents recursively.
1989
1990
            root_entries = _entries_for_path(current_root)
1990
 
            root_abspath = self.target.abspath(current_root)
 
1991
            root_abspath = self.target.abspath(current_root_unicode)
1991
1992
            try:
1992
1993
                root_stat = os.lstat(root_abspath)
1993
1994
            except OSError, e:
2025
2026
                        or result[6][0] != result[6][1] # kind
2026
2027
                        or result[7][0] != result[7][1] # executable
2027
2028
                        ):
2028
 
                        result = (result[0],
2029
 
                            ((utf8_decode(result[1][0])[0]),
2030
 
                             utf8_decode(result[1][1])[0]),) + result[2:]
2031
 
                        yield result
2032
 
            if want_unversioned and not path_handled:
 
2029
                        yield (result[0],
 
2030
                               (utf8_decode_or_none(result[1][0]),
 
2031
                                utf8_decode_or_none(result[1][1])),
 
2032
                               result[2],
 
2033
                               result[3],
 
2034
                               result[4],
 
2035
                               (utf8_decode_or_none(result[5][0]),
 
2036
                                utf8_decode_or_none(result[5][1])),
 
2037
                               result[6],
 
2038
                               result[7],
 
2039
                              )
 
2040
            if want_unversioned and not path_handled and root_dir_info:
2033
2041
                new_executable = bool(
2034
2042
                    stat.S_ISREG(root_dir_info[3].st_mode)
2035
2043
                    and stat.S_IEXEC & root_dir_info[3].st_mode)
2036
 
                yield (None, (None, current_root), True, (False, False),
2037
 
                    (None, None),
2038
 
                    (None, splitpath(current_root)[-1]),
2039
 
                    (None, root_dir_info[2]), (None, new_executable))
 
2044
                yield (None,
 
2045
                       (None, current_root_unicode),
 
2046
                       True,
 
2047
                       (False, False),
 
2048
                       (None, None),
 
2049
                       (None, splitpath(current_root_unicode)[-1]),
 
2050
                       (None, root_dir_info[2]),
 
2051
                       (None, new_executable)
 
2052
                      )
2040
2053
            initial_key = (current_root, '', '')
2041
2054
            block_index, _ = state._find_block_index_from_key(initial_key)
2042
2055
            if block_index == 0:
2111
2124
                                    or result[6][0] != result[6][1] # kind
2112
2125
                                    or result[7][0] != result[7][1] # executable
2113
2126
                                    ):
2114
 
                                    result = (result[0],
2115
 
                                        ((utf8_decode(result[1][0])[0]),
2116
 
                                         utf8_decode(result[1][1])[0]),) + result[2:]
2117
 
                                    yield result
 
2127
                                    yield (result[0],
 
2128
                                           (utf8_decode_or_none(result[1][0]),
 
2129
                                            utf8_decode_or_none(result[1][1])),
 
2130
                                           result[2],
 
2131
                                           result[3],
 
2132
                                           result[4],
 
2133
                                           (utf8_decode_or_none(result[5][0]),
 
2134
                                            utf8_decode_or_none(result[5][1])),
 
2135
                                           result[6],
 
2136
                                           result[7],
 
2137
                                          )
2118
2138
                        block_index +=1
2119
2139
                        if (block_index < len(state._dirblocks) and
2120
2140
                            osutils.is_inside(current_root,
2161
2181
                                or result[6][0] != result[6][1] # kind
2162
2182
                                or result[7][0] != result[7][1] # executable
2163
2183
                                ):
2164
 
                                result = (result[0],
2165
 
                                    ((utf8_decode(result[1][0])[0]),
2166
 
                                     utf8_decode(result[1][1])[0]),) + result[2:]
2167
 
                                yield result
 
2184
                                yield (result[0],
 
2185
                                       (utf8_decode_or_none(result[1][0]),
 
2186
                                        utf8_decode_or_none(result[1][1])),
 
2187
                                       result[2],
 
2188
                                       result[3],
 
2189
                                       result[4],
 
2190
                                       (utf8_decode_or_none(result[5][0]),
 
2191
                                        utf8_decode_or_none(result[5][1])),
 
2192
                                       result[6],
 
2193
                                       result[7],
 
2194
                                      )
2168
2195
                    elif current_entry[0][1] != current_path_info[1]:
2169
2196
                        if current_path_info[1] < current_entry[0][1]:
2170
2197
                            # extra file on disk: pass for now, but only
2186
2213
                                    or result[6][0] != result[6][1] # kind
2187
2214
                                    or result[7][0] != result[7][1] # executable
2188
2215
                                    ):
2189
 
                                    result = (result[0],
2190
 
                                        ((utf8_decode(result[1][0])[0]),
2191
 
                                         utf8_decode(result[1][1])[0]),) + result[2:]
2192
 
                                    yield result
 
2216
                                    yield (result[0],
 
2217
                                           (utf8_decode_or_none(result[1][0]),
 
2218
                                            utf8_decode_or_none(result[1][1])),
 
2219
                                           result[2],
 
2220
                                           result[3],
 
2221
                                           result[4],
 
2222
                                           (utf8_decode_or_none(result[5][0]),
 
2223
                                            utf8_decode_or_none(result[5][1])),
 
2224
                                           result[6],
 
2225
                                           result[7],
 
2226
                                          )
2193
2227
                            advance_path = False
2194
2228
                    else:
2195
2229
                        for result in _process_entry(current_entry, current_path_info):
2205
2239
                                or result[6][0] != result[6][1] # kind
2206
2240
                                or result[7][0] != result[7][1] # executable
2207
2241
                                ):
2208
 
                                result = (result[0],
2209
 
                                    ((utf8_decode(result[1][0])[0]),
2210
 
                                     utf8_decode(result[1][1])[0]),) + result[2:]
2211
 
                                yield result
 
2242
                                yield (result[0],
 
2243
                                       (utf8_decode_or_none(result[1][0]),
 
2244
                                        utf8_decode_or_none(result[1][1])),
 
2245
                                       result[2],
 
2246
                                       result[3],
 
2247
                                       result[4],
 
2248
                                       (utf8_decode_or_none(result[5][0]),
 
2249
                                        utf8_decode_or_none(result[5][1])),
 
2250
                                       result[6],
 
2251
                                       result[7],
 
2252
                                      )
2212
2253
                    if advance_entry and current_entry is not None:
2213
2254
                        entry_index += 1
2214
2255
                        if entry_index < len(current_block[1]):
2225
2266
                                    stat.S_ISREG(current_path_info[3].st_mode)
2226
2267
                                    and stat.S_IEXEC & current_path_info[3].st_mode)
2227
2268
                                if want_unversioned:
2228
 
                                    yield (None, (None, current_path_info[0]),
 
2269
                                    yield (None,
 
2270
                                        (None, utf8_decode_or_none(current_path_info[0])),
2229
2271
                                        True,
2230
2272
                                        (False, False),
2231
2273
                                        (None, None),
2232
 
                                        (None, current_path_info[1]),
 
2274
                                        (None, utf8_decode_or_none(current_path_info[1])),
2233
2275
                                        (None, current_path_info[2]),
2234
2276
                                        (None, new_executable))
2235
2277
                            # dont descend into this unversioned path if it is