512
     ˆÈÇË552ÆÊÉ (    ‹      ½•ÝŽÚ0…ï÷)\_ôŽ!�­Ø$Õ– •Ä¦j«ªŠLbkCÙÓ}úæ‡Š¨uÛR®lÇ'sæ›±lç…?Ÿcò6x˜’Åû7ÓÉˆÐÀkà~³a]`<£„¦ˆÅ`»Ý[Ë�*�`	)n24*¡cL½§úæÝ'å,.Gâ ÀŒ{“<æ;"×äWÔ"æ6ÈA³5²è©žA&VPì1•¹e˜&h�¼S”»,átÊ³LäIÊ64QK89+ï+óâ^eÈ„­jËjª<Sò�e"É]Š² ž#6	Ñ*r)ˆHæVËŸŒD¬))ý\úy2š)u€iõ·ç0’*¾véë‘;»›»>õflÃ`§5¥æžzS¦‘ld,Ö‚ÇgÅ��øQ|?Ðo4>×‘
™¥P"¶Q#™é‚•¬ý’ UmU#‰W�²´íb,î—ãYàO–MIâ*Ä1»¿ïõLñ‰/�Pªýªqx™¯tq÷sI)+‘¤H=B:ä¤ò8‘ï°Í|N†¡È†¡Qì©×Z´³ý%½^·7è˜ÝNo@zÖÐ|EÈáÀêÿ3ÇZf1Wm’s½
Ãb±(åaÊqõ–[bÞíþY–«ö$’Š79Ì.Ñ«Û½AŽuúõp‰ÜmÃ~w½“TH-våjÆÿzžy¿Ááæw ~chÞ¸VÜ”TF    C   ˆl–äY>”JeJe@†à¸Û*bÑ¿�þ[tR,Ü¡p¬ˆ$‘¦�üÿÍ„™¿Ì_ŠI|¥�+Wé3ž¯ÌË ?÷     # posix.py - Posix utility function implementations for Mercurial
#
#  Copyright 2005-2009 Olivia Mackall <olivia@selenic.com> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.


import errno
import fcntl
import getpass
import grp
import os
import pwd
import re
import select
import stat
import sys
import tempfile
import unicodedata

from .i18n import _
from .pycompat import (
    getattr,
    open,
)
from . import (
    encoding,
    error,
    policy,
    pycompat,
)

osutil = policy.importmod('osutil')

normpath = os.path.normpath
samestat = os.path.samestat
abspath = os.path.abspath  # re-exports

try:
    oslink = os.link
except AttributeError:
    # Some platforms build Python without os.link on systems that are
    # vaguely unix-like but don't have hardlink support. For those
    # poor souls, just say we tried and that it failed so we fall back
    # to copies.
    def oslink(src, dst):
        raise OSError(
            errno.EINVAL, b'hardlinks not supported: %s to %s' % (src, dst)
        )


readlink = os.readlink
unlink = os.unlink
rename = os.rename
removedirs = os.removedirs
expandglobs = False

umask = os.umask(0)
os.umask(umask)

posixfile = open


def split(p):
    """Same as posixpath.split, but faster

    >>> import posixpath
    >>> for f in [b'/absolute/path/to/file',
    ...           b'relative/path/to/file',
    ...           b'file_alone',
    ...           b'path/to/directory/',
    ...           b'/multiple/path//separators',
    ...           b'/file_at_root',
    ...           b'///multiple_leading_separators_at_root',
    ...           b'']:
    ...     assert split(f) == posixpath.split(f), f
    """
    ht = p.rsplit(b'/', 1)
    if len(ht) == 1:
        return b'', p
    nh = ht[0].rstrip(b'/')
    if nh:
        return nh, ht[1]
    return ht[0] + b'/', ht[1]


def openhardlinks():
    '''return true if it is safe to hold open file handles to hardlinks'''
    return True


def nlinks(name):
    '''return number of hardlinks for the given file'''
    return os.lstat(name).st_nlink


def parsepatchoutput(output_line):
    """parses the output produced by patch and returns the filename"""
    pf = output_line[14:]
    if pycompat.sysplatform == b'OpenVMS':
        if pf[0] == b'`':
            pf = pf[1:-1]  # Remove the quotes
    else:
        if pf.startswith(b"'") and pf.endswith(b"'") and b" " in pf:
            pf = pf[1:-1]  # Remove the quotes
    return pf


def sshargs(sshcmd, host, user, port):
    '''Build argument list for ssh'''
    args = user and (b"%s@%s" % (user, host)) or host
    if b'-' in args[:1]:
        raise error.Abort(
            _(b'illegal ssh hostname or username starting with -: %s') % args
        )
    args = shellquote(args)
    if port:
        args = b'-p %s %s' % (shellquote(port), args)
    return args


def isexec(f):
    """check whether a file is executable"""
    return os.lstat(f).st_mode & 0o100 != 0


def setflags(f, l, x):
    st = os.lstat(f)
    s = st.st_mode
    if l:
        if not stat.S_ISLNK(s):
            # switch file to link
            with open(f, b'rb') as fp:
                data = fp.read()
            unlink(f)
            try:
                os.symlink(data, f)
            except OSError:
                # failed to make a link, rewrite file
                with open