a
    &0__                     @   sV  d dl mZ d dlZddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZ ddlmZ dejhZd	d
 Zdd Zdd Zdd Zdd Zdd ZdZdZ G dd de!Z"g Z#dd Z$G dd de"Z%G dd de%Z&e$G dd  d e&Z'e$G d!d" d"e&Z(e$G d#d$ d$e&Z)e$G d%d& d&e&Z*e$G d'd( d(e&Z+e$G d)d* d*e&Z,e$G d+d, d,e&Z-e$G d-d. d.e%Z.e$G d/d0 d0e%Z/e$G d1d2 d2e%Z0d3d4 Z1d5d6d7d8d9Z2d:d; Z3d<d= Z4d>d? Z5d@dA Z6e! Z7e! Z8e! Z9e:e7e8e9gZ;dBdC Z<dDdE Z=e;fdFdGZ>dHdI Z?dJdK Z@e;fdLdMZAdRdPdQZBdS )S    )absolute_importN   )_)getattr)	changelogerrorfileloghg	localrepomanifestmetadatapycompatrequirementsrevlogscmutilutilvfs)compression   generaldeltac                 C   s   ddhS )zObtain requirements required to be present to upgrade a repo.

    An upgrade will not be allowed if the repository doesn't have the
    requirements returned by this function.
       revlogv1   store repor   r   3/usr/lib/python3/dist-packages/mercurial/upgrade.pyrequiredsourcerequirements'   s    r   c                 C   s   t jdt jhS )zObtain requirements that will prevent an upgrade from occurring.

    An upgrade cannot be performed if the source repository contains a
    requirements in the returned set.
    s   parentdelta)r   ZTREEMANIFEST_REQUIREMENTZSHARED_REQUIREMENTr   r   r   r   blocksourcerequirements5   s    	r   c                 C   sb   t jt jt jt jh}tjD ]B}tj| }| r| r|	d|  |
 dkr|	d q|S )zObtain requirements that can be removed during an upgrade.

    If an upgrade were to create a repository that dropped a requirement,
    the dropped requirement must appear in the returned set for the upgrade
    to be allowed.
       exp-compression-%s   zstd   revlog-compression-zstdr   SPARSEREVLOG_REQUIREMENTSIDEDATA_REQUIREMENTCOPIESSDC_REQUIREMENTNODEMAP_REQUIREMENTr   compengines	availablerevlogheaderaddnamer   Z	supportedr)   Zenginer   r   r   supportremovedrequirementsG   s    

r+   c              
   C   sp   dddddt jt jt jt jt jh
}tjD ]B}tj| }| r(|	 r(|
d|  | dkr(|
d q(|S )	zObtain requirements that upgrade supports in the destination.

    If the result of the upgrade would create requirements not in this set,
    the upgrade is disallowed.

    Extensions should monkeypatch this to add their custom requirements.
    	   dotencode   fncacher   r   r   r   r   r   )r   r!   r"   r#   r$   ZSHARESAFE_REQUIREMENTr   r%   r&   r'   r(   r)   r*   r   r   r   supporteddestrequirements]   s$    	

r.   c                 C   sh   dddt jt jt jt jh}tjD ]B}tj| }| r | r |	d|  |
 dkr |	d q |S )a  Obtain requirements that can be added to a repository during upgrade.

    This is used to disallow proposed requirements from being added when
    they weren't present before.

    We use a list of allowed requirement additions instead of a list of known
    bad additions because the whitelist approach is safer and will prevent
    future, unknown requirements from accidentally being added.
    r,   r-   r   r   r   r   r    r*   r   r   r   allowednewrequirementsz   s    	

r/   c                 C   s   t  S N)setr   r   r   r   preservedrequirements   s    r2   s
   deficiencys   optimizationc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )improvementa  Represents an improvement that can be made as part of an upgrade.

    The following attributes are defined on each instance:

    name
       Machine-readable string uniquely identifying this improvement. It
       will be mapped to an action later in the upgrade process.

    type
       Either ``deficiency`` or ``optimisation``. A deficiency is an obvious
       problem. An optimization is an action (sometimes optional) that
       can be taken to further improve the state of the repository.

    description
       Message intended for humans explaining the improvement in more detail,
       including the implications of it. For ``deficiency`` types, should be
       worded in the present tense. For ``optimisation`` types, should be
       worded in the future tense.

    upgrademessage
       Message intended for humans explaining what an upgrade addressing this
       issue will do. Should be worded in the future tense.
    c                 C   s   || _ || _|| _|| _d S r0   r)   typedescriptionupgrademessage)selfr)   r5   r6   r7   r   r   r   __init__   s    zimprovement.__init__c                 C   s   t |tstS | j|jkS r0   )
isinstancer3   NotImplementedr)   r8   otherr   r   r   __eq__   s    
zimprovement.__eq__c                 C   s
   | |k S r0   r   r<   r   r   r   __ne__   s    zimprovement.__ne__c                 C   s
   t | jS r0   )hashr)   r8   r   r   r   __hash__   s    zimprovement.__hash__N)__name__
__module____qualname____doc__r9   r>   r?   rB   r   r   r   r   r3      s
   r3   c                 C   s   t |  | S r0   )allformatvariantappend)clsr   r   r   registerformatvariant   s    
rJ   c                   @   sD   e Zd ZdZeZdZdZdZdZ	dd Z
edd Zedd ZdS )	formatvariantz6an improvement subclass dedicated to repository formatNc                 C   s
   t  d S r0   NotImplementedErrorrA   r   r   r   r9      s    zformatvariant.__init__c                 C   s
   t  dS )z.current value of the variant in the repositoryNrL   r   r   r   r   fromrepo   s    zformatvariant.fromrepoc                 C   s
   t  dS )z1current value of the variant in the configurationNrL   r   r   r   r   
fromconfig   s    zformatvariant.fromconfig)rC   rD   rE   rF   
deficiencyr5   r)   r6   r7   defaultr9   staticmethodrN   rO   r   r   r   r   rK      s   
rK   c                   @   s8   e Zd ZdZdZedd Zedd Zedd Z	dS )	requirementformatvariantzformatvariant based on a 'requirement' name.

    Many format variant are controlled by a 'requirement'. We define a small
    subclass to factor the code.
    Nc                 C   s   t | t | S r0   )r
   newreporequirementsdefaultcreateoptsuir   r   r   _newreporequirements   s    
z-requirementformatvariant._newreporequirementsc                 C   s   | j d usJ | j |jv S r0   )_requirementr   rI   r   r   r   r   rN     s    z!requirementformatvariant.fromrepoc                 C   s    | j d usJ | j | |jv S r0   )rY   rX   rW   rZ   r   r   r   rO     s    z#requirementformatvariant.fromconfig)
rC   rD   rE   rF   rY   rR   rX   classmethodrN   rO   r   r   r   r   rS      s   

rS   c                   @   s(   e Zd ZdZdZdZedZedZdS )fncacher-   TsY   long and reserved filenames may not work correctly; repository performance is sub-optimalss   repository will be more resilient to storing certain paths and performance of certain operations should be improvedN	rC   rD   rE   r)   rY   rQ   r   r6   r7   r   r   r   r   r\     s   r\   c                   @   s(   e Zd ZdZdZdZedZedZdS )	dotencoder,   TsL   storage of filenames beginning with a period or space may not work correctlysN   repository will be better able to store files beginning with a space or periodNr]   r   r   r   r   r^   %  s   r^   c                   @   s(   e Zd ZdZdZdZedZedZdS )generaldeltar   Ts   deltas within internal storage are unable to choose optimal revisions; repository is larger and slower than it could be; interaction with other repositories may require extra network and CPU resources, making "hg push" and "hg pull" slowers  repository storage will be able to create optimal deltas; new repository data will be smaller and read times should decrease; interacting with other repositories using this storage model should require less network and CPU resources, making "hg push" and "hg pull" fasterNr]   r   r   r   r   r_   8  s   r_   c                   @   s*   e Zd ZdZejZdZedZ	edZ
dS )sparserevlogs   sparserevlogTsX  in order to limit disk reading and memory usage on older version, the span of a delta chain from its root to its end is limited, whatever the relevant data in this span. This can severly limit Mercurial ability to build good chain of delta resulting is much more storage space being taken and limit reusability of on disk delta during exchange.s   Revlog supports delta chain with more unused data between payload. These gaps will be skipped at read time. This allows for better delta chains, making a better compression and faster exchange with server.N)rC   rD   rE   r)   r   r!   rY   rQ   r   r6   r7   r   r   r   r   r`   S  s   
r`   c                   @   s*   e Zd ZdZejZdZedZ	edZ
dS )sidedatas   sidedataFsU   Allows storage of extra data alongside a revision, unlocking various caching options.s2   Allows storage of extra data alongside a revision.N)rC   rD   rE   r)   r   r"   rY   rQ   r   r6   r7   r   r   r   r   ra   m  s   ra   c                   @   s*   e Zd ZdZejZdZedZ	edZ
dS )persistentnodemaps   persistent-nodemapFs9   persist the node -> rev mapping on disk to speedup lookups#   Speedup revision lookup by node id.N)rC   rD   rE   r)   r   r$   rY   rQ   r   r6   r7   r   r   r   r   rb   }  s   rb   c                   @   s*   e Zd ZdZejZdZedZ	edZ
dS )	copiessdcs
   copies-sdcFs/   Stores copies information alongside changesets.sA   Allows to use more efficient algorithm to deal with copy tracing.N)rC   rD   rE   r)   r   r#   rY   rQ   r   r6   r7   r   r   r   r   rc     s   rc   c                   @   s<   e Zd ZdZdZedZedZedd Z	edd Z
