/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 bzrlib/workingtree.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-20 11:18:38 UTC
  • mto: (5247.1.10 first-try)
  • mto: This revision was merged to the branch mainline in revision 5326.
  • Revision ID: v.ladeuil+lp@free.fr-20100620111838-3s726ne0g2ni42m1
No more use of the get_transport imported *symbol*, all uses are through
the module now, allowing effective wrapping.

* bzrlib/workingtree.py:
(WorkingTree.find_trees): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/transport/decorator.py:
(TransportDecorator.__init__): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/test_workingtree.py:
(TestWorkingTreeFormat.test_find_format.check_format): More evil
calls to transport.get_transport defeating the wrapping.

* bzrlib/tests/test_upgrade.py:
(TestUpgrade.test_upgrade_simple):
(TestUpgrade.test_upgrade_v6_to_meta_no_workingtree): More evil
calls to transport.get_transport defeating the wrapping.

* bzrlib/tests/test_transport_log.py:
(test_log_transport): More evil calls to transport.get_transport
defeating the wrapping.

* bzrlib/tests/test_smart_request.py:
(TestJailHook.test_jail_hook): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/test_sftp_transport.py:
(SFTPNonServerTest.test_abspath_root_sibling_server):
(SSHVendorBadConnection.test_bad_connection_paramiko):
(SSHVendorBadConnection.test_bad_connection_ssh):
(TestUsesAuthConfig.get_transport_for_connection): More evil calls
to transport.get_transport defeating the wrapping.

* bzrlib/tests/test_selftest.py:
(test_get_readonly_url_none):
(TestTestCaseWithTransport.test_get_readonly_url_none):
(TestTestCaseWithTransport.test_get_readonly_url_http):
(TestChrootedTest.test_root_is_root): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/test_remote.py:
(Test_ClientMedium_remote_path_from_transport.assertRemotePath):
(Test_ClientMedium_remote_path_from_transport.assertRemotePathHTTP):
More evil calls to transport.get_transport defeating the wrapping.

* bzrlib/tests/test_reconcile.py:
Unused import deleted.

* bzrlib/tests/test_permissions.py:
(check_mode_r):
(TestSftpPermissions.test_new_files):
(TestSftpPermissions.test_sftp_server_modes): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/test_lockable_files.py:
(setUp, TestLockableFiles_RemoteLockDir.setUp): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/test_knit.py:
(TestKnitIndex.test_knit_index_ignores_empty_files): More evil
calls to transport.get_transport defeating the wrapping.

* bzrlib/tests/test_index.py:
(test_build_index_empty_two_element_keys):
(test_build_index_one_reference_list_empty):
(test_build_index_two_reference_list_empty):
(test_build_index_one_node_no_refs):
(test_build_index_one_node_no_refs_accepts_empty_reflist):
(TestGraphIndexBuilder.test_build_index_one_node_2_element_keys):
(test_add_node_empty_value):
(test_build_index_nodes_sorted):
(test_build_index_2_element_key_nodes_sorted):
(test_build_index_reference_lists_are_included_one):
(test_build_index_reference_lists_with_2_element_keys):
(test_build_index_reference_lists_are_included_two):
(test_clear_cache):
(test_node_references_are_cr_delimited):
(test_multiple_reference_lists_are_tab_delimited):
(test_add_node_referencing_missing_key_makes_absent):
(test_node_references_three_digits):
(test_absent_has_no_reference_overhead):
(test_add_node_bad_key):
(TestGraphIndexBuilder.test_add_node_bad_key):
(test_add_node_bad_key_in_reference_lists):
(TestGraphIndexBuilder.test_add_node_bad_key_in_reference_lists):
(make_index):
(test_open_bad_index_no_error):
(test_iter_missing_entry_empty_no_size):
(test_validate_bad_index_errors):
(test_supports_unlimited_cache):
(TestCombinedGraphIndex.make_combined_index_with_missing):
(reload):
(TestCombinedGraphIndex.test_clear_cache):
(test_reorder_after_iter_entries):
(test_validate_reloads):
(TestCombinedGraphIndex.test_find_ancestors_across_indexes):
(TestCombinedGraphIndex.test_find_ancestors_missing_keys):
(test_find_ancestors_no_indexes):
(TestCombinedGraphIndex.test_find_ancestors_ghost_parent):
(test__find_ancestors_empty_index):
(test_construct): More evil calls to transport.get_transport
defeating the wrapping and some more import fixes.

* bzrlib/tests/test_directory_service.py:
(TestDirectoryLookup.test_get_transport): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/test_debug.py:
Unused import deleted.

* bzrlib/tests/test_btree_index.py:
(TestBTreeBuilder.test_three_level_tree_details):
(TestBTreeBuilder.test_spill_index_stress_2_2):
(TestBTreeIndex.make_index):
(test_trivial_constructor):
(test__read_nodes_no_size_one_page_reads_once):
(TestBTreeIndex.test__read_nodes_no_size_multiple_pages):
(TestBTreeIndex.test_2_levels_key_count_2_2):
(TestBTreeIndex.test_validate_two_pages):
(TestBTreeIndex.test_iter_all_entries_reads):
(TestBTreeIndex.test_iter_all_entries_reads):
(TestBTreeIndex.test_iter_entries_references_2_refs_resolved):
(TestBTreeIndex.test_iter_entries_references_2_refs_resolved):
(TestBTreeIndex.test_supports_unlimited_cache):
(TestExpandOffsets.make_index): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/per_workingtree/test_pull.py:
Unused import deleted.

* bzrlib/tests/per_versionedfile.py:
(test_readonly_mode):
(TestWeave.get_file):
(reopen_file):
(TestReadonlyHttpMixin.test_readonly_http_works):
(TestReadonlyHttpMixin.test_readonly_http_works_with_feeling):
(TestWeaveHTTP.get_file):
(TestWeaveMerge.get_file): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/per_repository/test_reconcile.py:
(setUp):
(TestReconcileWithIncorrectRevisionCache.setUp):
(test_reconcile_wrong_order):
(test_reconcile_wrong_order_secondary_inventory): More evil calls
to transport.get_transport defeating the wrapping.

* bzrlib/tests/per_repository/test_has_same_location.py:
(TestHasSameLocation.test_different_format_not_equal): More evil
calls to transport.get_transport defeating the wrapping.

* bzrlib/tests/per_repository/test_fetch.py:
Unused import deleted.

* bzrlib/tests/per_intertree/__init__.py:
Unused import deleted.

* bzrlib/tests/per_interrepository/__init__.py:
(TestCaseWithInterRepository.make_bzrdir): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/per_interbranch/test_push.py:
Unused import deleted.

* bzrlib/tests/per_interbranch/__init__.py:
Unused import deleted.

* bzrlib/tests/per_bzrdir/test_bzrdir.py:
(TestBzrDir.sproutOrSkip):
(TestBzrDir.test_format_initialize_find_open):
(TestBzrDir.test_open_not_bzrdir):
(TestBzrDir.test_open_branch):
(TestBzrDir.test_open_branch):
(TestBzrDir.test_list_branches):
(TestBzrDir.test_create_repository):
(TestBzrDir.test_create_repository_shared):
(TestBzrDir.test_create_repository_nonshared):
(TestBzrDir.test_open_repository):
(test_root_transport):
(TestBzrDir.test_find_repository_no_repo_under_standalone_branch):
(TestBzrDir.test_find_repository_containing_shared_repository):
(TestBzrDir.test_find_repository_shared_within_shared_repository):
(TestBzrDir.test_find_repository_with_nested_dirs_works):
(ChrootedBzrDirTests.test_find_repository_no_repository):
(TestBzrDirControlComponent): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/tests/per_branch/test_stacking.py: 
Unused import deleted.

* bzrlib/tests/per_branch/test_permissions.py: 
Unused import deleted.

* bzrlib/tests/per_branch/test_bound_sftp.py:
(test_unbinding): More evil calls to transport.get_transport
defeating the wrapping.

* bzrlib/tests/blackbox/test_upgrade.py:
(TestWithUpgradableBranches.test_upgrade_up_to_date_checkout_warns_branch_left_alone):
(test_upgrade_explicit_metaformat):
(TestWithUpgradableBranches.test_upgrade_explicit_knit):
(test_upgrade_with_existing_backup_dir):
(TestWithUpgradableBranches.test_upgrade_with_existing_backup_dir):
More evil calls to transport.get_transport defeating the wrapping.

* bzrlib/tests/blackbox/test_serve.py:
(test_bzr_serve_port_readonly): More evil calls to
transport.get_transport defeating the wrapping.

* bzrlib/plugins/launchpad/test_lp_directory.py:
(DirectoryOpenBranchTests.test_directory_open_branch): Use
transport.get_transport instead of get_transport.

* bzrlib/plugins/launchpad/account.py:
(check_lp_login): Use transport.get_transport instead of
get_transport.

* bzrlib/builtins.py (run): Use transport.get_transport instead of
get_transport.

* bzrlib/btree_index.py:
(BTreeBuilder._spill_mem_keys_to_disk): Use
transport.get_transport instead of get_transport.

* bzrlib/benchmarks/bench_commit.py:
Unused import deleted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    revisiontree,
62
62
    trace,
63
63
    transform,
 
64
    transport,
64
65
    ui,
65
66
    views,
66
67
    xml5,
67
68
    xml7,
68
69
    )
69
 
import bzrlib.branch
70
 
from bzrlib.transport import get_transport
71
70
from bzrlib.workingtree_4 import (
72
71
    WorkingTreeFormat4,
73
72
    WorkingTreeFormat5,
77
76
 
78
77
from bzrlib import symbol_versioning
79
78
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
79
from bzrlib.lock import LogicalLockResult
80
80
from bzrlib.lockable_files import LockableFiles
81
81
from bzrlib.lockdir import LockDir
82
82
import bzrlib.mutabletree
368
368
                return True, None
369
369
            else:
370
370
                return True, tree
371
 
        transport = get_transport(location)
372
 
        iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,
 
371
        t = transport.get_transport(location)
 
372
        iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
373
373
                                              list_current=list_current)
