
    	^c"                         d dl Z ddlmZ ddlmZmZ ddlmZmZmZm	Z	m
Z
mZmZ  e j        d          ZddZddZd Zd Zd Zd ZddZdS )    N   )_)hexnullrev)errornodeobsoleteobsutilrevsetscmutilutils   \b[0-9a-f]{6,64}\b   c                 "   | j         j        t          |          }||k     r$fd|D             }d                    |          }nH|                                }t          d          }|t          j         |                    |dz
  fz  }|S )zreturns a string summarizing revisions in a decent size

    If there are few enough revisions, we list them all. Otherwise we display a
    summary of the form:

        1ea73414a91b and 5 others
    c                 J    g | ]}t          j         |                     S  )r   short).0rtonodes     7/usr/lib/python3/dist-packages/mercurial/rewriteutil.py
<listcomp>z_formatrevs.<locals>.<listcomp>*   s+    666A$*VVAYY''666    s   , s   %s and %d othersr   )	changelogr   lenjoinfirstr   r   )reporevsmaxrevsnumrevsshortssummaryr   r   s          @r   _formatrevsr#      s     ^ F$iiG6666666**V$$

'((DJvve}}--w{;;Nr      rewriteTc                    t           |v r7t          d          |z  }t          d          }t          j        ||          t	          d |D                       r&| j                            d           d |D             }t          | d                                                   dk    r$t          j	        t          d	          |z            | 
                    d
|          }|rIt          | |          }t          d          ||fz  }t          d          }t          j        ||          t          | |          }|rDt          d          }t          j        t          d          |t          |          fz  |          |sdS t          j        | t          j                  st!          | |          }	|	r|	\  }
}}t          d          ||
|fz  }|
                                |                                k    r|t          d          |z  z  }| j        j        r||
                                |                                k    r|t          d          |
|fz  z  }|t          d          |||
fz  z  }t          j        |t          d                    t          j        |t          d                    dS dS )a&  check if revs can be rewritten
    action is used to control the error message.

    check_divergence allows skipping the divergence checks in cases like adding
    a prune marker (A, ()) to obsstore (which can't be diverging).

    Make sure this function is called after taking the lock.
    s   cannot %s the null revisions   no changeset checked out)hintc              3   @   K   | ]}t          j        |d           V  dS )revN)r   safehasattrr   r   s     r   	<genexpr>zprecheck.<locals>.<genexpr>A   s/      
4
4!4Au%%
4
4
4
4
4
4r   s-   rewriteutil.precheck called with ctx not revsc              3   >   K   | ]}|                                 V  d S N)r(   r*   s     r   r+   zprecheck.<locals>.<genexpr>C   s*      &&A&&&&&&r   Nr   s"   cannot %s changesets while mergings   %ld and public()s   cannot %s public changesets: %ss    see 'hg help phases' for detailss#   see 'hg help evolution.instability's7   cannot %s changeset, as that will orphan %d descendantss8   cannot %s %s, as that creates content-divergence with %ss	   , from %ss0   
    changeset %s is a successor of changeset %ss   
    changeset %s already has a successor in changeset %s
    rewriting changeset %s would create "content-divergence"
    set experimental.evolution.allowdivergence=True to skip this checksE   see 'hg help evolution.instability' for details on content-divergences@   add --verbose for details or see 'hg help evolution.instability')r   r   r   
InputErroranyui	develwarnr   parents
StateErrorr   r#   disallowednewunstabler	   	isenabledallowdivergenceopt_find_new_divergencer(   verbose)r   r   actioncheck_divergencemsgr&   
publicrevsr"   newunstablenew_divergence	local_ctx	other_ctxbase_ctxs                r   precheckrB   3   s5    $.//&8,--s....

4
4t
4
4
444 'JKKK&&&&&
4:  1$$344v=
 
 	
 .55J /dJ//233vw6GG455s....'d33K 
788HIIs;''()
 
 
 	
  dH$?@@ '-dD99 %	-;*Iy(K  C }}(,,..00q11w ==??hllnn441P "H-. .C q'  y)45 5 &`     &;    C' '%	 %	r   c                     t          j        | t           j                  }|rt          j                    S |                     d||          S )zChecks whether editing the revs will create new unstable changesets and
    are we allowed to create them.

    To allow new unstable changesets, set the config:
        `experimental.evolution.allowunstable=True`
    s   (%ld::) - %ld)r	   r5   allowunstableoptr   basesetr   )r   r   allowunstables      r   r4   r4      sF     &tX-FGGM  ~99%tT222r   c                     |                      d|          }|D ]Q}t          | | |                   }|r7| |         | |d                  |                                 |d                  fc S Rd S )Ns   %ld and obsolete()r   r   )r   find_new_divergence_from
unfiltered)r   r   obsrevsr   divs        r   r7   r7      s    ii-t44G F F&tT!W55 	FGT#a&\4??+<+<SV+DEEEE	F4r   c                 B   |                                 sdS t          j        | |                                          }|r"|d         d         |                                fS t          j        | |          }|r&|d         d         }|d         d         }|d         |fS dS )zreturn divergent revision if rewriting an obsolete cset (ctx) will
    create divergence

    Returns (<other node>, <common ancestor node>) or None
    Nr   s   divergentnodess   commonpredecessor)r	   r
   successorssetsr   divergentsets)r   ctxssetdivsetsnsuccsetprecs         r   rH   rH      s     <<>> t !$

33D 
Q
CHHJJ'' 'c22 	'qz"34H1:23DQK&&tr   c                     |                      dd          }|dk    rdS |dk    rdS t          j        t          d          ||fz            )Nr$   s   empty-successors   skipTs   keepFsf   %s doesn't know how to handle config rewrite.empty-successor=%s (only 'skip' and 'keep' are supported))configr   ConfigErrorr   )r0   commandempty_successors      r   skip_empty_successorrY      sl    ii
,>??O'!!t	G	#	#u 
 ()
 
 	
r   c           	      P   |si }i }t          j        t          |          }|                                 }|D ]m}	 t	          j        ||          }n!# t          j        t          j        f$ r Y 7w xY w|>||         }|	                                s|
                    |          }	|	r|	g}	n)t          j        | |                                |          }	t          |	          dk    rt          |	d                   dk    rx|	d         d         }
|
<t          |
          }|                    ||dt          |                             }| j                            t'          d          |z             C| j                            t'          d          |z             o|S )a  Replace all obsolete commit hashes in the message with the current hash.

    If the obsolete commit was split or is divergent, the hash is not replaced
    as there's no way to know which successor to choose.

    For commands that update a series of commits in the current transaction, the
    new obsolete markers can be considered by setting ``pending`` to a mapping
    of ``pending[oldnode] = [successor_node1, successor_node2,..]``.
    N)cacher   r   sb   The stale commit message reference to %s could not be updated
(The referenced commit was dropped)
s>   The stale commit message reference to %s could not be updated
)refindallNODE_RErI   r   resolvehexnodeidprefixr   WdirUnsupportedAmbiguousPrefixLookupErrorr	   getr
   rM   r   r   r   replacer0   noter   )r   	commitmsgpendingr[   hashesunfihfullnoderO   
successors	successornewhashs               r   update_hash_refsrn      s     EZ++F??D ) )	5dA>>HH%u'GH 	 	 	 H	 8n||~~ 	O X..J!$JJ /chhjjNNNJ z??aC
1$6$6!$;$;"1a(I$i..%--a3q661BCC		Q  	    GLL(  	    s   AA/.A/)r   )r$   Tr-   )r\   i18nr   r   r   r    r   r	   r
   r   r   r   compiler^   r#   rB   r4   r7   rH   rY   rn   r   r   r   <module>rr      s?   
			             
                  "*+
,
,   (Q Q Q Qh
3 
3 
3    2
 
 
": : : : : :r   