Show More
@@ -463,36 +463,6 b' def spawndetached(args):' | |||||
463 | def gethgcmd(): |
|
463 | def gethgcmd(): | |
464 | return sys.argv[:1] |
|
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 | def makedir(path, notindexed): |
|
466 | def makedir(path, notindexed): | |
497 | os.mkdir(path) |
|
467 | os.mkdir(path) | |
498 |
|
468 |
@@ -1,5 +1,7 b'' | |||||
1 | from __future__ import absolute_import |
|
1 | from __future__ import absolute_import | |
2 |
|
2 | |||
|
3 | import errno | |||
|
4 | import fcntl | |||
3 | import os |
|
5 | import os | |
4 | import sys |
|
6 | import sys | |
5 |
|
7 | |||
@@ -38,3 +40,33 b' def userrcpath():' | |||||
38 | return [encoding.environ['home'] + '/lib/hgrc'] |
|
40 | return [encoding.environ['home'] + '/lib/hgrc'] | |
39 | else: |
|
41 | else: | |
40 | return [os.path.expanduser('~/.hgrc')] |
|
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 | systemrcpath = scmplatform.systemrcpath |
|
41 | systemrcpath = scmplatform.systemrcpath | |
42 | userrcpath = scmplatform.userrcpath |
|
42 | userrcpath = scmplatform.userrcpath | |
|
43 | termwidth = scmplatform.termwidth | |||
43 |
|
44 | |||
44 | class status(tuple): |
|
45 | class status(tuple): | |
45 | '''Named tuple with a list of files per status. The 'deleted', 'unknown' |
|
46 | '''Named tuple with a list of files per status. The 'deleted', 'unknown' |
@@ -5,6 +5,7 b' import os' | |||||
5 | from . import ( |
|
5 | from . import ( | |
6 | osutil, |
|
6 | osutil, | |
7 | util, |
|
7 | util, | |
|
8 | win32, | |||
8 | ) |
|
9 | ) | |
9 |
|
10 | |||
10 | try: |
|
11 | try: | |
@@ -51,3 +52,6 b' def userrcpath():' | |||||
51 | path.append(os.path.join(userprofile, 'mercurial.ini')) |
|
52 | path.append(os.path.join(userprofile, 'mercurial.ini')) | |
52 | path.append(os.path.join(userprofile, '.hgrc')) |
|
53 | path.append(os.path.join(userprofile, '.hgrc')) | |
53 | return path |
|
54 | return path | |
|
55 | ||||
|
56 | def termwidth(): | |||
|
57 | return win32.termwidth() |
@@ -822,7 +822,7 b' class ui(object):' | |||||
822 | return int(encoding.environ['COLUMNS']) |
|
822 | return int(encoding.environ['COLUMNS']) | |
823 | except ValueError: |
|
823 | except ValueError: | |
824 | pass |
|
824 | pass | |
825 | return util.termwidth() |
|
825 | return scmutil.termwidth() | |
826 |
|
826 | |||
827 | def formatted(self): |
|
827 | def formatted(self): | |
828 | '''should formatted output be used? |
|
828 | '''should formatted output be used? |
@@ -122,7 +122,6 b' sshargs = platform.sshargs' | |||||
122 | statfiles = getattr(osutil, 'statfiles', platform.statfiles) |
|
122 | statfiles = getattr(osutil, 'statfiles', platform.statfiles) | |
123 | statisexec = platform.statisexec |
|
123 | statisexec = platform.statisexec | |
124 | statislink = platform.statislink |
|
124 | statislink = platform.statislink | |
125 | termwidth = platform.termwidth |
|
|||
126 | testpid = platform.testpid |
|
125 | testpid = platform.testpid | |
127 | umask = platform.umask |
|
126 | umask = platform.umask | |
128 | unlink = platform.unlink |
|
127 | unlink = platform.unlink |
@@ -38,7 +38,6 b' samefile = win32.samefile' | |||||
38 | setsignalhandler = win32.setsignalhandler |
|
38 | setsignalhandler = win32.setsignalhandler | |
39 | spawndetached = win32.spawndetached |
|
39 | spawndetached = win32.spawndetached | |
40 | split = os.path.split |
|
40 | split = os.path.split | |
41 | termwidth = win32.termwidth |
|
|||
42 | testpid = win32.testpid |
|
41 | testpid = win32.testpid | |
43 | unlink = win32.unlink |
|
42 | unlink = win32.unlink | |
44 |
|
43 |
General Comments 0
You need to be logged in to leave comments.
Login now