]> arthur.barton.de Git - bup.git/commitdiff
rev_list: allow multiple refs
authorRob Browning <rlb@defaultvalue.org>
Sun, 2 Jul 2017 16:38:57 +0000 (11:38 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 24 Sep 2017 17:19:01 +0000 (12:19 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/compat.py
lib/bup/git.py

index d0e2c5df77edf2174dccebb4556d12d50bccadae..7e362095d9fe8e63bbe48e1111062ab07ca7940f 100644 (file)
@@ -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]
index 8458b5cadee6f29c9d1299e863b79ab0795524d5..9eca25d9cc7f039750e099dc4d3f7dfe9c5d2fa7 100644 (file)
@@ -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,