comparison mercurial/debugcommands.py @ 39153:9d6fab487c13

debugrevlog: display snapshot details per depth This help in understanding the final structure of build manifest. All data about snapshot (full and intermediate) are gathered into a sub-list for clarity. Since we do not produce such snapshots yet, the only thing changing in test output is the way the information is presented.
author Boris Feld <boris.feld@octobus.net>
date Wed, 15 Aug 2018 12:30:30 +0200
parents 07b82f55f351
children 5b32b3c618b2
comparison
equal deleted inserted replaced
39152:3b1042cab4b4 39153:9d6fab487c13
2095 numemptydelta = 0 2095 numemptydelta = 0
2096 # full file content 2096 # full file content
2097 numfull = 0 2097 numfull = 0
2098 # intermediate snapshot against a prior snapshot 2098 # intermediate snapshot against a prior snapshot
2099 numsemi = 0 2099 numsemi = 0
2100 # snapshot count per depth
2101 numsnapdepth = collections.defaultdict(lambda: 0)
2100 # delta against previous revision 2102 # delta against previous revision
2101 numprev = 0 2103 numprev = 0
2102 # delta against first or second parent (not prev) 2104 # delta against first or second parent (not prev)
2103 nump1 = 0 2105 nump1 = 0
2104 nump2 = 0 2106 nump2 = 0
2116 2118
2117 # data about each revision 2119 # data about each revision
2118 datasize = [None, 0, 0] 2120 datasize = [None, 0, 0]
2119 fullsize = [None, 0, 0] 2121 fullsize = [None, 0, 0]
2120 semisize = [None, 0, 0] 2122 semisize = [None, 0, 0]
2123 # snapshot count per depth
2124 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0])
2121 deltasize = [None, 0, 0] 2125 deltasize = [None, 0, 0]
2122 chunktypecounts = {} 2126 chunktypecounts = {}
2123 chunktypesizes = {} 2127 chunktypesizes = {}
2124 2128
2125 def addsize(size, l): 2129 def addsize(size, l):
2145 if size == 0: 2149 if size == 0:
2146 numempty += 1 2150 numempty += 1
2147 numemptytext += 1 2151 numemptytext += 1
2148 else: 2152 else:
2149 numfull += 1 2153 numfull += 1
2154 numsnapdepth[0] += 1
2150 addsize(size, fullsize) 2155 addsize(size, fullsize)
2156 addsize(size, snapsizedepth[0])
2151 else: 2157 else:
2152 chainlengths.append(chainlengths[delta] + 1) 2158 chainlengths.append(chainlengths[delta] + 1)
2153 baseaddr = chainbases[delta] 2159 baseaddr = chainbases[delta]
2154 revaddr = r.start(rev) 2160 revaddr = r.start(rev)
2155 chainbases.append(baseaddr) 2161 chainbases.append(baseaddr)
2158 numempty += 1 2164 numempty += 1
2159 numemptydelta += 1 2165 numemptydelta += 1
2160 elif r.issnapshot(rev): 2166 elif r.issnapshot(rev):
2161 addsize(size, semisize) 2167 addsize(size, semisize)
2162 numsemi += 1 2168 numsemi += 1
2169 depth = r.snapshotdepth(rev)
2170 numsnapdepth[depth] += 1
2171 addsize(size, snapsizedepth[depth])
2163 else: 2172 else:
2164 addsize(size, deltasize) 2173 addsize(size, deltasize)
2165 if delta == rev - 1: 2174 if delta == rev - 1:
2166 numprev += 1 2175 numprev += 1
2167 if delta == p1: 2176 if delta == p1:
2202 totalrawsize = datasize[2] 2211 totalrawsize = datasize[2]
2203 datasize[2] /= numrevs 2212 datasize[2] /= numrevs
2204 fulltotal = fullsize[2] 2213 fulltotal = fullsize[2]
2205 fullsize[2] /= numfull 2214 fullsize[2] /= numfull
2206 semitotal = semisize[2] 2215 semitotal = semisize[2]
2216 snaptotal = {}
2207 if 0 < numsemi: 2217 if 0 < numsemi:
2208 semisize[2] /= numsemi 2218 semisize[2] /= numsemi
2219 for depth in snapsizedepth:
2220 snaptotal[depth] = snapsizedepth[depth][2]
2221 snapsizedepth[depth][2] /= numsnapdepth[depth]
2222
2209 deltatotal = deltasize[2] 2223 deltatotal = deltasize[2]
2210 if numdeltas > 0: 2224 if numdeltas > 0:
2211 deltasize[2] /= numdeltas 2225 deltasize[2] /= numdeltas
2212 totalsize = fulltotal + semitotal + deltatotal 2226 totalsize = fulltotal + semitotal + deltatotal
2213 avgchainlen = sum(chainlengths) / numrevs 2227 avgchainlen = sum(chainlengths) / numrevs
2244 ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs)) 2258 ui.write((' empty : ') + fmt % pcfmt(numempty, numrevs))
2245 ui.write((' text : ') 2259 ui.write((' text : ')
2246 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta)) 2260 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta))
2247 ui.write((' delta : ') 2261 ui.write((' delta : ')
2248 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta)) 2262 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta))
2249 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs)) 2263 ui.write((' snapshot : ') + fmt % pcfmt(numfull + numsemi, numrevs))
2250 ui.write((' inter : ') + fmt % pcfmt(numsemi, numrevs)) 2264 for depth in sorted(numsnapdepth):
2265 ui.write((' lvl-%-3d : ' % depth)
2266 + fmt % pcfmt(numsnapdepth[depth], numrevs))
2251 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs)) 2267 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2252 ui.write(('revision size : ') + fmt2 % totalsize) 2268 ui.write(('revision size : ') + fmt2 % totalsize)
2253 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize)) 2269 ui.write((' snapshot : ')
2254 ui.write((' inter : ') + fmt % pcfmt(semitotal, totalsize)) 2270 + fmt % pcfmt(fulltotal + semitotal, totalsize))
2271 for depth in sorted(numsnapdepth):
2272 ui.write((' lvl-%-3d : ' % depth)
2273 + fmt % pcfmt(snaptotal[depth], totalsize))
2255 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize)) 2274 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2256 2275
2257 def fmtchunktype(chunktype): 2276 def fmtchunktype(chunktype):
2258 if chunktype == 'empty': 2277 if chunktype == 'empty':
2259 return ' %s : ' % chunktype 2278 return ' %s : ' % chunktype
2283 ui.write('\n') 2302 ui.write('\n')
2284 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n') 2303 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2285 % tuple(datasize)) 2304 % tuple(datasize))
2286 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n') 2305 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2287 % tuple(fullsize)) 2306 % tuple(fullsize))
2307 ui.write(('inter-snapshot size (min/max/avg) : %d / %d / %d\n')
2308 % tuple(semisize))
2309 for depth in sorted(snapsizedepth):
2310 if depth == 0:
2311 continue
2312 ui.write((' level-%-3d (min/max/avg) : %d / %d / %d\n')
2313 % ((depth,) + tuple(snapsizedepth[depth])))
2288 ui.write(('delta size (min/max/avg) : %d / %d / %d\n') 2314 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2289 % tuple(deltasize)) 2315 % tuple(deltasize))
2290 2316
2291 if numdeltas > 0: 2317 if numdeltas > 0:
2292 ui.write('\n') 2318 ui.write('\n')