mercurial/revlogutils/deltas.py
changeset 39495 6a53842727c1
parent 39494 e72130f58f5d
child 39496 2f9f7889549b
equal deleted inserted replaced
39494:e72130f58f5d 39495:6a53842727c1
   614             yield tuple(group)
   614             yield tuple(group)
   615 
   615 
   616 def _findsnapshots(revlog, cache, start_rev):
   616 def _findsnapshots(revlog, cache, start_rev):
   617     """find snapshot from start_rev to tip"""
   617     """find snapshot from start_rev to tip"""
   618     deltaparent = revlog.deltaparent
   618     deltaparent = revlog.deltaparent
       
   619     issnapshot = revlog.issnapshot
   619     for rev in revlog.revs(start_rev):
   620     for rev in revlog.revs(start_rev):
   620         if deltaparent(rev) == nullrev:
   621         if issnapshot(rev):
   621             cache[nullrev].append(rev)
   622             cache[deltaparent(rev)].append(rev)
   622 
   623 
   623 def _rawgroups(revlog, p1, p2, cachedelta):
   624 def _rawgroups(revlog, p1, p2, cachedelta):
   624     """Provides group of revision to be tested as delta base
   625     """Provides group of revision to be tested as delta base
   625 
   626 
   626     This lower level function focus on emitting delta theorically interresting
   627     This lower level function focus on emitting delta theorically interresting
   671         for p in parents:
   672         for p in parents:
   672             for idx, s in enumerate(deltachain(p)):
   673             for idx, s in enumerate(deltachain(p)):
   673                 if not revlog.issnapshot(s):
   674                 if not revlog.issnapshot(s):
   674                     break
   675                     break
   675                 parents_snaps[idx].add(s)
   676                 parents_snaps[idx].add(s)
       
   677         snapfloor = min(parents_snaps[0]) + 1
       
   678         _findsnapshots(revlog, snapshots, snapfloor)
   676         # Test them as possible intermediate snapshot base
   679         # Test them as possible intermediate snapshot base
   677         # We test them from highest to lowest level. High level one are more
   680         # We test them from highest to lowest level. High level one are more
   678         # likely to result in small delta
   681         # likely to result in small delta
       
   682         floor = None
   679         for idx, snaps in sorted(parents_snaps.items(), reverse=True):
   683         for idx, snaps in sorted(parents_snaps.items(), reverse=True):
       
   684             siblings = set()
       
   685             for s in snaps:
       
   686                 siblings.update(snapshots[s])
       
   687             # Before considering making a new intermediate snapshot, we check
       
   688             # if an existing snapshot, children of base we consider, would be
       
   689             # suitable.
       
   690             #
       
   691             # It give a change to reuse a delta chain "unrelated" to the
       
   692             # current revision instead of starting our own. Without such
       
   693             # re-use, topological branches would keep reopening new chains.
       
   694             # Creating more and more snapshot as the repository grow.
       
   695 
       
   696             if floor is not None:
       
   697                 # We only do this for siblings created after the one in our
       
   698                 # parent's delta chain. Those created before has less chances
       
   699                 # to be valid base since our ancestors had to create a new
       
   700                 # snapshot.
       
   701                 siblings = [r for r in siblings if floor < r]
       
   702             yield tuple(sorted(siblings))
       
   703             # then test the base from our parent's delta chain.
   680             yield tuple(sorted(snaps))
   704             yield tuple(sorted(snaps))
       
   705             floor = min(snaps)
   681         # No suitable base found in the parent chain, search if any full
   706         # No suitable base found in the parent chain, search if any full
   682         # snapshots emitted since parent's base would be a suitable base for an
   707         # snapshots emitted since parent's base would be a suitable base for an
   683         # intermediate snapshot.
   708         # intermediate snapshot.
   684         #
   709         #
   685         # It give a chance to reuse a delta chain unrelated to the current
   710         # It give a chance to reuse a delta chain unrelated to the current
   686         # revisions instead of starting our own. Without such re-use,
   711         # revisions instead of starting our own. Without such re-use,
   687         # topological branches would keep reopening new full chains. Creating
   712         # topological branches would keep reopening new full chains. Creating
   688         # more and more snapshot as the repository grow.
   713         # more and more snapshot as the repository grow.
   689         snapfloor = min(parents_snaps[0]) + 1
       
   690         _findsnapshots(revlog, snapshots, snapfloor)
       
   691         yield tuple(snapshots[nullrev])
   714         yield tuple(snapshots[nullrev])
   692 
   715 
   693     # other approach failed try against prev to hopefully save us a
   716     # other approach failed try against prev to hopefully save us a
   694     # fulltext.
   717     # fulltext.
   695     yield (prev,)
   718     yield (prev,)