~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testworkingtree.py

  • Committer: Robert Collins
  • Date: 2005-10-17 23:35:18 UTC
  • mfrom: (1442.1.65)
  • Revision ID: robertc@robertcollins.net-20051017233518-6746654be564edde
Merge in more GPG work, and more Branch-api-shrinkage.

* Branch.remove has been moved to WorkingTree, which has also gained
  lock_read, lock_write and unlock methods for convenience. (Robert
  Collins)

* Two decorators, needs_read_lock and needs_write_lock have been added
  to the branch module. Use these to cause a function to run in a
  read or write lock respectively. (Robert Collins)

* Branch.open_containing now returns a tuple (Branch, relative-path),
  which allows direct access to the common case of 'get me this file
  from its branch'. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        tree = WorkingTree(branch.base)
80
80
        self.assertEqual('child',
81
81
                         tree.relpath(os.path.join(os.getcwd(), 'child')))
 
82
 
 
83
    def test_lock_locks_branch(self):
 
84
        branch = Branch.initialize('.')
 
85
        tree = WorkingTree(branch.base)
 
86
        tree.lock_read()
 
87
        self.assertEqual(1, tree.branch._lock_count)
 
88
        self.assertEqual('r', tree.branch._lock_mode)
 
89
        tree.unlock()
 
90
        self.assertEqual(None, tree.branch._lock_count)
 
91
        tree.lock_write()
 
92
        self.assertEqual(1, tree.branch._lock_count)
 
93
        self.assertEqual('w', tree.branch._lock_mode)
 
94
        tree.unlock()
 
95
        self.assertEqual(None, tree.branch._lock_count)