comparison mercurial/revlogutils/debug.py @ 49777:7aea9babac5d

debugrevlog: display total stored information This is an interesting statistis, so let's display it.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 21 Nov 2022 15:04:19 +0100
parents 511106bcb16c
children 4302db0f54c8
comparison
equal deleted inserted replaced
49776:511106bcb16c 49777:7aea9babac5d
286 gdelta = True 286 gdelta = True
287 flags.append(b'generaldelta') 287 flags.append(b'generaldelta')
288 if not flags: 288 if not flags:
289 flags = [b'(none)'] 289 flags = [b'(none)']
290 290
291 ### the total size of stored content if incompressed.
292 full_text_total_size = 0
291 ### tracks merge vs single parent 293 ### tracks merge vs single parent
292 nummerges = 0 294 nummerges = 0
293 295
294 ### tracks ways the "delta" are build 296 ### tracks ways the "delta" are build
295 # nodelta 297 # nodelta
345 numrevs = len(r) 347 numrevs = len(r)
346 for rev in range(numrevs): 348 for rev in range(numrevs):
347 p1, p2 = r.parentrevs(rev) 349 p1, p2 = r.parentrevs(rev)
348 delta = r.deltaparent(rev) 350 delta = r.deltaparent(rev)
349 if format > 0: 351 if format > 0:
350 addsize(r.rawsize(rev), datasize) 352 s = r.rawsize(rev)
353 full_text_total_size += s
354 addsize(s, datasize)
351 if p2 != nodemod.nullrev: 355 if p2 != nodemod.nullrev:
352 nummerges += 1 356 nummerges += 1
353 size = r.length(rev) 357 size = r.length(rev)
354 if delta == nodemod.nullrev: 358 if delta == nodemod.nullrev:
355 chainlengths.append(0) 359 chainlengths.append(0)
534 for chunktype in sorted(chunktypecounts): 538 for chunktype in sorted(chunktypecounts):
535 ui.write(fmtchunktype(chunktype)) 539 ui.write(fmtchunktype(chunktype))
536 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) 540 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize))
537 541
538 ui.write(b'\n') 542 ui.write(b'\n')
543 b_total = b"%d" % full_text_total_size
544 p_total = []
545 while len(b_total) > 3:
546 p_total.append(b_total[-3:])
547 b_total = b_total[:-3]
548 p_total.append(b_total)
549 p_total.reverse()
550 b_total = b' '.join(p_total)
551
552 ui.write(b'\n')
553 ui.writenoi18n(b'total-stored-content: %s bytes\n' % b_total)
554 ui.write(b'\n')
539 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio)) 555 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio))
540 ui.writenoi18n(b'avg chain length : ' + fmt % avgchainlen) 556 ui.writenoi18n(b'avg chain length : ' + fmt % avgchainlen)
541 ui.writenoi18n(b'max chain length : ' + fmt % maxchainlen) 557 ui.writenoi18n(b'max chain length : ' + fmt % maxchainlen)
542 ui.writenoi18n(b'max chain reach : ' + fmt % maxchainspan) 558 ui.writenoi18n(b'max chain reach : ' + fmt % maxchainspan)
543 ui.writenoi18n(b'compression ratio : ' + fmt % compratio) 559 ui.writenoi18n(b'compression ratio : ' + fmt % compratio)