
    6h                    4   S SK Jr  S SKrSSKJr  SSKJrJr  SSKJ	r	J
r
JrJrJr  SSKJr  SrSr " S	 S
5      rS6S jrS rS rS7S jrS7S jrS rS rS rSrSrSrSrSrSr Sr!Sr"\RF                  " S5      \RF                  " S5      \RF                  " S5      \RF                  " S5      /r$S r%S r&S r'S  r(S! r)S8S" jr* " S# S$\+5      r,S9S% jr-S& r.S' r/S( r0S) r1S* r2S+ r3S, r4\" S-5      \" S.5      \" S/5      \" S05      \" S15      S2.r5S:S3 jr6S4 r7S5 r8g);    )annotationsN   )_)hexshort)diffutilencodingerrorphasesutil)dateutil   c                  N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)marker<   zWrap obsolete marker raw datac                *    Xl         X l        S U l        g N)_repo_data_decodedmeta)selfrepodatas      3/usr/lib/python3/dist-packages/mercurial/obsutil.py__init__marker.__init__?   s    

     c                ,    [        U R                  5      $ r   )hashr   r   s    r   __hash__marker.__hash__E   s    DJJr   c                f    [        U5      [        U 5      :w  a  gU R                  UR                  :H  $ NF)typer   r   others     r   __eq__marker.__eq__H   s(    ;$t*$zzU[[((r   c                     U R                   S   $ )z%Predecessor changeset node identifierr   r   r    s    r   prednodemarker.prednodeM       zz!}r   c                     U R                   S   $ )z-List of successor changesets node identifiersr   r+   r    s    r   	succnodesmarker.succnodesQ   r.   r   c                     U R                   S   $ )z2Parents of the predecessors (None if not recorded)   r+   r    s    r   parentnodesmarker.parentnodesU   r.   r   c                2    [        U R                  S   5      $ )zDecoded metadata dictionary   )dictr   r    s    r   metadatamarker.metadataY   s    DJJqM""r   c                     U R                   S   $ )z#Creation date as (unixtime, offset)   r+   r    s    r   datemarker.date]   r.   r   c                     U R                   S   $ )zThe flags field of the markerr   r+   r    s    r   flagsmarker.flagsa   r.   r   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r!   r(   r,   r0   r4   r9   r=   r@   __static_attributes__ r   r   r   r   <   s2    '! )
#r   r   c              #     #    Uc  U R                   nO,U(       a  [        X5      nOU R                   R                  US9nU H  n[        X5      v   M     g7f)zwreturns markers known in a repository

If <nodes> is specified, only markers "relevant" to those nodes are are
returnedN)nodes)obsstoreexclusivemarkersrelevantmarkersr   )r   rJ   	exclusive
rawmarkers
markerdatas        r   
getmarkersrQ   f   sN     
 }]]
	%d2
]]222?
 
T&& !s   AAc                    [        U S S9$ )Nc                ,    U S S U S   =(       d    S4-   $ )NrH   rH   )ms    r   <lambda>sortedmarkers.<locals>.<lambda>x   s    3B1R5;B.)@r   )key)sortedmarkerss    r   sortedmarkersr\   v   s    '@AAr   c              #  >  #    U R                   R                  nU/n[        U5      nU(       an  UR                  5       nUR	                  US5      nU H<  nUS   nX;   a  M  UR                  U5        X;   a  Uv   M+  UR                  U5        M>     U(       a  Mm  gg7f)zyield the list of next predecessors pointing on visible changectx nodes

This function respect the repoview filtering, filtered revision will be
considered missing.
rH   r   N)rK   predecessorssetpopgetaddappend)	r   nodeid
precursorsstackseencurrentcurrentpreccsprec
precnodeids	            r   closestpredecessorsrl   {   s      ++JHEu:D
))+"w3!DaJ !HHZ !  Z( "	 %s   BBBc              #  H  #    [        U5      n[        U5      nU R                  R                  nU(       ak  UR                  5       nUv   U" US5       H@  nUS   U-  (       a  M  US   nX;  d  M  UR	                  U5        UR	                  U5        MB     U(       a  Mj  gg7f)zYield node for every precursors of <nodes>.

