Example #1
0
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] repository - clone a remote repository')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
Example #2
0
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] repository - clone a remote repository')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke hooks")
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")
    branch_group.add_option("--reference", action="store", dest="reference", default=None,
                            help="git reference repository (use local copies where possible)")
    cmd_group.add_config_file_option(option_name="postclone", dest="postclone",
                                     help="hook to run after cloning the source tree, "
                                     "default is '%(postclone)s'")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
Example #3
0
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] [repo] - safely update a repository from remote')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options")
    parser.add_option_group(branch_group)
    branch_group.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch")
    branch_group.add_option("--force", action="store_true", dest="force", default=False,
                            help="force a branch update even if it can't be fast forwarded")
    branch_group.add_option("--redo-pq", action="store_true", dest="redo_pq", default=False,
                            help="redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for deepening shallow clones)")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
Example #4
0
def build_parser(name):
    try:
        parser = GbpOptionParser(
            command=os.path.basename(name),
            prefix='',
            usage='%prog [options] repository - clone a remote repository')
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option(
        "--all",
        action="store_true",
        dest="all",
        default=False,
        help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_option(
        "--depth",
        action="store",
        dest="depth",
        default=0,
        help="git history depth (for creating shallow clones)")
    branch_group.add_option(
        "--reference",
        action="store",
        dest="reference",
        default=None,
        help="git reference repository (use local copies where possible)")

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
Example #5
0
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] command[.optionname] - display configuration settings')
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
def build_parser(name):
    """Create command line argument parser"""
    try:
        parser = GbpOptionParser(command=os.path.basename(name),
                                 prefix='',
                                 usage='%prog [options] repository - clone a '
                                 'remote per-package repository')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option(
        "--all",
        action="store_true",
        dest="all",
        help="track all branches, not only packaging and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="packaging-branch",
                                        dest="packaging_branch")
    branch_group.add_option(
        "--depth",
        action="store",
        dest="depth",
        default=0,
        help="git history depth (for creating shallow clones)")

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
Example #7
0
def parse_args (argv):
    parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
                             usage='%prog [options] repository - clone a remote repository')
    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')

    (options, args) = parser.parse_args(argv)
    gbp.log.setup(options.color, options.verbose)

    return (options, args)
Example #8
0
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] repository - clone a remote repository')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke hooks")
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")
    branch_group.add_option("--reference", action="store", dest="reference", default=None,
                            help="git reference repository (use local copies where possible)")
    cmd_group.add_config_file_option(option_name="postclone", dest="postclone",
                                     help="hook to run after cloning the source tree, "
                                     "default is '%(postclone)s'")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="repo-user", dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email", dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    return parser
Example #9
0
def main(argv):
    retval = 0
    current = None

    parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
                             usage='%prog [options] - safely update a repository from remote')
    branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options")
    parser.add_option_group(branch_group)
    branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
    branch_group.add_option("--force", action="store_true", dest="force", default=False,
                      help="force a branch update even if it can't be fast forwarded")
    branch_group.add_option("--redo-pq", action="store_true", dest="redo_pq", default=False,
                      help="redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for deepening shallow clones)")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")


    (options, args) = parser.parse_args(argv)
    gbp.log.setup(options.color, options.verbose, options.color_scheme)

    try:
        repo = DebianGitRepository(os.path.curdir)
    except GitRepositoryError:
        gbp.log.err("%s is not a git repository" % (os.path.abspath('.')))
        return 1

    try:
        branches = []
        try:
            current = repo.get_branch()
        except GitRepositoryError:
            # Not being on any branch is o.k. with --git-ignore-branch
            if  options.ignore_branch:
                current = repo.head
                gbp.log.info("Found detached head at '%s'" % current)
            else:
                raise

        for branch in [ options.debian_branch, options.upstream_branch ]:
            if repo.has_branch(branch):
                branches += [ branch ]

        if repo.has_pristine_tar_branch() and options.pristine_tar:
            branches += [ repo.pristine_tar_branch ]

        (ret, out) = repo.is_clean()
        if not ret:
            gbp.log.err("You have uncommitted changes in your source tree:")
            gbp.log.err(out)
            raise GbpError

        repo.fetch(depth=options.depth)
        repo.fetch(depth=options.depth, tags=True)
        for branch in branches:
            if not fast_forward_branch(branch, repo, options):
                retval = 2

        if options.redo_pq:
            repo.set_branch(options.debian_branch)
            Command("gbp-pq")(["drop"])
            Command("gbp-pq")(["import"])

        repo.set_branch(current)
    except CommandExecFailed:
        retval = 1
    except (GbpError, GitRepositoryError) as err:
        if len(err.__str__()):
            gbp.log.err(err)
        retval = 1

    return retval
Example #10
0
def build_parser(name):
    try:
        parser = GbpOptionParser(
            command=os.path.basename(name),
            prefix='',
            usage=
            '%prog [options] [repo] - safely update a repository from remote')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch update and layout options")
    parser.add_option_group(branch_group)
    branch_group.add_boolean_config_file_option(option_name="ignore-branch",
                                                dest="ignore_branch")
    branch_group.add_option(
        "--force",
        action="store_true",
        dest="force",
        default=False,
        help="force a branch update even if it can't be fast forwarded")
    branch_group.add_option("--all",
                            action="store_true",
                            default=False,
                            help="update all remote-tracking branches that "
                            "have identical name in the remote")
    branch_group.add_option(
        "--redo-pq",
        action="store_true",
        dest="redo_pq",
        default=False,
        help=
        "redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch"
    )
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_boolean_config_file_option(option_name="track-missing",
                                                dest="track_missing")
    branch_group.add_option(
        "--depth",
        action="store",
        dest="depth",
        default=0,
        help="git history depth (for deepening shallow clones)")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser