159
159
self.addCleanup(branch.unlock)
160
160
self.assertEqual(tree.get_symlink_target(file_id), target)
162
def assertExecutable(self, branch, tree, path, executable):
163
file_id = tree.inventory.path2id(path)
165
self.addCleanup(branch.unlock)
166
self.assertEqual(tree.is_executable(file_id), executable)
162
168
def assertRevisionRoot(self, revtree, path):
163
169
self.assertEqual(revtree.get_revision_id(),
164
170
revtree.inventory.root.children[path].revision)
167
173
class TestModify(TestCaseForGenericProcessor):
169
175
def file_command_iter(self, path, kind='file', content='aaa',
170
to_kind=None, to_content='bbb'):
176
executable=False, to_kind=None, to_content='bbb', to_executable=None):
177
# Revno 1: create a file or symlink
171
179
if to_kind is None:
181
if to_executable is None:
182
to_executable = executable
173
183
def command_list():
174
184
author = ['', 'bugs@a.com', time.time(), time.timezone]
175
185
committer = ['', 'elmer@a.com', time.time(), time.timezone]
177
yield commands.FileModifyCommand(path, kind, False,
187
yield commands.FileModifyCommand(path, kind, executable,
179
189
yield commands.CommitCommand('head', '1', author,
180
190
committer, "commit 1", None, [], files_one)
182
yield commands.FileModifyCommand(path, to_kind, False,
192
yield commands.FileModifyCommand(path, to_kind, to_executable,
183
193
None, to_content)
184
194
yield commands.CommitCommand('head', '2', author,
185
195
committer, "commit 2", ":1", [], files_two)
255
265
self.assertSymlinkTarget(branch, revtree1, path, "aaa")
256
266
self.assertContent(branch, revtree2, path, "bbb")
268
def test_modify_file_now_executable(self):
269
handler, branch = self.get_handler()
271
handler.process(self.file_command_iter(path,
272
executable=False, to_executable=True, to_content='aaa'))
273
revtree0, revtree1 = self.assertChanges(branch, 1,
274
expected_added=[('a',), (path,)])
275
revtree1, revtree2 = self.assertChanges(branch, 2,
276
expected_modified=[(path,)])
277
self.assertExecutable(branch, revtree1, path, False)
278
self.assertExecutable(branch, revtree2, path, True)
280
def test_modify_file_no_longer_executable(self):
281
handler, branch = self.get_handler()
283
handler.process(self.file_command_iter(path,
284
executable=True, to_executable=False, to_content='aaa'))
285
revtree0, revtree1 = self.assertChanges(branch, 1,
286
expected_added=[('a',), (path,)])
287
revtree1, revtree2 = self.assertChanges(branch, 2,
288
expected_modified=[(path,)])
289
self.assertExecutable(branch, revtree1, path, True)
290
self.assertExecutable(branch, revtree2, path, False)
259
293
class TestDelete(TestCaseForGenericProcessor):
261
295
def file_command_iter(self, path, kind='file'):
296
# Revno 1: create a file or symlink
262
298
def command_list():
263
299
author = ['', 'bugs@a.com', time.time(), time.timezone]
264
300
committer = ['', 'elmer@a.com', time.time(), time.timezone]
317
353
class TestRename(TestCaseForGenericProcessor):
319
355
def get_command_iter(self, old_path, new_path):
356
# Revno 1: create a file or symlink
320
358
def command_list():
321
359
author = ['', 'bugs@a.com', time.time(), time.timezone]
322
360
committer = ['', 'elmer@a.com', time.time(), time.timezone]
360
398
class TestCopy(TestCaseForGenericProcessor):
362
400
def file_command_iter(self, src_path, dest_path, kind='file'):
401
# Revno 1: create a file or symlink
363
403
def command_list():
364
404
author = ['', 'bugs@a.com', time.time(), time.timezone]
365
405
committer = ['', 'elmer@a.com', time.time(), time.timezone]