By default, filecmp.cmp() compares two files by looking file sizes.

shallow=False tells cmp() to look file content.
This commit is contained in:
Bahadır Kandemir
2009-01-20 12:46:56 +00:00
parent 9a17fe0ec0
commit b659c008b9
+3 -1
View File
@@ -208,7 +208,9 @@ def dosed(sourceFiles, findPattern, replacePattern = ''):
line = re.sub(findPattern, replacePattern, line)
sys.stdout.write(line)
if can_access_file(backupFile):
if filecmp.cmp(sourceFile, backupFile):
# By default, filecmp.cmp() compares two files by looking file sizes.
# shallow=False tells cmp() to look file content.
if filecmp.cmp(sourceFile, backupFile, shallow=False):
ctx.ui.warning(_('dosed method has not changed file \'%s\'.') % sourceFile)
else:
os.unlink(backupFile)