From: Rob Browning Date: Sun, 2 Jul 2017 16:38:57 +0000 (-0500) Subject: rev_list: allow multiple refs X-Git-Tag: 0.30~176 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=95612d35195fbf93d4cac7d6f35b6258f28ca3ea rev_list: allow multiple refs Signed-off-by: Rob Browning --- diff --git a/lib/bup/compat.py b/lib/bup/compat.py index d0e2c5d..7e36209 100644 --- a/lib/bup/compat.py +++ b/lib/bup/compat.py @@ -8,6 +8,8 @@ py3 = py_maj >= 3 if py3: + str_type = str + def add_ex_tb(ex): pass @@ -16,6 +18,8 @@ if py3: else: # Python 2 + str_type = basestring + def add_ex_tb(ex): if not getattr(ex, '__traceback__', None): ex.__traceback__ = sys.exc_info()[2] diff --git a/lib/bup/git.py b/lib/bup/git.py index 8458b5c..9eca25d 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -8,7 +8,7 @@ from collections import namedtuple from itertools import islice from numbers import Integral -from bup import _helpers, hashsplit, path, midx, bloom, xstat +from bup import _helpers, compat, hashsplit, path, midx, bloom, xstat from bup.helpers import (Sha1, add_error, chunkyreader, debug1, debug2, fdatasync, hostname, localtime, log, merge_iter, @@ -923,7 +923,7 @@ def read_ref(refname, repo_dir = None): return None -def rev_list(ref, count=None, parse=None, format=None, repo_dir=None): +def rev_list(ref_or_refs, count=None, 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 @@ -933,7 +933,10 @@ def rev_list(ref, count=None, parse=None, format=None, repo_dir=None): """ assert bool(parse) == bool(format) - assert not ref.startswith('-') + if isinstance(ref_or_refs, compat.str_type): + refs = (ref_or_refs,) + else: + refs = ref_or_refs argv = ['git', 'rev-list'] if isinstance(count, Integral): argv.extend(['-n', str(count)]) @@ -941,7 +944,8 @@ def rev_list(ref, count=None, parse=None, format=None, repo_dir=None): assert not count if format: argv.append('--pretty=format:' + format) - if ref: + for ref in refs: + assert not ref.startswith('-') argv.append(ref) argv.append('--') p = subprocess.Popen(argv,