Calculate dependencies with fewer sqlite queries.
This commit is contained in:
parent
c339359f04
commit
fb79851530
2 changed files with 21 additions and 11 deletions
|
|
@ -25,13 +25,12 @@ def dirty_deps(f, depth, max_changed):
|
|||
debug('%s-- DIRTY (mtime)\n' % depth)
|
||||
return True
|
||||
|
||||
for mode,name in f.deps():
|
||||
for mode,f2 in f.deps():
|
||||
if mode == 'c':
|
||||
if os.path.exists(name):
|
||||
if os.path.exists(os.path.join(vars.BASE, f2.name)):
|
||||
debug('%s-- DIRTY (created)\n' % depth)
|
||||
return True
|
||||
elif mode == 'm':
|
||||
f2 = state.File(name=os.path.join(vars.BASE, name))
|
||||
if dirty_deps(f2, depth = depth + ' ',
|
||||
max_changed = f.changed_runid):
|
||||
debug('%s-- DIRTY (sub)\n' % depth)
|
||||
|
|
|
|||
27
state.py
27
state.py
|
|
@ -113,7 +113,14 @@ class File(object):
|
|||
'checked_runid', 'changed_runid',
|
||||
'stamp', 'csum']
|
||||
|
||||
def __init__(self, id=None, name=None):
|
||||
def _init_from_cols(self, cols):
|
||||
(self.id, self.name, self.is_generated,
|
||||
self.checked_runid, self.changed_runid,
|
||||
self.stamp, self.csum) = cols
|
||||
|
||||
def __init__(self, id=None, name=None, cols=None):
|
||||
if cols:
|
||||
return self._init_from_cols(cols)
|
||||
q = ('select rowid, name, is_generated, checked_runid, changed_runid, '
|
||||
' stamp, csum '
|
||||
' from Files ')
|
||||
|
|
@ -136,9 +143,7 @@ class File(object):
|
|||
d.commit()
|
||||
row = d.execute(q, l).fetchone()
|
||||
assert(row)
|
||||
(self.id, self.name, self.is_generated,
|
||||
self.checked_runid, self.changed_runid,
|
||||
self.stamp, self.csum) = row
|
||||
self._init_from_cols(row)
|
||||
|
||||
def save(self):
|
||||
if not os.path.exists('%s/.redo' % vars.BASE):
|
||||
|
|
@ -180,11 +185,17 @@ class File(object):
|
|||
and self.changed_runid >= self.checked_runid))
|
||||
|
||||
def deps(self):
|
||||
q = "select mode, source from Deps where target=?"
|
||||
for mode,source_id in db().execute(q, [self.id]).fetchall():
|
||||
q = ('select Deps.mode, Deps.source, '
|
||||
' name, is_generated, checked_runid, changed_runid, '
|
||||
' stamp, csum '
|
||||
' from Files '
|
||||
' join Deps on Files.rowid = Deps.source '
|
||||
' where target=?')
|
||||
for row in db().execute(q, [self.id]).fetchall():
|
||||
mode = row[0]
|
||||
cols = row[1:]
|
||||
assert(mode in ('c', 'm'))
|
||||
name = File(id=source_id).name
|
||||
yield mode,name
|
||||
yield mode,File(cols=cols)
|
||||
|
||||
def zap_deps(self):
|
||||
debug2('zap-deps: %r\n' % self.name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue