In commit redo-0.11-4-g34669fb, we changed os.stat into os.lstat to avoid false positives in the "manual override" detector: a .do file that generates $3 as a symlink would trigger manual override if the *target* of that symlink ever changed, which is incorrect. Unfortunately using os.lstat() leads to a different problem: if X depends on Y and Y is a symlink to Z, then X would not be rebuilt when Z changes, which is clearly wrong. The fix is twofold: 1. read_stamp() should change on changes to both the link itself, *and* the target of the link. 2. We shouldn't mark a target as overridden under so many situations. We'll use *only* the primary mtime of the os.lstat(), not all the other bits in the stamp. Step 2 fixes a few other false positives also. For example, if you 'cp -a' a whole tree to another location, the st_ino of all the targets will change, which would trigger a mass of "manual override" warnings. Although a change in inode is sufficient to count an input as having changed (just to be extra safe), it should *not* be considered a manual override. Now we can distinguish between the two. Because the stamp format has changed, update the SCHEMA_VER field. I should have done this every other time I changed the stamp format, but I forgot. Sorry. That leads to spurious "manually modified" warnings after upgrading redo.
59 lines
1.7 KiB
Python
Executable file
59 lines
1.7 KiB
Python
Executable file
#!/usr/bin/env python2
|
|
import os, sys, traceback
|
|
|
|
import vars_init
|
|
vars_init.init(sys.argv[1:])
|
|
|
|
import vars, state, builder, jwack, deps
|
|
from helpers import unlink
|
|
from logs import debug, debug2, err
|
|
|
|
def should_build(t):
|
|
f = state.File(name=t)
|
|
if f.is_failed():
|
|
raise builder.ImmediateReturn(32)
|
|
dirty = deps.isdirty(f, depth = '', max_changed = vars.RUNID,
|
|
already_checked=[])
|
|
return f.is_generated, dirty==[f] and deps.DIRTY or dirty
|
|
|
|
|
|
rv = 202
|
|
try:
|
|
if vars_init.is_toplevel:
|
|
builder.start_stdin_log_reader(status=True, details=True,
|
|
pretty=True, color=True, debug_locks=False, debug_pids=False)
|
|
if vars.TARGET and not vars.UNLOCKED:
|
|
me = os.path.join(vars.STARTDIR,
|
|
os.path.join(vars.PWD, vars.TARGET))
|
|
f = state.File(name=me)
|
|
debug2('TARGET: %r %r %r\n' % (vars.STARTDIR, vars.PWD, vars.TARGET))
|
|
else:
|
|
f = me = None
|
|
debug2('redo-ifchange: not adding depends.\n')
|
|
jwack.setup(1)
|
|
try:
|
|
targets = sys.argv[1:]
|
|
if f:
|
|
for t in targets:
|
|
f.add_dep('m', t)
|
|
f.save()
|
|
state.commit()
|
|
rv = builder.main(targets, should_build)
|
|
finally:
|
|
try:
|
|
state.rollback()
|
|
finally:
|
|
try:
|
|
jwack.force_return_tokens()
|
|
except Exception, e:
|
|
traceback.print_exc(100, sys.stderr)
|
|
err('unexpected error: %r\n' % e)
|
|
rv = 1
|
|
except KeyboardInterrupt:
|
|
if vars_init.is_toplevel:
|
|
builder.await_log_reader()
|
|
sys.exit(200)
|
|
state.commit()
|
|
if vars_init.is_toplevel:
|
|
builder.await_log_reader()
|
|
sys.exit(rv)
|