[PATCH 1 of 1] python implementation of diffstat

Matt Mackall mpm at selenic.com
Sun Dec 21 14:59:39 CST 2008


On Sun, 2008-12-21 at 11:54 +0200, Alexander Solovyov wrote:
> 4 files changed, 97 insertions(+), 32 deletions(-)
>  mercurial/patch.py       |  79 ++++++++++++++++++++++++++++++++++-----
>  hgext/patchbomb.py       |  21 ++++------
>  tests/test-patchbomb.out |  26 +++++++++----
>  tests/test-notify.out    |   3 +-
> 
> 
> # HG changeset patch
> # User Alexander Solovyov <piranha at piranha.org.ua>
> # Date 1229853225 -7200
> # Node ID 1797935e306ae8f95ae81f436440822592788514
> # Parent  3896310bd797a3c0db22654321e88db9cc73d3e7
> python implementation of diffstat
> 
> Implemented as an class, string representation of which is similar to
> the output of system diffstat command. There is possibility to access
> attributes of a diffstat object to get already parsed statistics in
> python code.

Ugh, please, not a class. This is not something with complex state,
long-lived state, frequently manipulated state, writable state, numerous
operators, 'natural' operators, or other syntactic advantages.

It's perfectly simple to write one function (diffstatdata) that returns
a hash or list of [(filename, added, removed), ...] and another
(diffstat) that calls it and formats it as text. It will be more
natural, shorter, faster, and easier to understand and use.



-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list