
OcIc           @   s  d  Z  d d k l Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k	 Z	 d d k
 Z
 d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d   Z d   Z d d d     YZ e i e  d d d	     YZ e i e  d
 d d     YZ d e i f d     YZ d e f d     YZ d S(   s:   High level functions for mirroring and mirror+incrementingi(   t
   generatorsNc         C   s   t  i d |  i | i f d  |  i i i } | i i i } | i   } | i | | d  | i	 |  } | i
 |  } | i | |  d S(   s(   Turn dest_rpath into a copy of src_rpaths   Starting mirror %s to %si   i    N(   t   logt   Logt   patht   connt   backupt   SourceStructt   DestinationStructt   get_source_selectt   set_rorp_cachet   get_sigst	   get_diffst   patch(   t	   src_rpatht
   dest_rpatht   SourceSt   DestSt   source_rpitert   dest_sigitert   source_diffiter(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   Mirror   s     c         C   s   t  i d |  i | i f d  |  i i i } | i i i } | i   } | i | | d  | i	 |  } | i
 |  } | i | | |  d S(   s2   Mirror + put increments in tree based at inc_rpaths%   Starting increment operation %s to %si   i   N(   R   R   R   R   R   R   R   R   R	   R
   R   t   patch_and_increment(   R   R   t	   inc_rpathR   R   R   R   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   Mirror_and_increment(   s    	R   c           B   s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   s-   Hold info used on source side when backing upc         G   s_   t  i |  } | i | |  | i   t i d } t i | |  |  _ t i	 d |  d S(   sj  Initialize select object using tuplelist

		Note that each list in filelists must each be passed as
		separate arguments, so each is recognized as a file by the
		connection.  Otherwise we will get an error because a list
		containing files can't be pickled.

		Also, cls._source_select needs to be cached so get_diffs below
		can retrieve the necessary rps.

		i   t   select_mirrorN(
   t	   selectiont   Selectt	   ParseArgst   set_itert   Globalst   pipeline_max_lengtht   rorpitert   CacheIndexablet   _source_selectt   set(   t   clst   rpatht	   tuplelistt	   filelistst   selt
   cache_size(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   set_source_select9   s    
c         C   s   |  i  S(   s7   Return source select iterator, set by set_source_select(   R!   (   R#   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   L   s    c         #   s  |  i  } t i d      f d   }   f d   } x | D] } | t i j o t i Vq= n | i | i  p t i	 | i  } | i
   } | i   o | i | i    nW | i   o2 | i   o | | | |  q| | |  n | i   | i d  | Vq= Wd S(   s8   Return diffs of any files with signature in dest_sigitert	   ListErrorc            s]   t  i   t i i | d f  } | o |  i t i |   n |  i   |  i	 d  d S(   s7   Attach file of snapshot to diff_rorp, w/ error checkingt   rbt   snapshotN(
   t   robustt   check_common_errorR$   t   RPatht   opent   setfilet   hasht   FileWrappert   zerot   set_attached_filetype(   t	   diff_rorpt   src_rpt   fileobj(   t   error_handler(    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   attach_snapshotT   s     
c            s^   t  i   t i | | f  } | o |  i |  |  i d  n |  i   |  i d  d S(   s3   Attach file of diff to diff_rorp, w/ error checkingt   diffR,   N(   R-   R.   t   Rdifft   get_delta_sigrp_hashR1   R5   R4   (   R6   R7   t   dest_sigR8   (   R9   (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   attach_diff\   s    
R,   N(   R!   R-   t   get_error_handlert   iterfilet   MiscIterFlushRepeatt   MiscIterFlusht   gett   indexR$   t   RORPatht
   getRORPatht   isflaglinkedt
   flaglinkedt   get_link_flagt   isregt   close_if_necessaryR5   (   R#   R   t
   source_rpsR:   R?   R>   R7   R6   (    (   R9   s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   P   s*    	  
N(   t   __name__t
   __module__t   __doc__t   NoneR!   R)   R   R   (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   6   s
   		R   c           B   sS   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d	 d  Z d   Z	 RS(
   s2   Hold info used by destination side when backing upi   c            sO     f d   } t  i   | o( t  i i t i  } | o | SqH n |   S(   s   Return destination select rorpath iterator

		If metadata file doesn't exist, select all files on
		destination except rdiff-backup-data directory.

		c             s#   t  i    }  |  i   |  i   S(   s-   Get the combined iterator from the filesystem(   R   R   t   parse_rbdir_excludeR   (   R'   (   R$   (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   get_iter_from_fs   s    
(   t   metadatat
   SetManagert
   ManagerObjt	   GetAtTimet   Timet   prevtime(   R#   R$   t   use_metadataRS   t	   rorp_iter(    (   R$   s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   get_dest_select}   s    
 c         C   sD   |  i  | |  } t i | |  } t | t i d |  |  _ d S(   s   Initialize cls.CCPP, the destination rorp cache

		for_increment should be true if we are mirror+incrementing,
		false if we are just mirroring.

		i   N(   R\   R   t   Collate2Iterst   CacheCollatedPostProcessR   R   t   CCPP(   R#   t   baserpt   source_itert   for_incrementt	   dest_itert   collated(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR	      s    c         c   s   t  i d } d } x |  i D] \ } } t  i t  i j	 o- | d 7} | | j o d } t i Vqi n | o/ | o( | | j o t  i p t i	 | |  pV | o
 | i
 p | i
 } |  i | | | |  } | o |  i i |  | Vq q q Wd S(   s   Yield signatures of any changed destination files

		If we are backing up across a pipe, we must flush the pipeline
		every so often so it doesn't get congested on destination end.

		i   i    i   N(   R   R   R_   t   backup_readert   backup_writerRA   RB   t   preserve_hardlinkst   Hardlinkt   rorp_eqRE   t   get_one_sigt   flag_changed(   R#   t   dest_base_rpatht   flush_thresholdt   num_rorps_seent   src_rorpt	   dest_rorpRE   t   sig(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR
      s$    
 
c         C   s   t  i o@ | o9 t i |  o) t i |  } | i t i |   n{ | od | i   } | i	   oG t
 i | |  } |  i |  } | d j o d Sn | i |  q n t i |  } | S(   s5   Return a signature given source and destination rorpsN(   R   Rg   Rh   t   islinkedR$   RF   RI   t   get_link_indexRG   RK   t   longnamet   get_mirror_rpt   get_one_sig_fpRQ   R1   (   R#   Rl   RE   Ro   Rp   R>   t   dest_rpt   sig_fp(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyRj      s     c         C   s  | i    p t i i d | d  d Sn t i d j o6 | i   o( | i   o | i	 d | i
   B n y t i |  SWn t j
 o } | i t i j ob y( | i	 d | i
   B t i |  SWqt t f j
 o! t i i d | i f  qXq  n Xd S(   s?   Return a signature fp of given index, corresponding to reg filet   UpdateErrors/   File changed from regular file before signaturei    i   s9   Could not open %s for reading. Check permissions on file.N(   RK   R   t   ErrorLogt   write_if_openRQ   R   t   process_uidt   readablet   isownert   chmodt   getpermsR<   t   get_signaturet   IOErrort   errnot   EPERMt   OSErrorR   t
   FatalErrorR   (   R#   Rw   t   e(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyRv      s$    c         C   s   t  i t | |  i g  } xD t  i | |  D]0 } t i d | i   d  | | i |  q. W| i	   |  i i
   | i   d S(   s*   Patch dest_rpath with an rorpiter of diffss   Processing changed file i   N(   R   t   IterTreeReducert	   PatchITRBR_   t
   FillInIterR   R   t   get_indexpathRE   t   Finisht   closet   setdata(   R#   R   R   t   start_indext   ITRR;   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR      s     
c         C   s   t  i t | | |  i g  } xD t  i | |  D]0 } t i d | i   d  | | i |  q1 W| i	   |  i i
   | i   d S(   s<   Patch dest_rpath with rorpiter of diffs and write incrementss   Processing changed file i   N(   R   R   t   IncrementITRBR_   R   R   R   R   RE   R   R   R   (   R#   R   R   R   R   R;   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR      s    	 
(    (
   RN   RO   RP   R\   R	   R
   Rj   Rv   R   R   (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   {   s   				
R^   c           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s  Cache a collated iter of (source_rorp, dest_rorp) pairs

	This is necessary for three reasons:

	1.  The patch function may need the original source_rorp or
	    dest_rp information, which is not present in the diff it
	    receives.

	2.  The metadata must match what is stored in the destination
	    directory.  If there is an error, either we do not update the
	    dest directory for that file and the old metadata is used, or
	    the file is deleted on the other end..  Thus we cannot write
	    any metadata until we know the file has been procesed
	    correctly.

	3.  We may lack permissions on certain destination directories.
	    The permissions of these directories need to be relaxed before
	    we enter them to computer signatures, and then reset after we
	    are done patching everything inside them.

	4.  We need some place to put hashes (like SHA1) after computing
	    them and before writing them to the metadata.

	The class caches older source_rorps and dest_rps so the patch
	function can retrieve them if necessary.  The patch function can
	also update the processed correctly flag.  When an item falls out
	of the cache, we assume it has been processed, and write the
	metadata for it.

	c         C   s   | |  _  | |  _ | |  _ t i   |  _ t i o t i i	   n t
 i i   |  _ h  |  _ g  |  _ g  |  _ g  |  _ d S(   s   Initialize new CCWP.N(   t   iterR(   t   dest_root_rpt
   statisticst   init_statfileobjt   statfileobjR   t   file_statisticst	   FileStatst   initRT   RV   t	   GetWritert
   metawritert
   cache_dictt   cache_indiciest   dir_perms_listt   parent_list(   t   selft   collated_iterR(   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   __init__  s    			
 			c         C   s   |  S(   N(    (   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   __iter__<  s    c         C   s   |  i  i   \ } } |  i | |  | o
 | i p | i } | | d d d g |  i | <|  i i |  t |  i  |  i	 j o |  i
   n | | f S(   s@   Return next (source_rorp, dest_rorp) pair.  StopIteration passedi    N(   R   t   nextt   pre_processRE   RQ   R   R   t   appendt   lenR(   t   shorten_cache(   R   t   source_rorpRp   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   >  s     c         C   sx   t  i o | o t i | |  n | oH | i   o; t  i d j o+ | i   d d j  o |  i | |  n d S(   s   Do initial processing on source_rorp and dest_rorp

		It will not be clear whether source_rorp and dest_rorp have
		errors at this point, so don't do anything which assumes they
		will be backed up correctly.

		i    i   i  N(   R   Rg   Rh   t   add_rorpt   isdirR|   R   t   unreadable_dir_init(   R   R   Rp   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   I  s
    $c         C   sd   |  i  i | i  } | i d | i   B | o- | i   o  |  i i | | i   f  n d S(   s   Initialize an unreadable dir.

		Make it readable, and if necessary, store the old permissions
		in self.dir_perms_list so the old perms can be restored.

		i  N(   R   t	   new_indexRE   R   R   R   R   R   (   R   R   Rp   Rw   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   W  s    c      	   C   s   |  i  d } |  i  d =y  |  i | \ } } } } } Wn. t j
 o" t i d | f d  d Sn X|  i | =|  i | | | | |  |  i o |  i |  n |  i | | |  d S(   s=   Remove one element from cache, possibly adding it to metadatai    s(   Warning index %s missing from CCPP cachei   N(	   R   R   t   KeyErrorR   R   t   post_processR   t   reset_dir_permst   update_parent_list(   R   t   first_indext   old_source_rorpt   old_dest_rorpt   changed_flagt   success_flagt   inc(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   c  s    
 		

 c         C   s  | o | i    p | o
 | i    p d Sn |  i p | d j p
 t |  n |  i d d } t |  t |  } } | | j o% | | d j p t | | f  n4 | | d  | d  j p
 t |  |  i |  |  _ |  i i | | | f f  d S(   sI  Update the parent cache with the recently expired main cache entry

		This method keeps parent directories in the secondary parent
		cache until all their children have expired from the main
		cache.  This is necessary because we may realize we need a
		parent directory's information after we have processed many
		subfiles.

		Nii    i   (    (   R   R   t   AssertionErrorR   R   (   R   RE   Ro   Rp   t   last_parent_indext   lp_indext   li(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   s  s    
 
 %#c         C   s#  t  i o | o t i |  n | p | o: | o |  i i |  n | o |  i i |  qk n | d j o
 | } n | d j o
 | } n d } | d j p | d j o |  i i | |  n | o! | i	   o |  i
 i |  n t  i o t i i | | | |  n d S(   s  Post process source_rorp and dest_rorp.

		The point of this is to write statistics and metadata.

		changed will be true if the files have changed.  success will
		be true if the files have been successfully updated (this is
		always false for un-changed files).

		i    i   i   N(   R   Rg   Rh   t   del_rorpR   t   add_source_filet   add_dest_fileRQ   t   add_changedt   lstatR   t   write_objectR   R   R   t   update(   R   R   Rp   t   changedt   successR   t   metadata_rorp(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s$    
   
 

c         C   sU   |  i  d \ } } | i } | | j o( | t |   | j o | i |  n d S(   s;   Reset the permissions of directories when we have left themiN(   R   RE   R   R   (   R   t   current_indext   dir_rpt   permst	   dir_index(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s
    	c         C   s   |  i  i |  S(   s$   Return true if given index is cached(   R   t   has_key(   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   in_cache  s    c         C   s   d |  i  | d <d S(   s>   Signal that the file with given index was updated successfullyi   i   N(   R   (   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   flag_success  s    c         C   s   d |  i  | d <d S(   s,   Signal that the destination file was deletedi   i   N(   R   (   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   flag_deleted  s    c         C   s   d |  i  | d <d S(   s1   Signal that the file with given index has changedi   i   N(   R   (   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyRk     s    c         C   s   | |  i  | d <d S(   s%   Set the increment of the current filei   N(   R   (   R   RE   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   set_inc  s    c         C   s?   x, |  i  D]! \ } } | | j o | Sq
 q
 Wt |   d S(   s5   Retrieve (src_rorp, dest_rorp) pair from parent cacheN(   R   R   (   R   RE   t   parent_indext   pair(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   get_parent_rorps  s
    
  c         C   s:   y |  i  | d  SWn  t j
 o |  i |  Sn Xd S(   s,   Retrieve (source_rorp, dest_rorp) from cachei   N(   R   R   R   (   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt	   get_rorps  s      c         C   sy   | |  i  d j p' t d t |  t |  i  d  f  y |  i | d SWn$ t j
 o |  i |  d Sn Xd S(   s0   Retrieve source_rorp with given index from cachei    s   CCPP index out of order: %s %sN(   R   R   t   reprR   R   R   (   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   get_source_rorp  s    !  c         C   s>   y |  i  | d SWn$ t j
 o |  i |  d Sn Xd S(   s0   Retrieve mirror_rorp with given index from cachei   N(   R   R   R   (   R   RE   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   get_mirror_rorp  s      c         C   s   |  i  |  i |  d S(   s"   Update the source rorp's SHA1 hashN(   R   t   set_sha1(   R   RE   t   sha1sum(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   update_hash  s    c         C   sA   t  i |  } | p d Sn |  i | i  } | i |  d S(   s=   Tag associated source_rorp with same hash diff_rorp points toN(   Rh   t   get_sha1R   RE   R   (   R   R6   R   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   update_hardlink_hash  s
     c         C   s   x |  i  o |  i   q Wx1 |  i o& |  i i   \ } } | i |  q W|  i i   t i i	   t
 i o t i   n t
 i o t i i   n t i   d S(   s+   Process the remaining elements in the cacheN(   R   R   R   t   popR   R   R   RT   RV   t   ConvertMetaToDiffR   t   print_statisticsR   t   print_active_statsR   R   t   write_active_statfileobj(   R   R   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s     
  

 
 (   RN   RO   RP   R   R   R   R   R   R   R   R   R   R   R   R   Rk   R   R   R   R   R   R   R   R   (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR^      s,   	"																			R   c           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z RS(   sM  Patch an rpath with the given diff iters (use with IterTreeReducer)

	The main complication here involves directories.  We have to
	finish processing the directory after what's in the directory, as
	the directory may have inappropriate permissions to alter the
	contents or the dir's mtime could change as we change the
	contents.

	c         C   sp   | |  _  | i t i j p t  t i   p
 t i   |  _ d \ |  _
 |  _ | |  _ t i d  |  _ d S(   s9   Set basis_root_rp, the base of the tree to be incrementedRy   N(   NN(   t   basis_root_rpR   R   t   local_connectionR   R   t   get_active_statfileobjt   StatFileObjR   RQ   t   dir_replacementt
   dir_updateR_   R-   R@   R9   (   R   R   R_   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s    		c         C   s1   |  i  i |  } | i   p | o
 | i   S(   s0   True if diff_rorp and mirror are not directories(   R_   R   R   (   R   RE   R6   t   mirror_rorp(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   can_fast_process  s    c         C   s  t  i |  i i |  |  i  \ } } | i   p
 t |  t i |  } |  i	 | | |  o | i
   oJ t i |  i t i | | f  d j o |  i i |  q | i   q| o+ | i
   o | i   |  i i |  qn& | i   | i
   o | i   n d S(   s>   Patch base_rp with diff_rorp (case where neither is directory)N(   Rt   t   get_mirror_inc_rpsR_   R   R   R   R   t   TempFilet   newt   patch_to_tempR   R-   R.   R9   R$   t   renameRQ   R   t   deleteR   R   (   R   RE   R6   t	   mirror_rpt   discardt   tf(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   fast_process  s     !

 c         C   s   | i    o |  i | |  nl | i   d j o: |  i | |  } | p d Sq | d j o d Sq n |  i | | |  p d Sn | i   o" | i    o t i | |  n |  i | |  S(   s   Patch basis_rp, writing output in new, which doesn't exist yet

		Returns true if able to write new as desired, false if
		UpdateError or similar gets in the way.

		R,   i    i   i   (	   RH   t   patch_hardlink_to_tempt   get_attached_filetypet   patch_snapshot_to_tempt   patch_diff_to_tempR   R$   t   copy_attribst   matches_cached_rorp(   R   t   basis_rpR6   R   t   result(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s      c         C   s*   t  i | | |  i  |  i i |  d S(   s4   Hardlink diff_rorp to temp, update hash if necessaryN(   Rh   t   link_rpR   R_   R   (   R   R6   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   2  s    c         C   s   | i    o( |  i | |  t i | |  d Sn t i |  i t i | | f  } t | t	 i
  o! |  i i | i | i  d Sn | d j S(   s   Write diff_rorp to new, return true if successful

		Returns 1 if normal success, 2 if special file is written,
		whether or not it is successful.  This is because special
		files either fail with a SpecialFileError, or don't need to be
		compared.

		i   i   i    (   t	   isspecialt   write_specialR$   R   R-   R.   R9   t   copyt
   isinstanceR2   t   ReportR_   R   RE   t   sha1_digest(   R   R6   R   t   report(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   7  s    	c         C   s|   | i    d j p t  t i |  i t i | | | f  } t | t i	  o! |  i
 i | i | i  d Sn | d j S(   s0   Apply diff_rorp to basis_rp, write output in newR;   i   i    (   R   R   R-   R.   R9   R<   t   patch_localR   R2   R   R_   R   RE   R   (   R   R   R6   R   R  (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   L  s    c         C   sm   | i    p d Sn |  i i | i  } | o | i |  o d Sn t i i d | d | i f  d S(   s  Return true if new_rp matches cached src rorp

		This is a final check to make sure the temp file just written
		matches the stats which we got earlier.  If it doesn't it
		could confuse the regress operation.  This is only necessary
		for regular files.

		i   Ry   s1   Updated mirror temp file %s does not match sourcei    (	   RK   R_   R   RE   t   equal_looseR   Rz   R{   R   (   R   R6   t   new_rpt   cached_rorp(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   V  s    	  c         C   sk   t  i d  } t  i | t i | | f  d j o3 | i   | i   o | i   n | i   n d S(   s1   Write diff_rorp (which holds special file) to newt   SpecialFileErrori    N(	   R-   R@   R.   R$   R   R   R   R   t   touch(   R   R6   R   t   eh(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR   f  s    %
 c         C   s   t  i |  i i |  |  i  \ |  _ } | i   o |  i | |  i  nL |  i | |  i  o5 | i	   o |  i i
 |  q |  i i |  n d S(   s9   Start processing directory - record information for laterN(   Rt   R   R_   R   R   t   base_rpR   t   prepare_dirt   set_dir_replacementR   R   R   (   R   RE   R6   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   start_processn  s    $  c         C   s   | i    d j p t  t i |  |  _ |  i d | |  i  pK |  i i   o |  i i   n t	 i
 |  i i | i  |  i  d Sn d Sd S(   s   Set self.dir_replacement, which holds data until done with dir

		This is used when base_rp is a dir, and diff_rorp is not.
		Returns 1 for success or 0 for failure

		R,   i    i   N(   R   R   R   R   R   R   RQ   R   R   R$   t   copy_with_attribsR_   R   RE   (   R   R6   R	  (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR  w  s     
c         C   s   | i    |  _ | i   pI | i   o |  i i   n | i   | i   |  i i	 | i
  n. |  i i | i
  o |  i i	 | i
  n d S(   s!   Prepare base_rp to be a directoryN(   RG   R   R   R   R	  R   R   t   mkdirR_   R   RE   R   (   R   R6   R	  (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR
    s     

c         C   s   |  i  o| |  i i   p t  t i |  i  |  i  t i d j o; |  i  i   d d j  o! |  i i	 d |  i  i   B q nF |  i
 o; |  i i   |  i
 i   o t i |  i
 |  i  q n d S(   s   Finish processing directoryi    i   i  N(   R   R	  R   R   R$   R   R   R|   R   R   R   t   rmdirR   R   (   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyt   end_process  s    
%
(   RN   RO   RP   R   R   R   R   R   R   R   R   R   R  R  R
  R  (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s   		
						
						R   c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sw   Patch an rpath with the given diff iters and write increments

	Like PatchITRB, but this time also write increments.

	c         C   s    | |  _  t i |  | |  d  S(   N(   t   inc_root_rpR   R   (   R   R   R  t
   rorp_cache(    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s    	c         C   sy  t  i |  i i |  |  i |  i  \ } } t i |  } |  i | | |  o t	 i
 |  i t i | | | f  } | d j	 o t | t  o |  i i | |  | i   o | i   n | i   oJ t	 i
 |  i t i | | f  d j o |  i i |  qD| i   n, | i   o | i   |  i i |  n d SqPn | i   | i   o | i   n d S(   sA   Patch base_rp with diff_rorp and write increment (neither is dir)N(   Rt   R   R_   R   R   R  R   R   R   R-   R.   R9   t	   incrementt	   IncrementRQ   R   t   intR   RK   t   fsync_with_dirR   R$   R   R   R   R   R   (   R   RE   R6   R   t
   inc_prefixR   R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s,    '

 c         C   sU  t  i |  i i |  |  i |  i  \ |  _ } |  i i   | i   p9 |  i i   p) t	 d t
 | i  t
 |  i i  f  | i   o^ t i | |  i |  } | o | i   o | i   n |  i i   |  i | |  i  nd |  i | |  i  oM t i |  i |  i |  } | o' |  i i | |  |  i i |  qQn d S(   s   Start processing directorys#   Either %s or %s must be a directoryN(   Rt   R   R_   R   R   R  R	  R   R   R   R   R   R  R  RK   R  R
  R  R   R   R   (   R   RE   R6   R  R   (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR    s$    * 	(   RN   RO   RP   R   R   R  (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pyR     s   		(    (    (    (   RP   t
   __future__R    R   R   RT   R   R   Rh   R-   R  R$   t   staticR   R   RX   R<   R   RA   R2   Rt   R   R   R   t	   MakeClassR   R^   t	   ITRBranchR   R   (    (    (    s8   /var/lib/python-support/python2.5/rdiff_backup/backup.pys   <module>   s   		B}