def main():
    """Do the thing."""
    try:
        p4gf_version.git_version_check()

        # Connect.
        global P4PORT, P4USER, p4
        p4 = create_p4(port=P4PORT, user=P4USER)
        P4PORT = p4.port
        P4USER = p4.user
        report(INFO, "P4PORT : {}".format(p4.port))
        report(INFO, "P4USER : {}".format(p4.user))
        p4.connect()
        p4gf_version.p4d_version_check(p4)

        # Require that we have super permission.
        # Might as well keep the result in case we need to write a new protect
        # table later. Saves a 'p4 protect -o' trip to the server
        protect_lines = fetch_protect()

        ensure_user()
        ensure_group()
        ensure_depot()
        ensure_protect(protect_lines)
        ensure_protects_configurable()

    # pylint: disable=W0703
    # Catching too general exception
    except Exception as e:
        sys.stderr.write(e.args[0] + '\n')
        exit(1)
def main():
    """Do the thing."""
    try:
        p4gf_version.git_version_check()

        # Connect.
        global P4PORT, P4USER, p4
        p4 = create_p4(port=P4PORT, user=P4USER)
        P4PORT = p4.port
        P4USER = p4.user
        report(INFO, "P4PORT : {}".format(p4.port))
        report(INFO, "P4USER : {}".format(p4.user))
        p4.connect()
        p4gf_version.p4d_version_check(p4)

        # Require that we have super permission.
        # Might as well keep the result in case we need to write a new protect
        # table later. Saves a 'p4 protect -o' trip to the server
        protect_lines = fetch_protect()

        ensure_user()
        ensure_group()
        ensure_depot()
        ensure_protect(protect_lines)
        ensure_protects_configurable()

    # pylint: disable=W0703
    # Catching too general exception
    except Exception as e:
        sys.stderr.write(e.args[0] + '\n')
        exit(1)
Exemplo n.º 3
0
def main():
    """create Perforce user and client for Git Fusion"""
    p4gf_version.print_and_exit_if_argv()
    p4gf_version.log_version()
    try:
        p4gf_version.git_version_check()
    # pylint: disable=W0703
    # Catching too general exception
    except Exception as e:
        sys.stderr.write(e.args[0] + '\n')
        exit(1)

    p4 = connect_p4()
    if not p4:
        return 2

    LOG.debug("connected to P4 at %s", p4.port)
    p4gf_util.reset_git_enviro()

    init(p4)

    return 0
Exemplo n.º 4
0
                    # we are about to delete the current working directory.
                    os.chdir(cwd)
                    cleanup_client(ctx, view_name)
                raise

            # Detach git repo's workspace from master before calling
            # original git, otherwise we won't be able to push master.
            p4gf_util.checkout_detached_master()

            # Flush stderr before returning control to Git.
            # Otherwise Git's own output might interrupt ours.
            sys.stderr.flush()

            return _call_original_git(ctx, args)


if __name__ == "__main__":
    # Ensure any errors occurring in the setup are sent to stderr, while the
    # code below directs them to stderr once rather than twice.
    try:
        with p4gf_log.ExceptionLogger(squelch=False, write_to_stderr_=True):
            p4gf_audit_log.record_argv()
            p4gf_version.log_version()
            p4gf_version.git_version_check()
    # pylint: disable=W0702
    except:
        # Cannot continue if above code failed.
        exit(1)
    # main() already writes errors to stderr, so don't let logger do it again
    p4gf_log.run_with_exception_logger(main, write_to_stderr=False)
                    # we are about to delete the current working directory.
                    os.chdir(cwd)
                    cleanup_client(ctx, view_name)
                raise

            # Detach git repo's workspace from master before calling
            # original git, otherwise we won't be able to push master.
            p4gf_util.checkout_detached_master()

            # Flush stderr before returning control to Git.
            # Otherwise Git's own output might interrupt ours.
            sys.stderr.flush()

            return _call_original_git(ctx, args)


if __name__ == "__main__":
    # Ensure any errors occurring in the setup are sent to stderr, while the
    # code below directs them to stderr once rather than twice.
    try:
        with p4gf_log.ExceptionLogger(squelch=False, write_to_stderr_=True):
            p4gf_audit_log.record_argv()
            p4gf_version.log_version()
            p4gf_version.git_version_check()
    # pylint: disable=W0702
    except:
        # Cannot continue if above code failed.
        exit(1)
    # main() already writes errors to stderr, so don't let logger do it again
    p4gf_log.run_with_exception_logger(main, write_to_stderr=False)