
    6h^                        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JrJrJrJrJrJr  SS jr " S S	5      r SS
 jrS rSS jrS rS rS rS rg)    )annotationsN   )_)hexshort)	bookmarks	branchmaperrornodeobsoletephasespycompatscmutilsetdiscoverytreediscoveryutilc                  ^	^
 UR                  S5      (       d  [        R                  " XX#5      $ U(       a5  U R                  R                  m
[        U
4S jU 5       5      (       a  USU4$ [        R                  " U R                  U UU(       + US9nUu  pgnU(       a2  U(       d+  U R                  R                  m	[        U	4S jU 5       5      n[        U5      Xr=(       d    [        U5      4$ )a  Return a tuple (common, anyincoming, heads) used to identify the common
subset of nodes between repo and remote.

"common" is a list of (at least) the heads of the common subset.
"anyincoming" is testable as a boolean indicating if any nodes are missing
  locally. If remote does not support getbundle, this actually is a list of
  roots of the nodes that would be incoming, to be supplied to
  changegroupsubset. No code except for pull should be relying on this fact
  any longer.
"heads" is either the supplied heads, or else the remote's heads.
"ancestorsof" if not None, restrict the discovery to a subset defined by
  these nodes. Changeset outside of this set won't be considered (but may
  still appear in "common").

If you pass heads and they are all known locally, the response lists just
these heads in "common" and in "heads".

Please use findcommonoutgoing to compute the set of outgoing nodes to give
extensions a good hook into outgoing.
s	   getbundlec              3  4   >#    U  H  nT" U5      v   M     g 7fN .0h	knownnodes     5/usr/lib/python3/dist-packages/mercurial/discovery.py	<genexpr>%findcommonincoming.<locals>.<genexpr><   s     +Uy||U   F)abortwhenunrelatedancestorsofc              3  >   >#    U  H  nT" U5      (       + v   M     g 7fr   r   )r   nhas_nodes     r   r   r   J   s     4e!__e   )capabler   findcommonincoming	changeloghasnodeallr   findcommonheadsuianylist)reporemoteheadsforcer    rescommonanyincsrvheadsr#   r   s            @@r   r&   r&   !   s    , >>,''//eKKNN**	+U+++5%((

&
&$9C  #FHV>>))4e44L&"94>::    c                  r    \ rS rSrSr S	S jrS r\R                  S 5       r	\R                  S 5       r
Srg)
outgoingN   ar  Represents the result of a findcommonoutgoing() call.

Members:

  ancestorsof is a list of the nodes whose ancestors are included in the
  outgoing operation.

  missing is a list of those ancestors of ancestorsof that are present in
  local but not in remote.

  common is a set containing revs common between the local and the remote
  repository (at least all of those that are ancestors of ancestorsof).

  commonheads is the list of heads of common.

  excluded is the list of missing changeset that shouldn't be sent
  remotely.

Some members are computed on demand from the heads, unless provided upfront
by discovery.Nc                   Ub  Ub  Sn[         R                  " U5      eUR                  nUR                  5       nUR                  nUR                  n	S n
S nUnUc  UR                  5       nU[        R                  /:X  d  U/ :X  a^  UR                  /n[        5       nUc  U Vs/ s H
  o" U5      PM     n
nGOeUR                  SXC5      nU Vs/ s H
  o" U5      PM     n
nGO:UGb"  UR                  SXC5      nUR                  U5       Vs/ s H
  o" U5      PM     nnUR                  n[        5       nU H>  nU" U5      u  nnUU;  a  UR                  U5        UU;  d  M-  UR                  U5        M@     UR                  [        R                  5        U(       d  UR                  /n[        5       nO:UR                  SUU5      nU Vs/ s H
  o" U5      PM     nnUR                  USS9nU Vs/ s H
  o" U5      PM     n
nOU(       d  UR                  /nX l        X0l        X`l        Xl        Xl        / U l        g s  snf s  snf s  snf s  snf s  snf )Nz=commonheads and missingroots arguments are mutually exclusivez::%lnz%ln::%lnzheads(%ld::%ld)T	inclusive)r
   ProgrammingErrorr'   
unfilteredr   r0   nodemodnullrevnullidsetrevsheadrevs
parentrevsadddiscard	ancestorscommonheadsr    _revlog_common_missingexcluded)selfr.   rI   r    missingrootsmclunfiuclto_nodemissingr3   arg_ancrmissing_revparent_revscommon_legsp1p2commonheads_revss                       r   __init__outgoing.__init__d   s<    "|'?OA((++^^ nn((((*K GOO,,0B;;-KUF/12r!71:r2"iiK/:;{!71:{;%))JJK/2||K/HI/H!71:/HKI..K%K $QB[(OOB'[(OOB' ! 0#{{m#'99%$ 
 4DD3Cawqz3CD'74H+67;awqz;G7G;;-K&&I 3 < J& E7s   %II
II7Ic                    U R                   R                  U R                  U R                  5      nUu  U l        U l        g r   )rJ   findcommonmissingrI   r    rK   rL   )rN   setss     r   _computecommonmissingoutgoing._computecommonmissing   s7    ||--d..
 '+#dmr6   c                T    U R                   c  U R                  5         U R                   $ r   )rK   rc   rN   s    r   r3   outgoing.common   s"    <<&&(||r6   c                T    U R                   c  U R                  5         U R                   $ r   )rL   rc   rf   s    r   rU   outgoing.missing   s"    == &&(}}r6   )rK   rL   rJ   r    rI   rM   )NNN)__name__
__module____qualname____firstlineno____doc__r^   rc   r   propertycacher3   rU   __static_attributes__r   r6   r   r8   r8   N   sM    , FJ;z+ 
 
 
 r6   r8   c                   [        U SS5      nUc
  [        XX2S9nUu  Ul        px[        R                  " U 5      =(       d    U R
                  n	U	(       d   U=(       d    U R                  5       Ul        GOUcZ  U R                  S5      R                  5       Ul        U R                  S5       V
s/ s H  oR                  5       PM     sn
Ul        GObU R                  R                  UR                  U5      nUu  Ul        n/ =Ul        n/ =Ul        nU Hb  nX   n
U
R!                  5       [        R"                  :  d  U
R%                  5       (       a  UR'                  U5        MQ  UR'                  U5        Md     [)        U5      [)        U5      :X  a  UnOU R                  R*                  R,                  nU R                  R                  nU Vs/ s H  nU" U5      PM     nnU Vs/ s H  nU" U5      PM     nn[        R.                  " U UU5      nU Vs/ s H  nU" U5      PM     nnUUl        U(       a  UR1                  5         U R                  nUR                   Vs1 s H  nUR-                  U5      iM     nn[        UR3                  U5      5      U-
  Ul        [        UR                  5      nUR                   Vs/ s H  nUU;  d  M  UPM     snUl        U$ s  sn
f s  snf s  snf s  snf s  snf s  snf )a.  Return an outgoing instance to identify the nodes present in repo but
not in other.

If onlyheads is given, only nodes ancestral to nodes in onlyheads
(inclusive) are included. If you already know the local repo's heads,
passing them in onlyheads is faster than letting them be recomputed here.

If commoninc is given, it must be the result of a prior call to
findcommonincoming(repo, other, force) to avoid recomputing it here.

If portable is given, compute more conservative common and ancestorsof,
to make bundles created from the instance more portable.N)r1   r    s   serveds   secret() or extinct())r8   r&   rI   r   	hassecretobsstorer0   r    filteredrB   r   rM   r'   ra   rK   rL   phasesecretextinctappendlenindexrev	new_headsrc   rH   )r.   other	onlyheadsr1   	commonincportableog_any_hds
mayexcludectxrb   
allmissingrU   rM   r   r    to_revrT   rW   excluded_revsonlyheads_revsr|   rQ   r"   missingrevsrI   r   s                               r   findcommonoutgoingr      st     
$d	#B &u
	 "+BND !!$'84==J"2djjl		y1779-1XX6N-OP-Ocxxz-OP ~~//	J!%
J ""g!##hD*Cyy{fmm+s{{}}%t$  w<3z?*#K^^))--Fnn))G0891VAYM91:;AfQiN;((~}MI/89y!71:yK9$ 	  "^^*,++6+Qrvvay+6k23kA
"..)%'^^L^q7K!^LIE Q$ :;9 7 Ms*   /K%K*)K/K4%K9
K>K>c                $   U R                   R                  5       nU R                  nU R                  nUR                  n0 n[        5       n[        5       nUR                   H7  nX   n	UR                  U	5        UR                  U	R                  5       5        M9     UR                  5        n
U
R                  S0 5      R                  5       nSSS5        UR                  nWR                  5        HZ  u  pX;  a  M  / n/ nU H4  nU" U5      (       a  UR                  U5        M#  UR                  U5        M6     U[        U5      U4X]'   M\     U H  nX;  d  M
  S/ / 4X]'   M     [         R"                  " US UR                  5        5       5      nUR%                  US U 5       5        UR                  5        H  u  nnUX]   S   SS& M     UR                  5        H,  u  nnU H  nUc  M  UR'                  5         M     U/ 4-   X]'   M.     UR(                  (       a  UR                  R*                  nUR,                   Vs1 s H  nU" U5      iM     nnUUR.                   Vs1 s H  nU" U5      iM     sn-  nUR                  R1                  USS9n[3        [4        R6                  " U5      5       H9  u  pUu  nnnn[9        U UU5      nU[3        US   5      U[3        US   5      4X]'   M;     U$ ! , (       d  f       GN0= fs  snf s  snf )	a  compute a summary of branch and heads status before and after push

return {'branch': ([remoteheads], [newheads],
                   [unsyncedheads], [discardedheads])} mapping

- branch: the branch name,
- remoteheads: the list of remote heads known locally
               None if the branch is new,
- newheads: the new remote heads (known locally) with outgoing pushed,
- unsyncedheads: the list of remote heads unknown locally,
- discardedheads: the list of heads made obsolete by the push.
	   branchmapNc              3  B   #    U  H  u  pUS    c  M  XS   4v   M     g7f)r   Nr   r   )r   branchr0   s      r   r    _headssummary.<locals>.<genexpr>.  s)      	
!1Qx V1X!1s   c              3  @   #    U  H  oR                  5       v   M     g 7fr   )r{   )r   r   s     r   r   r   4  s     9jsj   r   Tr;   r   )r.   r>   r/   r8   r'   rB   rU   rF   r   commandexecutorcallcommandresultr(   itemsrx   r-   r	   remotebranchcacheupdatesortrs   r{   r    rI   rH   sortedr   	iteritems_postprocessobsolete)pushopr.   r/   r8   rQ   headssum
missingctxbranchesr"   r   e	remotemapr   r   r0   knownunsyncedr   newmapnewheadsr   ltorevfutureheadsallfuturecommonremoteheadsunsyncedheadsplaceholderr   s                                r   _headssummaryr      s    ;;!!#D]]FH	BHJuHgsSZZ\" 
 
			!QMM,3::<	 
" 

I"*!A||Q"	 
 "4;9 + ! $b"~H  ((	
!)!1	
F MM$9j9:"LLN!)A +!)A}  !B5=	 * }}"")1)=)=>)=AuQx)=>(*>*>?*>Qa*>??..22;$2O#H$6$6x$@AMF@E=K=+)&/8LFvay!vay!	 H B Os 
"	!Z ??s   ,!K6L'L6
Lc                   ^ U R                   R                  m[        U4S jU 5       5      nU R                  SXBR                  5      n[        S U 5       5      nU(       a  S/nO/ nSXFU/ 40$ )z;Compute branchmapsummary for repo without branchmap supportc              3  F   >#    U  H  nT" U5      (       d  M  Uv   M     g 7fr   r   r   s     r   r   #_oldheadssummary.<locals>.<genexpr>V  s     =A	!aas   !	!s   heads(%ln + %ln)c              3  @   #    U  H  oR                  5       v   M     g 7fr   )r   )r   cs     r   r   r   ]  s     *1ffhhr   N)r'   r(   r   rB   rU   )	r.   r   r8   incoldheadsrW   r   r   r   s	           @r   _oldheadssummaryr   O  sn     &&I===H 	$h0@0@AA***H
68x455r6   c                   U R                   R                  5       nU R                  nUR                  nUR	                  5        nUR                  SSS05      R                  5       nS S S 5        [        5       nU R                  R                  SS5       Vs/ s H  nUR                  U5      PM     nnU H  n	WR                  U	5      n
U
(       aN  X;   aI  XU	      X   p[        R                  " XU5      (       a!  UR                  UR                  5       5        Mg  Mi  X;   d  Mp  X;  d  Mw  UR                  X9   5        M     U$ ! , (       d  f       N= fs  snf )Ns   listkeyss	   namespaces	   bookmarkss   pushing)r.   r>   r/   
_bookmarksr   r   r   rB   r+   
configlist
expandnamegetr   	validdestrF   r   )r   r.   r/   localbookmarksr   remotebookmarksbookmarkedheadsbnewbookmarksbmrnodelctxrctxs                r   _nowarnheadsr   f  s:   ;;!!#D]]F__N				!Q--l

 &( 	 
" eO
 %%lJ??A 	!!!$?  
 ##B'U]R014;$""4t44##DIIK0 5 !b&?##N$67  5 
"	!s   #EE
Ec                	   U R                   R                  5       nU R                  nU R                  nU R                  nU R
                  n[        U R                  5      nXAR                  /:X  a  gUR                  S5      (       a  [        U 5      nO[        XX65      nXpl        UR                  5        VV	s/ s H  u  pU	S   b  M  UPM     n
nn	U
(       a  U(       d  SR                  [        U
5      5      n[!        5       nUR#                  5       R%                  5        H   u  ppU(       d  M  UR'                  U5        M"     U[!        U
5      -  nU(       a  [)        S5      U[+        U5      4-  nO[)        S5      U-  n[)        S5      n[,        R.                  " UUS9e[1        U 5      nSn[        [2        R4                  " U5      5       GH  u  pU	u  nnnnUc  [!        5       nO[!        U5      nUR7                  U5        Sn[!        U5      nUR7                  U5        U(       a  SU;   a  Sn	O[8        R:                  " UU5      n	U	c%  UR<                  R?                  [)        S	5      5        OSUc(  UR<                  R?                  [)        S
5      U	-  5        O(UR<                  R?                  [)        S5      X4-  5        Uc7  [+        U5      S:  a'  [A        U5      nUc  [)        S5      U-  n[)        S5      nO)[+        U5      [+        U5      :  a  [        UU-
  U-
  5      nU(       d  GMd  Uc  US;  a  [)        S5      [C        US   5      U4-  nOiUUS      RE                  5       (       a4  [)        S5      [C        US   5      UUS      RE                  5       S   4-  nO[)        S5      [C        US   5      -  nU(       a  [)        S5      nO[)        S5      nUc%  UR<                  RG                  [)        S5      5        O'UR<                  RG                  [)        S5      U-  5        U H*  nUR<                  RG                  S[C        U5      -  5        M,     GM     U(       a  [,        R.                  " UWS9egs  sn	nf )zhCheck that a push won't add any outgoing head

raise StateError error and display ui message as needed.
Nr   r   s   , s0   push creates new remote branches: %s (%d closed)s$   push creates new remote branches: %ss8   use 'hg push --new-branch' to create new remote branches)hints,   remote has heads that are not known locally
s0   remote has heads that are not known locally: %s
s?   remote has heads on branch '%s' that are not known locally: %s
r   s0   push creates new branch '%s' with multiple headss?   merge or see 'hg help push' for details about pushing new heads)s   defaultNs.   push creates new remote head %s on branch '%s's2   push creates new remote head %s with bookmark '%s's   push creates new remote head %ssH   pull and merge or see 'hg help push' for details about pushing new headss   new remote heads:
s!   new remote heads on branch '%s':
s    %s
)$r.   r>   r/   r8   r   	newbranchboolincomingrA   r%   r   r   pushbranchmapr   joinr   rB   r	   iterbranchesrF   r   ry   r
   
StateErrorr   r   r   r   r   nodesummariesr+   statusr-   r   r   note)r   r.   r/   r8   r   r   r   r   r   r0   newbranchesbranchnamesclosedbranchestagtipisclosederrmsgr   nowarnheadserrormsgr   r   discardedheadsoldhsdhsnewhsr   s                              r   
checkheadsr     sA    ;;!!#D]]FH$$K  I
v
C {{m#~~l## (#DxE#$,NN$4$4=6a$4   9jj!45)-)9)F)F)H%Cx""3' *I (#k*::JKN#O F
 >?+MFLMvD11 v&K
 H 2 28 <=?D<X}nEE$E]#H]#}$--dMB}FG JK
 3 o	& 5zA~5k#MN !  .D
 Z#e*$,u45C3!33 I  c!f H #a&\++-- .  s1vSV(>(>(@(CD EH
  !!CDuAH  H !.D .D
 ~Q567QDENOXa01 i >l xd33 gs   8R R c                  ^^^^^^^^ U R                   nUR                  5       mTR                  R                  R                  m[
        R                  mTR                  R                  mUUU4S jmUU4S jn[        R                  " [        TR                  U5      mTR                  R                  n[        5       n[        5       n[        5       n[        5       n	U Hh  n
U
T;   a  UR                  U
5        M  UR!                  U
5      b)  SnUR"                  R%                  U['        U
5      -  5        U	R                  U
5        Mj     [)        U5      S:X  a  U	[        U5      -  [        5       4$ [*        R,                  " TS5      n[/        T5      U-
  mU(       Ga$  UR1                  5       nT" U5      nTU   R3                  5       nT" U5      (       d  X;  a  UR                  U5        MX  TR5                  SXU5      n/ nU H=  nTU   nUR3                  5       U:X  d  M  UR7                  UR9                  5       5        M?     [;        U4S jU 5       5      (       d5  [;        UU4S jU 5       5      (       d  [;        U4S	 jU 5       5      (       a  UR                  U5        OUR                  U5        U(       a  GM$  Xi-  nXg4$ )
zpost process the list of new heads with obsolescence information

Exists as a sub-function to contain the complexity and allow extensions to
experiment with smarter logic.

Returns (newheads, discarded_heads) tuple
c                   > T" TU 5      T:H  $ r   r   )rW   getphasepublicrR   s    r   <lambda>&_postprocessobsolete.<locals>.<lambda>1  s    $*f4r6   c                   > T" U 5      T;   $ r   r   )r"   futurecommonr   s    r   r   r   2  s    q\1r6   s=   checkheads: remote head unknown locally has local marker: %s
r   s   obsoletes   only(%n, (%ln+%ln))c              3  4   >#    U  H  nT" U5      v   M     g 7fr   r   )r   rW   ispublics     r   r   '_postprocessobsolete.<locals>.<genexpr>h  s     0ZZr   c              3  :   >#    U  H  nT" U5      T;   v   M     g 7fr   r   )r   r"   futurenonobsoleter   s     r   r   r   i  s     F+Q5800+s   c              3  >   >#    U  H  nT" U5      (       + v   M     g 7fr   r   )r   r"   hasoutmarkers     r   r   r   j  s     <1|A&&r$   )r.   r>   r'   rz   get_revr   r   _phasecacheru   	functoolspartialpushingmarkerforrs   
successorsrB   rF   r   r+   debugr   ry   r   getrevs	frozensetpopr   rC   rx   r   r,   )r   r   candidate_newhsr.   ispushedsuccessorsmarkersr   	discardedlocalcandidateunknownheadsr   msgobsrevsnhrW   current_branch
branchrevsbranchnodesr   r   r   r   r   r   r   rR   s    `                 @@@@@@@r   r   r     sG     ;;D??DNN  ((E]]F%%H4H1H$$%5t}}hOL00EEIUN5L9q! $$Q'3+  cCFl+Q  >ac/22CE99t[1G!,/'9 !"Ib*A;;!*IIbM YY"B

 AQAxxz^+""1668,  0Z000F+FFF<<<<IIbM MM"I .J 
Er6   c                b   U R                   nU/n[        U5      nU(       a  UR                  5       nU" U5      (       a  gUR                  US5      nU HO  nUS   n	U	(       d  US   =(       d    Sn	U	 H,  n
X;  d  M
  UR	                  U
5        UR                  U
5        M.     MQ     U(       a  M  g)a  true if some markers are to be pushed for node

We cannot just look in to the pushed obsmarkers from the pushop because
discovery might have filtered relevant markers. In addition listing all
markers relevant to all changesets in the pushed set would be too expensive
(O(len(repo)))

(note: There are cache opportunity in this function. but it would requires
a two dimensional stack.)
Tr   r      F)r   rB   r   r   rF   rx   )rs   r   r   r   stackseencurrentmarkersrP   nextsr"   s              r   r   r   w  s     !++FEu:D
))+G#''4AaDE!
=HHQKLLO 	  % r6   )NFN)NFNF)F)
__future__r   r   i18nr   r   r   r    r   r	   r
   r?   r   r   r   r   r   r   r   r&   r8   r   r   r   r   r   r   r   r   r6   r   <module>r     so    #  
   *;Zc cN HMBJSl6. FP4fXvr6   