[PATCH 1 of 4] diffstat: scale adds/removes to exact graph width

Brodie Rao dackze at gmail.com
Wed Aug 5 09:07:09 CDT 2009


On Aug 5, 2009, at 7:44 AM, Dirkjan Ochtman wrote:

> On Thu, Jul 30, 2009 at 17:06, Brodie Rao<dackze at gmail.com> wrote:
>> # HG changeset patch
>> # User Brodie Rao <me+hg at dackz.net>
>> # Date 1248966170 14400
>> # Node ID 4076e49a0bf9555116bf4b6e5bb1fe0d420d4814
>> # Parent  25255ce87bcfb753df078b2f8cabc6bcb5cb96ce
>> diffstat: scale adds/removes to exact graph width
>>
>> The previous method of scaling had a tendency to go past the  
>> desired width.
>
> Why? What did you fix? The message here is kind of lacking.

Sorry about being vague.

I've noticed things like this with the current code:

$ ./hg diff -r 1.1:1.1.1 | ./diffstat.py
[snip]
  mercurial/store.py                  |    6 +
  mercurial/ui.py                     |    3 +-
  mercurial/util.py                   |    8 +-
  tests/run-tests.py                  |    4 +-
  tests/svn/branches.svndump          |  415 ++++++++++++++++++++++++++ 
+++++++++++++++
  tests/svn/move.svndump              |  401 ++++++++++++++++++++++++++ 
++++++++++++++
  tests/svn/startrev.svndump          |  240 ++++++++++++++++++++++++
  tests/svn/svndump-branches.sh       |   70 +++++++
  tests/svn/svndump-move.sh           |   62 ++++++
  tests/svn/svndump-startrev.sh       |   45 ++++
  tests/svn/svndump-tags.sh           |   49 ++++
  tests/svn/tags.svndump              |  295 ++++++++++++++++++++++++++ 
+++
  tests/test-acl                      |    6 +-
  tests/test-archive.out              |    2 +-
[snip]
  57 files changed, 2018 insertions(+), 595 deletions(-)

In that case, tests/svn/branches.svndump and tests/svn/move.svndump go  
past 80 characters.

It also doesn't necessarily scale to fill the entire graph area:

./hg diff -r 1.3:1.3.1 | ./diffstat.py
[snip]
  hgext/keyword.py                |  15 ++++---
  hgext/rebase.py                 |   1 +
  hgext/transplant.py             |   1 +
  hgext/win32mbcs.py              |  56 ++++++++++++++++++++--------
  mercurial/cmdutil.py            |   5 ++-
  mercurial/commands.py           |  37 ++++++++----------
  mercurial/context.py            |   5 +-
  mercurial/copies.py             |   2 +-
  mercurial/help.py               |  12 +++--
  mercurial/hgweb/hgwebdir_mod.py |   6 ++-
  mercurial/localrepo.py          |   3 +-
  mercurial/patch.py              |  21 +++++++---
  mercurial/repair.py             |   5 +-
  mercurial/store.py              |  13 +++---
  mercurial/subrepo.py            |   7 +++-
  mercurial/transaction.py        |   2 +-
  mercurial/url.py                |   2 +
  mercurial/util.py               |  36 +++++++++++++++++-
[snip]
  48 files changed, 340 insertions(+), 156 deletions(-)

hgext/win32mbcs.py is the longest line, but it's not 80 chars.

I opted to take an approach similar to what diffstat(1) and git's  
diffstat do: they scale the add/remove counts proportionally.


More information about the Mercurial-devel mailing list