comparison mercurial/util.py @ 31946:f3b80537a70d

util: fix human-readable printing of negative byte counts Apply the same human-readable printing rules to negative byte counts as to positive ones. Fixes output of debugupgraderepo.
author G?bor Stefanik <gabor.stefanik@nng.com>
date Mon, 10 Apr 2017 18:16:30 +0200
parents 12aca6770046
children cc70c6dbac30
comparison
equal deleted inserted replaced
31945:02c3b1f396de 31946:f3b80537a70d
2159 def unitcountfn(*unittable): 2159 def unitcountfn(*unittable):
2160 '''return a function that renders a readable count of some quantity''' 2160 '''return a function that renders a readable count of some quantity'''
2161 2161
2162 def go(count): 2162 def go(count):
2163 for multiplier, divisor, format in unittable: 2163 for multiplier, divisor, format in unittable:
2164 if count >= divisor * multiplier: 2164 if abs(count) >= divisor * multiplier:
2165 return format % (count / float(divisor)) 2165 return format % (count / float(divisor))
2166 return unittable[-1][2] % count 2166 return unittable[-1][2] % count
2167 2167
2168 return go 2168 return go
2169 2169