~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Rework test_script a little bit.


Don't allow someone to request a stdin request to echo.
Echo never reads from stdin, it just echos its arguments.
You use 'cat' if you want to read from stdin.

A few other fixes because the tests were using filenames
that are actually illegal on Windows, rather than just
nonexistant.


Change the exception handling for commands so that
unknown errors don't get silently squashed and then
turn into hard-to-debug errors later.

test_script now passes on Windows.

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,
1371
1372
 
1372
1373
 
1373
1374
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1374
 
 
1375
1375
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1376
1376
                   accelerator_tree=None, hardlink=False):
1377
1377
        """See WorkingTreeFormat.initialize().
1447
1447
                if basis_root_id is not None:
1448
1448
                    wt._set_root_id(basis_root_id)
1449
1449
                    wt.flush()
 
1450
                # If content filtering is supported, do not use the accelerator
 
1451
                # tree - the cost of transforming the content both ways and
 
1452
                # checking for changed content can outweight the gains it gives.
 
1453
                # Note: do NOT move this logic up higher - using the basis from
 
1454
                # the accelerator tree is still desirable because that can save
 
1455
                # a minute or more of processing on large trees!
 
1456
                # The original tree may not have the same content filters
 
1457
                # applied so we can't safely build the inventory delta from
 
1458
                # the source tree.
1450
1459
                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.
 
1460
                    if hardlink:
 
1461
                        # see https://bugs.edge.launchpad.net/bzr/+bug/408193
 
1462
                        trace.warning("hardlinking working copy files is not currently "
 
1463
                            "supported in %r" % (wt,))
 
1464
                    accelerator_tree = None
1454
1465
                    delta_from_tree = False
1455
1466
                else:
1456
1467
                    delta_from_tree = True
1755
1766
            return None
1756
1767
        parent_index = self._get_parent_index()
1757
1768
        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
 
1769
        return self._repository.get_revision(last_changed_revision).timestamp
1763
1770
 
1764
1771
    def get_file_sha1(self, file_id, path=None, stat_value=None):
1765
1772
        entry = self._get_entry(file_id=file_id, path=path)
1832
1839
        entry = self._get_entry(file_id=file_id)[1]
1833
1840
        if entry is None:
1834
1841
            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]]
 
1842
        return dirstate.DirState._minikind_to_kind[entry[1][0]]
1837
1843
 
1838
1844
    def stored_kind(self, file_id):
1839
1845
        """See Tree.stored_kind"""
1979
1985
        return result
1980
1986
 
1981
1987
    @classmethod
1982
 
    def make_source_parent_tree_compiled_dirstate(klass, test_case, source,
1983
 
                                                  target):
 
1988
    def make_source_parent_tree_compiled_dirstate(klass, test_case, source, target):
1984
1989
        from bzrlib.tests.test__dirstate_helpers import \
1985
 
            compiled_dirstate_helpers_feature
1986
 
        test_case.requireFeature(compiled_dirstate_helpers_feature)
 
1990
            CompiledDirstateHelpersFeature
 
1991
        if not CompiledDirstateHelpersFeature.available():
 
1992
            from bzrlib.tests import UnavailableFeature
 
1993
            raise UnavailableFeature(CompiledDirstateHelpersFeature)
1987
1994
        from bzrlib._dirstate_helpers_pyx import ProcessEntryC
1988
1995
        result = klass.make_source_parent_tree(source, target)
1989
1996
        result[1]._iter_changes = ProcessEntryC
2020
2027
            output. An unversioned file is defined as one with (False, False)
2021
2028
            for the versioned pair.
2022
2029
        """
 
2030
        # NB: show_status depends on being able to pass in non-versioned files
 
2031
        # and report them as unknown
2023
2032
        # TODO: handle extra trees in the dirstate.
2024
2033
        if (extra_trees or specific_files == []):
2025
2034
            # we can't fast-path these cases (yet)