~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Gordon Tyler
  • Date: 2010-01-14 15:24:04 UTC
  • mto: (5037.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5046.
  • Revision ID: gordon@doxxx.net-20100114152404-d64ik2afl96lcml0
Reverted changes to test_rules since the original should work now.

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,
567
568
            return _mod_revision.NULL_REVISION
568
569
 
569
570
    def lock_read(self):
570
 
        """See Branch.lock_read, and WorkingTree.unlock.
571
 
 
572
 
        :return: An object with an unlock method which will release the lock
573
 
            obtained.
574
 
        """
 
571
        """See Branch.lock_read, and WorkingTree.unlock."""
575
572
        self.branch.lock_read()
576
573
        try:
577
574
            self._control_files.lock_read()
590
587
        except:
591
588
            self.branch.unlock()
592
589
            raise
593
 
        return self
594
590
 
595
591
    def _lock_self_write(self):
596
592
        """This should be called after the branch is locked."""
611
607
        except:
612
608
            self.branch.unlock()
613
609
            raise
614
 
        return self
615
610
 
616
611
    def lock_tree_write(self):
617
 
        """See MutableTree.lock_tree_write, and WorkingTree.unlock.
618
 
 
619
 
        :return: An object with an unlock method which will release the lock
620
 
            obtained.
621
 
        """
 
612
        """See MutableTree.lock_tree_write, and WorkingTree.unlock."""
622
613
        self.branch.lock_read()
623
 
        return self._lock_self_write()
 
614
        self._lock_self_write()
624
615
 
625
616
    def lock_write(self):
626
 
        """See MutableTree.lock_write, and WorkingTree.unlock.
627
 
 
628
 
        :return: An object with an unlock method which will release the lock
629
 
            obtained.
630
 
        """
 
617
        """See MutableTree.lock_write, and WorkingTree.unlock."""
631
618
        self.branch.lock_write()
632
 
        return self._lock_self_write()
 
619
        self._lock_self_write()
633
620
 
634
621
    @needs_tree_write_lock
635
622
    def move(self, from_paths, to_dir, after=False):
1385
1372
 
1386
1373
 
1387
1374
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1388
 
 
1389
1375
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1390
1376
                   accelerator_tree=None, hardlink=False):
1391
1377
        """See WorkingTreeFormat.initialize().
1769
1755
            return None
1770
1756
        parent_index = self._get_parent_index()
1771
1757
        last_changed_revision = entry[1][parent_index][4]
1772
 
        try:
1773
 
            rev = self._repository.get_revision(last_changed_revision)
1774
 
        except errors.NoSuchRevision:
1775
 
            raise errors.FileTimestampUnavailable(self.id2path(file_id))
1776
 
        return rev.timestamp
 
1758
        return self._repository.get_revision(last_changed_revision).timestamp
1777
1759
 
1778
1760
    def get_file_sha1(self, file_id, path=None, stat_value=None):
1779
1761
        entry = self._get_entry(file_id=file_id, path=path)
1846
1828
        entry = self._get_entry(file_id=file_id)[1]
1847
1829
        if entry is None:
1848
1830
            raise errors.NoSuchId(tree=self, file_id=file_id)
1849
 
        parent_index = self._get_parent_index()
1850
 
        return dirstate.DirState._minikind_to_kind[entry[parent_index][0]]
 
1831
        return dirstate.DirState._minikind_to_kind[entry[1][0]]
1851
1832
 
1852
1833
    def stored_kind(self, file_id):
1853
1834
        """See Tree.stored_kind"""
1873
1854
            return None
1874
1855
        return ie.executable
1875
1856
 
1876
 
    def is_locked(self):
1877
 
        return self._locked
1878
 
 
1879
1857
    def list_files(self, include_root=False, from_dir=None, recursive=True):
1880
1858
        # We use a standard implementation, because DirStateRevisionTree is
1881
1859
        # dealing with one of the parents of the current state
1894
1872
            yield path, 'V', entry.kind, entry.file_id, entry
1895
1873
 
1896
1874
    def lock_read(self):
1897
 
        """Lock the tree for a set of operations.
1898
 
 
1899
 
        :return: An object with an unlock method which will release the lock
1900
 
            obtained.
1901
 
        """
 
1875
        """Lock the tree for a set of operations."""
1902
1876
        if not self._locked:
1903
1877
            self._repository.lock_read()
1904
1878
            if self._dirstate._lock_token is None:
1905
1879
                self._dirstate.lock_read()
1906
1880
                self._dirstate_locked = True
1907
1881
        self._locked += 1
1908
 
        return self
1909
1882
 
1910
1883
    def _must_be_locked(self):
1911
1884
        if not self._locked: