/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/workingtree_4.py

  • Committer: Breezy landing bot
  • Author(s): Martin
  • Date: 2017-06-10 02:49:30 UTC
  • mfrom: (6677.1.4 py3_bootstrap)
  • Revision ID: breezy.the.bot@gmail.com-20170610024930-enw8wdbjy9s4dtnm
Progress on Python 3 to get TestCaseWithTransport working

Merged from https://code.launchpad.net/~gz/brz/py3_bootstrap/+merge/325439

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        """See MutableTree._add."""
131
131
        state = self.current_dirstate()
132
132
        for f, file_id, kind in zip(files, ids, kinds):
133
 
            f = f.strip('/')
 
133
            f = f.strip(b'/')
134
134
            if self.path2id(f):
135
135
                # special case tree root handling.
136
 
                if f == '' and self.path2id(f) == ROOT_ID:
137
 
                    state.set_path_id('', generate_ids.gen_file_id(f))
 
136
                if f == b'' and self.path2id(f) == ROOT_ID:
 
137
                    state.set_path_id(b'', generate_ids.gen_file_id(f))
138
138
                continue
139
139
            if file_id is None:
140
140
                file_id = generate_ids.gen_file_id(f)
141
141
            # deliberately add the file with no cached stat or sha1
142
142
            # - on the first access it will be gathered, and we can
143
143
            # always change this once tests are all passing.
144
 
            state.add(f, file_id, kind, None, '')
 
144
            state.add(f, file_id, kind, None, b'')
145
145
        self._make_dirty(reset_inventory=True)
146
146
 
147
147
    def _get_check_refs(self):
312
312
        state._read_dirblocks_if_needed()
313
313
        root_key, current_entry = self._get_entry(path='')
314
314
        current_id = root_key[2]
315
 
        if not (current_entry[0][0] == 'd'): # directory
 
315
        if not (current_entry[0][0] == b'd'): # directory
316
316
            raise AssertionError(current_entry)
317
317
        inv = Inventory(root_id=current_id)
318
318
        # Turn some things into local variables
332
332
                continue
333
333
            for key, entry in block[1]:
334
334
                minikind, link_or_sha1, size, executable, stat = entry[0]
335
 
                if minikind in ('a', 'r'): # absent, relocated
 
335
                if minikind in (b'a', b'r'): # absent, relocated
336
336
                    # a parent tree only entry
337
337
                    continue
338
338
                name = key[1]
350
350
                    #inv_entry.text_sha1 = sha1
351
351
                elif kind == 'directory':
352
352
                    # add this entry to the parent map.
353
 
                    parent_ies[(dirname + '/' + name).strip('/')] = inv_entry
 
353
                    parent_ies[(dirname + b'/' + name).strip(b'/')] = inv_entry
354
354
                elif kind == 'tree-reference':
355
355
                    if not self._repo_supports_tree_reference:
