ó
a˜Qc           @   s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d „  Z	 d e
 f d „  ƒ  YZ e ƒ  Z e d „ Z d „  Z d d d e d „ Z e d	 „ Z e d
 „ Z d „  Z d „  Z d „  Z d „  Z d „  Z e j Z e j Z e j Z d S(   iÿÿÿÿ(   t   _Nc         C   sb   g  |  j  d ƒ D] } | d ^ q } | r^ | d d k rI | j ƒ  q^ | d d  | d <n  | S(   s0   like str.splitlines, but only split on newlines.s   
iÿÿÿÿ(   t   splitt   pop(   t   textt   lt   lines(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   splitnewlines   s    &t   diffoptsc           B   sq   e  Z d  Z i	 d d 6e d 6e d 6e d 6e d 6e d 6e d 6e d	 6e d
 6Z e j ƒ  Z d „  Z d „  Z RS(   s´  context is the number of context lines
    text treats all files as text
    showfunc enables diff -p output
    git enables the git extended patch format
    nodates removes dates from diff headers
    ignorews ignores all whitespace changes in the diff
    ignorewsamount ignores changes in the amount of whitespace
    ignoreblanklines ignores changes whose lines are all blank
    upgrade generates git diffs to avoid data loss
    i   t   contextR   t   showfunct   gitt   nodatest   ignorewst   ignorewsamountt   ignoreblanklinest   upgradec         K   s™   xL |  j  D]A } | j | ƒ } | d  k r; |  j | } n  t |  | | ƒ q
 Wy t |  j ƒ |  _ Wn- t k
 r” t j	 t
 d ƒ |  j ƒ ‚ n Xd  S(   Ns3   diff context lines count must be an integer, not %r(   t	   __slots__t   gett   Nonet   defaultst   setattrt   intR   t
   ValueErrort   utilt   AbortR    (   t   selft   optst   kt   v(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   __init__0   s    c            s6   t  ‡  f d †  ˆ  j Dƒ ƒ } | j | ƒ t |   S(   Nc         3   s$   |  ] } | t  ˆ  | ƒ f Vq d  S(   N(   t   getattr(   t   .0R   (   R   (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pys	   <genexpr>>   s    (   t   dictR   t   updateR   (   R   t   kwargsR   (    (   R   s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   copy=   s    (	   t   __name__t
   __module__t   __doc__t   FalseR   t   keysR   R   R#   (    (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyR      s   

	c         C   sp   |  j  r t j | d ƒ } n |  j r< t j | d ƒ } n  | rl |  j rl t j d d | ƒ j d ƒ } n  | S(   Ni   i    s   
+s   
(   R   t   bdifft   fixwsR   R   t   ret   subt   strip(   R   R   t   blank(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   wscleanD   s    		!c         c   sÎ  g  | D]! } t  | | ƒ r" d p% d ^ q } g  | D]! } t  | | ƒ rP d pS d ^ q5 } d t | ƒ } } d t | ƒ } }	 xE| | k  s | |	 k  rÉ| | d }
 } } |
 | k sé | |
 d k sé | |	 k sé | | d k rLd } x* |
 | k  r| |
 d k r|
 d 7}
 qò Wxt | |	 k  rH| | d k rH| d 7} qWnG xD |
 | k  r’| |
 d k r’| | d k r’|
 d 7}
 | d 7} qOW|  | |  |
 | | | | g | f V|
 } | } q… Wd  S(   Ni   i    t   =t   ~(   R/   t   len(   t   base1t   lines1t   base2t   lines2R   R   t   s1t   e1t   s2t   e2t   i1t   i2t   btype(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt
   splitblockM   s&    ../
'c      
   c   s¾  | d	 k r t } n  | j s' | j rN t | |  t ƒ }  t | | t ƒ } n  t j |  | ƒ } xWt | ƒ D]I\ } } | d k r– | | d }	 n d d d d g }	 |	 d | d |	 d | d g }	 |	 d |	 d k sò |	 d |	 d k r«d }
 | j	 r| d	 k rt
 |  ƒ } n  | d	 k r7t
 | ƒ } n  t | d j | |	 d |	 d !ƒ ƒ } t | d j | |	 d |	 d !ƒ ƒ } | | k rd }
 qn  |	 |
 f Vn  | d f Vqm Wd	 S(
   s·  Return (block, type) tuples, where block is an mdiff.blocks
    line entry. type is '=' for blocks matching exactly one another
    (bdiff blocks), '!' for non-matching blocks and '~' for blocks
    matching only after having filtered blank lines. If refine is True,
    then '~' blocks are refined and are only made of blank lines.
    line1 and line2 are text1 and text2 split with splitnewlines() if
    they are already available.
    i    i   i   i   t   !t    R1   R0   N(   R   t   defaultoptsR   R   R/   R'   R)   t   blockst	   enumerateR   R   t   join(   t   text1t   text2R   R4   R6   t   refinet   difft   iR7   t   st   typet   oldt   new(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt	   allblocksg   s0    		"(	''c            sç  d  ‡  f d † } |  r$ | r$ d St j d ƒ } t j | ƒ } t j | ƒ } ˆ  j r½ t j |  ƒ sy t j | ƒ r½ |  r­ | r­ t |  ƒ t | ƒ k r­ |  | k r­ d Sd | g }	 nÙ|  set | ƒ } |  d  k rî d | | ƒ }
 n d d | | | | ƒ f }
 d d	 | | | | ƒ f } d
 t | ƒ } |
 | | g g  | D] } d | ^ qK}	 n1| st |  ƒ }  d d | | | | ƒ f }
 | d  k r³d | | ƒ } n d d	 | | | | ƒ f } d t |  ƒ } |
 | | g g  |  D] } d | ^ qó}	 n‰ t |  ƒ } t | ƒ } t t	 |  | | | d ˆ  ƒƒ }	 |	 sPd S|	 j
 d d | | | | ƒ f ƒ |	 j
 d d | | | | ƒ f ƒ xA t t |	 ƒ ƒ D]- } |	 | d d k r©|	 | c d 7<q©q©Wd j |	 ƒ S(   Nc            s6   ˆ  j  r ˆ  j r d |  S| r2 d | k r2 d Sd S(   Ns   	%s
t    s   	
s   
(   R
   R   (   t   datet   fn(   R   (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   datetag’   s
    R@   i    s   Binary file %s has changed
s   --- /dev/null%ss   --- %s%ss   a/s   +++ %s%ss   b/s   @@ -0,0 +1,%d @@
t   +s   +++ /dev/null%ss   @@ -1,%d +0,0 @@
t   -R   s
   --- a/%s%si   s
   +++ b/%s%siÿÿÿÿs   
s   
\ No newline at end of file
(   i    i    (   R   R   t   datestrt   pconvertR   t   binaryR2   R   t   listt   _unidifft   insertt   xrangeRD   (   t   at   adt   bt   bdt   fn1t   fn2R   RR   t   epochR   t   l1t   l2t   l3t   et   alt   blt   ln(    (   R   s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   unidiff‘   sJ    (0--!##c         #   sP  ‡ f d †  ‰  ‡ f d †  } d d g ‰ ‡  ‡ ‡ ‡ f d †  } d  } d } xÖt |  | ˆ ˆ | ƒ D]¼\ }	 }
 |	 \ } } } } |
 d k r¼ |
 d k rg | | | | | 7} qg qg n  g  } ˆ | | !} | | | !} | | 8} | | 8} | | ƒ } | | ƒ } d  } | rk| | d ˆ j d k  rL| } | d } | d	 } qkx | | ƒ D] } | VqYWn  | r’| | d <| | d	 <| d
 } n | | | | | g } g  ˆ | | !D] } d | ^ qµ| t | ƒ )g  | D] } d | ^ qÜ| t | ƒ )g  | D] } d | ^ q| t | ƒ )qg W| rLx | | ƒ D] } | Vq:Wn  d  S(   Nc            s&   |  ˆ  j  } | | k r" | } n  | S(   N(   R   (   R   R2   t   ret(   R   (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt
   contextendÊ   s    	c            s!   |  ˆ  j  } | d k  r d S| S(   Ni    (   R   (   R   Rk   (   R   (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   contextstartÐ   s    i    R@   c         3   sL  |  \ } } } } } ˆ  | t  ˆ ƒ ƒ } | | } | | | | } d }	 ˆ j rÍ ˆ \ }
 }	 x\ t | d |
 d d ƒ D]@ } ˆ | d j ƒ  r| d ˆ | j ƒ  d  }	 |	 ˆ d <Pq| q| W| ˆ d <n  | rà | d 7} n  | ró | d 7} n  d | | | | |	 f Vx | D] } | VqWx$ t | | ƒ D] } d ˆ | Vq1Wd  S(   NR@   i   iÿÿÿÿi    RO   i(   s   @@ -%d,%d +%d,%d @@%s
(   R2   R	   R[   t   isalnumt   rstrip(   t   hunkt   astartt   a2t   bstartt   b2t   deltat   aendt   alent   blent   funct   lastposRI   t   x(   Rl   Rc   t   lastfuncR   (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt	   yieldhunk×   s.    
	!
		R?   R1   i   i   i   RO   RT   RS   (   R   RN   R   R2   (   t   t1t   t2Rc   Rd   R   Rm   R}   Rp   t   ignoredlinesRJ   t   stypet   a1Rr   t   b1Rt   Ru   RL   RM   Rq   Rs   t   prevR{   (    (   Rl   Rc   R|   R   s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyRY   É   sL    '%




.'+c         C   sÆ   d „  } d d „ } |  d k r* d }  n  | d k r? d } n  |  | k rO d Sg  } | j d ƒ | j d t | ƒ ƒ x0 | t j | ƒ ƒ D] } | j | | ƒ ƒ q W| j d ƒ d j | ƒ S(	   s    print base85-encoded binary diffc         S   sm   t  |  ƒ } | d k r5 t t d ƒ | d ƒ } n t | d t d ƒ d ƒ } d | t j |  t ƒ f S(   Ni   t   Ai   R\   s   %c%s
(   R2   t   chrt   ordt   base85t	   b85encodet   True(   t   lineR   (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   fmtline/  s
    i4   c         s   sC   t  |  ƒ } d } x* | | k  r> |  | | | !V| | 7} q Wd  S(   Ni    (   R2   (   R   t   csizeR   RI   (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   chunk7  s
    R@   s   GIT binary patch
s   literal %s
s   
N(   R   t   appendR2   t   zlibt   compressRD   (   t   tot   tnRŒ   RŽ   Rk   R   (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   b85diff-  s    			c         C   s„   d } g  } xh | t  |  ƒ k  rv t j d |  | | d !ƒ \ } } } | d 7} | j |  | | | !ƒ | | 7} q Wd j | ƒ S(   Ni    s   >llli   R@   (   R2   t   structt   unpackR   RD   (   t   bint   post   tt   p1t   p2R   (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt	   patchtextP  s    &
c         C   s5   t  |  ƒ d k r" t j | d ƒ St j |  | g ƒ S(   Ni    i   (   R2   R   t   buffert   mpatcht   patches(   R\   R—   (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   patchZ  s    c         C   s@   g  t  j |  | ƒ D]) } | d | d | d | d f ^ q S(   Ni    i   i   (   R)   RB   (   R\   R^   t   d(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   get_matching_blocksa  s    c         C   s   t  j d d d |  ƒ S(   Ns   >llli    (   R•   t   pack(   t   length(    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   trivialdiffheaderd  s    (   t   i18nR    R)   Rž   R   R+   R•   Rˆ   R   R   t   objectR   RA   RŠ   R/   R>   R   R'   RN   Rj   RY   R”   Rœ   R    R¢   R¥   RŸ   t   patchedsizet   textdiff(    (    (    s3   /sys/lib/python2.7/site-packages/mercurial/mdiff.pyt   <module>   s$   $0	
,			*8d	#	
					