DRIVER=processor
MODALIAS=cpu:type:x86,ven0002fam0017mod0031:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0017,0018,0019,001A,0020,0021,0022,0023,0024,0025,0026,0027,0028,0029,002B,002C,002D,002E,002F,0030,0031,0034,0036,0037,0038,0039,003A,003B,003D,0064,006E,0070,0072,0074,0075,0079,007A,007F,0080,0081,0089,008C,008D,0093,0094,0095,0096,0097,0098,0099,009A,009B,009C,009D,009E,009F,00C0,00C1,00C4,00C5,00C6,00C7,00C8,00C9,00D7,00EA,00ED,00F0,00F1,00F3,00F5,00F9,00FA,00FB,00FC,010F,0114,0115,0120,0121,0123,0125,0127,0128,0132,0133,0134,0137,0138,013D,0140,0141,0142,0165,016C,016E,016F,0170,017C,01A0,01A2,01A9,01AC,01AE,01AF,01B8,01C2,0202,0216,0220,0221,025A,025B,025D,025F,0282,0286,029C,029D

  A   ˆl–äY>”JeJe@†à¸Û*bÑ¿�þBó�Y¹BáYI#MùÂƒpMÁ_ŠI|¥�+Wé3ž¯ÁÀ a    # This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

# based on bundleheads extension by Gregory Szorc <gps@mozilla.com>


import abc
import os
import subprocess

from mercurial.node import hex
from mercurial.pycompat import open
from mercurial import pycompat
from mercurial.utils import (
    hashutil,
    procutil,
)


class BundleWriteException(Exception):
    pass


class BundleReadException(Exception):
    pass


class abstractbundlestore:  # pytype: disable=ignored-metaclass
    """Defines the interface for bundle stores.

    A bundle store is an entity that stores raw bundle data. It is a simple
    key-value store. However, the keys are chosen by the store. The keys can
    be any Python object understood by the corresponding bundle index (see
    ``abstractbundleindex`` below).
    """

    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def write(self, data):
        """Write bundle data to the store.

        This function receives the raw data to be written as a str.
        Throws BundleWriteException
        The key of the written data MUST be returned.
        """

    @abc.abstractmethod
    def read(self, key):
        """Obtain bundle data for a key.

        Returns None if the bundle isn't known.
        Throws BundleReadException
        The returned object should be a file object supporting read()
        and close().
        """


class filebundlestore:
    """bundle store in filesystem

    meant for storing bundles somewhere on disk and on network filesystems
    """

    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo
        self.storepath = ui.configpath(b'scratchbranch', b'storepath')
        if not self.storepath:
            self.storepath = self.repo.vfs.join(
                b"scratchbranches", b"filebundlestore"
            )
        if not os.path.exists(self.storepath):
            os.makedirs(self.storepath)

    def _dirpath(self, hashvalue):
        """First two bytes of the hash are the name of the upper
        level directory, next two bytes are the name of the
        next level directory"""
        return os.path.join(self.storepath, hashvalue[0:2], hashvalue[2:4])

    def _filepath(self, filename):
        return os.path.join(self._dirpath(filename), filename)

    def write(self, data):
        filename = hex(hashutil.sha1(data).digest())
        dirpath = self._dirpath(filename)

        if not os.path.exists(dirpath):
            os.makedirs(dirpath)

        with open(self._filepath(filename), b'wb') as f:
            f.write(data)

        return filename

    def read(self, key):
        try:
            with open(self._filepath(key), b'rb') as f:
                return f.read()
        except IOError:
            return None


def format_placeholders_args(args, filename=None, handle=None):
    """Formats `args` with Infinitepush replacements.

    Hack to get `str.format()`-ed strings working in a BC way with
    bytes.
    """
    formatted_args = []
    for arg in args:
        if filename and arg == b'{filename}':
            formatted_args.append(filename)
        elif handle and arg == b'{handle}':
            formatted_ar