Only mkdirp() the .redo directory in one place right at the beginning.

This doesn't really seem to change anything, but it's more correct and
should reveal weirdness (especially an incorrect .redo directory in a
sub-redo) sooner.
This commit is contained in:
Avery Pennarun 2010-11-19 03:13:40 -08:00
commit 132ff02840
3 changed files with 9 additions and 7 deletions

View file

@ -46,7 +46,6 @@ if not vars.TARGET:
try: try:
want_build = [] want_build = []
for t in sys.argv[1:]: for t in sys.argv[1:]:
mkdirp('%s/.redo' % vars.BASE)
state.add_dep(vars.TARGET, 'm', t) state.add_dep(vars.TARGET, 'm', t)
if dirty_deps(t, depth = ''): if dirty_deps(t, depth = ''):
want_build.append(t) want_build.append(t)

View file

@ -10,7 +10,6 @@ if not vars.TARGET:
try: try:
for t in sys.argv[1:]: for t in sys.argv[1:]:
mkdirp('%s/.redo' % vars.BASE)
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)

14
redo.py
View file

@ -22,7 +22,9 @@ if opt.verbose:
if opt.shuffle: if opt.shuffle:
os.environ['REDO_SHUFFLE'] = '1' os.environ['REDO_SHUFFLE'] = '1'
is_root = False
if not os.environ.get('REDO_BASE', ''): if not os.environ.get('REDO_BASE', ''):
is_root = True
base = os.path.commonprefix([os.path.abspath(os.path.dirname(t)) base = os.path.commonprefix([os.path.abspath(os.path.dirname(t))
for t in targets] + [os.getcwd()]) for t in targets] + [os.getcwd()])
bsplit = base.split('/') bsplit = base.split('/')
@ -35,18 +37,21 @@ if not os.environ.get('REDO_BASE', ''):
os.environ['REDO_STARTDIR'] = os.getcwd() os.environ['REDO_STARTDIR'] = os.getcwd()
os.environ['REDO'] = os.path.abspath(sys.argv[0]) os.environ['REDO'] = os.path.abspath(sys.argv[0])
import vars, state
from helpers import *
if is_root:
# FIXME: just wiping out all the locks is kind of cheating. But we # FIXME: just wiping out all the locks is kind of cheating. But we
# only do this from the toplevel redo process, so unless the user # only do this from the toplevel redo process, so unless the user
# deliberately starts more than one redo on the same repository, it's # deliberately starts more than one redo on the same repository, it's
# sort of ok. # sort of ok.
mkdirp('%s/.redo' % base)
for f in glob.glob('%s/.redo/lock^*' % base): for f in glob.glob('%s/.redo/lock^*' % base):
os.unlink(f) os.unlink(f)
import vars, state
from helpers import *
class BuildError(Exception): class BuildError(Exception):
pass pass
class BuildLocked(Exception): class BuildLocked(Exception):
@ -139,7 +144,6 @@ def _build(t):
def build(t): def build(t):
mkdirp('%s/.redo' % vars.BASE)
lock = state.Lock(t) lock = state.Lock(t)
lock.lock() lock.lock()
if not lock.owned: if not lock.owned: