/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/per_workingtree/test_executable.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
                the inventory is empty, just that the tree doesn't have them
57
57
        """
58
58
        tree.lock_read()
59
 
        if not ignore_inv:
 
59
        if not ignore_inv and getattr(tree, 'root_inventory', None):
60
60
            self.assertEqual(
61
61
                [('', tree.root_inventory.root)],
62
62
                list(tree.root_inventory.iter_entries()))
68
68
 
69
69
    def commit_and_branch(self):
70
70
        """Commit the current tree, and create a second tree"""
71
 
        self.wt.commit('adding a,b', rev_id='r1')
 
71
        r1 = self.wt.commit('adding a,b')
72
72
        # Now make sure that 'bzr branch' also preserves the
73
73
        # executable bit
74
 
        dir2 = self.wt.branch.controldir.sprout('b2', revision_id='r1')
 
74
        dir2 = self.wt.branch.controldir.sprout('b2', revision_id=r1)
75
75
        wt2 = dir2.open_workingtree()
76
 
        self.assertEqual(['r1'], wt2.get_parent_ids())
77
 
        self.assertEqual('r1', wt2.branch.last_revision())
78
 
        return wt2
 
76
        self.assertEqual([r1], wt2.get_parent_ids())
 
77
        self.assertEqual(r1, wt2.branch.last_revision())
 
78
        return wt2, r1
79
79
 
80
80
    def test_01_is_executable(self):
81
81
        """Make sure that the tree was created and has the executable bit set"""
88
88
 
89
89
    def test_03_after_commit(self):
90
90
        """Commit the change, and check the history"""
91
 
        self.wt.commit('adding a,b', rev_id='r1')
 
91
        r1 = self.wt.commit('adding a,b')
92
92
 
93
 
        rev_tree = self.wt.branch.repository.revision_tree('r1')
 
93
        rev_tree = self.wt.branch.repository.revision_tree(r1)
94
94
        self.check_exist(rev_tree)
95
95
 
96
96
    def test_04_after_removed(self):
97
97
        """Make sure reverting removed files brings them back correctly"""
98
 
        self.wt.commit('adding a,b', rev_id='r1')
 
98
        r1 = self.wt.commit('adding a,b')
99
99
 
100
100
        # Make sure the entries are gone
101
101
        os.remove('b1/a')
105
105
        # Make sure that revert is able to bring them back,
106
106
        # and sets 'a' back to being executable
107
107
 
108
 
        rev_tree = self.wt.branch.repository.revision_tree('r1')
 
108
        rev_tree = self.wt.branch.repository.revision_tree(r1)
109
109
 
110
110
        self.wt.revert(['a', 'b'], rev_tree, backups=False)
111
111
        self.check_exist(self.wt)
112
112
 
113
113
    def test_05_removed_and_committed(self):
114
114
        """Check that reverting to an earlier commit restores them"""
115
 
        self.wt.commit('adding a,b', rev_id='r1')
 
115
        r1 = self.wt.commit('adding a,b')
116
116
 
117
117
        # Now remove them again, and make sure that after a
118
118
        # commit, they are still marked correctly
119
119
        os.remove('b1/a')
120
120
        os.remove('b1/b')
121
 
        self.wt.commit('removed', rev_id='r2')
 
121
        r2 = self.wt.commit('removed')
122
122
 
123
123
        self.check_empty(self.wt)
124
124
 
125
 
        rev_tree = self.wt.branch.repository.revision_tree('r1')
 
125
        rev_tree = self.wt.branch.repository.revision_tree(r1)
126
126
        # Now revert back to the previous commit
127
127
        self.wt.revert(old_tree=rev_tree, backups=False)
128
128
 
131
131
    def test_06_branch(self):
132
132
        """branch b1=>b2 should preserve the executable bits"""
133
133
        # TODO: Maybe this should be a blackbox test
134
 
        wt2 = self.commit_and_branch()
 
134
        wt2, r1 = self.commit_and_branch()
135
135
 
136
136
        self.check_exist(wt2)
137
137
 
138
138
    def test_07_pull(self):
139
139
        """Test that pull will handle bits correctly"""
140
 
        wt2 = self.commit_and_branch()
 
140
        wt2, r1 = self.commit_and_branch()
141
141
 
142
142
        os.remove('b1/a')
143
143
        os.remove('b1/b')
144
 
        self.wt.commit('removed', rev_id='r2')
 
144
        r2 = self.wt.commit('removed')
145
145
 
146
146
        # now wt2 can pull and the files should be removed
147
147
 
148
148
        # Make sure pull will delete the files
149
149
        wt2.pull(self.wt.branch)
150
 
        self.assertEqual(['r2'], wt2.get_parent_ids())
151
 
        self.assertEqual('r2', wt2.branch.last_revision())
 
150
        self.assertEqual([r2], wt2.get_parent_ids())
 
151
        self.assertEqual(r2, wt2.branch.last_revision())
152
152
        self.check_empty(wt2)
153
153
 
154
154
        # Now restore the files on the first branch and commit
155
155
        # so that the second branch can pull the changes
156
156
        # and make sure that the executable bit has been copied
157
 
        rev_tree = self.wt.branch.repository.revision_tree('r1')
 
157
        rev_tree = self.wt.branch.repository.revision_tree(r1)
158
158
        self.wt.revert(old_tree=rev_tree, backups=False)
159
 
        self.wt.commit('resurrected', rev_id='r3')
 
159
        r3 = self.wt.commit('resurrected')
160
160
 
161
161
        self.check_exist(self.wt)
162
162
 
163
163
        wt2.pull(self.wt.branch)
164
 
        self.assertEqual(['r3'], wt2.get_parent_ids())
165
 
        self.assertEqual('r3', wt2.branch.last_revision())
 
164
        self.assertEqual([r3], wt2.get_parent_ids())
 
165
        self.assertEqual(r3, wt2.branch.last_revision())
166
166
        self.check_exist(wt2)
167
167
 
168
168
    def test_08_no_op_revert(self):
170
170
 
171
171
        The bits shouldn't swap.
172
172
        """
173
 
        self.wt.commit('adding a,b', rev_id='r1')
174
 
        rev_tree = self.wt.branch.repository.revision_tree('r1')
 
173
        r1 = self.wt.commit('adding a,b')
 
174
        rev_tree = self.wt.branch.repository.revision_tree(r1)
175
175
        self.wt.revert(old_tree=rev_tree, backups=False)
176
176
        self.check_exist(self.wt)
177
177
 
180
180
            self.wt._is_executable_from_path_and_stat_from_basis
181
181
        rev_id1 = self.wt.commit('one')
182
182
        rev_tree1 = self.wt.branch.repository.revision_tree(rev_id1)
183
 
        a_executable = rev_tree1.root_inventory[self.a_id].executable
184
 
        b_executable = rev_tree1.root_inventory[self.b_id].executable
 
183
        a_executable = rev_tree1.is_executable('a')
 
184
        b_executable = rev_tree1.is_executable('b')
185
185
        self.assertIsNot(None, a_executable)
186
186
        self.assertTrue(a_executable)
187
187
        self.assertIsNot(None, b_executable)