Commit Graph

15 Commits

Author SHA1 Message Date
Yuya Nishihara
cbe21a1cc9 osutil: proxy through util (and platform) modules (API)
See the previous commit for why. Marked as API change since osutil.listdir()
seems widely used in third-party extensions.

The win32mbcs extension is updated to wrap both util. and windows. aliases.
2017-04-26 22:26:28 +09:00
Yuya Nishihara
c11e91f8ff pager: use less as a fallback on Unix
This seems reasonable choice per discussion, and the default-default of Git.
See also the inline-comment for why.

https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-April/097042.html
2017-04-28 20:51:14 +09:00
Pulkit Goyal
48edb15e9c smcposix: pass unicode as first argument to array.array
This is an instance where we can safely convert the first argument, rest are
the cases except one where we are using 'c' which is not there in Python 3. So
that needs to be handled differently. This will help in making `hg help` run on
Python 3.
2017-03-12 22:27:53 +05:30
David Demelier
e7d1102f9f hg: allow usage of XDG_CONFIG_HOME/hg/hgrc
Modern applications must use the following paths to store configuration files:

  - $XDG_CONFIG_HOME/hg/hgrc,
  - $HOME/.config/hg/hgrc (if XDG_CONFIG_HOME is unset or not absolute).

For backward compatibility, ~/.hgrc is still created if no hgrc exist using hg
config --edit.

See https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
2017-02-07 17:33:35 +01:00
Pulkit Goyal
8edc9540ee py3: replace sys.platform with pycompat.sysplatform (part 1 of 2)
sys.platform returns unicode on python 3 world. Our code base has most of the
things bytes because of the transformer. So we have a bytes version of this as
pycompat.sysplatform. This series of 2 patches replaces occurences of
sys.platform with pycompat.sysplatform.
2016-12-19 02:15:24 +05:30
Pulkit Goyal
555274a3fd py3: use pycompat.sysargv in scmposix.systemrcpath()
sys.argv returns unicodes on Python 3. We have pycompat.sysargv which returns
bytes encoded using os.fsencode(). After this patch scmposix.systemrcpath()
returns bytes in Python 3 world. This change is also a part of making
`hg version` run in Python 3.
2016-11-21 15:26:47 +05:30
Yuya Nishihara
d1b623a5c1 scmutil: extend termwidth() to return terminal height, renamed to termsize()
It appears crecord.py has its own termsize() function. I want to get rid of it.

The fallback height is chosen from the default of cmd.exe on Windows, and
VT100 on Unix.
2016-10-20 23:09:05 +09:00
Yuya Nishihara
a85ef4fbe3 scmutil: remove superfluous indent from termwidth() 2016-10-20 21:57:32 +09:00
Yuya Nishihara
da9da141c4 scmutil: narrow ImportError handling in termwidth()
The array module must exist. It's sufficient to suppress the ImportError of
termios. Also salvaged the comment why we have to handle AttributeError, from
54db81f689bd.
2016-10-20 21:50:29 +09:00
Yuya Nishihara
5b9ee7c321 scmutil: make termwidth() obtain stdio from ui
I'm getting rid of direct sys.stderr|out|in references so Py3 porting will
be slightly easier.
2016-10-20 21:42:11 +09:00
Yuya Nishihara
52e59de51c scmutil: move util.termwidth()
I'm going to get rid of sys.stderr|out|in references from posix.termwidth().
In order to do that, termwidth() needs to take a ui, but functions in util.py
shouldn't depend on a ui object. So moves termwidth() to scmutil.py.
2016-10-20 21:38:44 +09:00
Pulkit Goyal
3174051816 py3: make scmposix.userrcpath() return bytes
We are making sure that we deal with bytes as much we can. This is a part
of fixing functions so that they return bytes if they have to.
Used encoding.environ to return bytes.

After this patch, scmposix.userrcpath() returns bytes and scmutil.osrcpath()
will also return bytes if the platform is posix. Functions is scmposix returns
bytes on Python 3 now.
2016-11-03 02:17:01 +05:30
Gregory Szorc
4b6a93ce1c scmposix: use absolute_import 2015-12-21 21:24:49 -08:00
Mads Kiilerich
f7a8635451 config: don't read the same config file twice
In some cases some config files would be read twice and shown twice in
showconfig --debug.
2014-09-04 21:36:35 +02:00
Kevin Bullock
d24c25031a scmutil: split platform-specific bits into their own modules
This parallels what's done for the util module, which imports either
mercurial.posix or mercurial.windows as 'platform' and then slurps the
appropriate functions into its own namespace.
2013-02-12 11:36:21 -06:00