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.
This commit is contained in:
Avery Pennarun 2010-11-12 23:20:37 -08:00
commit 2e71e20ce2
2 changed files with 9 additions and 2 deletions

View file

@ -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)