comparison mercurial/revlogutils/deltas.py @ 51342:866ab9f447d4

delta-find: simplify the delta checking function for snapshot Since the function is all about snapshot, we can safely use an early return and make the result simpler.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 07 Jan 2024 03:23:24 +0100
parents f3f35b37f4b2
children 2a333d791ecf
comparison
equal deleted inserted replaced
51341:f3f35b37f4b2 51342:866ab9f447d4
737 This performs checks for format that use sparse-revlog and intermediate 737 This performs checks for format that use sparse-revlog and intermediate
738 snapshots. 738 snapshots.
739 739
740 This is used by is_good_delta_info. 740 This is used by is_good_delta_info.
741 """ 741 """
742 # if not a snapshot, this method has no filtering to do
743 if deltainfo.snapshotdepth is None:
744 return True
742 # bad delta from intermediate snapshot size limit 745 # bad delta from intermediate snapshot size limit
743 # 746 #
744 # If an intermediate snapshot size is higher than the limit. The 747 # If an intermediate snapshot size is higher than the limit. The
745 # limit exist to prevent endless chain of intermediate delta to be 748 # limit exist to prevent endless chain of intermediate delta to be
746 # created. 749 # created.
747 if ( 750 if (
748 deltainfo.snapshotdepth is not None 751 self.revinfo.textlen >> deltainfo.snapshotdepth
749 and (self.revinfo.textlen >> deltainfo.snapshotdepth) 752 ) < deltainfo.deltalen:
750 < deltainfo.deltalen
751 ):
752 return False 753 return False
753 754
754 # bad delta if new intermediate snapshot is larger than the previous 755 # bad delta if new intermediate snapshot is larger than the previous
755 # snapshot 756 # snapshot
756 if ( 757 if self.revlog.length(deltainfo.base) < deltainfo.deltalen:
757 deltainfo.snapshotdepth
758 and self.revlog.length(deltainfo.base) < deltainfo.deltalen
759 ):
760 return False 758 return False
761 759
762 return True 760 return True
763 761
764 @property 762 @property