Move 'redo --ifchange' into 'redo-ifchange' to match djb's style.

It does simplify the logic of both redo.py and redo-ifchange.py, I suppose.
This commit is contained in:
Avery Pennarun 2010-11-13 00:45:49 -08:00
commit c57de820fb
12 changed files with 103 additions and 87 deletions

27
libdo.py Normal file
View file

@ -0,0 +1,27 @@
import sys, os
import vars
def relpath(t, base):
t = os.path.abspath(t)
tparts = t.split('/')
bparts = base.split('/')
for tp,bp in zip(tparts,bparts):
if tp != bp:
break
tparts.pop(0)
bparts.pop(0)
while bparts:
tparts.insert(0, '..')
bparts.pop(0)
return '/'.join(tparts)
def sname(typ, t):
# FIXME: t.replace(...) is non-reversible and non-unique here!
tnew = relpath(t, vars.BASE)
#log('sname: (%r) %r -> %r\n' % (vars.BASE, t, tnew))
return vars.BASE + ('/.redo/%s^%s' % (typ, tnew.replace('/', '^')))
def add_dep(t, mode, dep):
open(sname('dep', t), 'a').write('%s %s\n' % (mode, dep))