~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-06 14:42:00 UTC
  • mfrom: (2511.1.4 bzr.fast-commit)
  • Revision ID: pqm@pqm.ubuntu.com-20070606144200-rmsd3gyelimh8kal
(Ian Clatworthy) Improve 'bzr commit' time by removing some lock and dirstate._validate() calls

Show diffs side-by-side

added added

removed removed

Lines of Context:
472
472
 
473
473
    @needs_read_lock
474
474
    def id2path(self, file_id):
 
475
        "Convert a file-id to a path."
475
476
        file_id = osutils.safe_file_id(file_id)
476
477
        state = self.current_dirstate()
477
478
        entry = self._get_entry(file_id=file_id)
481
482
        return path_utf8.decode('utf8')
482
483
 
483
484
    if not osutils.supports_executable():
484
 
        @needs_read_lock
485
485
        def is_executable(self, file_id, path=None):
 
486
            """Test if a file is executable or not.
 
487
 
 
488
            Note: The caller is expected to take a read-lock before calling this.
 
489
            """
486
490
            file_id = osutils.safe_file_id(file_id)
487
491
            entry = self._get_entry(file_id=file_id, path=path)
488
492
            if entry == (None, None):
489
493
                return False
490
494
            return entry[1][0][3]
491
495
    else:
492
 
        @needs_read_lock
493
496
        def is_executable(self, file_id, path=None):
 
497
            """Test if a file is executable or not.
 
498
 
 
499
            Note: The caller is expected to take a read-lock before calling this.
 
500
            """
494
501
            if not path:
495
502
                file_id = osutils.safe_file_id(file_id)
496
503
                path = self.id2path(file_id)
530
537
                # path is missing on disk.
531
538
                continue
532
539
 
533
 
    @needs_read_lock
534
540
    def kind(self, file_id):
535
541
        """Return the kind of a file.
536
542
 
537
543
        This is always the actual kind that's on disk, regardless of what it
538
544
        was added as.
 
545
 
 
546
        Note: The caller is expected to take a read-lock before calling this.
539
547
        """
540
548
        relpath = self.id2path(file_id)
541
549
        assert relpath != None, \
1060
1068
            except (errors.NoSuchRevision, errors.RevisionNotPresent):
1061
1069
                revtree = None
1062
1070
            trees.append((revision_id, revtree))
1063
 
        self.current_dirstate()._validate()
1064
1071
        self.set_parent_trees(trees,
1065
1072
            allow_leftmost_as_ghost=allow_leftmost_as_ghost)
1066
 
        self.current_dirstate()._validate()
1067
1073
 
1068
1074
    @needs_tree_write_lock
1069
1075
    def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
1074
1080
            parent tree - i.e. a ghost.
1075
1081
        """
1076
1082
        dirstate = self.current_dirstate()
1077
 
        dirstate._validate()
1078
1083
        if len(parents_list) > 0:
1079
1084
            if not allow_leftmost_as_ghost and parents_list[0][1] is None:
1080
1085
                raise errors.GhostRevisionUnusableHere(parents_list[0][0])
1090
1095
                real_trees.append((rev_id,
1091
1096
                    self.branch.repository.revision_tree(None)))
1092
1097
                ghosts.append(rev_id)
1093
 
        dirstate._validate()
1094
1098
        dirstate.set_parent_trees(real_trees, ghosts=ghosts)
1095
 
        dirstate._validate()
1096
1099
        self._make_dirty(reset_inventory=False)
1097
 
        dirstate._validate()
1098
1100
 
1099
1101
    def _set_root_id(self, file_id):
1100
1102
        """See WorkingTree.set_root_id."""
1283
1285
                         _control_files=control_files)
1284
1286
        wt._new_tree()
1285
1287
        wt.lock_tree_write()
1286
 
        wt.current_dirstate()._validate()
1287
1288
        try:
1288
1289
            if revision_id in (None, NULL_REVISION):
1289
1290
                if branch.repository.supports_rich_root():
1291
1292
                else:
1292
1293
                    wt._set_root_id(ROOT_ID)
1293
1294
                wt.flush()
1294
 
                wt.current_dirstate()._validate()
1295
1295
            wt.set_last_revision(revision_id)
1296
1296
            wt.flush()
1297
1297
            basis = wt.basis_tree()