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
@@ -1201,7 +1201,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:
|
||||
@@ -1260,7 +1260,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:
|
||||
@@ -1280,11 +1280,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:
|
||||
@@ -1325,7 +1325,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1420,7 +1420,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1443,7 +1443,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
|
||||
@@ -1491,7 +1491,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:
|
||||
@@ -1905,7 +1905,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):
|
||||
@@ -1940,8 +1940,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:
|
||||
@@ -1985,13 +1985,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:
|
||||
@@ -2017,7 +2017,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:
|
||||
@@ -2077,7 +2077,7 @@ class Mtree:
|
||||
|
||||
mid = self.mid(0)
|
||||
while True:
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
mdirs_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
@@ -2255,7 +2255,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:
|
||||
@@ -2281,7 +2281,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:
|
||||
@@ -2307,8 +2307,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:
|
||||
@@ -2352,13 +2352,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:
|
||||
@@ -2381,7 +2381,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:
|
||||
@@ -3352,7 +3352,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
|
||||
@@ -3576,7 +3576,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?
|
||||
@@ -3587,7 +3587,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:
|
||||
@@ -3636,11 +3636,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:
|
||||
@@ -3664,7 +3664,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