From 132ff0284080e7206bbd7b5c1025ec57be369d69 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Fri, 19 Nov 2010 03:13:40 -0800 Subject: [PATCH] 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. --- redo-ifchange.py | 1 - redo-ifcreate.py | 1 - redo.py | 14 +++++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/redo-ifchange.py b/redo-ifchange.py index 0e7d79c..d0e9472 100755 --- a/redo-ifchange.py +++ b/redo-ifchange.py @@ -46,7 +46,6 @@ if not vars.TARGET: try: want_build = [] for t in sys.argv[1:]: - mkdirp('%s/.redo' % vars.BASE) state.add_dep(vars.TARGET, 'm', t) if dirty_deps(t, depth = ''): want_build.append(t) diff --git a/redo-ifcreate.py b/redo-ifcreate.py index 2bd8cd1..160fff5 100755 --- a/redo-ifcreate.py +++ b/redo-ifcreate.py @@ -10,7 +10,6 @@ if not vars.TARGET: try: for t in sys.argv[1:]: - mkdirp('%s/.redo' % vars.BASE) if os.path.exists(t): err('redo-ifcreate: error: %r already exists\n' % t) sys.exit(1) diff --git a/redo.py b/redo.py index 0fcdcaf..2092a99 100755 --- a/redo.py +++ b/redo.py @@ -22,7 +22,9 @@ if opt.verbose: if opt.shuffle: os.environ['REDO_SHUFFLE'] = '1' +is_root = False if not os.environ.get('REDO_BASE', ''): + is_root = True base = os.path.commonprefix([os.path.abspath(os.path.dirname(t)) for t in targets] + [os.getcwd()]) bsplit = base.split('/') @@ -35,18 +37,21 @@ if not os.environ.get('REDO_BASE', ''): os.environ['REDO_STARTDIR'] = os.getcwd() 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 # only do this from the toplevel redo process, so unless the user # deliberately starts more than one redo on the same repository, it's # sort of ok. + mkdirp('%s/.redo' % base) for f in glob.glob('%s/.redo/lock^*' % base): os.unlink(f) -import vars, state -from helpers import * - - class BuildError(Exception): pass class BuildLocked(Exception): @@ -139,7 +144,6 @@ def _build(t): def build(t): - mkdirp('%s/.redo' % vars.BASE) lock = state.Lock(t) lock.lock() if not lock.owned: