scripts: Renamed lookupleaf -> lookupnext_ to match lfs3.c
- lookupleaf -> lookupnext_ - namelookupleaf -> namelookup_ I want to move away from lookupleaf usage in general in the dbg scripts, like we have in lfs3.c, but I also just really don't want to touch these scripts again unless I need to. They've been useful, but also a big time sink. Maybe I should actually learn Python's new type system. That would probably help here...
This commit is contained in:
+30
-30
@@ -1171,7 +1171,7 @@ class Btree:
|
||||
shrub = Rbyd.fetchshrub(rbyd, trunk)
|
||||
return cls(bd, shrub)
|
||||
|
||||
def lookupleaf(self, bid, *,
|
||||
def lookupnext_(self, bid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not self or bid >= self.weight:
|
||||
@@ -1230,7 +1230,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1250,11 +1250,11 @@ class Btree:
|
||||
#
|
||||
# note this function expects bid to be known, use lookupnext
|
||||
# first if you don't care about the exact bid (or better yet,
|
||||
# lookupleaf and call lookup on the returned rbyd)
|
||||
# lookupnext_ and call lookup on the returned rbyd)
|
||||
#
|
||||
# this matches rbyd's lookup behavior, which needs a known rid
|
||||
# to avoid a double lookup
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1295,7 +1295,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1390,7 +1390,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1413,7 +1413,7 @@ class Btree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
rbyd = self.rbyd
|
||||
@@ -1461,7 +1461,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1875,7 +1875,7 @@ class Mtree:
|
||||
return cls(bd, mrootchain, mtree,
|
||||
mbits=mbits)
|
||||
|
||||
def _lookupleaf(self, mid, *,
|
||||
def _lookupnext_(self, mid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not isinstance(mid, Mid):
|
||||
@@ -1910,8 +1910,8 @@ class Mtree:
|
||||
|
||||
# mtree? lookup in mtree
|
||||
else:
|
||||
# need to do two steps here in case lookupleaf stops early
|
||||
r = self.mtree.lookupleaf(mid.mid,
|
||||
# need to do two steps here in case lookupnext_ stops early
|
||||
r = self.mtree.lookupnext_(mid.mid,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -1955,13 +1955,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def lookupleaf(self, mid, *,
|
||||
def lookupnext_(self, mid, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _lookupleaf, this just helps
|
||||
# most of the logic is in _lookupnext_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._lookupleaf(mid,
|
||||
r = self._lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1987,7 +1987,7 @@ class Mtree:
|
||||
mid = self.mid(mid)
|
||||
|
||||
# lookup the relevant mdir
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2047,7 +2047,7 @@ class Mtree:
|
||||
|
||||
mid = self.mid(0)
|
||||
while True:
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
mdirs_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
@@ -2225,7 +2225,7 @@ class Mtree:
|
||||
if not isinstance(mid, Mid):
|
||||
mid = self.mid(mid)
|
||||
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2251,7 +2251,7 @@ class Mtree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def _namelookupleaf(self, did, name, *,
|
||||
def _namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if path or depth:
|
||||
@@ -2277,8 +2277,8 @@ class Mtree:
|
||||
|
||||
# mtree? find name in mtree
|
||||
else:
|
||||
# need to do two steps here in case namelookupleaf stops early
|
||||
r = self.mtree.namelookupleaf(did, name,
|
||||
# need to do two steps here in case namelookup_ stops early
|
||||
r = self.mtree.namelookup_(did, name,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -2322,13 +2322,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _namelookupleaf, this just helps
|
||||
# most of the logic is in _namelookup_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._namelookupleaf(did, name,
|
||||
r = self._namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2351,7 +2351,7 @@ class Mtree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# lookup the relevant mdir
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3322,7 +3322,7 @@ class Lfs3:
|
||||
mbid, mrid = mid.mbid, mid.mrid + 1
|
||||
if mrid == mdir.weight:
|
||||
mbid, mrid = mbid + (1 << self.mbits), 0
|
||||
mdir = self.mtree.lookupleaf(mbid)
|
||||
mdir = self.mtree.lookupnext_(mbid)
|
||||
if mdir is None:
|
||||
break
|
||||
# lookup name and adjust rid if necessary, you don't
|
||||
@@ -3546,7 +3546,7 @@ class Lfs3:
|
||||
yield from self.sattrs()
|
||||
|
||||
# lookup data in the underlying bshrub
|
||||
def _lookupleaf(self, pos, *,
|
||||
def _lookupnext_(self, pos, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
# no bshrub?
|
||||
@@ -3557,7 +3557,7 @@ class Lfs3:
|
||||
return None, None
|
||||
|
||||
# lookup data in our bshrub
|
||||
r = self.bshrub.lookupleaf(pos,
|
||||
r = self.bshrub.lookupnext_(pos,
|
||||
path=path or depth,
|
||||
depth=depth)
|
||||
if path or depth:
|
||||
@@ -3606,11 +3606,11 @@ class Lfs3:
|
||||
else:
|
||||
return bid-(rattr.weight-1), rattr
|
||||
|
||||
def lookupleaf(self, pos, *,
|
||||
def lookupnext_(self, pos, *,
|
||||
data_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
r = self._lookupleaf(pos,
|
||||
r = self._lookupnext_(pos,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3634,7 +3634,7 @@ class Lfs3:
|
||||
depth=None):
|
||||
pos = 0
|
||||
while True:
|
||||
r = self.lookupleaf(pos,
|
||||
r = self.lookupnext_(pos,
|
||||
data_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
|
||||
Reference in New Issue
Block a user