
    q&f                         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 ddlmZ d Zd Z ej$                  dd	d
      d        Zd Zy)    )_)
stringutil)	bundle2errorexchange
extensionshg
narrowspecwireprototypeswireprotov1peerwireprotov1server   )narrowbundle2c                  6    t         t        j                  _        y )N)peernarrowwidenr   wirepeernarrow_widen     =/usr/lib/python3/dist-packages/hgext/narrow/narrowwirepeer.pyuisetupr      s    ,;O)r   c                 N      fd}t         j                  j                  |       y )Nc                 >    fd}t        j                  |d|       y )Nc                     |dk(  r7j                   \  }}dj                  |      |d<   dj                  |      |d<    | |g|i |S )Ns   unbundle   ,includepatsexcludepats)
narrowpatsjoin)origcmdargskwargsincludeexcluderepos         r   wrappedz1reposetup.<locals>.wirereposetup.<locals>.wrapped"   sV    k! $(?? (,		'(:}%(,		'(:}%-d-f--r   _calltwowaystream)r   wrapfunction)uipeerr'   r&   s      r   wirereposetupz reposetup.<locals>.wirereposetup!   s    	. 	&97Cr   )r	   wirepeersetupfuncsappend)r&   r,   s   ` r   	reposetupr/       s    
D   /r      narrow_widensT   oldincludes oldexcludes newincludes newexcludes commonheads cgversion known ellipsess   pull)
permissionc
           
      @   d}
	 d }t         ||            }t         ||            }t         ||            }t         ||            }| j                  j                  t        j                        rt        j
                  | ||d      }|d   }|d   |z
  }|r| j                  }|j                  |j                  j                  d      xs |j                               }t        j                  t        d      |t        j                  t        |            fz        |d   }t!        j"                  |       t!        j"                  |       t!        j"                  |       t!        j"                  |       t%        j&                  |      }t%        j&                  |      }|	dk(  rd}	nt)        |	      }	|}t+        j,                  | j                        }t!        j.                  | j0                  ||	      }t!        j.                  | j0                  ||	      }|	st+        j2                  || ||||||	       nt5        j6                  || |||||       |jC                         }t%        jD                  ||
      S # t        j                  $ r}t+        j,                  | j                        }d
|j8                  fg}g }|j:                  |j=                  d|j:                  f       |j?                  t+        j@                  d||             d}
Y d}~d}~ww xY w)a  wireprotocol command to send data when a narrow clone is widen. We will
    be sending a changegroup here.

    The current set of arguments which are required:
    oldincludes: the old includes of the narrow copy
    oldexcludes: the old excludes of the narrow copy
    newincludes: the new includes of the narrow copy
    newexcludes: the new excludes of the narrow copy
    commonheads: list of heads which are common between the server and client
    cgversion(maybe): the changegroup version to produce
    known: list of nodes which are known on the client (used in ellipses cases)
    ellipses: whether to send ellipses data or not
    Fc                 ,    | r| j                  d      S g S )Nr   )split)datas    r   
splitpathsz narrow_widen.<locals>.splitpathsU   s    '+4::d#33r   )r   r   r   r   s   REMOTE_USERs3   The following excludes cannot be removed for %s: %s   0)r$   r%   s   messageNs   hints   error:abortT)genprefer_uncompressed)#setr*   has_sectionr   _NARROWACL_SECTIONapplynarrowacl	shortuserenvirongetusernamer   Abortr   r   pprintlistr
   validatepatternsr   
decodelistboolr   bundle20matchrootwiden_bundler   &generate_ellipses_bundle2_for_wideningmessagehintr.   addpart
bundlepart	getchunks	streamres)r&   protooldincludesoldexcludesnewincludesnewexcludescommonheads	cgversionknownellipsespreferuncompressedr6   r#   requiredexcludesr*   rA   commonbundlernewmatcholdmatchexcmanargsadvargschunkss                           r   r   r   0   s   D R"	4 *[12*[12*[12*[12 77x::;,,k+NF !/K%m4{B
 WW<<JJNN>2Cbkkm kkLM!2!248H3I!JKL  !/K 	##K0##K0##K0##K0**;7))%0tHH~H	""477+##II{K
 ##II{K
   	 @@$  F##(:  ;; """477+,-88NNGSXX./**>7GLM!"s   II? ?LBLLc                    dD ]  }t        j                  ||         ||<    dD ]  }dj                  ||         ||<    dt        |d         z  |d<    | j                  di |}t        j                  | j                  |      S )N)rX   rZ   )rT   rV   rU   rW   r   s   %ir[   )r0   )r   
encodelistr   rG   _callcompressabler   getunbundlerr*   )remoter#   chfs       r   r   r      s    & ;#..vbz:r
; K +YYvbz*r
+ fZ&8!99F:   ;F;A		1--r   N)mercurial.i18nr   mercurial.utilsr   	mercurialr   r   r   r   r	   r
   r   r   r    r   r   r/   wireprotocommandr   r   r   r   r   <module>rr      sb     &
 
 
 <0  $## rrj	.r   