redo-always/redo-ifcreate/redo-stamp: work inside chdir().

If someone cd's to another directory and then runs redo-always, we weren't
adding to the right target.
This commit is contained in:
Avery Pennarun 2010-12-11 23:00:53 -08:00
commit e6f95521ae
6 changed files with 26 additions and 7 deletions

View file

@ -5,8 +5,10 @@ from log import err
try: try:
me = state.File(name=vars.TARGET) me = os.path.join(vars.STARTDIR,
me.add_dep('m', state.ALWAYS) os.path.join(vars.PWD, vars.TARGET))
f = state.File(name=me)
f.add_dep('m', state.ALWAYS)
always = state.File(name=state.ALWAYS) always = state.File(name=state.ALWAYS)
always.stamp = state.STAMP_MISSING always.stamp = state.STAMP_MISSING
always.set_changed() always.set_changed()

View file

@ -5,12 +5,14 @@ from log import err
try: try:
me = state.File(name=vars.TARGET) me = os.path.join(vars.STARTDIR,
os.path.join(vars.PWD, vars.TARGET))
f = state.File(name=me)
for t in sys.argv[1:]: for t in sys.argv[1:]:
if os.path.exists(t): if os.path.exists(t):
err('redo-ifcreate: error: %r already exists\n' % t) err('redo-ifcreate: error: %r already exists\n' % t)
sys.exit(1) sys.exit(1)
else: else:
me.add_dep('c', t) f.add_dep('c', t)
except KeyboardInterrupt: except KeyboardInterrupt:
sys.exit(200) sys.exit(200)

View file

@ -33,7 +33,9 @@ csum = sh.hexdigest()
if not vars.TARGET: if not vars.TARGET:
sys.exit(0) sys.exit(0)
f = state.File(name=vars.TARGET) me = os.path.join(vars.STARTDIR,
os.path.join(vars.PWD, vars.TARGET))
f = state.File(name=me)
changed = (csum != f.csum) changed = (csum != f.csum)
debug2('%s: old = %s\n' % (f.name, f.csum)) debug2('%s: old = %s\n' % (f.name, f.csum))
debug2('%s: sum = %s (%s)\n' % (f.name, csum, debug2('%s: sum = %s (%s)\n' % (f.name, csum,

View file

@ -1,3 +1,4 @@
echo $$ >>always1.log echo $$ >>always1.log
echo $$ echo $$
cd ..
redo-always redo-always

View file

@ -1,6 +1,8 @@
rm -f always1 always1.log rm -f always1 always1.log
redo always1 cd ..
redo t/always1
cd t
[ "$(wc -l <always1.log)" -eq 1 ] || exit 11 [ "$(wc -l <always1.log)" -eq 1 ] || exit 11
# This shouldn't rebuild, but because other people might be running flush-cache.sh # This shouldn't rebuild, but because other people might be running flush-cache.sh
@ -12,3 +14,12 @@ redo always1
redo-ifchange always1 redo-ifchange always1
. ./skip-if-minimal-do.sh . ./skip-if-minimal-do.sh
[ "$(wc -l <always1.log)" -eq 2 ] || exit 31 [ "$(wc -l <always1.log)" -eq 2 ] || exit 31
./flush-cache.sh
redo-ifchange always1
[ "$(wc -l <always1.log)" -eq 3 ] || exit 41
cd ..
./t/flush-cache.sh
redo-ifchange t/always1
[ "$(wc -l <t/always1.log)" -eq 4 ] || exit 51

View file

@ -1,4 +1,5 @@
echo $$ >>stampy.log echo $$ >>stampy.log
redo-ifchange inp bob redo-ifchange inp bob
cat inp cat inp
redo-stamp <inp cd ..
redo-stamp <stamp/inp