374
 
        return [t for t in iterator if t is not None]
 
374
        return [tr for tr in iterator if tr is not None]
375
375
 
376
376
    # should be deprecated - this is slow and in any case treating them as a
377
377
    # container is (we now know) bad style -- mbp 20070302
462
462
        return (file_obj, stat_value)
463
463
 
464
464
    def get_file_text(self, file_id, path=None, filtered=True):
465
 
        return self.get_file(file_id, path=path, filtered=filtered).read()
 
465
        my_file = self.get_file(file_id, path=path, filtered=filtered)
 
466
        try:
 
467
            return my_file.read()
 
468
        finally:
 
469
            my_file.close()
466
470
 
467
471
    def get_file_byname(self, filename, filtered=True):
468
472
        path = self.abspath(filename)
522
526
 
523
527
        # Now we have the parents of this content
524
528
        annotator = self.branch.repository.texts.get_annotator()
525
 
        text = self.get_file(file_id).read()
 
529
        text = self.get_file_text(file_id)
526
530
        this_key =(file_id, default_revision)
527
531
        annotator.add_special_text(this_key, file_parent_keys, text)
528
532
        annotations = [(key[-1], line)
1798
1802
            raise errors.ObjectNotLocked(self)
1799
1803
 
1800
1804
    def lock_read(self):
1801
 
        """See Branch.lock_read, and WorkingTree.unlock."""
 
1805
        """Lock the tree for reading.
 
1806
 
 
1807
        This also locks the branch, and can be unlocked via self.unlock().
 
1808
 
 
1809
        :return: A bzrlib.lock.LogicalLockResult.
 
1810
        """
1802
1811
        if not self.is_locked():
1803
1812
            self._reset_data()
1804
1813
        self.branch.lock_read()
1805
1814
        try:
1806
 
            return self._control_files.lock_read()
 
1815
            self._control_files.lock_read()
 
1816
            return LogicalLockResult(self.unlock)
1807
1817
        except:
1808
1818
            self.branch.unlock()
1809
1819
            raise
1810
1820
 
1811
1821
    def lock_tree_write(self):
1812
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
 
1822
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
 
1823
 
 
1824
        :return: A bzrlib.lock.LogicalLockResult.
 
1825
        """
1813
1826
        if not self.is_locked():
1814
1827
            self._reset_data()
1815
1828
        self.branch.lock_read()
1816
1829
        try:
1817
 
            return self._control_files.lock_write()
 
1830
            self._control_files.lock_write()
 
1831
            return LogicalLockResult(self.unlock)
1818
1832
        except:
1819
1833
            self.branch.unlock()
1820
1834
            raise
1821
1835
 
1822
1836
    def lock_write(self):
1823
 
        """See MutableTree.lock_write, and WorkingTree.unlock."""
 
1837
        """See MutableTree.lock_write, and WorkingTree.unlock.
 
1838
 
 
1839
        :return: A bzrlib.lock.LogicalLockResult.
 
1840
        """
1824
1841
        if not self.is_locked():
1825
1842
            self._reset_data()
1826
1843
        self.branch.lock_write()
1827
1844
        try:
1828
 
            return self._control_files.lock_write()
 
1845
            self._control_files.lock_write()
 
1846
            return LogicalLockResult(self.unlock)
1829
1847
        except:
1830
1848
            self.branch.unlock()
1831
1849
            raise
1956
1974
        def recurse_directory_to_add_files(directory):
1957
1975
            # Recurse directory and add all files
1958
1976
            # so we can check if they have changed.
1959
 
            for parent_info, file_infos in\
1960
 
                self.walkdirs(directory):
 
1977
            for parent_info, file_infos in self.walkdirs(directory):
1961
1978
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1962
1979
                    # Is it versioned or ignored?
1963
1980
                    if self.path2id(relpath) or self.is_ignored(relpath):
1998
2015
                            # ... but not ignored
1999
2016
                            has_changed_files = True
2000
2017
                            break
2001
 
                    elif content_change and (kind[1] is not None):
2002
 
                        # Versioned and changed, but not deleted
 
2018
                    elif (content_change and (kind[1] is not None) and
 
2019
                            osutils.is_inside_any(files, path[1])):
 
2020
                        # Versioned and changed, but not deleted, and still
 
2021
                        # in one of the dirs to be deleted.
2003
2022
                        has_changed_files = True
2004
2023
                        break
2005
2024
 
2636
2655
 
2637
2656
        In Format2 WorkingTrees we have a single lock for the branch and tree
2638
2657
        so lock_tree_write() degrades to lock_write().
 
2658
 
 
2659
        :return: An object with an unlock method which will release the lock
 
2660
            obtained.
2639
2661
        """
2640
2662
        self.branch.lock_write()
2641
2663
        try:
2642
 
            return self._control_files.lock_write()
 
2664
            self._control_files.lock_write()
 
2665
            return self
2643
2666
        except:
2644
2667
            self.branch.unlock()
2645
2668
            raise