/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/bzr/dirstate.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
 
219
219
"""
220
220
 
 
221
from __future__ import absolute_import
 
222
 
221
223
import bisect
222
 
import contextlib
223
224
import errno
224
225
import operator
225
226
import os
234
235
    )
235
236
from .. import (
236
237
    cache_utf8,
 
238
    cleanup,
237
239
    config,
238
240
    debug,
239
241
    errors,
243
245
    trace,
244
246
    urlutils,
245
247
    )
246
 
from .inventorytree import InventoryTreeChange
 
248
from ..sixish import (
 
249
    range,
 
250
    text_type,
 
251
    viewitems,
 
252
    viewvalues,
 
253
    )
 
254
from ..tree import TreeChange
247
255
 
248
256
 
249
257
# This is the Windows equivalent of ENOTDIR
493
501
        # you should never have files called . or ..; just add the directory
494
502
        # in the parent, or according to the special treatment for the root
495
503
        if basename == '.' or basename == '..':
496
 
            raise inventory.InvalidEntryName(path)
 
504
            raise errors.InvalidEntryName(path)
497
505
        # now that we've normalised, we need the correct utf8 path and
498
506
        # dirname and basename elements. This single encode and split should be
499
507
        # faster than three separate encodes.
991
999
            # Directories that need to be read
992
1000
            pending_dirs = set()
993
1001
            paths_to_search = set()
994
 
            for entry_list in newly_found.values():
 
1002
            for entry_list in viewvalues(newly_found):
995
1003
                for dir_name_id, trees_info in entry_list:
996
1004
                    found[dir_name_id] = trees_info
997
1005
                    found_dir_names.add(dir_name_id[:2])
1304
1312
        result = DirState.initialize(dir_state_filename,
1305
1313
                                     sha1_provider=sha1_provider)
1306
1314
        try:
1307
 
            with contextlib.ExitStack() as exit_stack:
 
1315
            with cleanup.ExitStack() as exit_stack:
1308
1316
                exit_stack.enter_context(tree.lock_read())
1309
1317
                parent_ids = tree.get_parent_ids()
1310
1318
                num_parents = len(parent_ids)
1415
1423
                                               fingerprint, new_child_path)
1416
1424
        self._check_delta_ids_absent(new_ids, delta, 0)
1417
1425
        try:
1418
 
            self._apply_removals(removals.items())
1419
 
            self._apply_insertions(insertions.values())
 
1426
            self._apply_removals(viewitems(removals))
 
1427
            self._apply_insertions(viewvalues(insertions))
1420
1428
            # Validate parents
1421
1429
            self._after_delta_check_parents(parents, 0)
1422
1430
        except errors.BzrError as e:
1956
1964
        #       higher level, because there either won't be anything on disk,
1957
1965
        #       or the thing on disk will be a file.
1958
1966
        fs_encoding = osutils._fs_enc
1959
 
        if isinstance(abspath, str):
 
1967
        if isinstance(abspath, text_type):
1960
1968
            # abspath is defined as the path to pass to lstat. readlink is
1961
1969
            # buggy in python < 2.6 (it doesn't encode unicode path into FS
1962
1970
            # encoding), so we need to encode ourselves knowing that unicode
2760
2768
        # --- end generation of full tree mappings
2761
2769
 
2762
2770
        # sort and output all the entries
2763
 
        new_entries = self._sort_entries(by_path.items())
 
2771
        new_entries = self._sort_entries(viewitems(by_path))
2764
2772
        self._entries_to_current_state(new_entries)
2765
2773
        self._parents = [rev_id for rev_id, tree in trees]
2766
2774
        self._ghosts = list(ghosts)
3340
3348
                raise AssertionError(
3341
3349
                    "entry %r has no data for any tree." % (entry,))
3342
3350
        if self._id_index is not None:
3343
 
            for file_id, entry_keys in self._id_index.items():
 
3351
            for file_id, entry_keys in viewitems(self._id_index):
3344
3352
                for entry_key in entry_keys:
3345
3353
                    # Check that the entry in the map is pointing to the same
3346
3354
                    # file_id
3759
3767
                    else:
3760
3768
                        path_u = self.utf8_decode(path)[0]
3761
3769
                source_kind = DirState._minikind_to_kind[source_minikind]
3762
 
                return InventoryTreeChange(
 
3770
                return TreeChange(
3763
3771
                    entry[0][2],
3764
3772
                    (old_path_u, path_u),
3765
3773
                    content_change,
3788
3796
                        and stat.S_IEXEC & path_info[3].st_mode)
3789
3797
                else:
3790
3798
                    target_exec = target_details[3]
3791
 
                return InventoryTreeChange(
 
3799
                return TreeChange(
3792
3800
                    entry[0][2],
3793
3801
                    (None, self.utf8_decode(path)[0]),
3794
3802
                    True,
3799
3807
                    (None, target_exec)), True
3800
3808
            else:
3801
3809
                # Its a missing file, report it as such.
3802
 
                return InventoryTreeChange(
 
3810
                return TreeChange(
3803
3811
                    entry[0][2],
3804
3812
                    (None, self.utf8_decode(path)[0]),
3805
3813
                    False,
3819
3827
                self.source_index, path_utf8=entry[0][0])[0][2]
3820
3828
            if parent_id == entry[0][2]:
3821
3829
                parent_id = None
3822
 
            return InventoryTreeChange(
 
3830
            return TreeChange(
3823
3831
                entry[0][2],
3824
3832
                (self.utf8_decode(old_path)[0], None),
3825
3833
                True,
3961
3969
                new_executable = bool(
3962
3970
                    stat.S_ISREG(root_dir_info[3].st_mode)
3963
3971
                    and stat.S_IEXEC & root_dir_info[3].st_mode)
3964
 
                yield InventoryTreeChange(
 
3972
                yield TreeChange(
3965
3973
                    None,
3966
3974
                    (None, current_root_unicode),
3967
3975
                    True,
4044
4052
                                new_executable = bool(
4045
4053
                                    stat.S_ISREG(current_path_info[3].st_mode)
4046
4054
                                    and stat.S_IEXEC & current_path_info[3].st_mode)
4047
 
                                yield InventoryTreeChange(
 
4055
                                yield TreeChange(
4048
4056
                                    None,
4049
4057
                                    (None, utf8_decode(current_path_info[0])[0]),
4050
4058
                                    True,
4180
4188
                                except UnicodeDecodeError:
4181
4189
                                    raise errors.BadFilenameEncoding(
4182
4190
                                        current_path_info[0], osutils._fs_enc)
4183
 
                                yield InventoryTreeChange(
 
4191
                                yield TreeChange(
4184
4192
                                    None,
4185
4193
                                    (None, relpath_unicode),
4186
4194
                                    True,