/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 breezy/tests/test_transform.py

  • Committer: Jelmer Vernooij
  • Date: 2017-08-29 21:07:17 UTC
  • mfrom: (6772 brz)
  • mto: This revision was merged to the branch mainline in revision 6773.
  • Revision ID: jelmer@jelmer.uk-20170829210717-ud3w6rh8x8fv48l9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3727
3727
        transform.apply()
3728
3728
        self.assertEqual(old_root_id, self.wt.get_root_id())
3729
3729
        self.assertEqual([(self.wt, transform)], calls)
 
3730
 
 
3731
 
 
3732
class TestLinkTree(tests.TestCaseWithTransport):
 
3733
 
 
3734
    _test_needs_features = [HardlinkFeature]
 
3735
 
 
3736
    def setUp(self):
 
3737
        tests.TestCaseWithTransport.setUp(self)
 
3738
        self.parent_tree = self.make_branch_and_tree('parent')
 
3739
        self.parent_tree.lock_write()
 
3740
        self.addCleanup(self.parent_tree.unlock)
 
3741
        self.build_tree_contents([('parent/foo', 'bar')])
 
3742
        self.parent_tree.add('foo', 'foo-id')
 
3743
        self.parent_tree.commit('added foo')
 
3744
        child_controldir = self.parent_tree.controldir.sprout('child')
 
3745
        self.child_tree = child_controldir.open_workingtree()
 
3746
 
 
3747
    def hardlinked(self):
 
3748
        parent_stat = os.lstat(self.parent_tree.abspath('foo'))
 
3749
        child_stat = os.lstat(self.child_tree.abspath('foo'))
 
3750
        return parent_stat.st_ino == child_stat.st_ino
 
3751
 
 
3752
    def test_link_fails_if_modified(self):
 
3753
        """If the file to be linked has modified text, don't link."""
 
3754
        self.build_tree_contents([('child/foo', 'baz')])
 
3755
        transform.link_tree(self.child_tree, self.parent_tree)
 
3756
        self.assertFalse(self.hardlinked())
 
3757
 
 
3758
    def test_link_fails_if_execute_bit_changed(self):
 
3759
        """If the file to be linked has modified execute bit, don't link."""
 
3760
        tt = TreeTransform(self.child_tree)
 
3761
        try:
 
3762
            trans_id = tt.trans_id_tree_file_id('foo-id')
 
3763
            tt.set_executability(True, trans_id)
 
3764
            tt.apply()
 
3765
        finally:
 
3766
            tt.finalize()
 
3767
        transform.link_tree(self.child_tree, self.parent_tree)
 
3768
        self.assertFalse(self.hardlinked())
 
3769
 
 
3770
    def test_link_succeeds_if_unmodified(self):
 
3771
        """If the file to be linked is unmodified, link"""
 
3772
        transform.link_tree(self.child_tree, self.parent_tree)
 
3773
        self.assertTrue(self.hardlinked())