mercurial/debugcommands.py
changeset 49223 13e523228623
parent 49222 e7d23c512d3d
child 49228 b909dd35d9ab
equal deleted inserted replaced
49222:e7d23c512d3d 49223:13e523228623
   766     :``deltatype``: role of delta / how it was computed
   766     :``deltatype``: role of delta / how it was computed
   767                     - base:  a full snapshot
   767                     - base:  a full snapshot
   768                     - snap:  an intermediate snapshot
   768                     - snap:  an intermediate snapshot
   769                     - p1:    a delta against the first parent
   769                     - p1:    a delta against the first parent
   770                     - p2:    a delta against the second parent
   770                     - p2:    a delta against the second parent
       
   771                     - skip1: a delta against the same base as p1
       
   772                               (when p1 has empty delta
       
   773                     - skip2: a delta against the same base as p2
       
   774                               (when p2 has empty delta
   771                     - prev:  a delta against the previous revision
   775                     - prev:  a delta against the previous revision
   772                     - other: a delta against an arbitrary revision
   776                     - other: a delta against an arbitrary revision
   773     :``compsize``:  compressed size of revision
   777     :``compsize``:  compressed size of revision
   774     :``uncompsize``: uncompressed size of revision
   778     :``uncompsize``: uncompressed size of revision
   775     :``chainsize``: total size of compressed revisions in chain
   779     :``chainsize``: total size of compressed revisions in chain
   801     start = r.start
   805     start = r.start
   802     length = r.length
   806     length = r.length
   803     generaldelta = r._generaldelta
   807     generaldelta = r._generaldelta
   804     withsparseread = getattr(r, '_withsparseread', False)
   808     withsparseread = getattr(r, '_withsparseread', False)
   805 
   809 
       
   810     # security to avoid crash on corrupted revlogs
       
   811     total_revs = len(index)
       
   812 
   806     def revinfo(rev):
   813     def revinfo(rev):
   807         e = index[rev]
   814         e = index[rev]
   808         compsize = e[revlog_constants.ENTRY_DATA_COMPRESSED_LENGTH]
   815         compsize = e[revlog_constants.ENTRY_DATA_COMPRESSED_LENGTH]
   809         uncompsize = e[revlog_constants.ENTRY_DATA_UNCOMPRESSED_LENGTH]
   816         uncompsize = e[revlog_constants.ENTRY_DATA_UNCOMPRESSED_LENGTH]
   810         chainsize = 0
   817         chainsize = 0
   811 
   818 
   812         base = e[revlog_constants.ENTRY_DELTA_BASE]
   819         base = e[revlog_constants.ENTRY_DELTA_BASE]
   813         p1 = e[revlog_constants.ENTRY_PARENT_1]
   820         p1 = e[revlog_constants.ENTRY_PARENT_1]
   814         p2 = e[revlog_constants.ENTRY_PARENT_2]
   821         p2 = e[revlog_constants.ENTRY_PARENT_2]
       
   822 
       
   823         # If the parents of a revision has an empty delta, we never try to delta
       
   824         # against that parent, but directly against the delta base of that
       
   825         # parent (recursively). It avoids adding a useless entry in the chain.
       
   826         #
       
   827         # However we need to detect that as a special case for delta-type, that
       
   828         # is not simply "other".
       
   829         p1_base = p1
       
   830         if p1 != nullrev and p1 < total_revs:
       
   831             e1 = index[p1]
       
   832             while e1[revlog_constants.ENTRY_DATA_COMPRESSED_LENGTH] == 0:
       
   833                 new_base = e1[revlog_constants.ENTRY_DELTA_BASE]
       
   834                 if (
       
   835                     new_base == p1_base
       
   836                     or new_base == nullrev
       
   837                     or new_base >= total_revs
       
   838                 ):
       
   839                     break
       
   840                 p1_base = new_base
       
   841                 e1 = index[p1_base]
       
   842         p2_base = p2
       
   843         if p2 != nullrev and p2 < total_revs:
       
   844             e2 = index[p2]
       
   845             while e2[revlog_constants.ENTRY_DATA_COMPRESSED_LENGTH] == 0:
       
   846                 new_base = e2[revlog_constants.ENTRY_DELTA_BASE]
       
   847                 if (
       
   848                     new_base == p2_base
       
   849                     or new_base == nullrev
       
   850                     or new_base >= total_revs
       
   851                 ):
       
   852                     break
       
   853                 p2_base = new_base
       
   854                 e2 = index[p2_base]
   815 
   855 
   816         if generaldelta:
   856         if generaldelta:
   817             if base == p1:
   857             if base == p1:
   818                 deltatype = b'p1'
   858                 deltatype = b'p1'
   819             elif base == p2:
   859             elif base == p2:
   820                 deltatype = b'p2'
   860                 deltatype = b'p2'
   821             elif base == rev:
   861             elif base == rev:
   822                 deltatype = b'base'
   862                 deltatype = b'base'
       
   863             elif base == p1_base:
       
   864                 deltatype = b'skip1'
       
   865             elif base == p2_base:
       
   866                 deltatype = b'skip2'
   823             elif r.issnapshot(rev):
   867             elif r.issnapshot(rev):
   824                 deltatype = b'snap'
   868                 deltatype = b'snap'
   825             elif base == rev - 1:
   869             elif base == rev - 1:
   826                 deltatype = b'prev'
   870                 deltatype = b'prev'
   827             else:
   871             else: