else: updated_refs[dest_ref] = (orig_ref, new_id) if dest_ref.startswith(b'refs/tags/'): log_item(item.spec.src, item.src.type, opt, tag=new_id) else: log_item(item.spec.src, item.src.type, opt, tree=tree, commit=new_id) # Only update the refs at the very end, once the writer is # closed, so that if something goes wrong above, the old refs # will be undisturbed. for ref_name, info in items(updated_refs): orig_ref, new_ref = info try: dest_repo.update_ref(ref_name, new_ref, orig_ref) if opt.verbose: new_hex = hexlify(new_ref) if orig_ref: orig_hex = hexlify(orig_ref) log('updated %r (%s -> %s)\n' % (ref_name, orig_hex, new_hex)) else: log('updated %r (%s)\n' % (ref_name, new_hex)) except (git.GitError, client.ClientError) as ex: add_error('unable to update ref %r: %s' % (ref_name, ex)) if saved_errors: log('WARNING: %d errors encountered while saving.\n' % len(saved_errors)) sys.exit(1) wrap_main(main)
def main(): wrap_main(lambda : run_subcmd(cmd_module, subcmd))
p = None try: p = subprocess.Popen(c, stdout=PIPE if fix_stdout else sys.stdout, stderr=PIPE if fix_stderr else sys.stderr, preexec_fn=force_tty, bufsize=4096, close_fds=True) # Assume p will receive these signals and quit, which will # then cause us to quit. for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGQUIT): signal.signal(sig, signal.SIG_IGN) filter_output(fix_stdout and p.stdout.fileno() or None, fix_stderr and p.stderr.fileno() or None, fix_stdout and sys.stdout.fileno() or None, fix_stderr and sys.stderr.fileno() or None) return p.wait() except BaseException as ex: add_ex_tb(ex) try: if p and p.poll() == None: os.kill(p.pid, signal.SIGTERM) p.wait() except BaseException as kill_ex: raise chain_ex(add_ex_tb(kill_ex), ex) raise ex wrap_main(lambda: run_subcmd(subcmd))
p = None try: p = subprocess.Popen(c, stdout=PIPE if fix_stdout else sys.stdout, stderr=PIPE if fix_stderr else sys.stderr, preexec_fn=force_tty, bufsize=4096, close_fds=True) # Assume p will receive these signals and quit, which will # then cause us to quit. for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGQUIT): signal.signal(sig, signal.SIG_IGN) filter_output(fix_stdout and p.stdout.fileno() or None, fix_stderr and p.stderr.fileno() or None, fix_stdout and sys.stdout.fileno() or None, fix_stderr and sys.stderr.fileno() or None) return p.wait() except BaseException as ex: add_ex_tb(ex) try: if p and p.poll() == None: os.kill(p.pid, signal.SIGTERM) p.wait() except BaseException as kill_ex: raise chain_ex(add_ex_tb(kill_ex), ex) raise ex wrap_main(lambda : run_subcmd(subcmd))
# Source is /foo/what/ever/ or /foo/what/ever/. -- extract # what/ever/* to the current directory, and if name == '.' # (i.e. /foo/what/ever/.), then also restore what/ever's # metadata to the current directory. treeish = vfs.item_mode(leaf_item) if not treeish: add_error('%r cannot be restored as a directory' % path) else: items = vfs.contents(repo, leaf_item, want_meta=True) dot, leaf_item = next(items, None) assert(dot == '.') for sub_name, sub_item in items: restore(repo, '', sub_name, sub_item, top, opt.sparse, opt.numeric_ids, owner_map, exclude_rxs, verbosity, hardlinks) if path_name == '.': leaf_item = vfs.augment_item_meta(repo, leaf_item, include_size=True) apply_metadata(leaf_item.meta, '.', opt.numeric_ids, owner_map) else: restore(repo, '', leaf_name, leaf_item, top, opt.sparse, opt.numeric_ids, owner_map, exclude_rxs, verbosity, hardlinks) if verbosity >= 0: progress('Restoring: %d, done.\n' % total_restored) die_if_errors() wrap_main(main)