403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/hgext/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/hgext/__pycache__/fix.cpython-39.opt-1.pyc
a

�+�b-��@s\dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!dZ"iZ#e�$e#�Z$iZ%e�&e%�Z&ddddd	d
d
d�Z'e'�(�D]\Z)Z*e&dd
e)e*d
d�q�e&dddd�e&dddd�dMdd�Z+ddd	e	d�fZ,ddge	d�e	d�fZ-ddge	d�e	d�fZ.dd ge	d!�e	d�fZ/d"d#d	e	d$�fZ0dd%d	e	d&�fZ1e	d'�Z2e$de,e-e.e/e0e1ge2e$j3d(�d)d*��Z4d+d,�Z5d-d.�Z6d/d0�Z7d1d2�Z8d3d4�Z9d5d6�Z:d7d8�Z;d9d:�Z<d;d<�Z=d=d>�Z>d?d@�Z?dAdB�Z@dCdD�ZAdEdF�ZBdGdH�ZCdIdJ�ZDGdKdL�dLeE�ZFdS)Na"rewrite file content in changesets or working copy (EXPERIMENTAL)

Provides a command that runs configured tools on the contents of modified files,
writing back any fixes to the working copy or replacing changesets.

Here is an example configuration that causes :hg:`fix` to apply automatic
formatting fixes to modified lines in C++ code::

  [fix]
  clang-format:command=clang-format --assume-filename={rootpath}
  clang-format:linerange=--lines={first}:{last}
  clang-format:pattern=set:**.cpp or **.hpp

The :command suboption forms the first part of the shell command that will be
used to fix a file. The content of the file is passed on standard input, and the
fixed file content is expected on standard output. Any output on standard error
will be displayed as a warning. If the exit status is not zero, the file will
not be affected. A placeholder warning is displayed if there is a non-zero exit
status but no standard error output. Some values may be substituted into the
command::

  {rootpath}  The path of the file being fixed, relative to the repo root
  {basename}  The name of the file being fixed, without the directory path

If the :linerange suboption is set, the tool will only be run if there are
changed lines in a file. The value of this suboption is appended to the shell
command once for every range of changed lines in the file. Some values may be
substituted into the command::

  {first}   The 1-based line number of the first line in the modified range
  {last}    The 1-based line number of the last line in the modified range

Deleted sections of a file will be ignored by :linerange, because there is no
corresponding line range in the version being fixed.

By default, tools that set :linerange will only be executed if there is at least
one changed line range. This is meant to prevent accidents like running a code
formatter in such a way that it unexpectedly reformats the whole file. If such a
tool needs to operate on unchanged files, it should set the :skipclean suboption
to false.

The :pattern suboption determines which files will be passed through each
configured tool. See :hg:`help patterns` for possible values. However, all
patterns are relative to the repo root, even if that text says they are relative
to the current working directory. If there are file arguments to :hg:`fix`, the
intersection of these patterns is used.

There is also a configurable limit for the maximum size of file that will be
processed by :hg:`fix`::

  [fix]
  maxfilesize = 2MB

Normally, execution of configured tools will continue after a failure (indicated
by a non-zero exit status). It can also be configured to abort after the first
such failure, so that no files will be affected if any tool fails. This abort
will also cause :hg:`fix` to exit with a non-zero status::

  [fix]
  failure = abort

When multiple tools are configured to affect a file, they execute in an order
defined by the :priority suboption. The priority suboption has a default value
of zero for each tool. Tools are executed in order of descending priority. The
execution order of tools with equal priority is unspecified. For example, you
could use the 'sort' and 'head' utilities to keep only the 10 smallest numbers
in a text file by ensuring that 'sort' runs before 'head'::

  [fix]
  sort:command = sort -n
  head:command = head -n 10
  sort:pattern = numbers.txt
  head:pattern = numbers.txt
  sort:priority = 2
  head:priority = 1

To account for changes made by each tool, the line numbers used for incremental
formatting are recomputed before executing the next tool. So, each tool may see
different values for the arguments added by the :linerange suboption.

Each fixer tool is allowed to return some metadata in addition to the fixed file
content. The metadata must be placed before the file content on stdout,
separated from the file content by a zero byte. The metadata is parsed as a JSON
value (so, it should be UTF-8 encoded and contain no zero bytes). A fixer tool
is expected to produce this metadata encoding if and only if the :metadata
suboption is true::

  [fix]
  tool:command = tool --prepend-json-metadata
  tool:metadata = true

The metadata values are passed to hooks, which can be used to print summaries or
perform other post-fixing work. The supported hooks are::

  "postfixfile"
    Run once for each file in each revision where any fixer tools made changes
    to the file content. Provides "$HG_REV" and "$HG_PATH" to identify the file,
    and "$HG_METADATA" with a map of fixer names to metadata values from fixer
    tools that affected the file. Fixer tools that didn't affect the file have a
    value of None. Only fixer tools that executed are present in the metadata.

  "postfix"
    Run once after all files and revisions have been handled. Provides
    "$HG_REPLACEMENTS" with information about what revisions were created and
    made obsolete. Provides a boolean "$HG_WDIRWRITTEN" to indicate whether any
    files in the working copy were updated. Provides a list "$HG_METADATA"
    mapping fixer tool names to lists of metadata values returned from
    executions that modified a file. This aggregates the same metadata
    previously passed to the "postfixfile" hook.

Fixer tools are run in the repository's root directory. This allows them to read
configuration files from the working copy, or even write to the working copy.
The working copy is not updated to match the revision being fixed. In fact,
several revisions may be fixed in parallel. Writes to the working copy are not
amended into the revision being fixed; fixer tools should always write fixed
file content back to stdout as documented above.
�)�absolute_importN)�_)�nullid�nullrev�wdirrev)�procutil)�cmdutil�context�copies�error�
logcmdutil�match�mdiff�merge�
mergestate�pycompat�	registrar�rewriteutil�scmutil�util�workersships-with-hg-coreFT)scommands	linerangespatternspriority�metadatas	skipcleansenabled�fixs.*:%s$)�defaultZgeneric�maxfilesizes2MB)r�failure�continuecCsJ|�dd�}|dvr0tjtd�|ftd�d��|dkrFtj||d��dS)	z)Abort with 'message' if fix.failure=abortrr)r�abortsunknown fix.failure action: %ssuse "continue" or "abort"��hintrN)�configr�Abortr)�ui�messager�action�r%�//usr/lib64/python3.9/site-packages/hgext/fix.py�checktoolfailureaction�s�r'��alls)fix all non-public non-obsolete revisions�basesdrevisions to diff against (overrides automatic selection, and applies to every revision being fixed)sREV�r�revsrevisions to fix (ADVANCED)�s�sources1fix the specified revisions and their descendants�wsworking-dirsfix the working directory�wholesalways fix every line of a files[OPTION]... [FILE]...)Zhelpcategorycs�t����t��ddd�t��dddg������������T��d���&t����}t	��|��t
��|�|��\}}t��|���t���t
�|��������fdd�}tj�d|t�|d	d
�}t�t�}	t�t�}
i}d	}t|dd�}
�jtd
�td�t|���d���
}|D]�\}}}}|j|d�|��D]\}}|
|�|��q@|du�r�||	||<|||d�}�jddd	it�|���||d8<|
�r ||
d�s |
��}�|}|tk�r�t �||	||�t!|	|�}nt"��||	||�|	|=�q��q Wd�n1�s,0Yt#�||�|||
d�}�jdddit�|���Wd�n1�s~0YWd�n1�s�0YWd�n1�s�0YdS)a�rewrite file content in changesets or working directory

    Runs any configured tools to fix the content of files. Only affects files
    with changes, unless file arguments are provided. Only affects changed lines
    of files, unless the --whole flag is used. Some tools may always affect the
    whole file regardless of --whole.

    If --working-dir is used, files with uncommitted changes in the working copy
    will be fixed. Note that no backup are made.

    If revisions are specified with --source, those revisions and their
    descendants will be checked, and they may be replaced with new revisions
    that have fixed file content. By automatically including the descendants,
    no merging, rebasing, or evolution will be required. If an ancestor of the
    working copy is included, then the working copy itself will also be fixed,
    and the working copy will be updated to the fixed parent.

    When determining what lines of each file to fix at each revision, the whole
    set of revisions being fixed is considered, so that fixes to earlier
    revisions are not forgotten in later ones. The --base flag can be used to
    override this default behavior, though it is not usually desirable to do so.
    r)r.r,�working_dirrc
3sn|D]d\}}}�|}||��}t����||��|�\}}||krL|nd}|D]}	|	|||fVqTqdS�N)�data�fixfile)
�items�srcrev�path�dstrevs�ctxZolddata�metadata�newdatar3Zdstrev��basectxs�	basepaths�fixers�opts�repor"r%r&�getfixess �zfix.<locals>.getfixesg�?F)Z
threadsafeT)�reversesfixingsfiles)ZtopicZunit�total��itemN)r,spathr�postfixfile�throw����)sreplacementsswdirwrittenr�postfix)rG)rK)$rZbyteskwargsrZcheck_at_most_one_argZcheck_incompatible_argumentsZwlock�lockZtransaction�getrevstofix�getbasectxs�getworkqueue�getbasepaths�	getfixers�_prefetchfilesr�tuple�collections�defaultdict�dict�list�sortedZmakeprogressr�sum�valuesZ	incrementr5�append�hookZ	strkwargs�popr�writeworkingdir�bool�
replacerev�cleanup)r"rA�patsr@�	revstofix�	workqueue�numitemsrB�results�filedataZaggregatemetadata�replacements�wdirwrittenZcommitorderZprogress�revr7Zfilerevmetadatar;�	fixernameZ
fixermetadataZhookargsr9r%r<r&�fix�sv

�&��


�
����
.�rlcCs*dd�t�|�D�}tj||ddd�dS)aCalls scmutil.cleanupnodes() with the given replacements.

    "replacements" is a dict from nodeid to nodeid, with one key and one value
    for every revision that was affected by fixing. This is slightly different
    from cleanupnodes().

    "wdirwritten" is a bool which tells whether the working copy was affected by
    fixing, since it has no entry in "replacements".

    Useful as a hook point for extending "hg fix" with output summarizing the
    effects of the command, though we choose not to output anything here.
    cSsi|]\}}||g�qSr%r%)�.0ZprecZsuccr%r%r&�
<dictcomp>}szcleanup.<locals>.<dictcomp>rT)ZfixphaseN)r�	iteritemsrZcleanupnodes)rArhrir%r%r&raps
�rac
Cst�t�}t�t�}|�dd�}t|�D]�}	||	}
t�|
||�}tt|||||||	|
��D]~}|
|}
|
�	�rtq^|
�
�|kr�|�td�t
�|�|f�q^tdd�||	D��}||
��||f�|	�||	d7<q^q(dd�|��D�}|��||fS)	aConstructs a list of files to fix and which revisions each fix applies to

    To avoid duplicating work, there is usually only one work item for each file
    revision that might need to be fixed. There can be multiple work items per
    file revision if the same file needs to be fixed in multiple changesets with
    different baserevs. Each work item also contains a list of changesets where
    the file's data should be replaced with the fixed data. The work items for
    earlier changesets come earlier in the work queue, to improve pipelining by
    allowing the first changeset to be replaced while fixes are still being
    computed for later changesets.

    Also returned is a map from changesets to the count of work items that might
    affect each changeset. This is used later to count when all of a changeset's
    work items have been finished, without having to inspect the remaining work
    queue in each worker subprocess.

    The example work item (1, "foo/bar.txt", (1, 2, 3)) means that the data of
    bar.txt should be read from revision 1, then fixed, and written back to
    revisions 1, 2 and 3. Revision 1 is called the "srcrev" and the list of
    revisions is called the "dstrevs". In practice the srcrev is always one of
    the dstrevs, and we make that choice when constructing the work item so that
    the choice can't be made inconsistently later on. The dstrevs should all
    have the same file revision for the given path, so the choice of srcrev is
    arbitrary. The wdirrev can be a dstrev and a srcrev.
    rrs!ignoring file larger than %s: %s
css|]}|��VqdSr2)rj)rmr9r%r%r&�	<genexpr>�r(zgetworkqueue.<locals>.<genexpr>rIcSs$g|]\\}}}}t|�||f�qSr%)�min)rmZ_filerevZ	_baserevsr7r8r%r%r&�
<listcomp>�s�z getworkqueue.<locals>.<listcomp>)rTrUrW�intZconfigbytesrXrr
�
pathstofix�islink�size�warnrrZ	bytecountrSZfilerevr[r5�sort)r"rArbr@rcr=Z	dstrevmapreZmaxfilesizerj�fixctxr
r7�fctx�baserevsrdr%r%r&rO�s6

����rOcCs�|dr|�d�}n~|drjt�||d�}t|�d|��}t|vrN|�t�|d��|vr�|�t�n(tt�||d��}|�d�r�|�t�t|�dkr�t|vs�t	�
|�t�||d	�t|vr�t
j�|���r�tjd
dd��|s�tjd
dd��|S)z8Returns the set of revision numbers that should be fixedr)s+(not public() and not obsolete()) or wdir()r.s(%ld::) - obsolete()�.r,r1rIrsunresolved conflictssuse 'hg resolve'rsno changesets specifiedsuse --source or --working-dir)�revsr�revrange�setr�addrj�get�lenrZcheckunfinishedrZprecheck�
mergestatemodr�readZunresolvedcountrr!)r"rAr@r}Zsource_revsr%r%r&rM�s2



���rMc

CsPt�}|D]@}|j||t|�t|�d�}	|�tt�|	j|	j|	j|	j	���q
|S)z�Returns the set of files that should be fixed in a context

    The result depends on the base contexts; we include any file that has
    changed relative to any of the base contexts. Base contexts should be
    ancestors of the context being fixed.
    )r
Z	listcleanZlistunknown)
r�statusr_�update�	itertools�chainZaddedZmodifiedZclean�unknown)
r"rArbr@r
r=ry�files�basectx�statr%r%r&rt�s����rtc
Csn|�d�rtd|�Sg}|D]H}|�|��|��|f|�}||vrP||��}	nd}	|�t|	|��qt|�S)a�Returns the set of line ranges that should be fixed in a file

    Of the form [(10, 20), (30, 40)].

    This depends on the given base contexts; we must consider lines that have
    changed versus any of the base contexts, and whether the file has been
    renamed versus any of them.

    Another way to understand this is that we exclude line ranges that are
    common to the file in all base contexts.
    r0r()r��difflinerangesrjr3�extend�unionranges)
r@r7r>r=ry�content2�
rangeslistr��basepath�content1r%r%r&�
lineranges�s

