Mercurial > hg > mercurial-crew-with-dirclash
comparison contrib/churn.py @ 4965:4106dde15aed
Merge with crew
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 21 Jul 2007 16:44:38 -0500 |
parents | 9bbc0217209b |
children | 041bd297f01e |
comparison
equal
deleted
inserted
replaced
4964:ee983d0dbea8 | 4965:4106dde15aed |
---|---|
9 # Aliases map file format is simple one alias per line in the following | 9 # Aliases map file format is simple one alias per line in the following |
10 # format: | 10 # format: |
11 # | 11 # |
12 # <alias email> <actual email> | 12 # <alias email> <actual email> |
13 | 13 |
14 import sys | |
15 from mercurial.i18n import gettext as _ | 14 from mercurial.i18n import gettext as _ |
16 from mercurial import hg, mdiff, cmdutil, ui, util, templater, node | 15 from mercurial import hg, mdiff, cmdutil, ui, util, templater, node |
16 import os, sys | |
17 | |
18 def get_tty_width(): | |
19 if 'COLUMNS' in os.environ: | |
20 try: | |
21 return int(os.environ['COLUMNS']) | |
22 except ValueError: | |
23 pass | |
24 try: | |
25 import termios, fcntl, struct | |
26 buf = 'abcd' | |
27 for dev in (sys.stdout, sys.stdin): | |
28 try: | |
29 if buf != 'abcd': | |
30 break | |
31 fd = dev.fileno() | |
32 if not os.isatty(fd): | |
33 continue | |
34 buf = fcntl.ioctl(fd, termios.TIOCGWINSZ, buf) | |
35 except ValueError: | |
36 pass | |
37 if buf != 'abcd': | |
38 return struct.unpack('hh', buf)[1] | |
39 except ImportError: | |
40 pass | |
41 return 80 | |
17 | 42 |
18 def __gather(ui, repo, node1, node2): | 43 def __gather(ui, repo, node1, node2): |
19 def dirtywork(f, mmap1, mmap2): | 44 def dirtywork(f, mmap1, mmap2): |
20 lines = 0 | 45 lines = 0 |
21 | 46 |
157 ordered = stats.items() | 182 ordered = stats.items() |
158 ordered.sort(lambda x, y: cmp(y[1], x[1])) | 183 ordered.sort(lambda x, y: cmp(y[1], x[1])) |
159 | 184 |
160 maximum = ordered[0][1] | 185 maximum = ordered[0][1] |
161 | 186 |
162 ui.note("Assuming 80 character terminal\n") | 187 width = get_tty_width() |
163 width = 80 - 1 | 188 ui.note(_("assuming %i character terminal\n") % width) |
189 width -= 1 | |
164 | 190 |
165 for i in ordered: | 191 for i in ordered: |
166 person = i[0] | 192 person = i[0] |
167 lines = i[1] | 193 lines = i[1] |
168 print "%s %6d %s" % (pad(person, 20), lines, | 194 print "%s %6d %s" % (pad(person, 20), lines, |