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)
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
"""
self._require_command(b'rev-list')
- assert (count is None) or (isinstance(count, Integral))
if format:
assert b'\n' not in format
assert parse
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)
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)
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
"""
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)