41
42
TestCaseInTempDir, TestSkipped)
45
class _AttribFeature(Feature):
48
if (sys.platform not in ('cygwin', 'win32')):
51
proc = subprocess.Popen(['attrib', '.'], stdout=subprocess.PIPE)
54
return (0 == proc.wait())
56
def feature_name(self):
57
return 'attrib Windows command-line tool'
59
AttribFeature = _AttribFeature()
44
62
class _CompiledPatienceDiffFeature(Feature):
1278
1296
self.assertEqual('a-tool-which-is-unlikely-to-exist could not be found'
1279
1297
' on this machine', str(e))
1299
def test_prepare_files_creates_paths_readable_by_windows_tool(self):
1300
self.requireFeature(AttribFeature)
1302
tree = self.make_branch_and_tree('tree')
1303
self.build_tree_contents([('tree/file', 'content')])
1304
tree.add('file', 'file-id')
1305
tree.commit('old tree')
1307
self.addCleanup(tree.unlock)
1308
diff_obj = DiffFromTool(['python', '-c',
1309
'print "%(old_path)s %(new_path)s"'],
1311
diff_obj._prepare_files('file-id', 'file', 'file')
1312
self.assertReadableByAttrib(diff_obj._root, 'old\\file', r'old\\file')
1313
self.assertReadableByAttrib(diff_obj._root, 'new\\file', r'new\\file')
1315
def assertReadableByAttrib(self, cwd, relpath, regex):
1316
proc = subprocess.Popen(['attrib', relpath],
1317
stdout=subprocess.PIPE,
1320
result = proc.stdout.read()
1321
self.assertContainsRe(result, regex)
1281
1323
def test_prepare_files(self):
1282
1324
output = StringIO()
1283
1325
tree = self.make_branch_and_tree('tree')
1284
1326
self.build_tree_contents([('tree/oldname', 'oldcontent')])
1327
self.build_tree_contents([('tree/oldname2', 'oldcontent2')])
1285
1328
tree.add('oldname', 'file-id')
1329
tree.add('oldname2', 'file2-id')
1286
1330
tree.commit('old tree', timestamp=0)
1287
1331
tree.rename_one('oldname', 'newname')
1332
tree.rename_one('oldname2', 'newname2')
1288
1333
self.build_tree_contents([('tree/newname', 'newcontent')])
1334
self.build_tree_contents([('tree/newname2', 'newcontent2')])
1289
1335
old_tree = tree.basis_tree()
1290
1336
old_tree.lock_read()
1291
1337
self.addCleanup(old_tree.unlock)
1303
1349
self.assertContainsRe(new_path, 'new/newname$')
1304
1350
self.assertFileEqual('oldcontent', old_path)
1305
1351
self.assertFileEqual('newcontent', new_path)
1306
if osutils.has_symlinks():
1352
if osutils.host_os_dereferences_symlinks():
1307
1353
self.assertTrue(os.path.samefile('tree/newname', new_path))
1308
1354
# make sure we can create files with the same parent directories
1309
diff_obj._prepare_files('file-id', 'oldname2', 'newname2')
1355
diff_obj._prepare_files('file2-id', 'oldname2', 'newname2')