~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

545ms, 600ms: Switch memory model from storing kind to using minikind
Need to profile effect on _generate_inventory, but makes a significant improvement for
both fast path and slow path, and should have minimal effect elsewhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
        state._read_dirblocks_if_needed()
234
234
        root_key, current_entry = self._get_entry(path='')
235
235
        current_id = root_key[2]
236
 
        assert current_entry[0][0] == 'directory'
 
236
        assert current_entry[0][0] == 'd' # directory
237
237
        inv = Inventory(root_id=current_id)
238
238
        # we could do this straight out of the dirstate; it might be fast
239
239
        # and should be profiled - RBC 20070216
246
246
                # all the paths in this block are not versioned in this tree
247
247
                continue
248
248
            for key, entry in block[1]:
249
 
                if entry[0][0] in ('absent', 'relocated'):
 
249
                if entry[0][0] in ('a', 'r'): # absent, relocated
250
250
                    # a parent tree only entry
251
251
                    continue
252
252
                name = key[1]
253
253
                name_unicode = name.decode('utf8')
254
254
                file_id = key[2]
255
 
                kind, link_or_sha1, size, executable, stat = entry[0]
 
255
                minikind, link_or_sha1, size, executable, stat = entry[0]
 
256
                kind = dirstate.DirState._minikind_to_kind[minikind]
256
257
                inv_entry = entry_factory[kind](file_id, name_unicode, parent_id)
257
258
                if kind == 'file':
258
259
                    # not strictly needed: working tree
342
343
        """
343
344
        result = []
344
345
        for key, tree_details in self.current_dirstate()._iter_entries():
345
 
            if tree_details[0][0] in ('absent', 'relocated'):
 
346
            if tree_details[0][0] in ('a', 'r'): # absent, relocated
346
347
                # not relevant to the working tree
347
348
                continue
348
349
            path = pathjoin(self.basedir, key[0].decode('utf8'), key[1].decode('utf8'))
397
398
            raise errors.BzrMoveFailedError('',to_dir,
398
399
                errors.NotADirectory(to_abs))
399
400
 
400
 
        if to_entry[1][0][0] != 'directory':
 
401
        if to_entry[1][0][0] != 'd':
401
402
            raise errors.BzrMoveFailedError('',to_dir,
402
403
                errors.NotADirectory(to_abs))
403
404
 
494
495
                from_key = old_block[old_entry_index][0]
495
496
                to_key = ((to_block[0],) + from_key[1:3])
496
497
                state._make_absent(old_block[old_entry_index])
 
498
                minikind = old_entry_details[0][0]
 
499
                kind = dirstate.DirState._minikind_to_kind[minikind]
497
500
                rollbacks.append(
498
501
                    lambda:state.update_minimal(from_key,
499
 
                        old_entry_details[0][0],
 
502
                        kind,
500
503
                        num_present_parents=len(old_entry_details) - 1,
501
504
                        executable=old_entry_details[0][3],
502
505
                        fingerprint=old_entry_details[0][1],
506
509
                        path_utf8=from_rel.encode('utf8')))
507
510
                # create new row in current block
508
511
                state.update_minimal(to_key,
509
 
                        old_entry_details[0][0],
 
512
                        kind,
510
513
                        num_present_parents=len(old_entry_details) - 1,
511
514
                        executable=old_entry_details[0][3],
512
515
                        fingerprint=old_entry_details[0][1],
517
520
                added_entry_index, _ = state._find_entry_index(to_key, to_block[1])
518
521
                new_entry = to_block[added_entry_index]
519
522
                rollbacks.append(lambda:state._make_absent(new_entry))
520
 
                if new_entry[1][0][0] == 'directory':
 
523
                if new_entry[1][0][0] == 'd':
521
524
                    import pdb;pdb.set_trace()
522
525
                    # if a directory, rename all the contents of child blocks
523
526
                    # adding rollbacks as each is inserted to remove them and
604
607
                for entry in path_entries:
605
608
                    # for each tree.
606
609
                    for index in search_indexes:
607
 
                        if entry[1][index][0] != 'absent':
 
610
                        if entry[1][index][0] != 'a': # absent
608
611
                            found_versioned = True
609
612
                            # all good: found a versioned cell
610
613
                            break
611
614
                if not found_versioned:
612
 
                    # non of the indexes was not 'absent' at all ids for this
 
615
                    # none of the indexes was not 'absent' at all ids for this
613
616
                    # path.
614
617
                    all_versioned = False
615
618
                    break
637
640
            nothing. Otherwise add the id to found_ids.
638
641
            """
