~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Pool
  • Date: 2010-04-23 00:44:15 UTC
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@canonical.com-20100423004415-py8ozrtkjo6tphj2
Update more code to use user_transport when it should

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
WorkingTree.open(dir).
30
30
"""
31
31
 
 
32
# TODO: Give the workingtree sole responsibility for the working inventory;
 
33
# remove the variable and references to it from the branch.  This may require
 
34
# updating the commit code so as to update the inventory within the working
 
35
# copy, and making sure there's only one WorkingTree for any directory on disk.
 
36
# At the moment they may alias the inventory and have old copies of it in
 
37
# memory.  (Now done? -- mbp 20060309)
32
38
 
33
39
from cStringIO import StringIO
34
40
import os
95
101
from bzrlib.filters import filtered_input_file
96
102
from bzrlib.trace import mutter, note
97
103
from bzrlib.transport.local import LocalTransport
 
104
from bzrlib.progress import ProgressPhase
98
105
from bzrlib.revision import CURRENT_REVISION
99
106
from bzrlib.rio import RioReader, rio_file, Stanza
100
107
from bzrlib.symbol_versioning import (
1798
1805
            raise errors.ObjectNotLocked(self)
1799
1806
 
1800
1807
    def lock_read(self):
1801
 
        """Lock the tree for reading.
1802
 
 
1803
 
        This also locks the branch, and can be unlocked via self.unlock().
1804
 
 
1805
 
        :return: An object with an unlock method which will release the lock
1806
 
            obtained.
1807
 
        """
 
1808
        """See Branch.lock_read, and WorkingTree.unlock."""
1808
1809
        if not self.is_locked():
1809
1810
            self._reset_data()
1810
1811
        self.branch.lock_read()
1811
1812
        try:
1812
 
            self._control_files.lock_read()
1813
 
            return self
 
1813
            return self._control_files.lock_read()
1814
1814
        except:
1815
1815
            self.branch.unlock()
1816
1816
            raise
1817
1817
 
1818
1818
    def lock_tree_write(self):
1819
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1820
 
 
1821
 
        :return: An object with an unlock method which will release the lock
1822
 
            obtained.
1823
 
        """
 
1819
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
1824
1820
        if not self.is_locked():
1825
1821
            self._reset_data()
1826
1822
        self.branch.lock_read()
1827
1823
        try:
1828
 
            self._control_files.lock_write()
1829
 
            return self
 
1824
            return self._control_files.lock_write()
1830
1825
        except:
1831
1826
            self.branch.unlock()
1832
1827
            raise
1833
1828
 
1834
1829
    def lock_write(self):
1835
 
        """See MutableTree.lock_write, and WorkingTree.unlock.
1836
 
 
1837
 
        :return: An object with an unlock method which will release the lock
1838
 
            obtained.
1839
 
        """
 
1830
        """See MutableTree.lock_write, and WorkingTree.unlock."""
1840
1831
        if not self.is_locked():
1841
1832
            self._reset_data()
1842
1833
        self.branch.lock_write()
1843
1834
        try:
1844
 
            self._control_files.lock_write()
1845
 
            return self
 
1835
            return self._control_files.lock_write()
1846
1836
        except:
1847
1837
            self.branch.unlock()
1848
1838
            raise
2653
2643
 
2654
2644
        In Format2 WorkingTrees we have a single lock for the branch and tree
2655
2645
        so lock_tree_write() degrades to lock_write().
2656
 
 
2657
 
        :return: An object with an unlock method which will release the lock
2658
 
            obtained.
2659
2646
        """
2660
2647
        self.branch.lock_write()
2661
2648
        try:
2662
 
            self._control_files.lock_write()
2663
 
            return self
 
2649
            return self._control_files.lock_write()
2664
2650
        except:
2665
2651
            self.branch.unlock()
2666
2652
            raise