
Qc        	   @   s  d  Z  d d l m Z m Z m Z m Z m Z m Z d d l m Z m	 Z	 m
 Z
 m Z m Z m Z d d l m Z d d l m Z d d l m Z d d l Z d d l Z d d l Z d d l Z e j d 7_ e j d	 7_ i  Z e j e  Z d
 Z d Z d Z d Z i d d 6d d 6d d 6d d 6d d 6Z d   Z  d   Z! d   Z" e j# j$ i e  d 6e! d 6e" d 6 i d d 6d d  6Z& d!   Z' d"   Z( d#   Z) d$ e* f d%     YZ+ d& e j f d'     YZ, d(   Z- d)   Z. e d* d+ d, d e d-  f d. d/ d e d0  e d1  f g e d2   d3    Z/ e d4 e j0 e d5   d6    Z1 e d7 d8 d9 d e d:  f d; d< d e d=  f d> d? d e d@  f g e j0 e dA   dB    Z2 e dC e j0 e dD   dE    Z3 dF   Z4 dG   Z5 d S(H   sB  expand keywords in tracked files

This extension expands RCS/CVS-like or self-customized $Keywords$ in
tracked text files selected by your configuration.

Keywords are only expanded in local repositories and not stored in the
change history. The mechanism can be regarded as a convenience for the
current user or for archive distribution.

Keywords expand to the changeset data pertaining to the latest change
relative to the working directory parent of each file.

Configuration is done in the [keyword], [keywordset] and [keywordmaps]
sections of hgrc files.

Example::

    [keyword]
    # expand keywords in every python file except those matching "x*"
    **.py =
    x*    = ignore

    [keywordset]
    # prefer svn- over cvs-like default keywordmaps
    svn = True

.. note::
   The more specific you are in your filename patterns the less you
   lose speed in huge repositories.

For [keywordmaps] template mapping and expansion demonstration and
control run :hg:`kwdemo`. See :hg:`help templates` for a list of
available templates and filters.

Three additional date template filters are provided:

:``utcdate``:    "2006/09/18 15:13:13"
:``svnutcdate``: "2006-09-18 15:13:13Z"
:``svnisodate``: "2006-09-18 08:13:13 -700 (Mon, 18 Sep 2006)"

The default template mappings (view with :hg:`kwdemo -d`) can be
replaced with customized keywords and templates. Again, run
:hg:`kwdemo` to control the results of your configuration changes.

Before changing/disabling active keywords, you must run :hg:`kwshrink`
to avoid storing expanded keywords in the change history.

To force expansion after enabling it, or a configuration change, run
:hg:`kwexpand`.

Expansions spanning more than one line and incremental expansions,
like CVS' $Log$, are not supported. A keyword template map "Log =
{desc}" expands to the first line of the changeset description.
i(   t   commandst   contextt   cmdutilt   dispatcht   filelogt
   extensions(   t	   localrepot   matcht   patcht   templatefilterst	   templatert   util(   t   scmutil(   t   webcommands(   t   _Ns    kwdemos    kwexpand kwfiles kwshrinkt   internalsg   add addremove annotate bundle export grep incoming init log outgoing push tip verify convert email glogs9   merge kwexpand kwshrink record qrecord resolve transplantt   records
   green bolds   kwfiles.enableds   cyan bold underlines   kwfiles.deletedt   greens   kwfiles.enabledunknownt   bolds   kwfiles.ignoredt   nones   kwfiles.ignoredunknownc         C   s#   t  j t  j |   d d f d  S(   sN   :utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13".
    i    s   %Y/%m/%d %H:%M:%S(   R   t   datestrt	   parsedate(   t   text(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   utcdatev   s    c         C   s   t  j |  d  S(   sj   :svnisodate: Date. Returns a date in this format: "2009-08-18 13:00:13
    +0200 (Tue, 18 Aug 2009)".
    s%   %Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)(   R   R   (   R   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt
   svnisodate{   s    c         C   s#   t  j t  j |   d d f d  S(   sV   :svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18
    11:00:13Z".
    i    s   %Y-%m-%d %H:%M:%SZ(   R   R   R   (   R   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt
   svnutcdate   s    R   R   R   R
   t    t   hgcmdc         C   s   i d d 6d d 6} i d d 6d d 6d d	 6d
 d 6d d 6d d 6i d d 6d d 6d d 6d d 6d d 6f } | j  | |  j d d   | S(   sB   Returns default keywordmaps according to keywordset configuration.s   {node|short}t   Revisions   {author|user}t   Authors   {date|utcdate}t   Dates   {file|basename},vt   RCSfilet   RCSFiles   {root}/{file},vt   Sources;   {file|basename},v {node|short} {date|utcdate} {author|user}t   Ids9   {root}/{file},v {node|short} {date|utcdate} {author|user}t   Headers   {date|svnisodate}s>   {file|basename},v {node|short} {date|svnutcdate} {author|user}t   LastChangedRevisiont   LastChangedByt   LastChangedDatet
   keywordsett   svn(   t   updatet
   configbool(   t   uit	   templatest   kwsets(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   _defaultkwmaps   s$    
c         C   s   | d |   S(   sl   Helper for keyword expansion removal in text.
    Depending on subfunc also returns number of substitutions.s   $\1$(    (   R   t   subfunc(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   _shrinktext   s    c         C   sd   |  d  \ } } g  | D] } | | k r | ^ q } g  | D] } | | k r< | ^ q< } | | f S(   s   Retrieves modified and added files from a working directory state
    and returns the subset of each contained in given changed files
    retrieved from a change context.i   (    (   t   wstatust   changedt   modifiedt   addedt   f(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt
   _preselect   s    %%t   kwtemplaterc           B   s   e  Z d  Z d   Z e j d    Z e j d    Z e j d    Z d   Z	 d   Z
 d   Z d   Z e d	  Z d
   Z d   Z d   Z RS(   sr   
    Sets up keyword templates, corresponding keyword regex, and
    provides keyword substitution functions.
    c         C   s   | |  _  | |  _ t j | j d g  | |  |  _ t d t j   k |  _ t |  _	 |  j  j
 d  } | r t d   | D  |  _ n t |  j   |  _ d  S(   NR   R   t   keywordmapsc         s   s-   |  ]# \ } } | t  j | t  f Vq d  S(   N(   R
   t   parsestringt   False(   t   .0t   kt   v(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pys	   <genexpr>   s   (   R+   t   repoR   t   roott   kwtoolst
   restrictedt   splitt   restrictR:   t
   postcommitt   configitemst   dictR,   R.   (   t   selfR+   R>   t   inct   exct   kwmaps(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   __init__   s    		!		c         C   s"   d j  t t j |  j j     S(   s+   Returns bar-separated and escaped keywords.t   |(   t   joint   mapt   ret   escapeR,   t   keys(   RG   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRP      s    c         C   s   t  j d |  j  S(   s&   Returns regex for unexpanded keywords.s   \$(%s)\$(   RO   t   compileRP   (   RG   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   rekw   s    c         C   s   t  j d |  j  S(   s$   Returns regex for expanded keywords.s   \$(%s): [^$\n\r]*? \$(   RO   RR   RP   (   RG   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   rekwexp   s    c            s"       f d   } | | |  S(   s1   Replaces keywords in data with expanded template.c            s   |  j  d  } t j  j  j t d  d t  } | j  j |   j j	   | j
   d  j j d  t j  j j    } d | | f S(   Ni   R   R?   t   files	   $%s: %s $(   t   groupR   t   changeset_templaterR+   R>   R:   t   Nonet   use_templateR,   t
   pushbuffert   showR?   R	   t	   firstlinet	   popbuffer(   t   mobjt   kwt   ctt   ekw(   t   ctxt   pathRG   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kwsub   s    (    (   RG   t   dataRc   Rb   R/   Rd   (    (   Rb   Rc   RG   s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt
   substitute   s    	c         C   s   |  j  j | d | j   S(   s4   Similar to filelog.linkrev, but returns a changectx.t   fileid(   R>   t   filectxt	   changectx(   RG   Rc   Rg   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   linkctx   s    c         C   s[   |  j  rW |  j |  rW t j |  rW |  j | |  } |  j | | | |  j j  S| S(   s$   Returns data with keywords expanded.(   RC   R   R   t   binaryRj   Rf   RS   t   sub(   RG   Rc   t   nodeRe   Rb   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   expand   s    )c         C   s;   g  | D]0 } |  j  |  r d | j |  k r | ^ q S(   sk   Returns subset of candidates which are configured for keyword
        expansion but are not symbolic links.t   l(   R   t   flags(   RG   t   candRb   R5   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   iskwfile   s    c         C   s  |  j  s | s |  j r- |  j | |  } n  | s7 d S|  j  oC | } |  j  s[ | rj | rj | j   } n  |  j  sy | r |  j } n	 |  j } | r t d  }	 n t d  }	 xf| D]^}
 |  j  r |  j j |
  j	 | |
  } n |  j j
 |
  } t j |  rq n  | rW| r3|  j |
 | |
  } n  |  j | |
 | | j  \ } } n3 |  j  rr| j |  } n t | | j  \ } } | r |  j j |	 |
  |  j j |
 d d t } | j |  | j   | r|  j j j |
  q|  j r|  j j j |
  qq q Wd S(   s7   Overwrites selected files expanding/shrinking keywords.Ns"   overwriting %s expanding keywords
s"   overwriting %s shrinking keywords
t   wbt
   atomictemp(   RC   RD   Rr   t   manifestRS   RT   R   R>   RU   t   readt   wreadR   Rk   Rj   Rf   t   subnt   searchR0   R+   t   notet   wopenert   Truet   writet   closet   dirstatet   normalt   normallookup(   RG   Rb   t
   candidatest   lookupRn   RS   t   kwcmdt   mft   re_kwt   msgR5   Re   t   foundt   fp(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt	   overwrite   sF    		"$	
	c         C   s6   |  j  |  r2 t j |  r2 t | |  j j  S| S(   s4   Returns text with all keyword substitutions removed.(   R   R   Rk   R0   RT   Rl   (   RG   t   fnameR   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   shrink  s    c         C   sP   |  j  |  rL d j |  } t j |  sL t | |  j j  j t  Sn  | S(   s1   Returns lines with keyword substitutions removed.R   (	   R   RM   R   Rk   R0   RT   Rl   t
   splitlinesR|   (   RG   R   t   linesR   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   shrinklines%  s
    c         C   s   |  j  r |  j | |  S| S(   s]   If in restricted mode returns data read from wdir with
        keyword substitutions removed.(   RC   R   (   RG   R   Re   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRw   -  s    	(   t   __name__t
   __module__t   __doc__RK   R   t   propertycacheRP   RS   RT   Rf   Rj   Rn   Rr   R:   R   R   R   Rw   (    (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR7      s   					*		t	   kwfilelogc           B   s8   e  Z d  Z d   Z d   Z d d d  Z d   Z RS(   s   
    Subclass of filelog to hook into its read, add, cmp methods.
    Keywords are "stored" unexpanded, and processed on reading.
    c         C   s/   t  t |   j | |  | |  _ | |  _ d  S(   N(   t   superR   RK   t   kwtRc   (   RG   t   openerR   Rc   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRK   9  s    	c         C   sD   t  t |   j |  } |  j |  r+ | S|  j j |  j | |  S(   s&   Expands keywords when reading filelog.(   R   R   Rv   t   renamedR   Rn   Rc   (   RG   Rm   Re   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRv   >  s    c         C   s=   |  j  j |  j |  } t t |   j | | | | | |  S(   s5   Removes keyword substitutions when adding to filelog.(   R   R   Rc   R   R   t   add(   RG   R   t   metat   trt   linkt   p1t   p2(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   E  s    c         C   s1   |  j  j |  j |  } t t |   j | |  S(   s-   Removes keyword substitutions for comparison.(   R   R   Rc   R   R   t   cmp(   RG   Rm   R   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   J  s    N(   R   R   R   RK   Rv   RX   R   R   (    (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   4  s
   		c      	   O   s   | rI | j  d t j | | |  d t d | j d  pE | j d   S|  j d  rp t j t d    n  t j t d    d S(	   s\   Bails out if [keyword] configuration is not active.
    Returns status of working directory.R   t   cleant   unknownt   allt   keywords   [keyword] patterns cannot matchs    no [keyword] patterns configuredN(	   t   statusR   R   R|   t   getRE   R   t   AbortR   (   R+   R>   t   wctxR   t   patst   opts(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   _statusO  s    $c         O   s   | d } t | j    d k r: t j t d    n  t d } | j   } z t |  | | | | |  } | \ }	 }
 } } } } } |	 s |
 s | s | r t j t d    n  | j	 | | t
 |  Wd | j   Xd S(   s7   Selects files and passes them to kwtemplater.overwrite.i   s   outstanding uncommitted mergeR
   s   outstanding uncommitted changesN(   RX   t   lent   parentsR   R   R   R@   t   wlockR   R   R|   t   release(   R+   R>   Rn   R   R   R   R   R   R   R3   R4   t   removedt   deletedR   t   ignoredR   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt	   _kwfwriteY  s    

t   kwdemot   dt   defaults"   show default keyword template mapsR5   t   rcfiles   read maps from rcfilet   FILEs+   hg kwdemo [-d] [-f RCFILE] [TEMPLATEMAP]...c            sN    f d   } d } t  j d d  }   j t d  |  t j | j | t  }   j d | d    j	 d d  }   j d d |    j
 d	  } | s | j d
  r  j t d   | r   j t d   n  | j d  s | r)| r  j t d   q)  j t d   n  | j d
  rQ  j | j d
   n  | rd g g  | D] }	 |	 d ^ qd}
 | j d d  } | j |
  | j     j | j d   n  t   j
 d	   } n | j d  rn| r   j t d   n   j t d   t    } | r  j t d   x0 | j   D] \ } }   j d	 | |  qEWqn4   j t d   | rt |  } n t    } t    t   |    j d  | d   j
 d   | d   j
 d   | d	 | j    d d j t | j     d } | j j | |  | d) j | g    j t d  |    j |  | j j d  x[   j
 d  D]J \ } } | j d d   d! j  d"  d# k r| j! j d | d  qqWt d$  }   j d% |  | j" d& |    j t d'     j | j# |   t$ j% | d( t d) S(*   s  print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend the current configuration by specifying maps as arguments
    and using -f/--rcfile to source an external hgrc file.

    Use -d/--default to disable current configuration.

    See :hg:`help templates` for information on templates and filters.
    c            sI     j  d |   x1 t |  D]# \ } }   j  d | | f  q Wd  S(   Ns   [%s]
s   %s = %s
(   R}   t   sorted(   t   sectiont   itemsR<   R=   (   R+   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt	   demoitems{  s    s   demo.txtR   s   kwdemo.s$   creating temporary repository at %s
R   R'   R(   R8   R   s3   
	configuration using custom keyword template maps
s!   	extending current template maps
R   s#   	overriding default svn keywordset
s#   	overriding default cvs keywordset
s   [keywordmaps]
s   
t   hgrct   ws-   
	configuration using default svn keywordset
s-   
	configuration using default cvs keywordset
s!   	disabling current template maps
s4   
	configuration using current keyword template maps
s   [extensions]
keyword =
t   $s   $
$s   $
s   
keywords written to %s:
t
   demobrancht   hookst   .i   i    t   commitis.   hg keyword configuration and expansion examples   hg ci -m '%s'
R   s   
	keywords expanded
t   ignore_errorsN(&   t   tempfilet   mkdtempRz   R   R   t   localrepositoryt   baseuiR|   t	   setconfigR*   RE   R   R   t
   readconfigR   t
   writelinesR~   RM   RF   R.   t	   iteritemst   uisetupt	   reposetupR}   R   RQ   R{   RX   R   R   t	   setbranchRB   t   findR+   R   Rw   t   shutilt   rmtree(   R+   R>   t   argsR   R   t   fnt   tmpdirR(   t   uikwmapst   at   rcmapsR   RJ   R<   R=   t   keywordst   namet   cmdR   (    (   R+   s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   demoi  sx    $

#%t   kwexpands!   hg kwexpand [OPTION]... [FILE]...c         O   s   t  |  | t | |  d S(   s   expand keywords in the working directory

    Run after (re)enabling keyword expansion.

    kwexpand refuses to run if given files contain local changes.
    N(   R   R|   (   R+   R>   R   R   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRn     s    	t   kwfilest   AR   s&   show keyword status flags of all filest   it   ignores"   show files excluded from expansiont   uR   s%   only show unknown (not tracked) filess    hg kwfiles [OPTION]... [FILE]...c         O   sO  t  d } | d } t |  | | | | |  } | rA | j   pD d } | \ } }	 }
 } } } } g  } | j d  s | j d  r t | |	 |  } n  | j | |  } | j | |  } | j | |  } | j d  s | j d  r| | | f } n g  g  g  f } | j d  s2| j d  r| g  | D] } | | k r<| ^ q<g  | D] } | | k r^| ^ q^f 7} n  d j   } t | d |  } |  j	 d |  } d	 } | j d  s|  j
 rd
 } n  xd | D]\ \ } } } d | } x@ | D]8 } | j   | j d | | | j | |  d | qWqW| j   d S(   s  show files configured for keyword expansion

    List which files in the working directory are matched by the
    [keyword] configuration patterns.

    Useful to prevent inadvertent keyword expansion and to speed up
    execution by including only files that are actual candidates for
    expansion.

    See :hg:`help keyword` on how to construct patterns both for
    inclusion and exclusion of files.

    With -A/--all and -v/--verbose the codes used to show the status
    of files are::

      K = keyword expansion candidate
      k = keyword expansion candidate (not tracked)
      I = ignored
      i = ignored (not tracked)
    R
   R   R   R   R   s5   enabled deleted enabledunknown ignored ignoredunknowns   K!kIiR   s   %.0s%s
s   %s %s
s   kwfiles.s   kwstatus patht   labelN(   R@   RX   R   t   getcwdR   R   Rr   RB   t   zipt	   formattert   verboset	   startitemR}   t   pathtot   end(   R+   R>   R   R   R   R   R   t   cwdR3   R4   R   R   R   R   R   t   filesR   t	   kwdeletedt	   kwunknownt	   showfilesR5   t   kwlabelst   kwstatest   fmt   fmtt   kwstatet   chart	   filenamesR   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR     s<    

%,	

!t   kwshrinks!   hg kwshrink [OPTION]... [FILE]...c         O   s   t  |  | t | |  d S(   s   revert expanded keywords in the working directory

    Must be run before changing/disabling active keywords.

    kwshrink refuses to run if given files contain local changes.
    N(   R   R:   (   R+   R>   R   R   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   
  s    	c         C   s    d   } t  j t d |  d S(   s8    Monkeypatches dispatch._parse to retrieve user command.c         S   s;   |  | |  \ } } } } } | t  d <| | | | | f S(   s9   Monkeypatch dispatch._parse to obtain running hg command.R   (   R@   (   t   origR+   R   R   t   funct   optionst
   cmdoptions(    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kwdispatch_parse  s    
t   _parseN(   R   t   wrapfunctionR   (   R+   R   (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR     s    	c            sy  yU | j    sP t d t j   k sP d t j | j  k sP | j j d  rT d SWn t	 k
 rh n Xg  d g } } xF |  j
 d  D]5 \ } } | d k r | j |  q | j |  q W| s d St |  | | |  t d < d	 | j f    f d
     Y  d  f d  } d d d d d d  f d  }  f d   }  f d   }	 t  f d  }
  f d   }  f d   } t j t j d |  t j t j d |  t j t d |  t j t d |	  t j t d |
  x' d j   D] } t j t | |  qWxN t j   D]@ } y& t j |  } t j | d |  Wq(t k
 rgq(Xq(W  | _ d S(   s  Sets up repo as kwrepo for keyword substitution.
    Overrides file method to return kwfilelog instead of filelog
    if file matches user configuration.
    Wraps commit to overwrite configured files with updated
    keyword substitutions.
    Monkeypatches patch and webcommands.R   s   .hgs   bundle:Ns   .hg*R   R   R
   t   kwrepoc              se   e  Z  f d    Z    f d   Z   f d   Z e    f d  Z e e    f d  Z RS(   c            s0   | d d k r | d } n  t  |  j   |  S(   Ni    t   /i   (   R   t   sopener(   RG   R5   (   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRU   =  s    c            s(   t    |   j |  }  j | |  S(   N(   R   Rw   (   RG   t   filenameRe   (   R   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyRw   B  s    c            s7   |  j  |  _ z t   |   j | |   SWd  |  ` Xd  S(   N(   t   kwcommitctxt	   commitctxR   R   (   RG   R   R   (   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   F  s    c            sv   t    |   j | |  }  j sr  j } t  _  j |  | t | j   | j    t	 t  |  _ n  | S(   N(
   R   R  RD   RC   R|   R   R   R4   R3   R:   (   RG   Rb   t   errort   nRC   (   R   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR  O  s    			&
c   	         s   |  j    } z | s( |  d j   } n  t   |   j | |  } | s |  d } t |  d  j   |  \ } }  j | | t t   j | | t t	  n  | SWd  | j
   Xd  S(   NR   (   R   R   R   t   rollbackR6   RX   R   R   R|   R:   R   (	   RG   t   dryrunt   forceR   R2   t   retRb   R3   R4   (   R   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR  Z  s    
(   R   R   RU   Rw   R   R:   R  R  (    (   R   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   <  s
   	c            s8   |  | | | | | |    j  | j | j  | _ d S(   sx   Monkeypatch/wrap patch.patchfile.__init__ to avoid
        rejects or conflicts due to expanded keywords in working dir.N(   R   R   R   (   R   RG   R+   t   gpt   backendt   storet   eolmode(   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kwpatchfile_initj  s    R   c            s%   t    _ |  | | | | | | |  S(   s*   Monkeypatch patch.diff to avoid expansion.(   R|   RC   (   R   R>   t   node1t   node2R   t   changesR   t   prefix(   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kw_diffq  s    	c            s   t  j   _ |  | | |  S(   s2   Wraps webcommands.x turning off keyword expansion.(   R   t   neverR   (   R   t   webt   reqt   tmpl(   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt
   kwweb_skipw  s    c            s   | j    } z| t   _ |  | | | | | | |  }	 |	 | j   k r | |	 }
 t   _   j |
 |
 j   t t  t   _ n  |	 SWd | j   Xd S(   s3   Wraps cmdutil.amend expanding keywords after amend.N(	   R   R|   RD   Rm   RC   R   R   R:   R   (   R   R+   R>   t
   commitfunct   oldt   extraR   R   R   t   newidRb   (   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kw_amend|  s    	
	c   
         s    j    } z |  |  | | |  | j d  r8 d S d   j          f d   } g   j j   D]- } d  j |  k rv | |  rv | ^ qv }	  j  |	 t t  Wd | j	   Xd S(   s  Wraps cmdutil.copy so that copy/rename destinations do not
        contain expanded keywords.
        Note that the source of a regular file destination may also be a
        symlink:
        hg cp sym x                -> x is symlink
        cp sym x; hg cp -A sym x   -> x is file (maybe expanded keywords)
        For the latter we have to follow the symlink to find out whether its
        target is configured for expansion and we therefore must unexpand the
        keywords in the destination.t   dry_runNc            s[    j  j |   } d  j |  k rN t j  j   t j j |   } n   j	 |  S(   s   Returns true if dest is a regular file and configured for
                expansion or a symlink which points to a file configured for
                expansion. Ro   (
   R   t   copiedRp   R   t	   canonpathR?   t   osRc   t   realpathR   (   t   destt   source(   R   R   R>   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   haskwsource  s
    Ro   (
   R   R   RX   R   R   t   copiesRp   R   R:   R   (
   R   R+   R>   R   R   t   renameR   R%  R5   R   (   R   (   R   R>   R   s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kw_copy  s    


-c            s   | j    } z t   _ | d } | d j   } |  | | | | |  }	 | d }
 | |
 k r t | |
 j    \ } } t   _   j	 |
 | t t    j	 |
 | t t t  t   _ n  |	 SWd | j
   Xd S(   s9   Wraps record.dorecord expanding keywords after recording.R   N(   R   R|   RD   RX   R   R6   R   R:   RC   R   R   (   R   R+   R>   R  R   R   R   Rb   R1   R	  t   recctxR3   R4   (   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kw_dorecord  s    	

	c            s   | j  d  k r^ | j j sv   j | j    rB d | j   k sv | j   d | j   k sv | j   | j   k r | j j	 | j
 | j    St S(   NRo   i   (   t   _filerevRX   t   _repot   _encodefilterpatsR   Rc   Rp   t   sizet   _filelogR   t	   _filenodeRe   R|   (   R   RG   t   fctx(   R   (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   kwfilectx_cmp  s    'R   RK   t   difft   amendt   copys$   annotate changeset rev filediff difft   dorecord(   t   localR@   t   nokwcommandsRB   R   t	   splitpathR?   t   _urlt
   startswitht   AttributeErrorRE   t   appendR7   t	   __class__RX   R:   R   R   R   Rh   R   t	   patchfileR   R   t   recordextensionsR   t   KeyError(   R+   R>   RH   RI   t   patt   optR  R  R  R  R(  R*  R2  t   cR   R   (    (   R   R   s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyR   !  sL    #"."(6   R   t	   mercurialR    R   R   R   R   R   R   R   R   R	   R
   R   R   t   mercurial.hgwebR   t   mercurial.i18nR   R!  RO   R   R   t   optionalrepot	   inferrepot   cmdtablet   commandt
   testedwithR8  RA   R@  t
   colortableR   R   R   t   filtersR)   RX   R@   R.   R0   R6   t   objectR7   R   R   R   R   t   walkoptsRn   R   R   R   R   (    (    (    s1   /sys/lib/python2.7/site-packages/hgext/keyword.pyt   <module>R   sb   ..0
						
	
		W$6$	