mercurial/revlog.py
changeset 45735 edf4fa06df94
parent 45671 2d6aea053153
child 45779 8719a5b68419
equal deleted inserted replaced
45734:53c265a6fc83 45735:edf4fa06df94
  2703         If not None, the `sidedatacompanion` is callable that accept two
  2703         If not None, the `sidedatacompanion` is callable that accept two
  2704         arguments:
  2704         arguments:
  2705 
  2705 
  2706             (srcrevlog, rev)
  2706             (srcrevlog, rev)
  2707 
  2707 
  2708         and return a triplet that control changes to sidedata content from the
  2708         and return a quintet that control changes to sidedata content from the
  2709         old revision to the new clone result:
  2709         old revision to the new clone result:
  2710 
  2710 
  2711             (dropall, filterout, update)
  2711             (dropall, filterout, update, new_flags, dropped_flags)
  2712 
  2712 
  2713         * if `dropall` is True, all sidedata should be dropped
  2713         * if `dropall` is True, all sidedata should be dropped
  2714         * `filterout` is a set of sidedata keys that should be dropped
  2714         * `filterout` is a set of sidedata keys that should be dropped
  2715         * `update` is a mapping of additionnal/new key -> value
  2715         * `update` is a mapping of additionnal/new key -> value
       
  2716         * new_flags is a bitfields of new flags that the revision should get
       
  2717         * dropped_flags is a bitfields of new flags that the revision shoudl not longer have
  2716         """
  2718         """
  2717         if deltareuse not in self.DELTAREUSEALL:
  2719         if deltareuse not in self.DELTAREUSEALL:
  2718             raise ValueError(
  2720             raise ValueError(
  2719                 _(b'value for deltareuse invalid: %s') % deltareuse
  2721                 _(b'value for deltareuse invalid: %s') % deltareuse
  2720             )
  2722             )
  2781             linkrev = entry[4]
  2783             linkrev = entry[4]
  2782             p1 = index[entry[5]][7]
  2784             p1 = index[entry[5]][7]
  2783             p2 = index[entry[6]][7]
  2785             p2 = index[entry[6]][7]
  2784             node = entry[7]
  2786             node = entry[7]
  2785 
  2787 
  2786             sidedataactions = (False, [], {})
  2788             sidedataactions = (False, [], {}, 0, 0)
  2787             if sidedatacompanion is not None:
  2789             if sidedatacompanion is not None:
  2788                 sidedataactions = sidedatacompanion(self, rev)
  2790                 sidedataactions = sidedatacompanion(self, rev)
  2789 
  2791 
  2790             # (Possibly) reuse the delta from the revlog if allowed and
  2792             # (Possibly) reuse the delta from the revlog if allowed and
  2791             # the revlog chunk is a delta.
  2793             # the revlog chunk is a delta.
  2792             cachedelta = None
  2794             cachedelta = None
  2793             rawtext = None
  2795             rawtext = None
  2794             if any(sidedataactions) or deltareuse == self.DELTAREUSEFULLADD:
  2796             if any(sidedataactions) or deltareuse == self.DELTAREUSEFULLADD:
  2795                 dropall, filterout, update = sidedataactions
  2797                 dropall = sidedataactions[0]
       
  2798                 filterout = sidedataactions[1]
       
  2799                 update = sidedataactions[2]
       
  2800                 new_flags = sidedataactions[3]
       
  2801                 dropped_flags = sidedataactions[4]
  2796                 text, sidedata = self._revisiondata(rev)
  2802                 text, sidedata = self._revisiondata(rev)
  2797                 if dropall:
  2803                 if dropall:
  2798                     sidedata = {}
  2804                     sidedata = {}
  2799                 for key in filterout:
  2805                 for key in filterout:
  2800                     sidedata.pop(key, None)
  2806                     sidedata.pop(key, None)
  2801                 sidedata.update(update)
  2807                 sidedata.update(update)
  2802                 if not sidedata:
  2808                 if not sidedata:
  2803                     sidedata = None
  2809                     sidedata = None
       
  2810 
       
  2811                 flags |= new_flags
       
  2812                 flags &= ~dropped_flags
       
  2813 
  2804                 destrevlog.addrevision(
  2814                 destrevlog.addrevision(
  2805                     text,
  2815                     text,
  2806                     tr,
  2816                     tr,
  2807                     linkrev,
  2817                     linkrev,
  2808                     p1,
  2818                     p1,