356
356
                        raise errors.UnsupportedOperation(
408
408
                    raise
409
409
        link_or_sha1 = dirstate.update_entry(state, entry, file_abspath,
410
410
            stat_value=stat_value)
411
 
        if entry[1][0][0] == 'f':
 
411
        if entry[1][0][0] == b'f':
412
412
            if link_or_sha1 is None:
413
413
                file_obj, statvalue = self.get_file_with_stat(file_id, path)
414
414
                try:
509
509
        self._must_be_locked()
510
510
        result = set()
511
511
        for key, tree_details in self.current_dirstate()._iter_entries():
512
 
            if tree_details[0][0] in ('a', 'r'): # relocated
 
512
            if tree_details[0][0] in (b'a', b'r'): # relocated
513
513
                continue
514
514
            result.add(key[2])
515
515
        return result
523
523
        """
524
524
        result = []
525
525
        for key, tree_details in self.current_dirstate()._iter_entries():
526
 
            if tree_details[0][0] in ('a', 'r'): # absent, relocated
 
526
            if tree_details[0][0] in (b'a', b'r'): # absent, relocated
527
527
                # not relevant to the working tree
528
528
                continue
529
529
            path = pathjoin(self.basedir, key[0].decode('utf8'), key[1].decode('utf8'))
537
537
            # return
538
538
            return
539
539
        for key, tree_details in self.current_dirstate()._iter_entries():
540
 
            if tree_details[0][0] in ('a', 'r'): # absent, relocated
 
540
            if tree_details[0][0] in (b'a', b'r'): # absent, relocated
541
541
                # not relevant to the working tree
542
542
                continue
543
543
            if not key[1]:
577
577
        if (self._repo_supports_tree_reference and kind == 'directory'):
578
578
            entry = self._get_entry(path=relpath)
579
579
            if entry[1] is not None:
580
 
                if entry[1][0][0] == 't':
 
580
                if entry[1][0][0] == b't':
581
581
                    kind = 'tree-reference'
582
582
        return kind
583
583
 
804
804
                         to_key=to_key,
805
805
                         to_path_utf8=to_rel_utf8)
806
806
 
807
 
                if minikind == 'd':
 
807
                if minikind == b'd':
808
808
                    def update_dirblock(from_dir, to_key, to_dir_utf8):
809
809
                        """Recursively update all entries in this dirblock."""
810
 
                        if from_dir == '':
 
810
                        if from_dir == b'':
811
811
                            raise AssertionError("renaming root not supported")
812
812
                        from_key = (from_dir, '')
813
813
                        from_block_idx, present = \
834
834
                            from_path_utf8 = osutils.pathjoin(entry[0][0], entry[0][1])
835
835
                            to_path_utf8 = osutils.pathjoin(to_dir_utf8, entry[0][1])
836
836
                            minikind = cur_details[0]
837
 
                            if minikind in 'ar':
 
837
                            if minikind in (b'a', b'r'):
838
838
                                # Deleted children of a renamed directory
839
839
                                # Do not need to be updated.
840
840
                                # Children that have been renamed out of this
849
849
                                     to_block=to_block,
850
850
                                     to_key=to_key,
851
851
                                     to_path_utf8=to_path_utf8)
852
 
                            if minikind == 'd':
 
852
                            if minikind == b'd':
853
853
                                # We need to move all the children of this
854
854
                                # entry
855
855
                                update_dirblock(from_path_utf8, to_key,
909
909
        # -- get the state object and prepare it.
910
910
        state = self.current_dirstate()
911
911
        if False and (state._dirblock_state == dirstate.DirState.NOT_IN_MEMORY
912
 
            and '' not in paths):
 
912
            and b'' not in paths):
913
913
            paths2ids = self._paths2ids_using_bisect
914
914
        else:
915
915
            paths2ids = self._paths2ids_in_memory
924
924
            """Return a list with all the entries that match path for all ids.
925
925
            """
926
926
            dirname, basename = os.path.split(path)
927
 
            key = (dirname, basename, '')
 
927
            key = (dirname, basename, b'')
928
928
            block_index, present = state._find_block_index_from_key(key)
929
929
            if not present:
930
930
                # the block which should contain path is absent.
952
952
                for entry in path_entries:
953
953
                    # for each tree.
954
954
                    for index in search_indexes:
955
 
                        if entry[1][index][0] != 'a': # absent
 
955
                        if entry[1][index][0] != b'a': # absent
956
956
                            found_versioned = True
957
957
                            # all good: found a versioned cell
958
958
                            break
981
981
            nothing. Otherwise add the id to found_ids.
982
982
            """
983
983
            for index in search_indexes:
984
 
                if entry[1][index][0] == 'r': # relocated
 
984
                if entry[1][index][0] == b'r': # relocated
985
985
                    if not osutils.is_inside_any(searched_paths, entry[1][index][1]):
986
986
                        search_paths.add(entry[1][index][1])
987
 
                elif entry[1][index][0] != 'a': # absent
 
987
                elif entry[1][index][0] != b'a': # absent
988
988
                    found_ids.add(entry[0][2])
989
989
        while search_paths:
990
990
            current_root = search_paths.pop()
997
997
                continue
998
998
            for entry in root_entries:
999
999
                _process_entry(entry)
1000
 
            initial_key = (current_root, '', '')
 
1000
            initial_key = (current_root, b'', b'')
1001
1001
            block_index, _ = state._find_block_index_from_key(initial_key)
1002
1002
            while (block_index < len(state._dirblocks) and
1003
1003
                osutils.is_inside(current_root, state._dirblocks[block_index][0])):
1023
1023
 
1024
1024
        for dir_name_id, trees_info in viewitems(found):
1025
1025
            for index in search_indexes:
1026
 
                if trees_info[index][0] not in ('r', 'a'):
 
1026
                if trees_info[index][0] not in (b'r', b'a'):
1027
1027
                    found_ids.add(dir_name_id[2])
1028
1028
        return found_ids
1029
1029
 
1157
1157
    def _set_root_id(self, file_id):
1158
1158
        """See WorkingTree.set_root_id."""
1159
1159
        state = self.current_dirstate()
1160
 
        state.set_path_id('', file_id)
 
1160
        state.set_path_id(b'', file_id)
1161
1161
        if state._dirblock_state == dirstate.DirState.IN_MEMORY_MODIFIED:
1162
1162
            self._make_dirty(reset_inventory=True)
1163
1163
 
1666
1666
 
1667
1667
    def _init_custom_control_files(self, wt):
1668
1668
        """Subclasses with custom control files should override this method."""
1669
 
        wt._transport.put_bytes('views', '', mode=wt.bzrdir._get_file_mode())
 
1669
        wt._transport.put_bytes('views', b'', mode=wt.bzrdir._get_file_mode())
1670
1670
 
1671
1671
    def supports_content_filtering(self):
1672
1672
        return True
1794
1794
        # for the tree index use.
1795
1795
        root_key, current_entry = self._dirstate._get_entry(parent_index, path_utf8='')
1796
1796
        current_id = root_key[2]
1797
 
        if current_entry[parent_index][0] != 'd':
 
1797
        if current_entry[parent_index][0] != b'd':
1798
1798
            raise AssertionError()
1799
1799
        inv = Inventory(root_id=current_id, revision_id=self._revision_id)
1800
1800
        inv.root.revision = current_entry[parent_index][4]
1815
1815
                continue
1816
1816
            for key, entry in block[1]:
1817
1817
                minikind, fingerprint, size, executable, revid = entry[parent_index]
1818
 
                if minikind in ('a', 'r'): # absent, relocated
 
1818
                if minikind in (b'a', b'r'): # absent, relocated
1819
1819
                    # not this tree
1820
1820
                    continue
1821
1821
                name = key[1]
1830
1830
                    inv_entry.text_size = size
1831
1831
                    inv_entry.text_sha1 = fingerprint
1832
1832
                elif kind == 'directory':
1833
 
                    parent_ies[(dirname + '/' + name).strip('/')] = inv_entry
 
1833
                    parent_ies[(dirname + b'/' + name).strip(b'/')] = inv_entry
1834
1834
                elif kind == 'symlink':
1835
1835
                    inv_entry.symlink_target = utf8_decode(fingerprint)[0]
1836
1836
                elif kind == 'tree-reference':
1870
1870
        entry = self._get_entry(file_id=file_id, path=path)
1871
1871
        parent_index = self._get_parent_index()
1872
1872
        parent_details = entry[1][parent_index]
1873
 
        if parent_details[0] == 'f':
 
1873
        if parent_details[0] == b'f':
1874
1874
            return parent_details[1]
1875
1875
        return None
1876
1876
 
1922
1922
    def get_symlink_target(self, file_id, path=None):
1923
1923
        entry = self._get_entry(file_id=file_id)
1924
1924
        parent_index = self._get_parent_index()
1925
 
        if entry[1][parent_index][0] != 'l':
 
1925
        if entry[1][parent_index][0] != b'l':
1926
1926
            return None
1927
1927
        else:
1928
1928
            target = entry[1][parent_index][1]
2188
2188
                specific_files_utf8.add(path.encode('utf8'))
2189
2189
            specific_files = specific_files_utf8
2190
2190
        else:
2191
 
            specific_files = {''}
 
2191
            specific_files = {b''}
2192
2192
        # -- specific_files is now a utf8 path set --
2193
2193
 
2194
2194
        # -- get the state object and prepare it.
2208
2208
                for entry in path_entries:
2209
2209
                    # for each tree.
2210
2210
                    for index in indices:
2211
 
                        if entry[1][index][0] != 'a': # absent
 
2211
                        if entry[1][index][0] != b'a': # absent
2212
2212
                            found_versioned = True
2213
2213
                            # all good: found a versioned cell
2214
2214
                            break
2334
2334
 
2335
2335
    def init_custom_control_files(self, tree):
2336
2336
        """Initialize custom control files."""
2337
 
        tree._transport.put_bytes('views', '',
 
2337
        tree._transport.put_bytes('views', b'',
2338
2338
            mode=tree.bzrdir._get_file_mode())
2339
2339
 
2340
2340
    def update_format(self, tree):