Show More
@@ -1210,6 +1210,20 class imanifestrevisionstored(imanifestr | |||||
1210 | The returned object conforms to the ``imanifestdict`` interface. |
|
1210 | The returned object conforms to the ``imanifestdict`` interface. | |
1211 | """ |
|
1211 | """ | |
1212 |
|
1212 | |||
|
1213 | def read_delta_parents(*, shallow=False, exact=True): | |||
|
1214 | """return a diff from this revision against both parents. | |||
|
1215 | ||||
|
1216 | If `exact` is False, this might return a superset of the diff, containing | |||
|
1217 | files that are actually present as is in one of the parents. | |||
|
1218 | ||||
|
1219 | If `shallow` is True, this will read the delta for this directory, | |||
|
1220 | without recursively reading subdirectory manifests. Instead, any | |||
|
1221 | subdirectory entry will be reported as it appears in the manifest, i.e. | |||
|
1222 | the subdirectory will be reported among files and distinguished only by | |||
|
1223 | its 't' flag. This only apply if the underlying manifest support it. | |||
|
1224 | ||||
|
1225 | The returned object conforms to the ``imanifestdict`` interface.""" | |||
|
1226 | ||||
1213 | def readfast(shallow=False): |
|
1227 | def readfast(shallow=False): | |
1214 | """Calls either ``read()`` or ``readdelta()``. |
|
1228 | """Calls either ``read()`` or ``readdelta()``. | |
1215 |
|
1229 |
@@ -2283,6 +2283,40 class ManifestCtx: | |||||
2283 | ) |
|
2283 | ) | |
2284 | return (None, self.read()) |
|
2284 | return (None, self.read()) | |
2285 |
|
2285 | |||
|
2286 | def read_delta_parents( | |||
|
2287 | self, | |||
|
2288 | *, | |||
|
2289 | shallow: bool = False, | |||
|
2290 | exact: bool = True, | |||
|
2291 | ) -> ManifestDict: | |||
|
2292 | """see `interface.imanifestrevisionbase` documentations""" | |||
|
2293 | store = self._storage() | |||
|
2294 | r = store.rev(self._node) | |||
|
2295 | deltaparent = store.deltaparent(r) | |||
|
2296 | parents = [p for p in store.parentrevs(r) if p is not nullrev] | |||
|
2297 | if not exact and deltaparent in parents: | |||
|
2298 | d = mdiff.patchtext(store.revdiff(store.deltaparent(r), r)) | |||
|
2299 | return manifestdict(store.nodeconstants.nodelen, d) | |||
|
2300 | elif not exact or len(parents) == 0: | |||
|
2301 | return self.read() | |||
|
2302 | elif len(parents) == 1: | |||
|
2303 | p = parents[0] | |||
|
2304 | d = mdiff.patchtext(store.revdiff(p, r)) | |||
|
2305 | return manifestdict(store.nodeconstants.nodelen, d) | |||
|
2306 | else: | |||
|
2307 | p1, p2 = parents | |||
|
2308 | d1 = mdiff.patchtext(store.revdiff(p1, r)) | |||
|
2309 | d2 = mdiff.patchtext(store.revdiff(p2, r)) | |||
|
2310 | d1 = manifestdict(store.nodeconstants.nodelen, d1) | |||
|
2311 | d2 = manifestdict(store.nodeconstants.nodelen, d2) | |||
|
2312 | md = manifestdict(store.nodeconstants.nodelen) | |||
|
2313 | for f, new_node, new_flag in d1.iterentries(): | |||
|
2314 | if f not in d2: | |||
|
2315 | continue | |||
|
2316 | if new_node is not None: | |||
|
2317 | md.set(f, new_node, new_flag) | |||
|
2318 | return md | |||
|
2319 | ||||
2286 | def find(self, key: bytes) -> Tuple[bytes, bytes]: |
|
2320 | def find(self, key: bytes) -> Tuple[bytes, bytes]: | |
2287 | return self.read().find(key) |
|
2321 | return self.read().find(key) | |
2288 |
|
2322 | |||
@@ -2486,6 +2520,62 class TreeManifestCtx: | |||||
2486 | md.setflag(f, fl1) |
|
2520 | md.setflag(f, fl1) | |
2487 | return md |
|
2521 | return md | |
2488 |
|
2522 | |||
|
2523 | def read_delta_parents( | |||
|
2524 | self, | |||
|
2525 | *, | |||
|
2526 | shallow: bool = False, | |||
|
2527 | exact: bool = True, | |||
|
2528 | ) -> AnyManifestDict: | |||
|
2529 | """see `interface.imanifestrevisionbase` documentations""" | |||
|
2530 | store = self._storage() | |||
|
2531 | r = store.rev(self._node) | |||
|
2532 | parents = [p for p in store.parentrevs(r) if p is not nullrev] | |||
|
2533 | if not exact: | |||
|
2534 | return self.read_any_fast_delta(parents, shallow=shallow)[1] | |||
|
2535 | elif len(parents) == 0: | |||
|
2536 | if shallow: | |||
|
2537 | d = store.revision(self._node) | |||
|
2538 | return manifestdict(store.nodeconstants.nodelen, d) | |||
|
2539 | else: | |||
|
2540 | return self.read() | |||
|
2541 | elif len(parents) == 1: | |||
|
2542 | p = parents[0] | |||
|
2543 | if shallow: | |||
|
2544 | d = mdiff.patchtext(store.revdiff(p, r)) | |||
|
2545 | return manifestdict(store.nodeconstants.nodelen, d) | |||
|
2546 | else: | |||
|
2547 | return self._read_storage_slow_delta(base=p) | |||
|
2548 | else: | |||
|
2549 | p1, p2 = parents | |||
|
2550 | if shallow: | |||
|
2551 | d1 = mdiff.patchtext(store.revdiff(p1, r)) | |||
|
2552 | d2 = mdiff.patchtext(store.revdiff(p2, r)) | |||
|
2553 | d1 = manifestdict(store.nodeconstants.nodelen, d1) | |||
|
2554 | d2 = manifestdict(store.nodeconstants.nodelen, d2) | |||
|
2555 | md = manifestdict(store.nodeconstants.nodelen) | |||
|
2556 | for f, new_node, new_flag in d1.iterentries(): | |||
|
2557 | if f not in d2: | |||
|
2558 | continue | |||
|
2559 | if new_node is not None: | |||
|
2560 | md.set(f, new_node, new_flag) | |||
|
2561 | return md | |||
|
2562 | else: | |||
|
2563 | m1 = self._manifestlog.get(self._dir, store.node(p1)).read() | |||
|
2564 | m2 = self._manifestlog.get(self._dir, store.node(p2)).read() | |||
|
2565 | mc = self.read() | |||
|
2566 | d1 = m1.diff(mc) | |||
|
2567 | d2 = m2.diff(mc) | |||
|
2568 | md = treemanifest( | |||
|
2569 | self._manifestlog.nodeconstants, | |||
|
2570 | dir=self._dir, | |||
|
2571 | ) | |||
|
2572 | for f, new_node, new_flag in d1.iterentries(): | |||
|
2573 | if f not in d2: | |||
|
2574 | continue | |||
|
2575 | if new_node is not None: | |||
|
2576 | md.set(f, new_node, new_flag) | |||
|
2577 | return md | |||
|
2578 | ||||
2489 | def readfast(self, shallow=False) -> AnyManifestDict: |
|
2579 | def readfast(self, shallow=False) -> AnyManifestDict: | |
2490 | """Calls either readdelta or read, based on which would be less work. |
|
2580 | """Calls either readdelta or read, based on which would be less work. | |
2491 | readdelta is called if the delta is against the p1, and therefore can be |
|
2581 | readdelta is called if the delta is against the p1, and therefore can be |
General Comments 0
You need to be logged in to leave comments.
Login now