From 2e71e20ce2cc572e49236eafa5de3bc67f9667b7 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Fri, 12 Nov 2010 23:20:37 -0800 Subject: [PATCH] When auto-choosing a .redo dir, prefer ones uphill that already exist. So if we're in redo/t/ and running 'redo hello', we'll detect redo/.redo and use that one rather than creating a new redo/t/.redo directory. The downside of this is we get slightly different behaviour if the *first* thing you build isn't from the root. Probably that's bad, but it should hopefully be rare. --- clean.do | 3 ++- redo.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clean.do b/clean.do index 69f280e..b519b35 100644 --- a/clean.do +++ b/clean.do @@ -1,2 +1,3 @@ rm -f t/hello t/[by]ellow t/*.o *~ .*~ t/*~ t/.*~ *.pyc t/CC t/LD -rm -rf .redo +rm -rf .redo t/.redo + diff --git a/redo.py b/redo.py index 052286d..fd97abf 100755 --- a/redo.py +++ b/redo.py @@ -173,7 +173,13 @@ assert(not (opt.ifchange and opt.ifcreate)) if not os.environ.get('REDO_BASE', ''): base = os.path.commonprefix([os.path.abspath(os.path.dirname(t)) - for t in targets]) + for t in targets] + [os.getcwd()]) + bsplit = base.split('/') + for i in range(len(bsplit)-1, 0, -1): + newbase = '%s/.redo' % '/'.join(bsplit[:i]) + if os.path.exists(newbase): + base = newbase + break os.environ['REDO_BASE'] = base mkdirp('%s/.redo' % base)