def show_diff(before, after, opts): """Run the difftool If we are diffing a notebook, show the diff via nbdiff-web. Otherwise, call out to `git diff`. """ if before.endswith('.ipynb') or after.endswith('ipynb'): return nbdifftool.main_parsed(opts) else: # Never returns os.execvp('git', ['git', 'diff', before, after])
def main(args=None): if args is None: args = sys.argv[1:] import argparse parser = ConfigBackedParser('hg-nbdiffweb', description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) nbdifftool.build_arg_parser(parser) opts = parser.parse_args(args) # TODO: If a/b are files that are not notebooks, ensure a decent error is printed. if not os.path.isfile(opts.local) or not os.path.isfile(opts.remote): local, remote = opts.local, opts.remote for a, b in diff_directories(local, remote): opts.local, opts.remote = a, b ret = nbdifftool.main_parsed(opts) if ret != 0: return ret return ret else: return nbdifftool.main_parsed(opts)