~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
 
18
import stat
 
19
import sys
18
20
 
19
 
from bzrlib import tests
 
21
from bzrlib import (
 
22
    tests,
 
23
    urlutils,
 
24
    )
20
25
from bzrlib.bzrdir import BzrDir
21
26
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
22
27
                              UnversionedParent, ParentLoop, DeletingParent,)
30
35
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths, 
31
36
                              resolve_conflicts, cook_conflicts, 
32
37
                              find_interesting, build_tree, get_backup_name)
33
 
import bzrlib.urlutils as urlutils
34
38
from bzrlib.workingtree import gen_root_id
35
39
 
36
40
 
537
541
        self.assertTrue(wt.is_executable('soc'))
538
542
        self.assertTrue(wt.is_executable('sac'))
539
543
 
 
544
    def test__set_mode_stats_correctly(self):
 
545
        """_set_mode stats to determine file mode."""
 
546
        if sys.platform == 'win32':
 
547
            raise TestSkipped('chmod has no effect on win32')
 
548
 
 
549
        stat_paths = []
 
550
        real_stat = os.stat
 
551
        def instrumented_stat(path):
 
552
            stat_paths.append(path)
 
553
            return real_stat(path)
 
554
 
 
555
        transform, root = self.get_transform()
 
556
 
 
557
        bar1_id = transform.new_file('bar', root, 'bar contents 1\n',
 
558
                                     file_id='bar-id-1', executable=False)
 
559
        transform.apply()
 
560
 
 
561
        transform, root = self.get_transform()
 
562
        bar1_id = transform.trans_id_tree_path('bar')
 
563
        bar2_id = transform.trans_id_tree_path('bar2')
 
564
        try:
 
565
            os.stat = instrumented_stat
 
566
            transform.create_file('bar2 contents\n', bar2_id, mode_id=bar1_id)
 
567
        finally:
 
568
            os.stat = real_stat
 
569
            transform.finalize()
 
570
 
 
571
        bar1_abspath = self.wt.abspath('bar')
 
572
        self.assertEqual([bar1_abspath], stat_paths)
 
573
 
540
574
 
541
575
class TransformGroup(object):
542
576
    def __init__(self, dirname, root_id):
738
772
        self.assertIs(os.path.lexists(this.wt.abspath('b/h1.OTHER')), False)
739
773
        self.assertEqual(this.wt.id2path('i'), pathjoin('b/i1.OTHER'))
740
774
 
 
775
 
741
776
class TestBuildTree(tests.TestCaseWithTransport):
742
777
 
743
778
    def test_build_tree(self):