manifest: allow skipping valid_bases argument to `read_any_fast_delta`
In some case it make sens to just want a delta. So we update the API to support
this.
--- a/mercurial/interfaces/repository.py Thu Aug 01 05:35:06 2024 +0200
+++ b/mercurial/interfaces/repository.py Thu Aug 01 13:40:46 2024 +0200
@@ -1187,7 +1187,7 @@
The returned object conforms to the ``imanifestdict`` interface.
"""
- def read_any_fast_delta(valid_bases, *, shallow=False):
+ def read_any_fast_delta(valid_bases=None, *, shallow=False):
"""read some manifest information as fast if possible
This might return a "delta", a manifest object containing only file
--- a/mercurial/manifest.py Thu Aug 01 05:35:06 2024 +0200
+++ b/mercurial/manifest.py Thu Aug 01 13:40:46 2024 +0200
@@ -2264,7 +2264,7 @@
def read_any_fast_delta(
self,
- valid_bases: Collection[int],
+ valid_bases: Optional[Collection[int]] = None,
*,
shallow: bool = False,
) -> Tuple[Optional[int], ManifestDict]:
@@ -2272,6 +2272,9 @@
store = self._storage()
r = store.rev(self._node)
deltaparent = store.deltaparent(r)
+ if valid_bases is None:
+ # make sure the next check is True
+ valid_bases = (deltaparent,)
if deltaparent != nullrev and deltaparent in valid_bases:
d = mdiff.patchtext(store.revdiff(deltaparent, r))
return (
@@ -2419,7 +2422,7 @@
def read_any_fast_delta(
self,
- valid_bases: Collection[int],
+ valid_bases: Optional[Collection[int]] = None,
*,
shallow: bool = False,
) -> Tuple[Optional[int], AnyManifestDict]:
@@ -2428,6 +2431,9 @@
r = store.rev(self._node)
deltaparent = store.deltaparent(r)
+ if valid_bases is None:
+ # make sure the next check is True
+ valid_bases = (deltaparent,)
can_use_delta = deltaparent != nullrev and deltaparent in valid_bases
if shallow: