import re, sys
from bup import git, vint
-from bup.compat import hexstr, pending_raise, range, str_type
+from bup.compat import hexstr, pending_raise
from bup.git import BUP_CHUNKED, parse_commit, tree_decode
-from bup.helpers import debug2, last
+from bup.helpers import debug2, last, nullcontext_if_not
from bup.io import path_msg
from bup.metadata import Metadata
from bup.vint import read_bvec, write_bvec
break
if mangled_name > b'.bupm':
break
- for item in tree_items(oid, tree_data, names, bupm):
- yield item
+ with nullcontext_if_not(bupm):
+ for item in tree_items(oid, tree_data, names, bupm):
+ yield item
_save_name_rx = re.compile(br'^\d\d\d\d-\d\d-\d\d-\d{6}(-\d+)?$')
def tag_item(oid):
assert len(oid) == 20
+ cached = cache_get_commit_item(oid, need_meta=False)
+ if cached:
+ return cached
oidx = hexlify(oid)
it = repo.cat(oidx)
_, typ, size = next(it)
if typ == b'commit':
- return cache_get_commit_item(oid, need_meta=False) \
- or _commit_item_from_data(oid, b''.join(it))
+ return _commit_item_from_data(oid, b''.join(it))
for _ in it: pass
if typ == b'blob':
return Item(meta=default_file_mode, oid=oid)
if parent:
for x in parent:
assert len(x) == 2
- assert isinstance(x[0], (bytes, str_type))
+ assert isinstance(x[0], (bytes, str))
assert isinstance(x[1], item_types)
assert parent[0][1] == _root
if not S_ISDIR(item_mode(parent[-1][1])):