From 89cd30c0d82c2b71e6fe14de7ad210f635b38f91 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 29 Jan 2020 00:21:01 +0100 Subject: [PATCH] git/client/server: remove rev_list() count support This is obviously not used, as passing count!=None would crash the client method (client.py doesn't import Integral). Rather than fixing that, just remove support for it entirely. While at it, also clean up a duplicate rev_list_invocation() call in the server. Signed-off-by: Johannes Berg Reviewed-by: Rob Browning --- cmd/server-cmd.py | 8 ++++---- lib/bup/client.py | 5 +---- lib/bup/git.py | 10 +++------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/cmd/server-cmd.py b/cmd/server-cmd.py index acd7007..2c8cc05 100755 --- a/cmd/server-cmd.py +++ b/cmd/server-cmd.py @@ -214,15 +214,15 @@ def rev_list(conn, _): count = conn.readline() if not count: raise Exception('Unexpected EOF while reading rev-list count') - count = None if count == b'\n' else int(count) + assert count == b'\n' + count = None fmt = conn.readline() if not fmt: raise Exception('Unexpected EOF while reading rev-list format') fmt = None if fmt == b'\n' else fmt[:-1] refs = tuple(x[:-1] for x in lines_until_sentinel(conn, b'\n', Exception)) - args = git.rev_list_invocation(refs, count=count, format=fmt) - p = subprocess.Popen(git.rev_list_invocation(refs, count=count, format=fmt), - env=git._gitenv(git.repodir), + args = git.rev_list_invocation(refs, format=fmt) + p = subprocess.Popen(args, env=git._gitenv(git.repodir), stdout=subprocess.PIPE) while True: out = p.stdout.read(64 * 1024) diff --git a/lib/bup/client.py b/lib/bup/client.py index 927e053..f8f5807 100644 --- a/lib/bup/client.py +++ b/lib/bup/client.py @@ -407,7 +407,7 @@ class Client: raise not_ok self._not_busy() - def rev_list(self, refs, count=None, parse=None, format=None): + def rev_list(self, refs, parse=None, format=None): """See git.rev_list for the general semantics, but note that with the current interface, the parse function must be able to handle (consume) any blank lines produced by the format because the @@ -416,7 +416,6 @@ class Client: """ self._require_command(b'rev-list') - assert (count is None) or (isinstance(count, Integral)) if format: assert b'\n' not in format assert parse @@ -427,8 +426,6 @@ class Client: self._busy = b'rev-list' conn = self.conn conn.write(b'rev-list\n') - if count is not None: - conn.write(b'%d' % count) conn.write(b'\n') if format: conn.write(format) diff --git a/lib/bup/git.py b/lib/bup/git.py index f364227..d1515e3 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -973,16 +973,12 @@ def read_ref(refname, repo_dir = None): return None -def rev_list_invocation(ref_or_refs, count=None, format=None): +def rev_list_invocation(ref_or_refs, format=None): if isinstance(ref_or_refs, bytes): refs = (ref_or_refs,) else: refs = ref_or_refs argv = [b'git', b'rev-list'] - if isinstance(count, Integral): - argv.extend([b'-n', b'%d' % count]) - elif count: - raise ValueError('unexpected count argument %r' % count) if format: argv.append(b'--pretty=format:' + format) @@ -993,7 +989,7 @@ def rev_list_invocation(ref_or_refs, count=None, format=None): return argv -def rev_list(ref_or_refs, count=None, parse=None, format=None, repo_dir=None): +def rev_list(ref_or_refs, parse=None, format=None, repo_dir=None): """Yield information about commits as per "git rev-list". If a format is not provided, yield one hex hash at a time. If a format is provided, pass it to rev-list and call parse(git_stdout) for each @@ -1003,7 +999,7 @@ def rev_list(ref_or_refs, count=None, parse=None, format=None, repo_dir=None): """ assert bool(parse) == bool(format) - p = subprocess.Popen(rev_list_invocation(ref_or_refs, count=count, + p = subprocess.Popen(rev_list_invocation(ref_or_refs, format=format), env=_gitenv(repo_dir), stdout = subprocess.PIPE) -- 2.39.2