Exemplo n.º 1
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = ConfigBackedParser(
        "git-pjmergedriver",
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    subparsers = parser.add_subparsers(dest="subcommand")

    merge_parser = subparsers.add_parser(
        "merge",
        description=
        "The actual entrypoint for the merge tool. Git will call this.",
    )
    add_generic_args(parser)
    add_diff_args(merge_parser)
    add_merge_args(merge_parser)

    # Argument list, we are given base, local, remote
    add_filename_args(merge_parser, ["base", "local", "remote"])

    # TODO: support git-config-specified conflict markers inside sources
    merge_parser.add_argument("marker")
    merge_parser.add_argument("out", nargs="?")
    # "The merge driver can learn the pathname in which the merged result will
    # be stored via placeholder %P"
    # - NOTE: This is not where the driver should store its output, see below!

    add_git_config_subcommand(
        subparsers,
        enable,
        disable,
        subparser_help=
        "Configure git to use packson for notebooks in `git merge`",
        enable_help="enable packson merge driver via git config",
        disable_help="disable packson merge driver via git config",
    )

    opts = parser.parse_args(args)
    if opts.subcommand == "merge":
        # "The merge driver is expected to leave the result of the merge in the
        # file named with %A by overwriting it, and exit with zero status if it
        # managed to merge them cleanly, or non-zero if there were conflicts."
        opts.out = opts.local
        # mergeapp expects an additional decisions arg:
        opts.decisions = False
        return main_merge(opts)
    elif opts.subcommand == "config":
        opts.config_func(opts.scope)
        return 0
    else:
        parser.print_help()
        return 1
Exemplo n.º 2
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = ConfigBackedParser('git-nbmergedriver', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    subparsers = parser.add_subparsers(dest='subcommand')

    merge_parser = subparsers.add_parser('merge',
        description="The actual entrypoint for the merge tool. Git will call this."
    )
    add_generic_args(parser)
    add_diff_args(merge_parser)
    add_merge_args(merge_parser)

    # Argument list, we are given base, local, remote
    add_filename_args(merge_parser, ["base", "local", "remote"])

    # TODO: support git-config-specified conflict markers inside sources
    merge_parser.add_argument('marker')
    merge_parser.add_argument('out', nargs='?')
    # "The merge driver can learn the pathname in which the merged result will
    # be stored via placeholder %P"
    # - NOTE: This is not where the driver should store its output, see below!


    add_git_config_subcommand(
        subparsers,
        enable, disable,
        subparser_help="Configure git to use nbdime for notebooks in `git merge`",
        enable_help="enable nbdime merge driver via git config",
        disable_help="disable nbdime merge driver via git config")

    opts = parser.parse_args(args)
    if opts.subcommand == 'merge':
        # "The merge driver is expected to leave the result of the merge in the
        # file named with %A by overwriting it, and exit with zero status if it
        # managed to merge them cleanly, or non-zero if there were conflicts."
        opts.out = opts.local
        # mergeapp expects an additional decisions arg:
        opts.decisions = False
        return nbmergeapp.main_merge(opts)
    elif opts.subcommand == 'config':
        opts.config_func(opts.scope)
        return 0
    else:
        parser.print_help()
        return 1
Exemplo n.º 3
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(description=_description, add_help=True)
    from nbdime.args import (
        add_generic_args,
        add_diff_args,
        add_merge_args,
        filename_help,
        add_filename_args,
        add_prettyprint_args,
    )

    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)
    add_prettyprint_args(parser)

    parser.add_argument(
        "base",
        type=Path,
        help=filename_help["base"],
        nargs="?",
        default=EXPLICIT_MISSING_FILE,
    )
    add_filename_args(parser, ["local", "remote"])

    parser.add_argument(
        "--out",
        default=None,
        type=Path,
        help="if supplied, the merged notebook is written "
        "to this file. Otherwise it is printed to the "
        "terminal.",
    )
    parser.add_argument(
        "--decisions",
        action="store_true",
        help="print a human-readable summary of conflicted "
        "merge decisions instead of merging the notebook.",
    )

    return parser
Exemplo n.º 4
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = argparse.ArgumentParser('hg-nbmerge', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)

    # Argument list, we are given base, local, remote
    add_filename_args(parser, ["base", "local", "remote", "merged"])

    opts = parser.parse_args(args)
    # mergeapp expects an additional decisions arg:
    opts.decisions = False
    opts.out = opts.merged
    del opts.merged
    return nbmergeapp.main_merge(opts)
Exemplo n.º 5
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = ConfigBackedParser('hg-nbmerge', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)

    # Argument list, we are given base, local, remote
    add_filename_args(parser, ["base", "local", "remote", "merged"])

    opts = parser.parse_args(args)
    # mergeapp expects an additional decisions arg:
    opts.decisions = False
    opts.out = opts.merged
    del opts.merged
    return nbmergeapp.main_merge(opts)