Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 26826:39dbf495880b stable
debugrevlog: cope with empty revlog files
I have no idea where it came from, but my clone of Mercurial has an
empty filelog for `contrib/hgfixes/__init__.py` - it's *valid*, just
contains no nodes. Without this change, debugrevlog crashes with a
zero division error.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 23 Oct 2015 11:04:53 -0400 |
parents | c7d30fdb13b2 |
children | 853154f27525 ed5f20f9c22e |
comparison
equal
deleted
inserted
replaced
26825:78539633acf3 | 26826:39dbf495880b |
---|---|
3035 if numrevs - numfull > 0: | 3035 if numrevs - numfull > 0: |
3036 deltasize[2] /= numrevs - numfull | 3036 deltasize[2] /= numrevs - numfull |
3037 totalsize = fulltotal + deltatotal | 3037 totalsize = fulltotal + deltatotal |
3038 avgchainlen = sum(chainlengths) / numrevs | 3038 avgchainlen = sum(chainlengths) / numrevs |
3039 maxchainlen = max(chainlengths) | 3039 maxchainlen = max(chainlengths) |
3040 compratio = totalrawsize / totalsize | 3040 compratio = 1 |
3041 if totalsize: | |
3042 compratio = totalrawsize / totalsize | |
3041 | 3043 |
3042 basedfmtstr = '%%%dd\n' | 3044 basedfmtstr = '%%%dd\n' |
3043 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' | 3045 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n' |
3044 | 3046 |
3045 def dfmtstr(max): | 3047 def dfmtstr(max): |
3046 return basedfmtstr % len(str(max)) | 3048 return basedfmtstr % len(str(max)) |
3047 def pcfmtstr(max, padding=0): | 3049 def pcfmtstr(max, padding=0): |
3048 return basepcfmtstr % (len(str(max)), ' ' * padding) | 3050 return basepcfmtstr % (len(str(max)), ' ' * padding) |
3049 | 3051 |
3050 def pcfmt(value, total): | 3052 def pcfmt(value, total): |
3051 return (value, 100 * float(value) / total) | 3053 if total: |
3054 return (value, 100 * float(value) / total) | |
3055 else: | |
3056 return value, 100.0 | |
3052 | 3057 |
3053 ui.write(('format : %d\n') % format) | 3058 ui.write(('format : %d\n') % format) |
3054 ui.write(('flags : %s\n') % ', '.join(flags)) | 3059 ui.write(('flags : %s\n') % ', '.join(flags)) |
3055 | 3060 |
3056 ui.write('\n') | 3061 ui.write('\n') |