Some precursors may be unknown locally.

This is a linear yield unsuited to detecting folded changesets. It includes
initial nodes too.rH   r   r   N)r_   r^   ra   r`   rb   )	rK   rJ   ignoreflags	remainingrg   rj   rh   marksucs	            r   allpredecessorsrr      s      E
Iy>D  $$D
--/"%DAw$q'Cc" & )s   A+B"1-B" B"c              #  P  #    [        U5      n[        U5      nU(       a  UR                  5       nUv   U R                  R                  US5       HG  nUS   U-  (       a  M  US    H,  nXt;  d  M
  UR	                  U5        UR	                  U5        M.     MI     U(       a  M  gg7f)zYield node for every successor of <nodes>.

Some successors may be unknown locally.

This is a linear yield unsuited to detecting split changesets. It includes
initial nodes too.rH   r   r   N)r_   r`   
successorsra   rb   )rK   rJ   rn   ro   rg   rh   rp   rq   s           r   allsuccessorsru      s      E
Iy>D
--/''++GR8DAw$Aw?HHSMMM#& 	 9 )s   A+B&11B&$B&c                H    U  Vs1 s H  oS   (       d  M  UiM     sn$ s  snf )z"return a set with no prune markersr   rH   r[   rU   s     r   _filterprunesrx      s    'w!A$Aw'''s   c           	     b   U R                  5       nUR                  R                  R                  nUR                  R
                  nUR                  R                  nUR                  R                  n[        5       n[        U5      nU Vs/ s H'  n[        UR                  US5      5      (       a  M%  UPM)     n	nU	R                  5         [        U	5      n
U	(       GaK  U	R                  5       n[        UR                  US5      5      nUR                  US5       H   nUS   (       a  M  UR                  U5        M"     UR                  US5       H   nUS   (       a  M  UR                  U5        M"     U H  nX;   a  M
  US   (       d	  US   U:X  a  UR                  U5        US   nX;   a  M:  U" U5      nU(       a  X;  a  MP  [        UR                  U5      5      nUR!                  U5      (       d  M  U
R                  U5        U	R                  U5        M     U	(       a  GMK  U$ s  snf )at  set of markers relevant to "nodes" but no other locally-known nodes

This function compute the set of markers "exclusive" to a locally-known
node. This means we walk the markers starting from <nodes> until we reach a
locally-known precursors outside of <nodes>. Element of <nodes> with
locally-known successors outside of <nodes> are ignored (since their
precursors markers are also relevant to these successors).

For example:

    # (A0 rewritten as A1)
    #
    # A0 <-1- A1 # Marker "1" is exclusive to A1

    or

    # (A0 rewritten as AX; AX rewritten as A1; AX is unknown locally)
    #
    # <-1- A0 <-2- AX <-3- A1 # Marker "2,3" are exclusive to A1

    or

    # (A0 has unknown precursors, A0 rewritten as A1 and A2 (divergence))
    #
    #          <-2- A1 # Marker "2" is exclusive to A0,A1
    #        /
    # <-1- A0
    #                #         <-3- A2 # Marker "3" is exclusive to A0,A2
    #
    # in addition:
    #
    #  Markers "2,3" are exclusive to A1,A2
    #  Markers "1,2,3" are exclusive to A0,A1,A2

    See test/test-obsolete-bundle-strip.t for more examples.

An example usage is strip. When stripping a changeset, we also want to
strip the markers exclusive to this changeset. Otherwise we would have
"dangling"" obsolescence markers from its precursors: Obsolescence markers
marking a node as obsolete without any successors available locally.

As for relevant markers, the prune markers for children will be followed.
Of course, they will only be followed if the pruned children is
locally-known. Since the prune markers are relevant to the pruned node.
However, while prune markers are considered relevant to the parent of the
pruned changesets, prune markers for locally-known changeset (with no
successors) are considered exclusive to the pruned nodes. This allows
to strip the prune markers (with the rest of the exclusive chain) alongside
the pruned changesets.
rH   r   r   )
unfiltered	changelogindexhas_noderK   r^   rt   childrenr_   rx   ra   sortr`   listrc   rb   issubset)r   rJ   unfir}   precursorsmarkerssuccessormarkerschildrenmarkersexclmarkersnrf   	seennodesrh   r[   rp   rj   knownprecmarkerss                    r   rL   rL      s   l ??D ~~##,,H22}}//mm,,O %KJE P1]3C3G3G23N%OQEP	JJLE
I
))+(,,Wb9:$(("5D77t$ 6 $''4D77t$ 5 D"
 Aw$q'W,% 7D   TNE *
 ((8(<(<T(BCK##K00d#T"?  %\ e Qs   $H,4H,c                  ^ U R                  5       n [        U R                  SU5      5      nU R                  (       a  U R                  R                  R
                  mSn[        U5      U:w  a  [        U5      nU Vs1 s H  oDR                  5       iM     nnU Vs/ s H)  oDR                  5       (       d  M  UR                  5       PM+     nnUR                  [        U R                  U5      5        U4S jU 5       n[        U R                  SU5      5      n[        U5      U:w  a  M  U Vs1 s H  oDR                  5       iM     sn$ s  snf s  snf s  snf )a>  return all nodes in the "foreground" of other node

The foreground of a revision is anything reachable using parent -> children
or precursor -> successor relation. It is very similar to "descendant" but
augmented with obsolescence information.

Beware that possible obsolescence cycle may result if complex situation.
s   %ln::rT   c              3  F   >#    U  H  nT" U5      (       d  M  Uv   M     g 7fr   rH   ).0r   r}   s     r   	<genexpr>foreground.<locals>.<genexpr>[  s     51!QQs   !	!)rz   r_   rK   r{   r|   r}   lennodemutableupdateru   )	r   rJ   
foregroundplencsuccsr   r   r}   s	           @r   r   r   E  s    ??DTXXh./J}} >>''00*o%z?D'12z!VVXzE2)3CAyy{xqvvxGCLLt}}g>?55ETXXh67J *o% ))jFFHj)) 3C *s   >EE9E0Es   ef1   r<          @   s   ^branch$s   ^.*-source$s   ^.*_source$s   ^source$c                J   ^ U S   m[        U4S j[         5       5      (       + $ )znCheck that the key of a meta item (extrakey, extravalue) does not
match at least one of the blacklist pattern
r   c              3  D   >#    U  H  oR                  T5      v   M     g 7fr   )match)r   patternmetakeys     r   r   %metanotblacklisted.<locals>.<genexpr>  s     Gg==))s    )anyMETABLACKLIST)metaitemr   s    @r   metanotblacklistedr     s"     qkGGGGGGr   c                    / nU R                  5        HZ  nUR                  S5      (       d  UR                  S5      (       a  M1  UR                  S5      (       a  SnUR                  U5        M\     U$ )z/Drop all information but the username and patchs   # User   #s   @@s   @@
)
splitlines
startswithrc   )hunk	cleanhunklines      r   _prepare_hunkr     s_    I!??9%%T__T-B-Bu%%T"	 "
 r   c                :    [        U S5      nUc  U$ [        U5      $ )zreturn a cleaned up linesN)nextr   )iterdiffliness     r   _getdifflinesr     s#    4 E}r   c                   [         R                  " U R                  5       R                  SSS.5      nU R                  R                  5       U R                  5          nUR                  US9nUR                  R                  5       UR                  5          nUR                  US9nSu  pxSXx4;  a%  [        U5      n[        U5      nXx:w  a  gSXx4;  a  M%  g)ztreturn True if both ctx introduce the "same diff"

This is a first and basic implementation, with many shortcoming.
Tr   )s   gits   unified)opts)r   r   NF)	r   diffalloptsr   uir   rz   revdiffr   )	leftctxrightctxdiffoptsleftunfileftdiff	rightunfi	rightdiffleftrights	            r   _cmpdiffr     s    
 ##1%H }}'')'++-8H}}(}+H))+HLLN;IH-IKD
tm
#X&i(= tm
# r   c                   SnU GHs  nUR                  5       U R                  5       :w  a	  U[        -  nUR                  5       U R                  5       :w  a	  U[        -  nUR	                  5       U R	                  5       :w  a	  U[
        -  nUR                  5       U R                  5       :w  a	  U[        -  nUR                  5       U R                  5       :w  a	  U[        -  nUR                  5       R                  5       n[        [        [        U5      5      nU R                  5       R                  5       n[        [        [        U5      5      nXW:w  a	  U[        -  n[!        X5      (       a  GMj  U["        -  nGMv     U$ )z]From an obs-marker relation, compute what changed between the
predecessor and the successor.
r   )descriptionDESCCHANGEDuserUSERCHANGEDr=   DATECHANGEDbranchBRANCHCHANGEDparentsPARENTCHANGEDextraitemsrY   filterr   METACHANGEDr   DIFFCHANGED)sourcert   effects	changectxchangeextractxmetasourceextrasrcmetas           r   geteffectflagr     s?    G	  "f&8&8&::{"G >>v{{},{"G >>v{{},{"G 0}$G &.."22}$G  oo'--/ 2K@Alln**, 2K@A{"G **{"GC  F Nr   c                   USL USL :X  a  Sn[         R                  " U5      eU R                  5       R                  R                  R
                  nU R                  R                  nU R                  R                  R                  n[        R                  nUc  UR                  nUS   nUS   n	[        5       n
[        5       nU H  nUS   nU" U5      nUb
  X;   d  X:  a  M  U
R                  U5        U" X5      U:X  a  M>  [        U" U5      =(       d    / 5      R!                  U5      (       d  Mn  UR                  U5        M     U$ )zreturn the set of pre-existing revisions obsoleted by a transaction

Either the transaction or changes item of the transaction (for hooks)
must be provided, but not both.
Ns.   exactly one of tr and changes must be provideds
   obsmarkerss   origrepolenr   )r
   ProgrammingErrorrz   r{   r|   get_rev_phasecachephaserK   rt   ra   r   publicchangesr_   rb   r   )r   trr   etorevr   succsmarkersr   addedmarkersorigrepolenseenrevs	obsoletedrp   r   r   s                  r   getobsoletedr     s$    	d
4(=$$Q''OO''--55E""E==++//L]]F**=)L.)KuHIAwDk;#/S-?Sv%|D!'R(11,??MM#  r   c                  \   ^  \ rS rSrSrU 4S jrS r\R                  S 5       r	S r
SrU =r$ )_succsi
  zAsmall class to represent a successors with some metadata about itc                D   > [         TU ]  " U0 UD6  [        5       U l        g r   )superr   r_   r[   )r   argskwargs	__class__s      r   r   _succs.__init__  s    $)&)ur   c                Z    [        U 5      nU R                  R                  5       Ul        U$ r   )r   r[   copy)r   news     r   r   _succs.copy  s$    Tlll'')
r   c                    [        U 5      $ r   )r_   r    s    r   _set_succs._set  s     4yr   c                L    U R                   R                  UR                   5      $ r   )r   r   r&   s     r   canmerge_succs.canmerge  s    yy!!%**--r   rZ   )rB   rC   rD   rE   rF   r   r   r   propertycacher   r   rG   __classcell__)r   s   @r   r   r   
  s4    K
 
 . .r   r   c                   U R                   R                  nU/n[        U5      nUc  0 nU(       GaV  US   nXt;  =(       d    U=(       a    Xq:g  =(       a    Xp;   nXs;   a!  UR                  UR	                  5       5        GOU(       a  Xp;   a  [        U45      /X7'   GO/ X7'   GO[        XG   5       HF  n	U	S    H7  n
X;  d  M
  X;   a  / X:'   M  UR                  U
5        UR                  U
5          O   ME    GO   / n[        XG   5       H  n	[        5       nUR                  R                  U	5        U/nU	S    H  n
/ nU Hv  nX:    Hk  nUR                  5       nUR                  R                  UR                  5        U H  nUU;  d  M  UR                  U5        M     UR                  U5        Mm     Mx     U(       d  M  UnM     UR                  U5        M     / n/ n[        S U 5       [        SS9nU Hl  nU HA  nUR                  U5      (       d  M  UR                  R                  UR                  5          MH     UR                  U5        UR                  U5        Mn     UR!                  5         UX7'   U(       a  GMV  X1   $ )a		  Return set of all latest successors of initial nodes

The successors set of a changeset A are the group of revisions that succeed
A. It succeeds A as a consistent whole, each revision being only a partial
replacement. By default, the successors set contains non-obsolete
changesets only, walking the obsolescence graph until reaching a leaf. If
'closest' is set to True, closest successors-sets are return (the
obsolescence walk stops on known changesets).

This function returns the full list of successor sets which is why it
returns a list of tuples and not just a single tuple. Each tuple is a valid
successors set. Note that (A,) may be a valid successors set for changeset A
(see below).

In most cases, a changeset A will have a single element (e.g. the changeset
A is replaced by A') in its successors set. Though, it is also common for a
changeset A to have no elements in its successor set (e.g. the changeset
has been pruned). Therefore, the returned list of successors sets will be
[(A',)] or [], respectively.

When a changeset A is split into A' and B', however, it will result in a
successors set containing more than a single element, i.e. [(A',B')].
Divergent changesets will result in multiple successors sets, i.e. [(A',),
(A'')].

If a changeset A is not obsolete, then it will conceptually have no
successors set. To distinguish this from a pruned changeset, the successor
set will contain itself only, i.e. [(A,)].

Finally, final successors unknown locally are considered to be pruned
(pruned: obsoleted without any successors). (Final: successors not affected
by markers).

The 'closest' mode respect the repoview filtering. For example, without
filter it will stop at the first locally known changeset, with 'visible'
filter it will stop on visible changesets).

The optional `cache` parameter is a dictionary that may contains
precomputed successors sets. It is meant to reuse the computation of a
previous call to `successorssets` when multiple calls are made at the same
time. The cache dictionary is updated in place. The caller is responsible
for its life span. Code that makes multiple calls to `successorssets`
*should* use this cache mechanism or risk a performance hit.

Since results are different depending of the 'closest' most, the same cache
cannot be reused for both mode.
rT   r   c              3  6   #    U  H  o(       d  M  Uv   M     g 7fr   rH   )r   ss     r   r   !successorssets.<locals>.<genexpr>  s     /	1QQQ	s   
	T)rX   reverse)rK   rt   r_   remover`   r   r\   rc   rb   r[   r   r   extendrY   r   r   r  )r   initialnodeclosestcachesuccmarkers	toproceed
stackedsetrh   case2conditionrp   rq   	succssetsbasemarkssproductresultprefixsuffixnewsspartrg   final
candidatescand	seensuccss                           r   successorssetsr    st   b --**K I YJ}8 $ B- "4 
B.B7? 	 immo."('"4!5 "$B &k&:;7C',)+EJ &,,S1&NN3/! # ! <H 	)+*>?D!8DLL$$T*"VF#Aw(*&,F*/*(. % 4 4V^^ D,2D (,5'8(-T(:	 -3
 !. 4 4U ; +5 '- )=%2F  ' $$V,) @, #/	/S$
 'D%)	==33%--44T\\B! &*
 T*D) ' !&_ )` r   c                h   UR                  5       (       d  g[        XR                  5       SS9nU/ :X  a  [        5       /nU R                  R
                  n/ nU H  nU(       a  UR                  U5        M  SnUR                  UR                  5       S5       HG  nUS   (       a  M  Sn[        5       nUR                  R                  U5        UR                  U5        MI     U(       a  M  UR                  [        5       5        M     / nU H   nUR                  XUR                  S.5        M"     U$ )zfcompute the raw data needed for computing obsfate
Returns a list of dict, one dict per successors set
NT)r  FrH   r   )s
   successorss   markers)
obsoleter  r   r   rK   rt   rc   ra   r[   rb   )	r   ctxssetssuccsmapfullsuccessorsetsssetfoundanyrp   valuess	            r   successorsandmarkersr"    s    <<>>4T:E {
 }}''H$$T* H SXXZ4Aww#H!8DLL$$T*%,,T2 5 8!((2- 0 F!dEF " Mr   c                n    [        U 5      S:X  a  g[        U 5      S:  a  gU S   n[        U5      S:X  a  gg)aY  Compute a changeset obsolescence fate based on its successorssets.
Successors can be the tipmost ones or the immediate ones. This function
return values are not meant to be shown directly to users, it is meant to
be used by internal functions only.
Returns one fate from the following values:
- pruned
- diverged
- superseded
- superseded_split
r      prunedr      diverged
   superseded   superseded_splitr   )r  rt   s     r   _getobsfater)  7  sB     >a	^	q	  $A&
