comparison mercurial/upgrade.py @ 39857:8dab7c8a93eb

upgrade: report size of backing files, not internal storage size upgrade.py is the only consumer of filelog.index, which I'd like to eliminate from the file storage interface. This commit changes the upgrade code to report the storage size of files by looking at the size of the files backing its storage instead of looking at the index. I'm not convinced the approach in this patch will live very long because it is relying on low-level attributes like "opener" and "files," which may behave very differently on non-revlog storage. But the data is only used for reporting purposes and it does get us one step closer to eliminating "index." A side-effect of this change is we now report the size of the revlog index data - not just the revision data. I think this is more accurate. Differential Revision: https://phab.mercurial-scm.org/D4717
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 09:37:19 -0700
parents 41aa5dced975
children 32d3ed3023bb
comparison
equal deleted inserted replaced
39856:96838b620b9c 39857:8dab7c8a93eb
485 rl = _revlogfrompath(srcrepo, unencoded) 485 rl = _revlogfrompath(srcrepo, unencoded)
486 revcount += len(rl) 486 revcount += len(rl)
487 487
488 datasize = 0 488 datasize = 0
489 rawsize = 0 489 rawsize = 0
490
491 for path in rl.files():
492 datasize += rl.opener.stat(path).st_size
493
490 idx = rl.index 494 idx = rl.index
491 for rev in rl: 495 for rev in rl:
492 e = idx[rev] 496 e = idx[rev]
493 datasize += e[1]
494 rawsize += e[2] 497 rawsize += e[2]
495 498
496 srcsize += datasize 499 srcsize += datasize
497 srcrawsize += rawsize 500 srcrawsize += rawsize
498 501
580 oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision, 583 oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision,
581 deltareuse=deltareuse, 584 deltareuse=deltareuse,
582 deltabothparents=deltabothparents) 585 deltabothparents=deltabothparents)
583 586
584 datasize = 0 587 datasize = 0
585 idx = newrl.index 588 for path in newrl.files():
586 for rev in newrl: 589 datasize += newrl.opener.stat(path).st_size
587 datasize += idx[rev][1]
588 590
589 dstsize += datasize 591 dstsize += datasize
590 592
591 if isinstance(newrl, changelog.changelog): 593 if isinstance(newrl, changelog.changelog):
592 cdstsize += datasize 594 cdstsize += datasize