diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-03-10 01:53:24 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-03-10 01:53:24 +0200 |
commit | ba70bf7e3f8f83fea1f1b780525002dd7c735003 (patch) | |
tree | 94b34228f675c616081ee84e0587f3ef4171e59b /backends.py | |
parent | 8b7465d10153c139f468e0d2a5341ad4f10ab1e0 (diff) | |
download | meson-ba70bf7e3f8f83fea1f1b780525002dd7c735003.zip meson-ba70bf7e3f8f83fea1f1b780525002dd7c735003.tar.gz meson-ba70bf7e3f8f83fea1f1b780525002dd7c735003.tar.bz2 |
Do not touch conf files if the new one would be identical to the old one.
Diffstat (limited to 'backends.py')
-rwxr-xr-x | backends.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/backends.py b/backends.py index 0aec6e2..9ac6fbf 100755 --- a/backends.py +++ b/backends.py @@ -53,7 +53,16 @@ def do_conf_file(src, dst, variables): line = line.replace('@' + varname + '@', var) match = re.search(regex, line) result.append(line) - open(dst, 'w').writelines(result) + dst_tmp = dst + '~' + open(dst_tmp, 'w').writelines(result) + # If contents are identical, don't touch the file to prevent + # unnecessary rebuilds. + try: + if open(dst, 'r').read() == open(dst_tmp, 'r').read(): + return + except FileNotFoundError: + pass + os.replace(dst_tmp, dst) class Backend(): |