r�cCsn|�d�riSi}|D]R\}}}||}||D]6}	t�|	|��||�}
|
|	vr0|
||	��|��|f<q0q|S)Nr0)r�r
Z
pathcopiesrj)rAr@rdr=r>r6r7�_dstrevsryr�r�r%r%r&rPs
rPcCsxtt|��}g}|r,|dg|dd�}}|D]B\}}|d\}}||dkr`|�||f�q0|t||�f|d<q0|S)aReturn the union of some closed intervals

    >>> unionranges([])
    []
    >>> unionranges([(1, 100)])
    [(1, 100)]
    >>> unionranges([(1, 100), (1, 100)])
    [(1, 100)]
    >>> unionranges([(1, 100), (2, 100)])
    [(1, 100)]
    >>> unionranges([(1, 99), (1, 100)])
    [(1, 100)]
    >>> unionranges([(1, 100), (40, 60)])
    [(1, 100)]
    >>> unionranges([(1, 49), (50, 100)])
    [(1, 100)]
    >>> unionranges([(1, 48), (50, 100)])
    [(1, 48), (50, 100)]
    >>> unionranges([(1, 2), (3, 4), (5, 6)])
    [(1, 6)]
    rrINrJ)rXrr[�max)r�Zunioned�a�b�c�dr%r%r&r�#sr�cCsPg}t�||�D]:\}}|dd�\}}|dkr||kr|�|d|f�q|S)a�Return list of line number ranges in content2 that differ from content1.

    Line numbers are 1-based. The numbers are the first and last line contained
    in the range. Single-line ranges have the same line number for the first and
    last line. Excludes any empty ranges that result from lines that are only
    present in content1. Relies on mdiff's idea of where the line endings are in
    the string.

    >>> from mercurial import pycompat
    >>> lines = lambda s: b'\n'.join([c for c in pycompat.iterbytestr(s)])
    >>> difflineranges2 = lambda a, b: difflineranges(lines(a), lines(b))
    >>> difflineranges2(b'', b'')
    []
    >>> difflineranges2(b'a', b'')
    []
    >>> difflineranges2(b'', b'A')
    [(1, 1)]
    >>> difflineranges2(b'a', b'a')
    []
    >>> difflineranges2(b'a', b'A')
    [(1, 1)]
    >>> difflineranges2(b'ab', b'')
    []
    >>> difflineranges2(b'', b'AB')
    [(1, 2)]
    >>> difflineranges2(b'abc', b'ac')
    []
    >>> difflineranges2(b'ab', b'aCb')
    [(2, 2)]
    >>> difflineranges2(b'abc', b'aBc')
    [(2, 2)]
    >>> difflineranges2(b'ab', b'AB')
    [(1, 2)]
    >>> difflineranges2(b'abcde', b'aBcDe')
    [(2, 2), (4, 4)]
    >>> difflineranges2(b'abcde', b'aBCDe')
    [(2, 4)]
    ���!rI)rZ	allblocksr[)r�r��ranges�lines�kind�	firstlineZlastliner%r%r&r�Fs'r�cs�|�d�rNtt��|�d���}|s*th}�fdd�|D���fdd�|D�St�t��t|�D]L}�|}|��D]6}|�	��vr��|�
�|�	��qt�|�|�qtq`�S)a4Returns a map of the base contexts for each revision

    The base contexts determine which lines are considered modified when we
    attempt to fix just the modified lines in a file. It also determines which
    files we attempt to fix, so it is important to compute this even when
    --whole is used.
    r*csh|]}�|�qSr%r%�rmrj�rAr%r&�	<setcomp>�r(zgetbasectxs.<locals>.<setcomp>csi|]
}|��qSr%r%r�)r=r%r&rn�r(zgetbasectxs.<locals>.<dictcomp>)r�rrr~rrTrUrX�parentsrjr�r�)rAr@rcr{rjr9Zpctxr%)r=rAr&rNus


rNc
svt�}|D]"\}}}|tkrq
|�||f�q
|��D]\\}}}}	|�||	f�q6|rrt���fdd�|D��dS)Ncs"g|]\}}|t��|g�f�qSr%)rZ
matchfiles)rmrjr7r�r%r&rr�s�z"_prefetchfiles.<locals>.<listcomp>)rrr�r5rZ
prefetchfiles)
rArdr>Z
toprefetchr6r7r�ZbaserevZfixrevr�r%r�r&rR�s
��rRc	Cs|i}||��}	t�|�D�]V\}
}|�|||�rt||||||	�}|�|||�}
|
dur\q|�d|
f�tjt	�
|
�dt	�
|j�tjtjtjd�}|�
|	�\}}|r�t||��|
|�|}|���rz"|�dd�\}}t�|�||
<Wn,t�y|�td�|
f�YqYn0nd||
<|jdk�r4|}	q|�s\td	�|jf}t||��|
|�t|td
�td�d�q||	fS)
a*Run any configured fixers that should affect the file in this context

    Returns the file content that results from applying the fixers in some order
    starting with the file's content in the fixctx. Fixers that support line
    ranges will affect lines that have changed relative to any of the basectxs
    (i.e. they will only avoid lines that are common to all basectxs).

    A fixer tool's stdout will become the file's new content if and only if it
    exits with code zero. The fixer tool's working directory is the repository's
    root.
    Nssubprocess: %s
T)�shell�cwd�stdin�stdout�stderr�rIs+ignored invalid output from fixer tool: %s
rsexited with status %d
sno fixes will be appliedsFuse --config fix.failure=continue to apply any successful fixes anywayr)r3rro�affectsr��command�debug�
subprocess�PopenrZtonativestr�root�PIPEZcommunicate�
showstderrrj�shouldoutputmetadata�splitZ
json_loads�
ValueErrorrwr�
returncoder')r"rAr@r?ryr7r>r=r:r;rkZfixerr�r��procr�r�Z	newerdataZmetadatajsonr#r%r%r&r4�s`�
�
����r4cCsdt�d|�D]R}|r|�d�|dur:|jtd�dd�n|jd|dd�|�d||f�qdS)	a9Writes the lines of the stderr string as warnings on the ui

    Uses the revision number and fixername to give more context to each line of
    the error message. Doesn't include file names, since those take up a lot of
    space and would tend to be included in the error message if they were
    relevant.
    s[
]+�[Nswdirs
evolve.rev)Zlabels%ds	] %s: %s
)�rer�rwr)r"rjrkr��liner%r%r&r��s
r�c	Cs�t�|�D] \}}||}|�||���q
|j��}|�||�}||kr�|j��� t�	|||�Wd�n1sz0YdS)a�Write new content to the working copy and check out the new p1 if any

    We check out a new revision if and only if we fixed something in both the
    working directory and its parent revision. This avoids the need for a full
    update/merge, and means that the working directory simply isn't affected
    unless the --working-dir flag is given.

    Directly updates the dirstate for the affected files.
    N)
rro�write�flagsZdirstate�p1r�ZparentchangerZmovedirstate)	rAr9rgrhr7r3rzZoldp1Znewp1r%r%r&r^�s

r^cCs�|j�|���\}}||||}}|�|��|���}	|�|��|���}
|sn|��|vrn|��|vrndS|����}|��|d<t�	|�}|�
||	�tj||d�t
�|||���|��D]<}
||
}|��}|j|
||
|��d�|r�|�|
|�q�t�||��dd�|��D��}|j||��||��|	|
f|��d�}|��}|��}||k�rx|�d|���n|||��<dS)	a�Commit a new revision like the given one, but with file content changes

    "ctx" is the original revision to be replaced by a modified one.

    "filedata" is a dict that maps paths to their new file content. All other
    paths will be recreated from the original revision without changes.
    "filedata" may contain paths that didn't exist in the original revision;
    they will be added.

    "replacements" is a dict that maps a single node to a single node, and it is
    updated to indicate the original revision is replaced by the newly created
    one. No entry is added if the replacement's node already exists.

    The new revision has the same parents as the old one, unless those parents
    have already been replaced, in which case those replacements are the parents
    of this new revision. Thus, if revisions are replaced in topological order,
    there is no need to rebase them into the original topology later.
    Ns
fix_source)Zwc)r�cSsi|]\}}||g�qSr%r%)rmZoldnodeZnewnoder%r%r&rnJr(zreplacerev.<locals>.<dictcomp>)�text�branch�extra�dater��usersnode %s already existed
)Z	changelogZ
parentrevsrjr�Znoder��copy�hexr	ZoverlayworkingctxZsetbaserZ	revert_tor
Zgraftcopiesr��keys�
copysourcer�r�Z
markcopiedrZupdate_hash_refs�descriptionr5Ztomemctxr�r�r�Zcommitr�)r"rAr9rgrhZp1revZp2revZp1ctxZp2ctxZ	newp1nodeZ	newp2noder�Zwctxr7rzr�ZdescZmemctxZsucnodeZprenoder%r%r&r`sR	�
�
�
��	
r`c
Csi}t|�D]�}|�d|d�}|�d|d�}|�d|d�}|�d|d�}|�d|d�}|�d|d�}|�d|d�}	|d	ur�|�td
�|f�q|d	ur�|�td�|f�q|s�|�d|f�qt||||||	�||<qt�	t
|��d
d�dd��S)z�Returns a map of configured fixer tools indexed by their names

    Each value is a Fixer object with methods that implement the behavior of the
    fixer's config suboptions. Does not validate the config values.
    rs:enableds:commands:patterns
:lineranges	:prioritys	:metadatas
:skipcleanNs,fixer tool has no command configuration: %s
s,fixer tool has no pattern configuration: %s
s!ignoring disabled fixer tool: %s
cSs
|djS)NrI)�	_priorityrEr%r%r&�<lambda>�r(zgetfixers.<locals>.<lambda>T)�keyrC)�
fixernamesZ
configboolr Z	configintrwrr��FixerrT�OrderedDictrXr5)
r"r?�nameZenabledr��pattern�	linerange�priorityr:�	skipcleanr%r%r&rQ^s2���
�rQcCs<t�}|�d�D]&\}}d|vr|�|�dd�d�q|S)z>Returns the names of [fix] config options that have suboptionsr�:rIr)rZconfigitemsr�r�)r"�names�k�vr%r%r&r��s
r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)r�z4Wraps the raw config values for a fixer with methodscCs(||_||_||_||_||_||_dSr2)�_command�_pattern�
_lineranger��	_metadata�
_skipclean)�selfr�r�r�r�r:r�r%r%r&�__init__�szFixer.__init__cCs*|��}tj|j|j|jg|d�}||�S)z@Should this fixer run on the file at the given path and context?)r9)rA�matchmodr
r�r�)r�r@ryr7rAZmatcherr%r%r&r��s
�z
Fixer.affectscCs|jS)z@Should the stdout of this fixer start with JSON and a null byte?)r�)r�r%r%r&r��szFixer.shouldoutputmetadatac	Csjtj}|||j|tj�|�d��g}|jr`|jr8|s8dS|D]"\}}|�|||j||d���q<d�	|�S)z�A shell command to use to invoke this fixer on the given file/lines

        May return None if there is no appropriate command to run for the given
        parameters.
        )srootpathsbasenameN)sfirstslast� )
rZrendercommandtemplater��osr7�basenamer�r�r[�join)r�r"r7r��expand�parts�firstZlastr%r%r&r��s"��
��z
Fixer.commandN)�__name__�
__module__�__qualname__�__doc__r�r�r�r�r%r%r%r&r��s

r�)N)Gr�Z
__future__rrTr�r�r�r�Zmercurial.i18nrZmercurial.noderrrZmercurial.utilsrZ	mercurialrr	r
rrr
r�rrrr�rrrrrrZ
testedwithZcmdtabler�ZconfigtableZ
configitemZFIXER_ATTRSr5r�rr'ZalloptZbaseoptZrevoptZ	sourceoptZwdiroptZwholeopt�usageZCATEGORY_FILE_CONTENTSrlrarOrMrtr�rPr�r�rNrRr4r�r^r`rQr��objectr�r%r%r%r&�<module>s�vD

�

����
> #/@L&	

Youez - 2016 - github.com/yon3zu
LinuXploit