ó
U³úVc           @@  s+  d  d l  m Z d  d l Z d  d l Z d  d l Z d d l m Z d d l m Z m	 Z	 m
 Z
 m Z m 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 d „  Z e j Z e j  Z  e	 j	 Z! d S(   i    (   t   absolute_importNi   (   t   _(   t   base85t   bdifft   errort   mpatcht   utilc         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   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   splitnewlines   s    &t   diffoptsc           B@  s   e  Z d  Z i d d 6e d 6e 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
    nobinary ignores binary files
    noprefix disables the 'a/' and 'b/' prefixes (ignored in plain mode)
    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   nobinaryt   noprefixt   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
   ValueErrorR   t   AbortR   (   t   selft   optst   kt   v(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   __init__?   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   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pys	   <genexpr>M   s    (   t   dictR   t   updateR   (   R    t   kwargsR!   (    (   R    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   copyL   s    (	   t   __name__t
   __module__t   __doc__t   FalseR   t   keysR   R$   R*   (    (    (    s3   /usr/lib/python2.7/dist-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   R   t   fixwsR   R   t   ret   subt   strip(   R!   R	   t   blank(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   wscleanS   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   ~(   R5   t   len(   t   base1t   lines1t   base2t   lines2R!   R
   t   s1t   e1t   s2t   e2t   i1t   i2t   btype(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt
   splitblock\   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    R7   R6   N(   R   t   defaultoptsR   R   R5   R.   R   t   blockst	   enumerateR   R   t   join(   t   text1t   text2R!   R:   R<   t   refinet   difft   iR=   t   st   typet   oldt   new(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt	   allblocksv   s0    		"(	''c         @  s  d  ‡  f d † } |  r$ | r$ d Sˆ  j r: d } }	 n d } d }	 t j d ƒ }
 t j | ƒ } t j | ƒ } ˆ  j rß t j |  ƒ s› t j | ƒ rß |  rÏ | rÏ t |  ƒ t | ƒ k rÏ |  | k rÏ d Sd | g } nÜ|  s†t | ƒ } |  d  k rd | |
 ƒ } n d | | | | | ƒ f } d	 |	 | | | | ƒ f } d
 t | ƒ } | | | g g  | D] } d | ^ ql} n5| s,t |  ƒ }  d | | | | | ƒ f } | d  k rÓd | |
 ƒ } n d |	 | | | | ƒ f } d t |  ƒ } | | | g g  |  D] } d | ^ q} n t |  ƒ } t | ƒ } t	 t
 |  | | | d ˆ  ƒƒ } | so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   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   datetag¡   s
    RF   s   a/s   b/i    s   Binary file %s has changed
s   --- /dev/null%ss
   --- %s%s%ss   +++ %s%ss   @@ -0,0 +1,%d @@
t   +s   +++ /dev/null%ss
   +++ %s%s%ss   @@ -1,%d +0,0 @@
t   -R!   i   iÿÿÿÿs   
s   
\ No newline at end of file
(   i    i    (   R   R   R   t   datestrt   pconvertR	   t   binaryR8   R   t   listt   _unidifft   insertt   xrangeRJ   (   t   at   adt   bt   bdt   fn1t   fn2R!   RX   t   aprefixt   bprefixt   epochR
   t   l1t   l2t   l3t   et   alt   blt   ln(    (   R!   s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   unidiff    sR    	(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
   R8   t   ret(   R!   (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt
   contextendà   s    	c         @  s!   |  ˆ  j  } | d k  r d S| S(   Ni    (   R   (   R
   Rs   (   R!   (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   contextstartæ   s    i    RF   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(   NRF   i   iÿÿÿÿi    RU   i(   s   @@ -%d,%d +%d,%d @@%s
(   R8   R   Ra   t   isalnumt   rstrip(   t   hunkt   astartt   a2t   bstartt   b2t   deltat   aendt   alent   blent   funct   lastposRO   t   x(   Rt   Rk   t   lastfuncR!   (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt	   yieldhunkí   s.    
	!
		RE   R7   i   i   i   RU   RZ   RY   (   R   RT   R   R8   (   t   t1t   t2Rk   Rl   R!   Ru   R…   Rx   t   ignoredlinesRP   t   stypet   a1Rz   t   b1R|   R}   RR   RS   Ry   R{   t   prevRƒ   (    (   Rt   Rk   R„   R!   s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyR_   ß   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   Rb   s   %c%s
(   R8   t   chrt   ordR   t	   b85encodet   True(   t   lineR
   (    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   fmtlineE  s
    i4   c         s@  sC   t  |  ƒ } d } x* | | k  r> |  | | | !V| | 7} q Wd  S(   Ni    (   R8   (   R	   t   csizeR
   RO   (    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   chunkM  s
    RF   s   GIT binary patch
s   literal %s
s   
N(   R   t   appendR8   t   zlibt   compressRJ   (   t   tot   tnR“   R•   Rs   R
   (    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   b85diffC  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   RF   (   R8   t   structt   unpackR–   RJ   (   t   bint   post   tt   p1t   p2R
   (    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt	   patchtextf  s    &
c         C@  s5   t  |  ƒ d k r" t j | d ƒ St j |  | g ƒ S(   Ni    i   (   R8   R   t   bufferR   t   patches(   Rb   Rž   (    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   patchp  s    c         C@  s@   g  t  j |  | ƒ D]) } | d | d | d | d f ^ q S(   Ni    i   i   (   R   RH   (   Rb   Rd   t   d(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   get_matching_blocksw  s    c         C@  s    |  r t  j d d d |  ƒ Sd S(   Ns   >llli    RF   (   Rœ   t   pack(   t   length(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   trivialdiffheaderz  s    c         C@  s   t  j d d |  | ƒ S(   Ns   >llli    (   Rœ   R©   (   t   oldlent   newlen(    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   replacediffheader}  s    ("   t
   __future__R    R1   Rœ   R—   t   i18nR   RF   R   R   R   R   R   R   t   objectR   RG   R‘   R5   RD   R   R.   RT   Rr   R_   R›   R£   R¦   R¨   R«   R®   R¥   t   patchedsizet   textdiff(    (    (    s3   /usr/lib/python2.7/dist-packages/mercurial/mdiff.pyt   <module>   s,   (	
0			*?d	#	
						