def rev_list(conn, _): _init_session() count = conn.readline() if not count: raise Exception('Unexpected EOF while reading rev-list count') count = None if count == '\n' else int(count) fmt = conn.readline() if not fmt: raise Exception('Unexpected EOF while reading rev-list format') fmt = None if fmt == '\n' else fmt[:-1] refs = tuple(x[:-1] for x in lines_until_sentinel(conn, '\n', Exception)) args = git.rev_list_invocation(refs, count=count, format=fmt) p = subprocess.Popen(git.rev_list_invocation(refs, count=count, format=fmt), preexec_fn=git._gitenv(git.repodir), stdout=subprocess.PIPE) while True: out = p.stdout.read(64 * 1024) if not out: break conn.write(out) rv = p.wait() # not fatal if rv: msg = 'git rev-list returned error %d' % rv conn.error(msg) raise GitError(msg) conn.ok()
def rev_list_raw(self, refs, fmt): args = git.rev_list_invocation(refs, format=fmt) p = subprocess.Popen(args, env=git._gitenv(self.repo_dir), stdout=subprocess.PIPE) while True: out = p.stdout.read(64 * 1024) if not out: break yield out rv = p.wait() # not fatal if rv: raise git.GitError('git rev-list returned error %d' % rv)