]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/git.py
Add bup get; see the documentation for further information
[bup.git] / lib / bup / git.py
index 45fab04ad7470edb0320a31227fd4a0a26c1daf6..73dce1914571adbe0be965c89c8ae4278329b4f4 100644 (file)
@@ -112,13 +112,14 @@ def parse_commit(content):
                       message=matches['message'])
 
 
-def get_commit_items(id, cp):
-    commit_it = cp.get(id)
-    _, typ, _ = next(commit_it)
-    assert(typ == 'commit')
-    commit_content = ''.join(commit_it)
-    return parse_commit(commit_content)
+def get_cat_data(cat_iterator, expected_type):
+    _, kind, _ = next(cat_iterator)
+    if kind != expected_type:
+        raise Exception('expected %r, saw %r' % (expected_type, kind))
+    return ''.join(cat_iterator)
 
+def get_commit_items(id, cp):
+    return parse_commit(get_cat_data(cp.get(id), 'commit'))
 
 def _local_git_date_str(epoch_sec):
     return '%d %s' % (epoch_sec, utc_offset_str(epoch_sec))