1407
1399
return ChangeExecFlag(exec_flag_a, exec_flag_b)
1409
def make_contents_change(self, full_path_a, stat_a, full_path_b, stat_b):
1410
if stat_a is None and stat_b is None:
1412
if None not in (stat_a, stat_b) and stat.S_ISDIR(stat_a.st_mode) and\
1413
stat.S_ISDIR(stat_b.st_mode):
1415
if None not in (stat_a, stat_b) and stat.S_ISREG(stat_a.st_mode) and\
1416
stat.S_ISREG(stat_b.st_mode):
1417
if stat_a.st_ino == stat_b.st_ino and \
1418
stat_a.st_dev == stat_b.st_dev:
1401
def make_contents_change(self, file_id):
1402
kind_a = kind_b = None
1403
if file_id in self.tree_a:
1404
kind_a = self.tree_a.kind(file_id)
1405
if file_id in self.tree_b:
1406
kind_b = self.tree_b.kind(file_id)
1421
a_contents = self.get_contents(stat_a, full_path_a)
1422
b_contents = self.get_contents(stat_b, full_path_b)
1408
a_contents = self.get_contents(self.tree_a, file_id, kind_a)
1409
b_contents = self.get_contents(self.tree_b, file_id, kind_b)
1423
1410
if a_contents == b_contents:
1425
1412
return ReplaceContents(a_contents, b_contents)
1427
def get_contents(self, stat_result, full_path):
1428
if stat_result is None:
1414
def get_contents(self, tree, file_id, kind):
1430
elif stat.S_ISREG(stat_result.st_mode):
1431
return FileCreate(file(full_path, "rb").read())
1432
elif stat.S_ISDIR(stat_result.st_mode):
1417
elif kind == "file":
1418
return FileCreate(tree.get_file(file_id).read())
1419
elif kind in ("directory", "root_directory"):
1433
1420
return dir_create
1434
elif stat.S_ISLNK(stat_result.st_mode):
1435
return SymlinkCreate(os.readlink(full_path))
1421
elif kind == "symlink":
1422
return SymlinkCreate(tree.get_symlink_target(file_id))
1437
1424
raise UnsupportedFiletype(full_path, stat_result)
1439
def lstat(self, full_path):
1441
if full_path is not None:
1443
stat_result = os.lstat(full_path)
1445
if e.errno != errno.ENOENT:
1450
1427
def full_path(entry, tree):
1451
1428
return os.path.join(tree.root, entry.path)