~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree_4.py

  • Committer: Andrew Bennetts
  • Date: 2009-07-27 05:35:00 UTC
  • mfrom: (4570 +trunk)
  • mto: (4634.6.29 2.0)
  • mto: This revision was merged to the branch mainline in revision 4680.
  • Revision ID: andrew.bennetts@canonical.com-20090727053500-q76zsn2dx33jhmj5
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
"""Tests for WorkingTreeFormat4"""
19
19
 
64
64
            - when the WorkingTree is locked, LockDir can see that
65
65
        """
66
66
        # this test could be factored into a subclass of tests common to both
67
 
        # format 3 and 4, but for now its not much of an issue as there is only one in common.
 
67
        # format 3 and 4, but for now its not much of an issue as there is only
 
68
        # one in common.
68
69
        t = self.get_transport()
69
70
        tree = self.make_workingtree()
70
71
        self.assertIsDirectory('.bzr', t)
578
579
        self.assertEqual([], changes)
579
580
        self.assertEqual(['', 'versioned', 'versioned2'], returned)
580
581
 
 
582
    def test_iter_changes_unversioned_error(self):
 
583
        """ Check if a PathsNotVersionedError is correctly raised and the
 
584
            paths list contains all unversioned entries only.
 
585
        """
 
586
        tree = self.make_branch_and_tree('tree')
 
587
        self.build_tree_contents([('tree/bar', '')])
 
588
        tree.add(['bar'], ['bar-id'])
 
589
        tree.lock_read()
 
590
        self.addCleanup(tree.unlock)
 
591
        tree_iter_changes = lambda files: [
 
592
            c for c in tree.iter_changes(tree.basis_tree(), specific_files=files,
 
593
                                         require_versioned=True)
 
594
        ]
 
595
        e = self.assertRaises(errors.PathsNotVersionedError,
 
596
                              tree_iter_changes, ['bar', 'foo'])
 
597
        self.assertEqual(e.paths, ['foo'])
 
598
 
581
599
    def get_tree_with_cachable_file_foo(self):
582
600
        tree = self.make_branch_and_tree('.')
583
601
        self.build_tree(['foo'])
592
610
        revid = tree.commit('a commit')
593
611
        # tree's dirstate should now have a valid stat entry for foo.
594
612
        tree.lock_read()
 
613
        self.addCleanup(tree.unlock)
595
614
        entry = tree._get_entry(path='foo')
596
615
        expected_sha1 = osutils.sha_file_by_name('foo')
597
616
        self.assertEqual(expected_sha1, entry[1][0][1])
659
678
        # Create a corrupted dirstate
660
679
        tree.lock_write()
661
680
        try:
662
 
            tree.commit('init') # We need a parent, or we always compare with NULL
 
681
            # We need a parent, or we always compare with NULL
 
682
            tree.commit('init')
663
683
            state = tree.current_dirstate()
664
684
            state._read_dirblocks_if_needed()
665
685
            # Now add in an invalid entry, a rename with a dangling pointer