d	S )
removecldeltachains   plain-cl-deltaTs   changelog storage is using deltas instead of raw entries; changelog reading and any operation relying on changelog data are slower than they could besz   changelog storage will be reformated to store raw entries; changelog reading will be faster; changelog size may be reducedc                    s"   | j }|j t fdd|D S )Nc                 3   s   | ]}| |kV  qd S r0   r   ).0rev	chainbaser   r   	<genexpr>      z.removecldeltachain.fromrepo.<locals>.<genexpr>)r   rh   all)r   Zclr   rg   r   rN     s    zremovecldeltachain.fromrepoc                 C   s   dS )NTr   r   r   r   r   rO     s    zremovecldeltachain.fromconfigN)rC   rD   rE   r)   rQ   r   r6   r7   rR   rN   rO   r   r   r   r   rd     s   
rd   c                   @   s<   e Zd ZdZdZedZedZedd Z	edd Z
d	S )
compressionengines   compression   zlibsM   Compresion algorithm used to compress data. Some engine are faster than others;   revlog content will be recompressed with the new algorithm.c                 C   s:   d}|j D ]*}|j}|ds$|dr
|ddd }q
|S )Nrm   s   revlog-compression-s   exp-compression-   -   )r   
startswithsplit)rI   r   r   Zreqprefixr   r   r   rN     s    
zcompressionengine.fromrepoc                 C   s4   |j dd}|D ]}|tjv r|  S qd|S )Ns   formats   revlog-compression   ,)rW   Z
configlistr   r%   join)rI   r   r%   compr   r   r   rO     s
    

zcompressionengine.fromconfigNrC   rD   rE   r)   rQ   r   r6   r7   r[   rN   rO   r   r   r   r   rl     s   
rl   c                   @   s<   e Zd ZdZdZedZedZedd Z	edd Z
d	S )
compressionlevels   compression-level   defaults   compression levels#   revlog content will be recompressedc                 C   sP   t |}d }|dkr&|jdd}n|dkr<|jdd}|d u rHdS t|S Nrm   s   storages   revlog.zlib.levelr   s   revlog.zstd.levelrx   )rl   rN   rW   	configintbytesrI   r   ru   levelr   r   r   rN     s    
zcompressionlevel.fromrepoc                 C   sP   t |}d }|dkr&|jdd}n|dkr<|jdd}|d u rHdS t|S ry   )rl   rO   rW   rz   r{   r|   r   r   r   rO     s    
zcompressionlevel.fromconfigNrv   r   r   r   r   rw     s   
rw   c                 C   s&   g }t D ]}|| s|| q|S )z8returns a list of deficiencies that the repo suffer from)rG   rN   rH   )r   deficienciesZfvr   r   r   finddeficiencies  s
    
r      re-delta-parent   re-delta-multibase   re-delta-all   re-delta-fulladd)s   redeltaparents   redeltamultibases
   redeltaalls   redeltafulladdc                 C   s   g }| tdttdtdd | tdttdtdd | tdttd	td
d | tdttdtdd |S )z8Determine optimisation that could be used during upgrader   s]  deltas within internal storage will be recalculated to choose an optimal base revision where this was not already done; the size of the repository may shrink and various operations may become faster; the first time this optimization is performed could slow down upgrade execution considerably; subsequent invocations should not run noticeably slowersH   deltas within internal storage will choose a new base revision if neededr4   r   s  deltas within internal storage will be recalculated against multiple base revision and the smallest difference will be used; the size of the repository may shrink significantly when there are many merges; this optimization will slow down execution in proportion to the number of merges in the repository and the amount of files in the repository; this slow down should not be significant unless there are tens of thousands of files and thousands of mergess   deltas within internal storage will choose an optimal delta by computing deltas against multiple parents; may slow down execution time significantlyr   s   deltas within internal storage will always be recalculated without reusing prior deltas; this will likely make execution run several times slower; this optimization is typically not neededsn   deltas within internal storage will be fully recomputed; this will likely drastically slow down execution timer   s   every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.s   each revision will be added as new content to the internal storage; this will likely drastically slow down execution time, but some extensions might need it)rH   r3   optimisationr   )r   optimizationsr   r   r   findoptimizations!  sd    	r   c                 C   s4   g }|D ]&}|j }|dur$||vr$q|| q|S )a  Determine upgrade actions that will be performed.

    Given a list of improvements as returned by ``finddeficiencies`` and
    ``findoptimizations``, determine the list of upgrade actions that
    will be performed.

    The role of this function is to filter improvements if needed, apply
    recommended optimizations from the improvements list that make sense,
    etc.

    Returns a list of action names.
    N)rY   rH   )r   r~   Z
sourcereqsZdestreqsZ
newactionsdr)   r   r   r   determineactions|  s    r   c                 C   sZ   |dkrt  | jS |dr@|dtd  }tj| j|dS t| j|dd S dS )z]Obtain a revlog from a repo path.

    An instance of the appropriate class is returned.
       00changelog.i   00manifest.iN)Ztree   )r   svfsendswithlenr   manifestrevlogr   )r   pathZmandirr   r   r   _revlogfrompath  s    
r   c                 C   s   t |d|}t||}t |d|}|j}|j}||j}||j}||j}	||j}
||jd W d   n1 s0    Y  t|| |j|j}|rt|	|
 |	ds|	ds|j
j| |r|j
j|dd d  dS )a   copy all relevant files for `oldrl` into `destrepo` store

    Files are copied "as is" without any transformation. The copy is performed
    without extra checks. Callers are responsible for making sure the copied
    content is compatible with format of the destination repository.
    _revlog   wNr   r   r      .d)r   r   Zopenerrt   Z	indexfileZdatafiler   copyfileexistsr   r   r\   r(   )trZdestrepooldrlZunencodednamenewrlZoldvfsZnewvfsZoldindexZnewindexZolddatanewdataZcopydatar   r   r   _copyrevlog  s,    
r   c                 C   sb   d }| j |j  }|j | j  }t j|v r0dd }n.t j|v rHt| |}nt j|v r^t| |}|S )Nc                 S   s8   t | d| } | |tj@ r*ddi ddfS ddi ddfS )Nr   Tr   r   F)r   flagsr   ZREVIDX_SIDEDATA)rlrf   r   r   r   sidedatacompanion  s    z/getsidedatacompanion.<locals>.sidedatacompanion)r   r"   r#   r   ZgetsidedataadderZgetsidedataremover)srcrepodstrepor   removedreqs	addedreqsr   r   r   getsidedatacompanion  s    



r   c                 C   s,   | drt| v S | dr$t| v S t| v S )zcheck if a revlog is selected for cloning.

    In other words, are there any updates which need to be done on revlog
    or it can be blindly copied.

    The store entry is checked against the passed filterr   r   )r   UPGRADE_CHANGELOGUPGRADE_MANIFESTUPGRADE_FILELOG)Zrevlogfilterentryr   r   r   matchrevlog  s
    

r   c           '   
      s  d}d}d}	d}
