# 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) if not vars.DEPTH: # toplevel call to redo exenames = [os.path.abspath(sys.argv[0]), os.path.realpath(sys.argv[0])] if exenames[0] == exenames[1]: exenames = [exenames[0]] dirnames = [os.path.dirname(p) for p in exenames] os.environ['PATH'] = ':'.join(dirnames) + ':' + os.environ['PATH'] try: j = atoi.atoi(opt.jobs or 1) if j < 1 or j > 1000: err('invalid --jobs value: %r\n' % opt.jobs) jwack.setup(j) try: retcode = builder.main(targets, builder.build) finally: jwack.force_return_tokens() if retcode: err('exiting: %d\n' % retcode) sys.exit(retcode) except KeyboardInterrupt: sys.exit(200)
try: from main import mains do_init, jobs, redo_flavour, targets = read_opts() if do_init: init(targets, redo_flavour, mains.keys()) from log import err, debug import jwack if not redo_flavour.startswith("redo"): redo_flavour = "redo-%s" % redo_flavour if redo_flavour not in mains: err("invalid redo: %s\n", redo_flavour) sys.exit(1) set_main(redo_flavour) if jobs < 1 or jobs > 1000: err('invalid --jobs value: %r\n', opt.jobs) jwack.setup(jobs) debug("%s %r\n", redo_flavour, targets) import vars vars.init() sys.exit(mains[redo_flavour](redo_flavour, targets) or 0) except KeyboardInterrupt: sys.exit(200)
if vars_init.is_toplevel: builder.start_stdin_log_reader(status=opt.status, details=opt.details, pretty=opt.pretty, color=opt.color, debug_locks=opt.debug_locks, debug_pids=opt.debug_pids) for t in targets: if os.path.exists(t): f = state.File(name=t) if not f.is_generated: warn('%s: exists and not marked as generated; not redoing.\n' % f.nicename()) state.rollback() j = atoi(opt.jobs or 1) if j < 1 or j > 1000: err('invalid --jobs value: %r\n' % opt.jobs) jwack.setup(j) try: assert(state.is_flushed()) retcode = builder.main(targets, lambda t: (True, True)) assert(state.is_flushed()) finally: try: state.rollback() finally: try: jwack.force_return_tokens() except Exception, e: traceback.print_exc(100, sys.stderr) err('unexpected error: %r\n' % e) retcode = 1 if vars_init.is_toplevel:
rv = 202 try: if vars_init.is_toplevel: builder.start_stdin_log_reader(status=True, details=True, pretty=True, color=True, debug_locks=False, debug_pids=False) if vars.TARGET and not vars.UNLOCKED: me = os.path.join(vars.STARTDIR, os.path.join(vars.PWD, vars.TARGET)) f = state.File(name=me) debug2('TARGET: %r %r %r\n' % (vars.STARTDIR, vars.PWD, vars.TARGET)) else: f = me = None debug2('redo-ifchange: not adding depends.\n') jwack.setup(1) try: targets = sys.argv[1:] if f: for t in targets: f.add_dep('m', t) f.save() state.commit() rv = builder.main(targets, should_build) finally: try: state.rollback() finally: try: jwack.force_return_tokens() except Exception, e: