[PATCH 1 of 2] util: generalize bytecount to unitcount

Benoit Boissinot bboissin at gmail.com
Sat Feb 23 16:01:55 CST 2013


On Thu, Feb 21, 2013 at 10:33 PM, Bryan O'Sullivan <bos at serpentine.com>wrote:

> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1361482359 28800
> # Node ID 19d3300883ce1407d0b527549a82f25d3f182873
> # Parent  5779b305bf3a9192823252b8caf2240124238706
> util: generalize bytecount to unitcount
>
> This gives us a function we can reuse to count units of other kinds.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1268,7 +1268,18 @@ def ellipsis(text, maxlength=400):
>      except (UnicodeDecodeError, UnicodeEncodeError):
>          return _ellipsis(text, maxlength)[0]
>
> -_byteunits = (
> +def unitcount(*unittable):
> +    '''return a count of some quantity formatted as a readable string'''
>

Maybe call it unitcountfn? (or something similar), since it's not directly
usable (returns a function).
(I also think the docstring could be improved).

Otherwise looks good to me.

Cheers,

Benoit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130223/a8413eb7/attachment.html>


More information about the Mercurial-devel mailing list