~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Martin Pool
  • Date: 2009-09-14 02:30:23 UTC
  • mto: This revision was merged to the branch mainline in revision 4693.
  • Revision ID: mbp@sourcefrog.net-20090914023023-ros0f3ndo04j3bww
Clearer docs about bzr help.  (Thanks to Naoki)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
53
53
from bzrlib.decorators import needs_read_lock, needs_write_lock
54
54
from bzrlib.filters import filtered_input_file, internal_size_sha_file_byname
55
55
from bzrlib.inventory import Inventory, ROOT_ID, entry_factory
 
56
import bzrlib.mutabletree
56
57
from bzrlib.mutabletree import needs_tree_write_lock
57
58
from bzrlib.osutils import (
58
59
    file_kind,
1266
1267
        if self._dirty:
1267
1268
            raise AssertionError("attempting to write an inventory when the "
1268
1269
                "dirstate is dirty will lose pending changes")
1269
 
        had_inventory = self._inventory is not None
1270
 
        # Setting self._inventory = None forces the dirstate to regenerate the
1271
 
        # working inventory. We do this because self.inventory may be inv, or
1272
 
        # may have been modified, and either case would prevent a clean delta
1273
 
        # being created.
1274
 
        self._inventory = None
1275
 
        # generate a delta,
1276
 
        delta = inv._make_delta(self.inventory)
1277
 
        # and apply it.
1278
 
        self.apply_inventory_delta(delta)
1279
 
        if had_inventory:
 
1270
        self.current_dirstate().set_state_from_inventory(inv)
 
1271
        self._make_dirty(reset_inventory=False)
 
1272
        if self._inventory is not None:
1280
1273
            self._inventory = inv
1281
1274
        self.flush()
1282
1275
 
1371
1364
 
1372
1365
 
1373
1366
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1374
 
 
1375
1367
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1376
1368
                   accelerator_tree=None, hardlink=False):
1377
1369
        """See WorkingTreeFormat.initialize().
1447
1439
                if basis_root_id is not None:
1448
1440
                    wt._set_root_id(basis_root_id)
1449
1441
                    wt.flush()
 
1442
                # If content filtering is supported, do not use the accelerator
 
1443
                # tree - the cost of transforming the content both ways and
 
1444
                # checking for changed content can outweight the gains it gives.
 
1445
                # Note: do NOT move this logic up higher - using the basis from
 
1446
                # the accelerator tree is still desirable because that can save
 
1447
                # a minute or more of processing on large trees!
 
1448
                # The original tree may not have the same content filters
 
1449
                # applied so we can't safely build the inventory delta from
 
1450
                # the source tree.
1450
1451
                if wt.supports_content_filtering():
1451
 
                    # The original tree may not have the same content filters
1452
 
                    # applied so we can't safely build the inventory delta from
1453
 
                    # the source tree.
 
1452
                    if hardlink:
 
1453
                        # see https://bugs.edge.launchpad.net/bzr/+bug/408193
 
1454
                        trace.warning("hardlinking working copy files is not currently "
 
1455
                            "supported in %r" % (wt,))
 
1456
                    accelerator_tree = None
1454
1457
                    delta_from_tree = False
1455
1458
                else:
1456
1459
                    delta_from_tree = True
1755
1758
            return None
1756
1759
        parent_index = self._get_parent_index()
1757
1760
        last_changed_revision = entry[1][parent_index][4]
1758
 
        try:
1759
 
            rev = self._repository.get_revision(last_changed_revision)
1760
 
        except errors.NoSuchRevision:
1761
 
            raise errors.FileTimestampUnavailable(self.id2path(file_id))
1762
 
        return rev.timestamp
 
1761
        return self._repository.get_revision(last_changed_revision).timestamp
1763
1762
 
1764
1763
    def get_file_sha1(self, file_id, path=None, stat_value=None):
1765
1764
        entry = self._get_entry(file_id=file_id, path=path)
1832
1831
        entry = self._get_entry(file_id=file_id)[1]
1833
1832
        if entry is None:
1834
1833
            raise errors.NoSuchId(tree=self, file_id=file_id)
1835
 
        parent_index = self._get_parent_index()
1836
 
        return dirstate.DirState._minikind_to_kind[entry[parent_index][0]]
 
1834
        return dirstate.DirState._minikind_to_kind[entry[1][0]]
1837
1835
 
1838
1836
    def stored_kind(self, file_id):
1839
1837
        """See Tree.stored_kind"""
1979
1977
        return result
1980
1978
 
1981
1979
    @classmethod
1982
 
    def make_source_parent_tree_compiled_dirstate(klass, test_case, source,
1983
 
                                                  target):
 
1980
    def make_source_parent_tree_compiled_dirstate(klass, test_case, source, target):
1984
1981
        from bzrlib.tests.test__dirstate_helpers import \
1985
 
            compiled_dirstate_helpers_feature
1986
 
        test_case.requireFeature(compiled_dirstate_helpers_feature)
 
1982
            CompiledDirstateHelpersFeature
 
1983
        if not CompiledDirstateHelpersFeature.available():
 
1984
            from bzrlib.tests import UnavailableFeature
 
1985
            raise UnavailableFeature(CompiledDirstateHelpersFeature)
1987
1986
        from bzrlib._dirstate_helpers_pyx import ProcessEntryC
1988
1987
        result = klass.make_source_parent_tree(source, target)
1989
1988
        result[1]._iter_changes = ProcessEntryC
2020
2019
            output. An unversioned file is defined as one with (False, False)
2021
2020
            for the versioned pair.
2022
2021
        """
 
2022
        # NB: show_status depends on being able to pass in non-versioned files
 
2023
        # and report them as unknown
2023
2024
        # TODO: handle extra trees in the dirstate.
2024
2025
        if (extra_trees or specific_files == []):
2025
2026
            # we can't fast-path these cases (yet)