##// END OF EJS Templates
color: don't infer vt status from TERM on Windows...
color: don't infer vt status from TERM on Windows Previously, it was assumed that Windows environments with "xterm" in the TERM environment variable meant that either "virtual terminal mode" was already enabled, or that we are running in an environment that didn't need a "virtual terminal mode" (such as mintty, that interprets ANSI sequences itself). However, modern Cygwin and MSYS2 set TERM=xterm when using the Command Prompt as the terminal, which needs "virtual terminal mode" to be manually enabled. However, due to (issue6640), the vtmode wasn't being enabled. This patch ensures that we always try to enable vtmode on Windows regardless of the state of TERM, so that: * ANSI-based colors work in modern Cygwin/MSYS2 (with Command Prompt), and * The vtmode is unnecessarily set when running in a different terminal such as mintty, but it is simply redundant and doesn't appear to have ill effects. Differential Revision: https://phab.mercurial-scm.org/D12158

File last commit:

r47758:07b9ebea default
r49587:fd2cf9e0 default
Show More
gitutil.py
53 lines | 1.1 KiB | text/x-python | PythonLexer
"""utilities to assist in working with pygit2"""
from __future__ import absolute_import
from mercurial.node import bin, hex, sha1nodeconstants
from mercurial import pycompat
pygit2_module = None
def get_pygit2():
global pygit2_module
if pygit2_module is None:
try:
import pygit2 as pygit2_module
pygit2_module.InvalidSpecError
except (ImportError, AttributeError):
pass
return pygit2_module
def pygit2_version():
mod = get_pygit2()
v = "N/A"
if mod:
try:
v = mod.__version__
except AttributeError:
pass
return b"(pygit2 %s)" % v.encode("utf-8")
def togitnode(n):
"""Wrapper to convert a Mercurial binary node to a unicode hexlified node.
pygit2 and sqlite both need nodes as strings, not bytes.
"""
assert len(n) == 20
return pycompat.sysstr(hex(n))
def fromgitnode(n):
"""Opposite of togitnode."""
assert len(n) == 40
if pycompat.ispy3:
return bin(n.encode('ascii'))
return bin(n)
nullgit = togitnode(sha1nodeconstants.nullid)