##// END OF EJS Templates
revlog: add a way to control sidedata changes during revlog.clone...
marmoute -
r43403:3de4d13f default
parent child Browse files
Show More
@@ -2542,6 +2542,7 b' class revlog(object):'
2542 addrevisioncb=None,
2542 addrevisioncb=None,
2543 deltareuse=DELTAREUSESAMEREVS,
2543 deltareuse=DELTAREUSESAMEREVS,
2544 forcedeltabothparents=None,
2544 forcedeltabothparents=None,
2545 sidedatacompanion=None,
2545 ):
2546 ):
2546 """Copy this revlog to another, possibly with format changes.
2547 """Copy this revlog to another, possibly with format changes.
2547
2548
@@ -2583,6 +2584,20 b' class revlog(object):'
2583 In addition to the delta policy, the ``forcedeltabothparents``
2584 In addition to the delta policy, the ``forcedeltabothparents``
2584 argument controls whether to force compute deltas against both parents
2585 argument controls whether to force compute deltas against both parents
2585 for merges. By default, the current default is used.
2586 for merges. By default, the current default is used.
2587
2588 If not None, the `sidedatacompanion` is callable that accept two
2589 arguments:
2590
2591 (srcrevlog, rev)
2592
2593 and return a triplet that control changes to sidedata content from the
2594 old revision to the new clone result:
2595
2596 (dropall, filterout, update)
2597
2598 * if `dropall` is True, all sidedata should be dropped
2599 * `filterout` is a set of sidedata keys that should be dropped
2600 * `update` is a mapping of additionnal/new key -> value
2586 """
2601 """
2587 if deltareuse not in self.DELTAREUSEALL:
2602 if deltareuse not in self.DELTAREUSEALL:
2588 raise ValueError(
2603 raise ValueError(
@@ -2617,7 +2632,12 b' class revlog(object):'
2617 destrevlog._deltabothparents = forcedeltabothparents or oldamd
2632 destrevlog._deltabothparents = forcedeltabothparents or oldamd
2618
2633
2619 self._clone(
2634 self._clone(
2620 tr, destrevlog, addrevisioncb, deltareuse, forcedeltabothparents
2635 tr,
2636 destrevlog,
2637 addrevisioncb,
2638 deltareuse,
2639 forcedeltabothparents,
2640 sidedatacompanion,
2621 )
2641 )
2622
2642
2623 finally:
2643 finally:
@@ -2626,7 +2646,13 b' class revlog(object):'
2626 destrevlog._deltabothparents = oldamd
2646 destrevlog._deltabothparents = oldamd
2627
2647
2628 def _clone(
2648 def _clone(
2629 self, tr, destrevlog, addrevisioncb, deltareuse, forcedeltabothparents
2649 self,
2650 tr,
2651 destrevlog,
2652 addrevisioncb,
2653 deltareuse,
2654 forcedeltabothparents,
2655 sidedatacompanion,
2630 ):
2656 ):
2631 """perform the core duty of `revlog.clone` after parameter processing"""
2657 """perform the core duty of `revlog.clone` after parameter processing"""
2632 deltacomputer = deltautil.deltacomputer(destrevlog)
2658 deltacomputer = deltautil.deltacomputer(destrevlog)
@@ -2642,12 +2668,24 b' class revlog(object):'
2642 p2 = index[entry[6]][7]
2668 p2 = index[entry[6]][7]
2643 node = entry[7]
2669 node = entry[7]
2644
2670
2671 sidedataactions = (False, [], {})
2672 if sidedatacompanion is not None:
2673 sidedataactions = sidedatacompanion(self, rev)
2674
2645 # (Possibly) reuse the delta from the revlog if allowed and
2675 # (Possibly) reuse the delta from the revlog if allowed and
2646 # the revlog chunk is a delta.
2676 # the revlog chunk is a delta.
2647 cachedelta = None
2677 cachedelta = None
2648 rawtext = None
2678 rawtext = None
2649 if deltareuse == self.DELTAREUSEFULLADD:
2679 if any(sidedataactions) or deltareuse == self.DELTAREUSEFULLADD:
2650 text = self.revision(rev)
2680 dropall, filterout, update = sidedataactions
2681 text, sidedata = self._revisiondata(rev)
2682 if dropall:
2683 sidedata = {}
2684 for key in filterout:
2685 sidedata.pop(key, None)
2686 sidedata.update(update)
2687 if not sidedata:
2688 sidedata = None
2651 destrevlog.addrevision(
2689 destrevlog.addrevision(
2652 text,
2690 text,
2653 tr,
2691 tr,
@@ -2658,6 +2696,7 b' class revlog(object):'
2658 node=node,
2696 node=node,
2659 flags=flags,
2697 flags=flags,
2660 deltacomputer=deltacomputer,
2698 deltacomputer=deltacomputer,
2699 sidedata=sidedata,
2661 )
2700 )
2662 else:
2701 else:
2663 if destrevlog._lazydelta:
2702 if destrevlog._lazydelta:
General Comments 0
You need to be logged in to leave comments. Login now