639
642
            for index in search_indexes:
640
 
                if entry[1][index][0] == 'relocated':
 
643
                if entry[1][index][0] == 'r': # relocated
641
644
                    if not osutils.is_inside_any(searched_paths, entry[1][index][1]):
642
645
                        search_paths.add(entry[1][index][1])
643
 
                elif entry[1][index][0] != 'absent':
 
646
                elif entry[1][index][0] != 'a': # absent
644
647
                    found_ids.add(entry[0][2])
645
648
        while search_paths:
646
649
            current_root = search_paths.pop()
800
803
        # walk the state marking unversioned things as absent.
801
804
        # if there are any un-unversioned ids at the end, raise
802
805
        for key, details in state._dirblocks[0][1]:
803
 
            if (details[0][0] not in ('absent', 'relocated') and
 
806
            if (details[0][0] not in ('a', 'r') and # absent or relocated
804
807
                key[2] in ids_to_unversion):
805
808
                # I haven't written the code to unversion / yet - it should be
806
809
                # supported.
836
839
            entry_index = 0
837
840
            while entry_index < len(block[1]):
838
841
                entry = block[1][entry_index]
839
 
                if (entry[1][0][0] in ('absent', 'relocated') or
 
842
                if (entry[1][0][0] in ('a', 'r') or # absent, relocated
840
843
                    # ^ some parent row.
841
844
                    entry[0][2] not in ids_to_unversion):
842
845
                    # ^ not an id to unversion
843
846
                    entry_index += 1
844
847
                    continue
845
 
                if entry[1][0][0] == 'directory':
 
848
                if entry[1][0][0] == 'd':
846
849
                    paths_to_unversion.add(os.path.join(*entry[0][0:2]))
847
850
                if not state._make_absent(entry):
848
851
                    entry_index += 1
1010
1013
        # for the tree index use.
1011
1014
        root_key, current_entry = self._dirstate._get_entry(parent_index, path_utf8='')
1012
1015
        current_id = root_key[2]
1013
 
        assert current_entry[parent_index][0] == 'directory'
 
1016
        assert current_entry[parent_index][0] == 'd'
1014
1017
        inv = Inventory(root_id=current_id, revision_id=self._revision_id)
1015
1018
        inv.root.revision = current_entry[parent_index][4]
1016
1019
        # we could do this straight out of the dirstate; it might be fast
1024
1027
                # all the paths in this block are not versioned in this tree
1025
1028
                continue
1026
1029
            for key, entry in block[1]:
1027
 
                if entry[parent_index][0] in ('absent', 'relocated'):
 
1030
                if entry[parent_index][0] in ('a', 'r'): # absent, relocated
1028
1031
                    # not this tree
1029
1032
                    continue
1030
1033
                name = key[1]
1031
1034
                name_unicode = name.decode('utf8')
1032
1035
                file_id = key[2]
1033
 
                kind, link_or_sha1, size, executable, revid = entry[parent_index]
 
1036
                minikind, link_or_sha1, size, executable, revid = entry[parent_index]
 
1037
                kind = dirstate.DirState._minikind_to_kind[minikind]
1034
1038
                inv_entry = entry_factory[kind](file_id, name_unicode, parent_id)
1035
1039
                inv_entry.revision = revid
1036
1040
                if kind == 'file':