z?a &r   c                F    U (       d  SnU$ [        U 5      S:X  a  SnU$ SnU$ )z`Return the verb summarizing the successorset and potentially using
information from the markers
r$  r   s	   rewrittens   splitr(  )successorsetr[   verbs      r   obsfateverbr-  R  s:     
 K	 
\	a	 K Kr   c                6    U  Vs/ s H  oS   PM	     sn$ s  snf )z/returns the list of dates for a list of markersr<   rH   rw   s     r   markersdatesr/  _  s    !"'QaD'"""s   c                    U  Vs/ s H  n[        US   5      PM     nnU Vs1 s H4  nUR                  S5      (       d  M  [        R                  " US   5      iM6     nn[	        U5      $ s  snf s  snf )z9Returns a sorted list of markers users without duplicatesr7   s   user)r8   ra   r	   tolocalrY   )r[   rU   markersmetametauserss        r   markersusersr5  d  ss    './w!4!:wK/  D88G 	(g' 
  %= 0s   A+A0A0c                    U  Vs/ s H  n[        US   5      PM     nnU Vs1 s H+  o3R                  S5      (       d  M  UR                  S5      iM-     nn[        U5      $ s  snf s  snf )z>Returns a sorted list of markers operations without duplicatesr7   s	   operation)r8   ra   rY   )r[   rU   r2  r3  
operationss        r   markersoperationsr8  p  sf    './w!4!:wK/+6+64((<:P;   * 0s   A"A' A'c                   U R                   nU R                  nU(       + =(       a    U(       + n/ nUR                  [        X#5      5        [	        U5      n	U	(       a#  UR                  SSR                  U	5      -  5        U(       a<  U V
s/ s H  o" X   5      PM     nn
UR                  SSR                  U5      -  5        [        U5      nU(       d%  U R                  SS9n[        U5      S:X  a  X;   a  SnU(       d  U(       a*  U(       a#  UR                  SSR                  U5      -  5        [        U5      nU(       a  U(       a  [        U5      n[        U5      nUU:X  a,  [        R                  " US	5      nUR                  S
U-  5        OD[        R                  " US	5      n[        R                  " US	5      nUR                  SUU4-  5        SR                  U5      $ s  sn
f )zgBuild a obsfate string for a single successorset using all obsfate
related function defined in obsutil
s	    using %s   , s    as %sT)acceptemptyr   Ns    by %ss   %Y-%m-%d %H:%M %1%2s    (at %s)s    (between %s and %s)r   )quietverboserc   r-  r8  joinr5  usernamer   r/  minmaxr   datestr)r   r   rt   r[   	formatctxr<  r=  normalr   r7  succfmtsuccessorsr4  currentuserdatesmin_datemax_datefmtmin_datefmtmax_dates                      r   obsfateprinterrM  z  s    HHEjjG[&YFD 	KKJ01 #7+JL5::j#99: ;EF:44:.:FI

= 99: !E kkdk3u:?{3E6uI

5 112 !Eu:u:x"**85KLKKKk12"**85KLK"**85KLKKK/;2LLM88D>= Gs   
G's   hidden revision '%s' is pruneds!   hidden revision '%s' has divergeds)   hidden revision '%s' was rewritten as: %ss%   hidden revision '%s' was split as: %ss1   hidden revision '%s' was split as: %s and %d more)r$  r%  r&  r'     superseded_split_severalc                &   [        XR                  5       5      n[        U5      nUS:X  a  [        S   U-  $ US:X  a  [        S   U-  $ US:X  a  [	        US   S   5      n[        S   X4-  $ US:X  a  / nUS    H  nUR                  [	        U5      5        M     [        U5      S::  a  SR                  U5      n[        S   X4-  $ SR                  USS 5      n	[        U5      S-
  n
XU
4n[        S	   U-  $ [        R                  " S
U-  5      e)zDreturn a human-friendly string on why a obsolete changeset is hiddenr$  r%  r&  r   r'  r   r:  NrN  zunhandled fate: %r)
r  r   r)  filteredmsgtabler   rc   r   r>  r
   r   )r   changeidr  rt   fatesingle_successorr   node_idfmtsuccsfirstsuccessorsremainingnumberr   s               r   _getfilteredreasonrX    s+   hhj1Jz"D y	*X55		,x77		 Aq!12.(1MMM	$	$!!}GLLw( % u:?zz%(H#$78H;OOO#jjr3O!%j1nO?D#$?@4GG$$%9D%@AAr   c                x   0 n0 n[        U R                  UR                  5       /5       Ha  nXAR                  5       :X  a  M  [        XU5      nU H7  nUR                  5       U;   a  M  [	        U5      U;   a  M*  XC[	        U5      '   M9     Mc     UR                  5        VVs/ s H	  u  pxXxS.PM     snn$ s  snnf )z2Compute sets of commits divergent with a given one)   divergentnodes   commonpredecessor)rr   rK   r   r  tupler   )	r   r  r  r  r   	nsuccsetsnsuccsetdivsetbs	            r   divergentsetsra    s    EDT]]SXXZL9
?"4E2	!HxxzX%X$&$%x! " : %IF #<%  s   "B6c           
     ,   / nUR                  5       (       as  UR                  5        H_  nS nUR                  5       (       a  SnOUR                  5       (       a  SnUc  M9  UR                  SSU-  UR	                  5       S.5        Ma     UR                  5       (       a  [        U R                  UR                  5       /[        S9nU Vs/ s H'  ofU ;   d  M
  X   R                  5       (       a  M#  X   PM)     nnU H&  nUR                  SSUR	                  5       S.5        M(     UR                  5       (       aM  [        X5      n	U	 H<  n
U
S    Vs/ s H  oU   PM	     nnUR                  S	US
[	        U
S   5      S.5        M>     U$ s  snf s  snf )Ns   orphans   obsoletes	   %s parent)   instability   reason   node)rn   s   phase-divergents   immutable predecessorrZ  s   content-divergents   predecessorr[  )rc  rZ  rd  re  )orphanr   r  rc   r   phasedivergentrr   rK   r   	bumpedfixr   contentdivergentra  )r   r  resultparentkindr^   p	immutablepredecessordsetsdsetr   divnodess                r   whyunstablers    s   F
zz||kkmFD}} """(1#/$#6!' $ &MMCHHJ<Y
 *
)$YGtw?PGDG\ 	 
 %KMM$67(__. % d(D)-.?)@A)@AQ)@HAMM$8'/- &:!;<	  M/
 Bs   	FF2FFr$   )r   )NN)FN)returnbytes)9
__future__r   rei18nr   r   r   r    r   r	   r
   r   r   utilsr   rh  usingsha256r   rQ   r\   rl   rr   ru   rx   rL   r   EFFECTFLAGFIELDr   r   r   r   r   r   r   compiler   r   r   r   r   r   r   r   r   r  r"  r)  r-  r/  r5  r8  rM  rP  rX  ra  rs  rH   r   r   <module>r~     sm   # 	   @ 	' 'T' B
):#0',(
wt*T  JJ{JJ~JJ~JJ{	H >)X@.T .*eP-`'6
#
	2l 2378ABCD!"<" B>.,r   