/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: Canonical.com Patch Queue Manager
  • Date: 2010-04-28 09:40:23 UTC
  • mfrom: (5155.1.5 320119-exclude-ancestry)
  • Revision ID: pqm@pqm.ubuntu.com-20100428094023-7504mlou1qk28r9n
(vila) Add --exclude-common-ancestry log option (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    revisiontree,
62
62
    trace,
63
63
    transform,
64
 
    transport,
65
64
    ui,
66
65
    views,
67
66
    xml5,
68
67
    xml7,
69
68
    )
 
69
import bzrlib.branch
 
70
from bzrlib.transport import get_transport
70
71
from bzrlib.workingtree_4 import (
71
72
    WorkingTreeFormat4,
72
73
    WorkingTreeFormat5,
76
77
 
77
78
from bzrlib import symbol_versioning
78
79
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
95
95
from bzrlib.filters import filtered_input_file
96
96
from bzrlib.trace import mutter, note
97
97
from bzrlib.transport.local import LocalTransport
 
98
from bzrlib.progress import ProgressPhase
98
99
from bzrlib.revision import CURRENT_REVISION
99
100
from bzrlib.rio import RioReader, rio_file, Stanza
100
101
from bzrlib.symbol_versioning import (
176
177
 
177
178
    It is possible for a `WorkingTree` to have a filename which is
178
179
    not listed in the Inventory and vice versa.
179
 
 
180
 
    :ivar basedir: The root of the tree on disk. This is a unicode path object
181
 
        (as opposed to a URL).
182
180
    """
183
181
 
184
182
    # override this to set the strategy for storing views
371
369
                return True, None
372
370
            else:
373
371
                return True, tree
374
 
        t = transport.get_transport(location)
375
 
        iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
 
372
        transport = get_transport(location)
 
373
        iterator = bzrdir.BzrDir.find_bzrdirs(transport, evaluate=evaluate,
376
374
                                              list_current=list_current)
377
 
        return [tr for tr in iterator if tr is not None]
 
375
        return [t for t in iterator if t is not None]
378
376
 
379
377
    # should be deprecated - this is slow and in any case treating them as a
380
378
    # container is (we now know) bad style -- mbp 20070302
465
463
        return (file_obj, stat_value)
466
464
 
467
465
    def get_file_text(self, file_id, path=None, filtered=True):
468
 
        my_file = self.get_file(file_id, path=path, filtered=filtered)
469
 
        try:
470
 
            return my_file.read()
471
 
        finally:
472
 
            my_file.close()
 
466
        return self.get_file(file_id, path=path, filtered=filtered).read()
473
467
 
474
468
    def get_file_byname(self, filename, filtered=True):
475
469
        path = self.abspath(filename)
529
523
 
530
524
        # Now we have the parents of this content
531
525
        annotator = self.branch.repository.texts.get_annotator()
532
 
        text = self.get_file_text(file_id)
 
526
        text = self.get_file(file_id).read()
533
527
        this_key =(file_id, default_revision)
534
528
        annotator.add_special_text(this_key, file_parent_keys, text)
535
529
        annotations = [(key[-1], line)
1805
1799
            raise errors.ObjectNotLocked(self)
1806
1800
 
1807
1801
    def lock_read(self):
1808
 
        """Lock the tree for reading.
1809
 
 
1810
 
        This also locks the branch, and can be unlocked via self.unlock().
1811
 
 
1812
 
        :return: A bzrlib.lock.LogicalLockResult.
1813
 
        """
 
1802
        """See Branch.lock_read, and WorkingTree.unlock."""
1814
1803
        if not self.is_locked():
1815
1804
            self._reset_data()
1816
1805
        self.branch.lock_read()
1817
1806
        try:
1818
 
            self._control_files.lock_read()
1819
 
            return LogicalLockResult(self.unlock)
 
1807
            return self._control_files.lock_read()
1820
1808
        except:
1821
1809
            self.branch.unlock()
1822
1810
            raise
1823
1811
 
1824
1812
    def lock_tree_write(self):
1825
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
1826
 
 
1827
 
        :return: A bzrlib.lock.LogicalLockResult.
1828
 
        """
 
1813
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
1829
1814
        if not self.is_locked():
1830
1815
            self._reset_data()
1831
1816
        self.branch.lock_read()
1832
1817
        try:
1833
 
            self._control_files.lock_write()
1834
 
            return LogicalLockResult(self.unlock)
 
1818
            return self._control_files.lock_write()
1835
1819
        except:
1836
1820
            self.branch.unlock()
1837
1821
            raise
1838
1822
 
1839
1823
    def lock_write(self):
1840
 
        """See MutableTree.lock_write, and WorkingTree.unlock.
1841
 
 
1842
 
        :return: A bzrlib.lock.LogicalLockResult.
1843
 
        """
 
1824
        """See MutableTree.lock_write, and WorkingTree.unlock."""
1844
1825
        if not self.is_locked():
1845
1826
            self._reset_data()
1846
1827
        self.branch.lock_write()
1847
1828
        try:
1848
 
            self._control_files.lock_write()
1849
 
            return LogicalLockResult(self.unlock)
 
1829
            return self._control_files.lock_write()
1850
1830
        except:
1851
1831
            self.branch.unlock()
1852
1832
            raise
1977
1957
        def recurse_directory_to_add_files(directory):
1978
1958
            # Recurse directory and add all files
1979
1959
            # so we can check if they have changed.
1980
 
            for parent_info, file_infos in self.walkdirs(directory):
 
1960
            for parent_info, file_infos in\
 
1961
                self.walkdirs(directory):
1981
1962
                for relpath, basename, kind, lstat, fileid, kind in file_infos:
1982
1963
                    # Is it versioned or ignored?
1983
1964
                    if self.path2id(relpath) or self.is_ignored(relpath):
2018
1999
                            # ... but not ignored
2019
2000
                            has_changed_files = True
2020
2001
                            break
2021
 
                    elif (content_change and (kind[1] is not None) and
2022
 
                            osutils.is_inside_any(files, path[1])):
2023
 
                        # Versioned and changed, but not deleted, and still
2024
 
                        # in one of the dirs to be deleted.
 
2002
                    elif content_change and (kind[1] is not None):
 
2003
                        # Versioned and changed, but not deleted
2025
2004
                        has_changed_files = True
2026
2005
                        break
2027
2006
 
2658
2637
 
2659
2638
        In Format2 WorkingTrees we have a single lock for the branch and tree
2660
2639
        so lock_tree_write() degrades to lock_write().
2661
 
 
2662
 
        :return: An object with an unlock method which will release the lock
2663
 
            obtained.
2664
2640
        """
2665
2641
        self.branch.lock_write()
2666
2642
        try:
2667
 
            self._control_files.lock_write()
2668
 
            return self
 
2643
            return self._control_files.lock_write()
2669
2644
        except:
2670
2645
            self.branch.unlock()
2671
2646
            raise