bmap: scripts: Added on-disk bmap traversal to dbgbmap and friends

And yes, dbgbmapsvg.py's parents are working, thanks to a hacky blocks
@property (Python to the rescue!)
This commit is contained in:
Christopher Haster
2025-07-23 22:58:26 -05:00
parent 88180b6081
commit 5f65b49ef8
3 changed files with 72 additions and 0 deletions

View File

@ -2693,6 +2693,11 @@ class Gstate:
fillvalue=0))
self.data = data
@property
def blocks(self):
return tuple(it.chain.from_iterable(
gdelta.blocks for _, gdelta in self.gdeltas))
@property
def size(self):
return len(self.data)
@ -3224,6 +3229,7 @@ class Lfs3:
# traverse the filesystem
def traverse(self, *,
mtree_only=False,
gstate=True,
shrubs=False,
fragments=False,
path=False):
@ -3285,6 +3291,24 @@ class Lfs3:
else:
yield data
# traverse any gstate
if not mtree_only and gstate:
for gstate_ in self.gstate:
if getattr(gstate_, 'btree', None) is None:
continue
for r in gstate_.btree.traverse(
path=path):
if path:
bid, rbyd, path_ = r
else:
bid, rbyd = r
if path:
yield rbyd, [(self.mid(-1), gstate_)]+path_
else:
yield rbyd
# common file operations, note Reg extends this for regular files
class File:
tag = None