Mercurial > hg
comparison mercurial/commands.py @ 30452:932b18c95e11
commands: print chunk type in debugrevlog
Each data entry ("chunk") in a revlog has a type based on the first
byte of the data. This type indicates how to interpret the data.
This seems like a useful thing to be able to query through a debug
command. So let's add that to `hg debugrevlog`.
This does make `hg debugrevlog` slightly slower, as it has to read
more than just the index. However, even on the mozilla-unified
manifest (which is ~200MB spread over ~350K revisions), this takes
<400ms.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 17 Nov 2016 20:30:00 -0800 |
parents | 945f8229b30d |
children | 356406ac454f |
comparison
equal
deleted
inserted
replaced
30451:94ca0e13d1fc | 30452:932b18c95e11 |
---|---|
13 import os | 13 import os |
14 import random | 14 import random |
15 import re | 15 import re |
16 import shlex | 16 import shlex |
17 import socket | 17 import socket |
18 import string | |
18 import sys | 19 import sys |
19 import tempfile | 20 import tempfile |
20 import time | 21 import time |
21 | 22 |
22 from .i18n import _ | 23 from .i18n import _ |
3192 chainlengths = [] | 3193 chainlengths = [] |
3193 | 3194 |
3194 datasize = [None, 0, 0] | 3195 datasize = [None, 0, 0] |
3195 fullsize = [None, 0, 0] | 3196 fullsize = [None, 0, 0] |
3196 deltasize = [None, 0, 0] | 3197 deltasize = [None, 0, 0] |
3198 chunktypecounts = {} | |
3199 chunktypesizes = {} | |
3197 | 3200 |
3198 def addsize(size, l): | 3201 def addsize(size, l): |
3199 if l[0] is None or size < l[0]: | 3202 if l[0] is None or size < l[0]: |
3200 l[0] = size | 3203 l[0] = size |
3201 if size > l[1]: | 3204 if size > l[1]: |
3229 elif delta == p2: | 3232 elif delta == p2: |
3230 nump2 += 1 | 3233 nump2 += 1 |
3231 elif delta != nullrev: | 3234 elif delta != nullrev: |
3232 numother += 1 | 3235 numother += 1 |
3233 | 3236 |
3237 # Obtain data on the raw chunks in the revlog. | |
3238 chunk = r._chunkraw(rev, rev)[1] | |
3239 if chunk: | |
3240 chunktype = chunk[0] | |
3241 else: | |
3242 chunktype = 'empty' | |
3243 | |
3244 if chunktype not in chunktypecounts: | |
3245 chunktypecounts[chunktype] = 0 | |
3246 chunktypesizes[chunktype] = 0 | |
3247 | |
3248 chunktypecounts[chunktype] += 1 | |
3249 chunktypesizes[chunktype] += size | |
3250 | |
3234 # Adjust size min value for empty cases | 3251 # Adjust size min value for empty cases |
3235 for size in (datasize, fullsize, deltasize): | 3252 for size in (datasize, fullsize, deltasize): |
3236 if size[0] is None: | 3253 if size[0] is None: |
3237 size[0] = 0 | 3254 size[0] = 0 |
3238 | 3255 |
3279 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs)) | 3296 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs)) |
3280 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) | 3297 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) |
3281 ui.write(('revision size : ') + fmt2 % totalsize) | 3298 ui.write(('revision size : ') + fmt2 % totalsize) |
3282 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize)) | 3299 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize)) |
3283 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) | 3300 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) |
3301 | |
3302 def fmtchunktype(chunktype): | |
3303 if chunktype == 'empty': | |
3304 return ' %s : ' % chunktype | |
3305 elif chunktype in string.ascii_letters: | |
3306 return ' 0x%s (%s) : ' % (hex(chunktype), chunktype) | |
3307 else: | |
3308 return ' 0x%s : ' % hex(chunktype) | |
3309 | |
3310 ui.write('\n') | |
3311 ui.write(('chunks : ') + fmt2 % numrevs) | |
3312 for chunktype in sorted(chunktypecounts): | |
3313 ui.write(fmtchunktype(chunktype)) | |
3314 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) | |
3315 ui.write(('chunks size : ') + fmt2 % totalsize) | |
3316 for chunktype in sorted(chunktypecounts): | |
3317 ui.write(fmtchunktype(chunktype)) | |
3318 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) | |
3284 | 3319 |
3285 ui.write('\n') | 3320 ui.write('\n') |
3286 fmt = dfmtstr(max(avgchainlen, compratio)) | 3321 fmt = dfmtstr(max(avgchainlen, compratio)) |
3287 ui.write(('avg chain length : ') + fmt % avgchainlen) | 3322 ui.write(('avg chain length : ') + fmt % avgchainlen) |
3288 ui.write(('max chain length : ') + fmt % maxchainlen) | 3323 ui.write(('max chain length : ') + fmt % maxchainlen) |