ó
€ˆtPc        
   @   së   d  Z  d d l m Z m Z m Z m Z d d l m Z d d l Z d d l	 Z	 i  Z
 e j e
 ƒ Z d Z e d d d d e d	 ƒ f d
 d d e d ƒ f d d d e d ƒ f d d d e d ƒ f g e j e d ƒ ƒ d „  ƒ Z d S(   s<   command to delete untracked files from the working directoryiÿÿÿÿ(   t   utilt   commandst   cmdutilt   scmutil(   t   _Nt   internals   purge|cleant   as   abort-on-errs   abort if an error occurst    t   alls   purge ignored files toot   pt   prints(   print filenames instead of deleting themt   0t   print0s?   end filenames with NUL, for use with xargs (implies -p/--print)s   hg purge [OPTION]... [DIR]...c   
         sR  ˆ d ‰  d ‰ ˆ d r* d ‰ t  ‰  n  ‡  ‡ ‡ ‡ ‡ f d †  } d „  } g  } t j ˆ d | ˆ ƒ } | j | _ ˆ j d | d ˆ d	 d
 t ƒ } xD t | d | d ƒ D]* }	 ˆ j	 t
 d ƒ |	 ƒ | | |	 ƒ q´ Wxi t | d t ƒD]U }	 | |	 ƒ rõ t j ˆ j |	 ƒ ƒ rõ ˆ j	 t
 d ƒ |	 ƒ | t j |	 ƒ qõ qõ Wd S(   s  removes files not tracked by Mercurial

    Delete files not known to Mercurial. This is useful to test local
    and uncommitted changes in an otherwise-clean source tree.

    This means that purge will delete:

    - Unknown files: files marked with "?" by :hg:`status`
    - Empty directories: in fact Mercurial ignores directories unless
      they contain files under source control management

    But it will leave untouched:

    - Modified and unmodified tracked files
    - Ignored files (unless --all is specified)
    - New files added to the repository (with :hg:`add`)

    If directories are given on the command line, only files in these
    directories are considered.

    Be careful with purge, as you could irreversibly delete some files
    you forgot to add to the repository. If you only want to print the
    list of files that this program would delete, use the --print
    option.
    R
   s   
R   t    c            s’   ˆ  rw y |  ˆ j  | ƒ ƒ WqŽ t k
 rs t d ƒ | } ˆ d rY t j | ƒ ‚ n  ˆ j t d ƒ | ƒ qŽ Xn ˆ j d | ˆ f ƒ d  S(   Ns   %s cannot be removedt   abort_on_errs   warning: %s
s   %s%s(   t   wjoint   OSErrorR   R    t   Abortt   warnt   write(   t   remove_funct   namet   m(   t   actt   eolt   optst   repot   ui(    s/   /sys/lib/python2.7/site-packages/hgext/purge.pyt   removeK   s    
c         S   s„   y t  j |  ƒ Wnl t k
 r t  j |  ƒ } | j t j @d k rL ‚  n  t  j |  t j | j ƒ t j Bƒ t  j |  ƒ n Xd  S(   Ni    (   t   osR   R   t   statt   st_modet   S_IWRITEt   chmodt   S_IMODE(   t   patht   s(    (    s/   /sys/lib/python2.7/site-packages/hgext/purge.pyt
   removefileW   s    #t   matcht   ignoredR   t   unknowni   i   s   removing file %s
t   reverses   removing directory %s
N(   t   FalseR   R&   t   Nonet   appendt   dirt   statust   Truet   sortedt   noteR   R   t   listdirR   t   rmdir(
   R   R   t   dirsR   R   R%   t   directoriesR&   R.   t   f(    (   R   R   R   R   R   s/   /sys/lib/python2.7/site-packages/hgext/purge.pyt   purge#   s$    "
		"%(   t   __doc__t	   mercurialR    R   R   R   t   mercurial.i18nR   R   R   t   cmdtablet   commandt
   testedwithR+   t   walkoptsR7   (    (    (    s/   /sys/lib/python2.7/site-packages/hgext/purge.pyt   <module>   s   "