~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-22 00:24:07 UTC
  • mfrom: (2027.1.1 revert-subpath-56549)
  • Revision ID: pqm@pqm.ubuntu.com-20060922002407-21dde3dd8419b20b
(jam, abentley) Fix bug #56549 by making TreeTransform._set_mode stat the right file

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
 
38
 
34
39
 
35
40
class TestTreeTransform(TestCaseInTempDir):
36
41
 
535
540
        self.assertTrue(wt.is_executable('soc'))
536
541
        self.assertTrue(wt.is_executable('sac'))
537
542
 
 
543
    def test__set_mode_stats_correctly(self):
 
544
        """_set_mode stats to determine file mode."""
 
545
        if sys.platform == 'win32':
 
546
            raise TestSkipped('chmod has no effect on win32')
 
547
 
 
548
        stat_paths = []
 
549
        real_stat = os.stat
 
550
        def instrumented_stat(path):
 
551
            stat_paths.append(path)
 
552
            return real_stat(path)
 
553
 
 
554
        transform, root = self.get_transform()
 
555
 
 
556
        bar1_id = transform.new_file('bar', root, 'bar contents 1\n',
 
557
                                     file_id='bar-id-1', executable=False)
 
558
        transform.apply()
 
559
 
 
560
        transform, root = self.get_transform()
 
561
        bar1_id = transform.trans_id_tree_path('bar')
 
562
        bar2_id = transform.trans_id_tree_path('bar2')
 
563
        try:
 
564
            os.stat = instrumented_stat
 
565
            transform.create_file('bar2 contents\n', bar2_id, mode_id=bar1_id)
 
566
        finally:
 
567
            os.stat = real_stat
 
568
            transform.finalize()
 
569
 
 
570
        bar1_abspath = self.wt.abspath('bar')
 
571
        self.assertEqual([bar1_abspath], stat_paths)
 
572
 
538
573
 
539
574
class TransformGroup(object):
540
575
    def __init__(self, dirname):
731
766
        self.assertIs(os.path.lexists(this.wt.abspath('b/h1.OTHER')), False)
732
767
        self.assertEqual(this.wt.id2path('i'), pathjoin('b/i1.OTHER'))
733
768
 
 
769
 
734
770
class TestBuildTree(tests.TestCaseWithTransport):
735
771
 
736
772
    def test_build_tree(self):