Show More
@@ -463,36 +463,6 b' def spawndetached(args):' | |||
|
463 | 463 | def gethgcmd(): |
|
464 | 464 | return sys.argv[:1] |
|
465 | 465 | |
|
466 | def termwidth(): | |
|
467 | try: | |
|
468 | import array | |
|
469 | import termios | |
|
470 | for dev in (sys.stderr, sys.stdout, sys.stdin): | |
|
471 | try: | |
|
472 | try: | |
|
473 | fd = dev.fileno() | |
|
474 | except AttributeError: | |
|
475 | continue | |
|
476 | if not os.isatty(fd): | |
|
477 | continue | |
|
478 | try: | |
|
479 | arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) | |
|
480 | width = array.array('h', arri)[1] | |
|
481 | if width > 0: | |
|
482 | return width | |
|
483 | except AttributeError: | |
|
484 | pass | |
|
485 | except ValueError: | |
|
486 | pass | |
|
487 | except IOError as e: | |
|
488 | if e[0] == errno.EINVAL: | |
|
489 | pass | |
|
490 | else: | |
|
491 | raise | |
|
492 | except ImportError: | |
|
493 | pass | |
|
494 | return 80 | |
|
495 | ||
|
496 | 466 | def makedir(path, notindexed): |
|
497 | 467 | os.mkdir(path) |
|
498 | 468 |
@@ -1,5 +1,7 b'' | |||
|
1 | 1 | from __future__ import absolute_import |
|
2 | 2 | |
|
3 | import errno | |
|
4 | import fcntl | |
|
3 | 5 | import os |
|
4 | 6 | import sys |
|
5 | 7 | |
@@ -38,3 +40,33 b' def userrcpath():' | |||
|
38 | 40 | return [encoding.environ['home'] + '/lib/hgrc'] |
|
39 | 41 | else: |
|
40 | 42 | return [os.path.expanduser('~/.hgrc')] |
|
43 | ||
|
44 | def termwidth(): | |
|
45 | try: | |
|
46 | import array | |
|
47 | import termios | |
|
48 | for dev in (sys.stderr, sys.stdout, sys.stdin): | |
|
49 | try: | |
|
50 | try: | |
|
51 | fd = dev.fileno() | |
|
52 | except AttributeError: | |
|
53 | continue | |
|
54 | if not os.isatty(fd): | |
|
55 | continue | |
|
56 | try: | |
|
57 | arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) | |
|
58 | width = array.array('h', arri)[1] | |
|
59 | if width > 0: | |
|
60 | return width | |
|
61 | except AttributeError: | |
|
62 | pass | |
|
63 | except ValueError: | |
|
64 | pass | |
|
65 | except IOError as e: | |
|
66 | if e[0] == errno.EINVAL: | |
|
67 | pass | |
|
68 | else: | |
|
69 | raise | |
|
70 | except ImportError: | |
|
71 | pass | |
|
72 | return 80 |
@@ -40,6 +40,7 b' else:' | |||
|
40 | 40 | |
|
41 | 41 | systemrcpath = scmplatform.systemrcpath |
|
42 | 42 | userrcpath = scmplatform.userrcpath |
|
43 | termwidth = scmplatform.termwidth | |
|
43 | 44 | |
|
44 | 45 | class status(tuple): |
|
45 | 46 | '''Named tuple with a list of files per status. The 'deleted', 'unknown' |
@@ -5,6 +5,7 b' import os' | |||
|
5 | 5 | from . import ( |
|
6 | 6 | osutil, |
|
7 | 7 | util, |
|
8 | win32, | |
|
8 | 9 | ) |
|
9 | 10 | |
|
10 | 11 | try: |
@@ -51,3 +52,6 b' def userrcpath():' | |||
|
51 | 52 | path.append(os.path.join(userprofile, 'mercurial.ini')) |
|
52 | 53 | path.append(os.path.join(userprofile, '.hgrc')) |
|
53 | 54 | return path |
|
55 | ||
|
56 | def termwidth(): | |
|
57 | return win32.termwidth() |
@@ -822,7 +822,7 b' class ui(object):' | |||
|
822 | 822 | return int(encoding.environ['COLUMNS']) |
|
823 | 823 | except ValueError: |
|
824 | 824 | pass |
|
825 | return util.termwidth() | |
|
825 | return scmutil.termwidth() | |
|
826 | 826 | |
|
827 | 827 | def formatted(self): |
|
828 | 828 | '''should formatted output be used? |
@@ -122,7 +122,6 b' sshargs = platform.sshargs' | |||
|
122 | 122 | statfiles = getattr(osutil, 'statfiles', platform.statfiles) |
|
123 | 123 | statisexec = platform.statisexec |
|
124 | 124 | statislink = platform.statislink |
|
125 | termwidth = platform.termwidth | |
|
126 | 125 | testpid = platform.testpid |
|
127 | 126 | umask = platform.umask |
|
128 | 127 | unlink = platform.unlink |
General Comments 0
You need to be logged in to leave comments.
Login now