Some very suspicious changes to relpath() and sname() calls.

The problem is that redo-ifchange has a different $PWD than its
sub-dependencies, so as it's chasing them down, fixing up the relative paths
totally doesn't work at all.

There's probably a much smarter fix than this, but it's too late at night to
think of it right now.
This commit is contained in:
Avery Pennarun 2010-11-16 05:46:52 -08:00
commit 84046bcab2
3 changed files with 19 additions and 14 deletions

View file

@ -83,12 +83,17 @@ def relpath(t, base):
return '/'.join(tparts) return '/'.join(tparts)
def sname(typ, t): def sname(typ, t, fromdir=None):
# FIXME: t.replace(...) is non-reversible and non-unique here! # FIXME: t.replace(...) is non-reversible and non-unique here!
if fromdir:
t = os.path.join(fromdir, t)
tnew = relpath(t, vars.BASE) tnew = relpath(t, vars.BASE)
#log('sname: (%r) %r -> %r\n' % (vars.BASE, t, tnew)) v = vars.BASE + ('/.redo/%s^%s' % (typ, tnew.replace('/', '^')))
return vars.BASE + ('/.redo/%s^%s' % (typ, tnew.replace('/', '^'))) debug2('sname: (%r) %r -> %r\n' % (os.getcwd(), t, tnew))
return v
def add_dep(t, mode, dep): def add_dep(t, mode, dep):
open(sname('dep', t), 'a').write('%s %s\n' % (mode, dep)) debug2('add-dep(%r)\n' % t)
open(sname('dep', t), 'a').write('%s %s\n'
% (mode, relpath(dep, vars.BASE)))

View file

@ -4,15 +4,15 @@ import vars
from helpers import sname, add_dep, debug, err, mkdirp, unlink from helpers import sname, add_dep, debug, err, mkdirp, unlink
def _dirty_deps(t, depth): def _dirty_deps(t, depth, fromdir):
debug('%s?%s\n' % (depth, t)) debug('%s?%s\n' % (depth, t))
if not os.path.exists(sname('stamp', t)): if not os.path.exists(sname('stamp', t, fromdir)):
debug('%s-- DIRTY (no stamp)\n' % depth) debug('%s-- DIRTY (no stamp)\n' % depth)
return True return True
stamptime = os.stat(sname('stamp', t)).st_mtime stamptime = os.stat(sname('stamp', t, fromdir)).st_mtime
try: try:
realtime = os.stat(t).st_mtime realtime = os.stat(os.path.join(fromdir or '', t)).st_mtime
except OSError: except OSError:
realtime = 0 realtime = 0
@ -20,7 +20,7 @@ def _dirty_deps(t, depth):
debug('%s-- DIRTY (mtime)\n' % depth) debug('%s-- DIRTY (mtime)\n' % depth)
return True return True
for sub in open(sname('dep', t)).readlines(): for sub in open(sname('dep', t, fromdir)).readlines():
assert(sub[0] in ('c','m')) assert(sub[0] in ('c','m'))
assert(sub[1] == ' ') assert(sub[1] == ' ')
assert(sub[-1] == '\n') assert(sub[-1] == '\n')
@ -31,15 +31,15 @@ def _dirty_deps(t, depth):
debug('%s-- DIRTY (created)\n' % depth) debug('%s-- DIRTY (created)\n' % depth)
return True return True
elif mode == 'm': elif mode == 'm':
if dirty_deps(name, depth + ' '): if dirty_deps(name, depth + ' ', fromdir=vars.BASE):
#debug('%s-- DIRTY (sub)\n' % depth) #debug('%s-- DIRTY (sub)\n' % depth)
return True return True
return False return False
def dirty_deps(t, depth): def dirty_deps(t, depth, fromdir=None):
if _dirty_deps(t, depth): if _dirty_deps(t, depth, fromdir):
unlink(sname('stamp', t)) # short circuit future checks unlink(sname('stamp', t, fromdir)) # short circuit future checks
return True return True
return False return False

View file

@ -93,7 +93,7 @@ def stamp(t):
def _preexec(t): def _preexec(t):
os.environ['REDO_TARGET'] = t os.environ['REDO_TARGET'] = os.path.basename(t)
os.environ['REDO_DEPTH'] = vars.DEPTH + ' ' os.environ['REDO_DEPTH'] = vars.DEPTH + ' '
dn = os.path.dirname(t) dn = os.path.dirname(t)
if dn: if dn: