HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //usr/lib64/python2.7/site-packages/hgext/fix.pyo
�
1�3\c@@s�dZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
mZddl
mZddlmZmZmZmZmZmZmZmZmZmZmZmZd	ZiZeje�ZiZej e�Z d6Z!x+e!D]#Z"e d
de"ddde$�q!We d
ddd�dde%e	d�fZ&ddge	d�e	d�fZ'ddge	d�e	d�fZ(dde%e	d�fZ)dde%e	d �fZ*e	d!�Z+ed
e&e'e(e)e*ge+d"ej,�d#��Z-d$�Z.d%�Z/d&�Z0d'�Z1d(�Z2d)�Z3d*�Z4d+�Z5d,�Z6d-�Z7d.�Z8d/�Z9d0�Z:d1�Z;d2�Z<d3�Z=d4e>fd5��YZ?dS(7s�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:fileset=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. If there is any output on
standard error, the file will not be affected. 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

The :fileset suboption determines which files will be passed through each
configured tool. See :hg:`help fileset` for possible values. If there are file
arguments to :hg:`fix`, the intersection of these filesets is used.

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

  [fix]
  maxfilesize=2MB

i(tabsolute_importN(t_(tnullrev(twdirrev(tprocutil(tcmdutiltcontexttcopiesterrortmdifftmergetobsoletetpycompatt	registrartscmutiltutiltworkersships-with-hg-coretcommandt	linerangetfilesettfixs.*(:%s)?tdefaulttgenerictmaxfilesizet2MBttalls)fix all non-public non-obsolete revisionstbasesdrevisions to diff against (overrides automatic selection, and applies to every revision being fixed)tREVtrtrevsrevisions to fixtwsworking-dirsfix the working directorytwholesalways fix every line of a files[OPTION]... [FILE]...thelpcategoryc@s�tj����drU�dr;tjtd���ndg�d<t�d<n�j���j���jd���t	����}t
��|��t��|�|��\}}t��������fd�}t
j
�d|t�|d	t�}tjt�}	i}
t}t|d
t�}�jdtd�d
td�dt|j�����}
x�|D]�\}}}|
jd|�|dk	r�||	||<n||cd8<x�|rP||drP|j�}�|}|tkr,t�||	||
�t|	|�}nt��||	||
�|	|=q�Wq|WWdQXt�|
|�WdQXWdQXWdQXdS(s�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 revisions are specified with --rev, those revisions will be checked, and
    they may be replaced with new revisions that have fixed file content.  It is
    desirable to specify all descendants of each specified revision, so that the
    fixes propagate to the descendants. If all descendants are fixed at the same
    time, no merging, rebasing, or evolution will be required.

    If --working-dir is used, files with uncommitted changes in the working copy
    will be fixed. If the checked-out revision is also fixed, the working
    directory will update to the replacement revision.

    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.
    RRs'cannot specify both "--rev" and "--all"snot public() and not obsolete()tworking_dirRc	3@stxm|D]e\}}�|}||j�}t���||�|�}||||krd|ndfVqWdS(N(tdatatfixfiletNone(titemsRtpathtctxtolddatatnewdata(tbasectxstfixerstoptstrepotui(s//usr/lib64/python2.7/site-packages/hgext/fix.pytgetfixes�s

g�?t
threadsafetreversettopictfixingtunittfilesttotaltitemii����N(RtbyteskwargsRtAbortRtTruetwlocktlockttransactiontgetrevstofixtgetbasectxstgetworkqueuet	getfixersRttupletFalsetcollectionstdefaultdicttdicttsortedtmakeprogresstsumtvaluest	incrementR%tpopRtwriteworkingdirtboolt
replacerevtcleanup(R/R.tpatsR-t	revstofixt	workqueuetnumitemsR0tresultstfiledatatreplacementstwdirwrittentcommitordertprogressRR'R*R(((R+R,R-R.R/s//usr/lib64/python2.7/site-packages/hgext/fix.pyRpsJ





	!
cC@s3d�|j�D�}tj||ddt�dS(sCalls 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.
    cS@s"i|]\}}|g|�qS(((t.0tprectsucc((s//usr/lib64/python2.7/site-packages/hgext/fix.pys
<dictcomp>�s	RtfixphaseN(t	iteritemsRtcleanupnodesR;(R.RXRY((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRQ�s
c	C@s#g}tjt�}|jdd�}x�t|�D]�}	||	}
tj|
||�}x�t|||||||	|
�D]�}||
kr�q|n|
|}
|
j�r�q|n|
j	�|kr�|j
td�tj
|�|f�q|n|j|	|f�||	cd7<q|Wq4W||fS(s�"Constructs the list of files to be fixed at specific revisions

    It is up to the caller how to consume the work items, and the only
    dependence between them is that replacement revisions must be committed in
    topological order. Each work item represents a file in the working copy or
    in some revision that should be fixed and written back to the working copy
    or into a replacement revision.

    Work items for the same revision are grouped together, so that a worker
    pool starting with the first N items in parallel is likely to finish the
    first revision's work before other revisions. This can allow us to write
    the result to disk and reduce memory footprint. At time of writing, the
    partition strategy in worker.py seems favorable to this. We also sort the
    items by ascending revision number to match the order in which we commit
    the fixes later.
    RRs!ignoring file larger than %s: %s
i(RERFtinttconfigbytesRHRtmatcht
pathstofixtislinktsizetwarnRRt	bytecounttappend(R/R.RRR-RSR+RTRURRtfixctxRdR'tfctx((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRA�s(


cC@s�ttj||d��}x"|D]}t||||�q#W|rdtj|�t||�n|jd�r�|jt	�t
tjj
|�j��r�tjddd��q�n|s�tjddd��n|S(s8Returns the set of revision numbers that should be fixedRR"sunresolved conflictsthintsuse 'hg resolve'sno changesets specifiedsuse --rev or --working-dir(tsetRtrevrangetcheckfixablectxRtcheckunfinishedtchecknodescendantstgettaddRtlistR
t
mergestatetreadt
unresolvedRR:(R/R.R-trevsR((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR?�s


cC@sGtj|tj�rC|jd||�rCtjtd���ndS(Ns(%ld::) - (%ld)s:can only fix a changeset together with all its descendants(Rt	isenabledtallowunstableoptRyRR:R(R.Ry((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRrscC@sk|j�s.tjdtj|�f��n|j�rg|jdd�}|sgtjd��qgndS(s>Aborts if the revision shouldn't be replaced with a fixed one.s can't fix immutable changeset %stexperimentalsevolution.allowdivergences/fixing obsolete revision could cause divergenceN(tmutableRR:RtformatchangeidRt
configbool(R/R.R(tallowdivergence((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRps			c

C@s|t�}xl|D]d}|j|d|dt|�dt|��}	|jttj|	j|	j|	j|	j	���qW|S(s�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.
    Rdt	listcleantlistunknown(
RntstatusROtupdatet	itertoolstchaintaddedtmodifiedtcleantunknown(
R/R.RRR-RdR+RkR6tbasectxtstat((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRes	
c	C@s�|jd�rtd|�Sg}xg|D]_}tj||�j||�}||krl||j�}nd}|jt||��q)Wt|�S(s�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.
    R R(RstdifflinerangesRt
pathcopiesR#textendtunionranges(	R-R'R+Rktcontent2t
rangeslistR�tbasepathtcontent1((s//usr/lib64/python2.7/site-packages/hgext/fix.pyt
lineranges-s

cC@s�tt|��}g}|r9|dg|d}}nxc|D][\}}|d\}}||dkr�|j||f�q@|t||�f|d<q@W|S(sReturn 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)]
    iii����(RHRnRjtmax(R�tunionedtatbtctd((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR�HscC@srg}xetj||�D]Q\}}|dd!\}}|dkr||kr|j|d|f�qqW|S(s�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)]
    iit!i(R	t	allblocksRj(R�R�trangestlinestkindt	firstlinetlastline((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR�js'c@s�|jd�rlttj�|jd���}|sBth}n�fd�|D���fd�|D�Stjt��xvt|�D]h}�|}xU|j�D]G}|j	��kr��|j
�|j	��q��|j|�q�Wq�W�S(s4Returns 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.
    Rc@sh|]}�|�qS(((R\R(R.(s//usr/lib64/python2.7/site-packages/hgext/fix.pys	<setcomp>�s	c@si|]}�|�qS(((R\R(R+(s//usr/lib64/python2.7/site-packages/hgext/fix.pys
<dictcomp>�s	(RsRnRRoRRERFRHtparentsRR�Rt(R.R-RStbaserevsRR(tpctx((R+R.s//usr/lib64/python2.7/site-packages/hgext/fix.pyR@�s
!
c

@sh��j��xQ|j�D]C\}}|j����r�����fd�}|j|�|�}	|	dkr�qn|jd|	f�tjtj	|	�dt
dtj	d�dtjdtjdtj�}
|
j��\}}|rt
|�j�||�n|
jd	kr+|�q`|s`t
|�j�|td
�|
jf�q`qqW�S(s�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.
    c@st������S(N(R�((R+RkR*R-R'(s//usr/lib64/python2.7/site-packages/hgext/fix.pyt<lambda>�Rssubprocess: %s
tshelltcwdt/tstdintstdouttstderrisexited with status %d
N(R#R`taffectsRR%tdebugt
subprocesstPopenRttonativestrR;tPIPEtcommunicatet
showstderrRt
returncodeR(
R/R-R,RkR'R+t	fixernametfixertrangesfnRtproct	newerdataR�((R+RkR*R-R's//usr/lib64/python2.7/site-packages/hgext/fix.pyR$�s0			!cC@s�x�tjd|�D]t}|r|jd�|dkrT|jtd�dd�n|jt|�dd�|jd||f�qqWdS(s9Writes 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[
]+t[twdirtlabels
evolve.revs	] %s: %s
N(tretsplitRhR%Rtstr(R/RR�R�tline((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR��s
c
C@s�x`|j�D]R\}}||}|j||j��|j|dkr
|jj|�q
q
W|jj�}g|D]}|j||�^qy}	|	|kr�|j|	�ndS(s�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.
    tnN(R`twritetflagstdirstatetnormallookupR�Rst
setparents(
R.R(RWRXR'R#RltoldparentnodesR�tnewparentnodes((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRN�s

%c@sX|jj�j��\}}||||}}|j|j�|j��}	|j|j�|j��}
��fd�}tj|d|	|
fd�j�dt�j	��t�j
��Bd|d�j�d�j�d�j
�d	�j�d
d�	}|j�}
�j�}||
krD|jd�j��n|
|�j�<dS(
s�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.
    c
@s�|�krdS�|}|j�}|r9|d}ntj||d|j�d�j||j��d|j�d|j�d|�S(NiR'R#Rftisexectcopied(	R%trenamedRt
memfilectxR'RsR#RfR�(R.tmemctxR'RlR�(R(RW(s//usr/lib64/python2.7/site-packages/hgext/fix.pyt	filectxfns

R�ttextR6R�tusertdatetextratbranchteditorsnode %s already existed
N(t	changelogt
parentrevsRRstnodeRR�tdescriptionRnR6tkeysR�R�R�R�R%tcommitR�thex(R/R.R(RWRXtp1revtp2revtp1ctxtp2ctxt	newp1nodet	newp2nodeR�R�tsucnodetprenode((R(RWs//usr/lib64/python2.7/site-packages/hgext/fix.pyRP�s*"	cC@s�i}xut|�D]g}t�||<|jd|�d}x;tD]3}t||tjd|�|j|d��qCWqW|S(s�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.
    RiRR(t
fixernamestFixertconfigsuboptionstFIXER_ATTRStsetattrRtsysstrRs(R/tresulttnametattrstkey((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRB:s

cC@sYt�}xI|jd�D]8\}}d|kr|j|jdd�d�qqW|S(s>Returns the names of [fix] config options that have suboptionsRt:ii(RntconfigitemsRtR�(R/tnamestktv((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR�Is
	$R�cB@s eZdZd�Zd�ZRS(s4Wraps the raw config values for a fixer with methodscC@stj||jg|�|�S(s@Should this fixer run on the file at the given path and context?(RRdt_fileset(tselfR-RkR'((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR�Tsc	C@s�tj}|||ji|d6tjj|�d6�g}|jr�|�}|sWdSxA|D]6\}}|j|||ji|d6|d6��q^Wndj	|�S(s�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.
        trootpathtbasenametfirsttlastt N(
Rtrendercommandtemplatet_commandtosR'R�t
_linerangeR%Rjtjoin(	R�R/R'R�texpandtpartsR�R�R�((s//usr/lib64/python2.7/site-packages/hgext/fix.pyRXs	&		(t__name__t
__module__t__doc__R�R(((s//usr/lib64/python2.7/site-packages/hgext/fix.pyR�Qs	(RRR(@Rt
__future__RRER�R�R�R�tmercurial.i18nRtmercurial.nodeRRtmercurial.utilsRt	mercurialRRRRR	R
RRR
RRRt
testedwithtcmdtableRtconfigtablet
configitemR�R�R%R;RDtallopttbaseopttrevopttwdiropttwholeopttusagetCATEGORY_FILE_CONTENTSRRQRAR?RrRpReR�R�R�R@R$R�RNRPRBR�tobjectR�(((s//usr/lib64/python2.7/site-packages/hgext/fix.pyt<module>/s\R
!!S		&						"	.		$			;