Mercurial > public > mercurial-scm > hg-stable
diff hgext/churn.py @ 7547:4949729ee9ee
python implementation of diffstat
Implemented as two functions: diffstat, which yields lines of text,
formatted as a usual diffstat output, and diffstatdata, which is called
inside diffstat to do real performing and yield file names with
appropriate data (numbers of added and removed lines).
author | Alexander Solovyov <piranha@piranha.org.ua> |
---|---|
date | Thu, 25 Dec 2008 10:48:24 +0200 |
parents | 87158be081b8 |
children | 26adfaccdf73 |
line wrap: on
line diff
--- a/hgext/churn.py Sun Dec 28 19:59:42 2008 +0100 +++ b/hgext/churn.py Thu Dec 25 10:48:24 2008 +0200 @@ -12,27 +12,6 @@ import os, sys import time, datetime -def get_tty_width(): - if 'COLUMNS' in os.environ: - try: - return int(os.environ['COLUMNS']) - except ValueError: - pass - try: - import termios, array, fcntl - for dev in (sys.stdout, sys.stdin): - try: - fd = dev.fileno() - if not os.isatty(fd): - continue - arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) - return array.array('h', arri)[1] - except ValueError: - pass - except ImportError: - pass - return 80 - def maketemplater(ui, repo, tmpl): tmpl = templater.parsestring(tmpl, quoted=False) try: @@ -157,7 +136,7 @@ maxcount = float(max([v for k, v in rate])) maxname = max([len(k) for k, v in rate]) - ttywidth = get_tty_width() + ttywidth = util.termwidth() ui.debug(_("assuming %i character terminal\n") % ttywidth) width = ttywidth - maxname - 2 - 6 - 2 - 2