Ejemplo n.º 1
0
def read_one_line(repo):
    """Reads and processes one command.
    """

    line = sys.stdin.readline()

    cmdline = line

    if not cmdline:
        warn("Unexpected EOF")
        return False

    cmdline = cmdline.strip().split()
    if not cmdline:
        # Blank line means we're about to quit
        return False

    cmd = cmdline.pop(0)
    debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))

    if cmd not in COMMANDS:
        die("Unknown command, %s", cmd)

    func = COMMANDS[cmd]
    func(repo, cmdline)
    sys.stdout.flush()

    return True
Ejemplo n.º 2
0
def main(args):
    """Starts a new remote helper for the specified repository.
    """

    if len(args) != 3:
        die("Expecting exactly three arguments.")
        sys.exit(1)

    if os.getenv("GIT_DEBUG_TESTGIT"):
        import git_remote_helpers.util
        git_remote_helpers.util.DEBUG = True

    alias = sanitize(args[1])
    url = sanitize(args[2])

    if not alias.isalnum():
        warn("non-alnum alias '%s'", alias)
        alias = "tmp"

    args[1] = alias
    args[2] = url

    repo = get_repo(alias, url)

    debug("Got arguments %s", args[1:])

    more = True

    while (more):
        more = read_one_line(repo)
Ejemplo n.º 3
0
def main(args):
    """Starts a new remote helper for the specified repository.
    """

    if len(args) != 3:
        die("Expecting exactly three arguments.")
        sys.exit(1)

    if os.getenv("GIT_DEBUG_TESTGIT"):
        import git_remote_helpers.util
        git_remote_helpers.util.DEBUG = True

    alias = sanitize(args[1])
    url = sanitize(args[2])

    if not alias.isalnum():
        warn("non-alnum alias '%s'", alias)
        alias = "tmp"

    args[1] = alias
    args[2] = url

    repo = get_repo(alias, url)

    debug("Got arguments %s", args[1:])

    more = True

    while (more):
        more = read_one_line(repo)
Ejemplo n.º 4
0
def read_one_line(repo):
    """Reads and processes one command.
    """

    sleepy = os.environ.get("GIT_REMOTE_TESTGIT_SLEEPY")
    if sleepy:
        debug("Sleeping %d sec before readline" % int(sleepy))
        time.sleep(int(sleepy))

    line = sys.stdin.readline()

    cmdline = line

    if not cmdline:
        warn("Unexpected EOF")
        return False

    cmdline = cmdline.strip().split()
    if not cmdline:
        # Blank line means we're about to quit
        return False

    cmd = cmdline.pop(0)
    debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))

    if cmd not in COMMANDS:
        die("Unknown command, %s", cmd)

    func = COMMANDS[cmd]
    func(repo, cmdline)
    sys.stdout.flush()

    return True
Ejemplo n.º 5
0
def read_one_line(repo):
    """Reads and processes one command.
    """

    line = sys.stdin.readline()

    cmdline = line

    if not cmdline:
        warn("Unexpected EOF")
        return False

    cmdline = cmdline.strip().split()
    if not cmdline:
        # Blank line means we're about to quit
        return False

    cmd = cmdline.pop(0)
    debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))

    if cmd not in COMMANDS:
        die("Unknown command, %s", cmd)

    func = COMMANDS[cmd]
    func(repo, cmdline)
    sys.stdout.flush()

    return True
Ejemplo n.º 6
0
    def main(self, args):
        """Starts a new remote helper for the specified repository.
        """

        if len(args) != 3:
            die("Expecting exactly three arguments.")
            sys.exit(1)

        if os.getenv("GIT_REMOTE_HELPER_DEBUG"):
            import git_remote_helpers.util

            git_remote_helpers.util.DEBUG = True

        alias = self.sanitize(args[1])
        url = self.sanitize(args[2])

        if not alias.isalnum():
            warn("non-alnum alias '%s'", alias)
            alias = "tmp"

        args[1] = alias
        args[2] = url

        repo = self.get_repo(alias, url)

        debug("Got arguments %s", args[1:])

        more = True

        sys.stdin = os.fdopen(sys.stdin.fileno(), "r", 0)
        while more:
            more = self.read_one_line(repo)
Ejemplo n.º 7
0
    def read_one_line(self, repo):
        """Reads and processes one command.
        """

        sleepy = os.environ.get("GIT_REMOTE_TESTGIT_SLEEPY")
        if sleepy:
            debug("Sleeping %d sec before readline" % int(sleepy))
            time.sleep(int(sleepy))

        line = sys.stdin.readline()

        cmdline = line

        if not cmdline:
            warn("Unexpected EOF")
            return False

        cmdline = cmdline.strip().split()
        if not cmdline:
            # Blank line means we're about to quit
            return False

        cmd = cmdline.pop(0)
        debug("Got command '%s' with args '%s'", cmd, " ".join(cmdline))

        if cmd not in self.commands:
            die("Unknown command, %s", cmd)

        func = self.commands[cmd]
        func(repo, cmdline)
        sys.stdout.flush()

        return True
Ejemplo n.º 8
0
def main(args):
    """Starts a new remote helper for the specified repository.
    """

    if len(args) != 3:
        die("Expecting exactly three arguments.")
        sys.exit(1)

    if os.getenv("GIT_DEBUG_TESTGIT"):
        import git_remote_helpers.util
        git_remote_helpers.util.DEBUG = True

    alias = sanitize(args[1])
    url = sanitize(args[2])

    if not alias.isalnum():
        warn("non-alnum alias '%s'", alias)
        alias = "tmp"

    args[1] = alias
    args[2] = url

    repo = get_repo(alias, url)

    debug("Got arguments %s", args[1:])

    more = True

    # Use binary mode since Python 3 does not permit unbuffered I/O in text
    # mode.  Unbuffered I/O is required to avoid data that should be going
    # to git-fast-import after an "export" command getting caught in our
    # stdin buffer instead.
    sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
    while (more):
        more = read_one_line(repo)
Ejemplo n.º 9
0
    def main(self, args):
        """Starts a new remote helper for the specified repository.
        """

        if len(args) != 3:
            die("Expecting exactly three arguments.")
            sys.exit(1)

        if os.getenv("GIT_REMOTE_HELPER_DEBUG"):
            import git_remote_helpers.util
            git_remote_helpers.util.DEBUG = True

        alias = self.sanitize(args[1])
        url = self.sanitize(args[2])

        if not alias.isalnum():
            warn("non-alnum alias '%s'", alias)
            alias = "tmp"

        args[1] = alias
        args[2] = url

        repo = self.get_repo(alias, url)

        debug("Got arguments %s", args[1:])

        more = True

        sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)
        while (more):
            more = self.read_one_line(repo)