d}d}d}d}d}d}d}d}d}d}d}d}d}d}t |j }|D ]\}}}|drrqZt||}|jddddd}||d pd7 }|d pd}|d pd} ||7 }|	| 7 }	t|tjr|t|7 }||7 }|| 7 }qZt|t	j
r$|d7 }|t|7 }||7 }|| 7 }qZt|tjrX|d7 }|t|7 }||7 }|| 7 }qZtd	 qZ|snd
S | td||||f  | tdt|t|	f  d
  fdd}!t||}"t }#|D ]f\}}}|drqt||}$t|$tjrrd|#vrr| td||t|| f  | td|t|t|f  |#d |jjtd|d nt|$t	j
r d|#vr | td||t|| f  | td||t|t|f  |#d  r   |jjtd|d n\d|#vr\| td||t|t|f  |#d  rH   |jjtd|d t||r| tdt|$|f  t||}%|$j||%|!|||"d n6td}&| |&|t|$f  t|||$| t||}%|%jdd}|d pd}|
|7 }
t|%tjr||7 }n t|%t	j
r,||7 }n||7 }qΈ   | td|t|| f  | td |t|
| f  d
S )!zCopy revlogs between 2 repos.r   r   T)ZexclusivefilesZrevisionscountZtrackedsize
storedsizes   revisionscounts
   storedsizes   trackedsizer   s   unknown revlog typeNsP   migrating %d total revisions (%d in filelogs, %d in manifests, %d in changelog)
s'   migrating %s in store; %s tracked data
c                    s       d S r0   )Z	increment)r   rf   ZnodeZprogressr   r   oncopiedrevisionP  s    z'_clonerevlogs.<locals>.oncopiedrevision   csQ   finished migrating %d manifest revisions across %d manifests; change in size: %s
sK   migrating changelog containing %d revisions (%s in store; %s tracked data)
s   changelog revisions)total   msO   finished migrating %d filelog revisions across %d filelogs; change in size: %s
sN   migrating %d manifests containing %d revisions (%s in store; %s tracked data)
s   manifest revisions   fsM   migrating %d filelogs containing %d revisions (%s in store; %s tracked data)
s   file revisionss   cloning %d revisions from %s
)Zaddrevisioncb
deltareuseforcedeltabothparentsr   s+   blindly copying %s containing %i revisions
)r   s>   finished migrating %d changelog revisions; change in size: %s
sF   finished migrating %d total revisions; total change in store size: %s
)liststorewalkr   r   Zstorageinfor:   r   r   r   r   r   r   ZProgrammingErrorstatusr   r   Z	bytecountr   r1   r(   rW   ZmakeprogressZcompleter   ZnoteZcloner   )'rW   r   r   r   r   r   revlogsZrevcountZsrcsizeZ
srcrawsizeZdstsizeZfcountZ	frevcountZfsrcsizeZfrawsizeZfdstsizeZmcountZ	mrevcountZmsrcsizeZmrawsizeZmdstsizeZ	crevcountZcsrcsizeZcrawsizeZcdstsizeZalldatafilesZ	unencodedZencodedsizer   infoZdatasizeZrawsizer   r   seenr   r   msgr   r   r   _clonerevlogs  s`   













	


r   c                 C   s:   | drdS |drdS |tjkr*dS |dv r6dS dS )a  Determine whether to copy a store file during upgrade.

    This function is called when migrating store files from ``srcrepo`` to
    ``dstrepo`` as part of upgrading a repository.

    Args:
      srcrepo: repo we are copying from
      dstrepo: repo we are copying to
      requirements: set of requirements for ``dstrepo``
      path: store file being examined
      mode: the ``ST_MODE`` file type of ``path``
      st: ``stat`` data structure for ``path``

    Function should return ``True`` if the file is to be copied.
    )s   .ir   s   .ns   .ndFs   undo)s   lockr-   T)r   rp   statS_IFREG)r   r   r   r   modestr   r   r   _filterstorefile  s    


r   c                 C   s   dS )zHook point for extensions to perform additional actions during upgrade.

    This function is called after revlogs and store files have been copied but
    before the new store is swapped into the original location.
    Nr   )rW   r   r   r   r   r   r   _finishdatamigration  s    r   c              
   C   sB  |  sJ |  sJ | td d|v r8tjj}n>d|v rJtjj}n,d|v r\tjj}nd|v rntjj}ntjj}|d*}t	| ||||d|v |d W d   n1 s0    Y  t
|jjjd	d
dD ]^\}}	}
t|||||	|
sq|jtd|  |jj|}|jj|}tj||d
d qt| ||| | td tjd|jd}t|}t|jd|d | td t||jdhB  | td | td|  | td t }t|j|d t|j|j t | }| td|  | td t|| |d |S )ay  Do the low-level work of upgrading a repository.

    The upgrade is effectively performed as a copy between a source
    repository and a temporary destination repository.

    The source repository is unmodified for as long as possible so the
    upgrade can abort at any time without causing loss of service for
    readers and without corrupting the source repository.
    sP   (it is safe to interrupt this process any time before data migration completes)
r   r   r   r   s   upgrader   Nrj   T)r   s   copying %s
)Zcopystats,   data fully migrated to temporary repository
s   upgradebackup.rr   dirs   requiress\   marking source repository as being upgraded; clients will be unable to read from repository
s   upgradeinprogresss*   starting in-place swap of repository data
s'   replaced files will be backed up at %s
s   replacing store...
r   sC   store replacement complete; repository was inconsistent for %0.1fs
sB   finalizing requirements file and making repository readable again
s
   store/lock) Zcurrentwlockr   r   r   ZDELTAREUSENEVERZDELTAREUSESAMEREVSZDELTAREUSEFULLADDZDELTAREUSEALWAYSZtransactionr   sortedr   r   Zreaddirr   rW   Zrawvfsrt   r   r   r   r   mkdtempr   vfsmodr   Zwritereporequirementsr   ZtimerrenameZspathunlink)rW   r   r   r   actionsr   r   r   pkindr   srcZdst
backuppathZ	backupvfsZtstartelapsedr   r   r   _upgraderepo   s    



$ 


r   FTc           '         s  |du rg }dd |D }  tt}d|fd|ff}dd |D }	|	rtdd	 |	D rt }|	D ]2\}
}|rh|
dkr|t qh|
dkrh|t qhn4|	D ].\}
}|
dkr|t q|
dkr|t qtj	 }|rt
td
tdt| tj	@ }|r:t
tdtdt| tjtjt j	 t }|rt
tdtdt| j	 t }|rt
tdtdt| t }|r t
tdtdt| t}g }|D ](}|j|v r|| ||j q|rdt
jtddt| tddt}t|j	   fdd	t|D  j	 }j	 }|tkrt||B @ }|rtd} |dt|  t}fddfdd} fdd} fdd}|sng }g }|D ]0}|!rV|| n|j"r:|| q:|sx|r|r#td |D ]} #d| j| j$f  q|r#td |D ]} #d| j| j$f  qƈ#d  n#td! #td" |  |  |   fd#d|D }!|!rj#td$ |!D ] } #td| j| j$f  qHdS %td% |  |  |  d&d  D }"#td' &  '  #td( t(j)d)j*d*}#d}$z"#td+|#  j+j}%t,j-|%|#d,d-}&|&& N |&' $ t.|&|"|d.}$W d   n1 sV0    Y  W d   n1 sv0    Y  |s|$du s#td/|$  j/j0|$d,d0 d}$W #td1|#  j/j0|#d,d0 |$r\j1s\ td2|$   td3 nR#td1|#  j/j0|#d,d0 |$rZj1sZ td2|$   td3 0 W d   n1 sr0    Y  W d   n1 s0    Y  dS )4zUpgrade a repository in place.Nc                 S   s   h | ]}t ||qS r   )legacy_opts_mapgetre   or   r   r   	<setcomp>  rj   zupgraderepo.<locals>.<setcomp>r   r   c                 S   s    g | ]\}}|d ur||fqS r0   r   re   yxr   r   r   
<listcomp>  rj   zupgraderepo.<locals>.<listcomp>c                 s   s   | ]\}}|V  qd S r0   r   r   r   r   r   ri     rj   zupgraderepo.<locals>.<genexpr>s2   cannot upgrade repository; requirement missing: %s   , s=   cannot upgrade repository; unsupported source requirement: %ss;   cannot upgrade repository; requirement would be removed: %ss@   cannot upgrade repository; do not support adding requirement: %ssE   cannot upgrade repository; do not support destination requirement: %ss)   unknown optimization action requested: %ss0   run without arguments to see valid optimizations)hintc                 3   s   | ]}| vr|V  qd S r0   r   r   r   r   r   ri     s   sA   ignoring revlogs selection flags, format requirements change: %s
c                    s6   d}t | D ]$}|s d  j||d d}qd S )NTr   )labelF)r   write)lr   firstrrV   r   r   write_labeled  s    
z"upgraderepo.<locals>.write_labeledc                     s    td  td  j@ d  d j  } j  rl td | d  d  j }|r td |d  d  d d S )	Ns   requirements
s      preserved: z"upgrade-repo.requirement.preserved   
s      removed: z upgrade-repo.requirement.removeds
      added: zupgrade-repo.requirement.added)r   r   r   )ZremovedZadded)newreqsr   rW   r   r   r   printrequirements  s"    








z&upgraderepo.<locals>.printrequirementsc                     sR   dd  D } | j dd d | rNtd dd | D d d	 d S )
Nc                 S   s   g | ]}|j tkr|qS r   )r5   r   re   ar   r   r   r     rj   z;upgraderepo.<locals>.printoptimisations.<locals>.<listcomp>c                 S   s   | j S r0   r)   r   r   r   r   <lambda>  rj   z9upgraderepo.<locals>.printoptimisations.<locals>.<lambda>)keys   optimisations: c                 S   s   g | ]
}|j qS r   r   r   r   r   r   r     rj   z#upgrade-repo.optimisation.performeds   

)sortr   r   )Zoptimisations)r   rW   r   r   r   printoptimisations  s    z'upgraderepo.<locals>.printoptimisationsc                     s$    D ]}  d| j| jf  qd S )N
   %s
   %s

)r   r)   r7   r   )r   rW   r   r   printupgradeactions  s    z(upgraderepo.<locals>.printupgradeactionssB   repository lacks features recommended by current config options:

r   s?   repository lacks features used by the default config options:

r   s7   (no feature deficiencies found in existing repository)
sE   performing an upgrade with "--run" will make the following changes:

c                    s   g | ]}| vr|qS r   r   )re   ir   r   r   r   W  rj   sK   additional optimizations are available by specifying "--optimize <name>":

s-   upgrade will perform the following actions:

c                 S   s   g | ]
}|j qS r   r   r   r   r   r   r   j  rj   s   beginning upgrade...
s    repository locked and read-only
s   upgrade.r   s9   creating temporary repository to stage migrated data: %s
T)r   Zcreater   s"   removing old repository content%s
)Zforciblys!   removing temporary repository %s
s'   copy of old repository backed up at %s
sq   the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
)2Z
unfilteredr1   UPGRADE_ALL_REVLOGSanyr(   r   r   discardr   r   r   ZAbortr   rt   r   r   r
   rT   rW   rU   updater2   r+   r/   r.   r   r)   rH   r   r   extendRECLONES_REQUIREMENTSwarnrO   rQ   r   r6   r   Zwlocklockr   r   r   	__class__r	   Z
repositoryr   r   Zrmtreequiet)'rW   r   runoptimizeZbackupr   r   r   ZspecentriesZ	specifiedr   Zenabled__ZmissingreqsZblockedreqsZnoremovereqsZ	noaddreqsZunsupportedreqsZalloptimizationsr   r   r~   r   r   Zincompatibler   r   r   r   rO   Zonlydefaultr   r   ZunusedoptimizeZupgradeactionsZtmppathr   Zrepouir   r   )r   r   r   rW   r   r   upgraderepou  s   

	



	F


r   )FNTNN)CZ
__future__r   r   Zi18nr   r   r    r   r   r   r	   r
   r   r   r   r   r   r   r   r   Zutilsr   r!   r   r   r   r+   r.   r/   r2   rP   r   objectr3   rG   rJ   rK   rS   r\   r^   r_   r`   ra   rb   rc   rd   rl   rw   r   r   r   r   r   r   r   r   r   	frozensetr   r   r   r   r   r   r   r   r   r   r   r   <module>   s   <,$&![#
 b 	
x     