ó
3Rc           @   sH   d  Z  d d l Z d d l Z d d l m Z d e f d     YZ d S(   sD   Handle checkin and checkout of archives from the pristine-tar branchi˙˙˙˙N(   t   Commandt   PristineTarc           B   sG   e  Z d  Z d Z d Z d   Z d   Z d   Z d   Z d   Z	 RS(   s+   The pristine-tar branch in a git repositorys   /usr/bin/pristine-tars   pristine-tarc         C   s/   | |  _  t t |   j |  j d | j d  S(   Nt   cwd(   t   repot   superR   t   __init__t   cmdt   path(   t   selfR   (    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyR      s    	c         C   s   |  j  |  r t St S(   s  
        Do we have a pristine-tar commit for package I{package} at version
        {version} with compression type I{comp_type}?

        @param archive_regexp: archive name to look for (regexp wildcards allowed)
        @type archive_regexp: C{str}
        (   t
   get_committ   Truet   False(   R   t   archive_regexp(    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyt
   has_commit    s    c         C   sa   |  j  j   s d Sd | } |  j  j | |  j  } | r] | d } t j j d |  | Sd S(   sü   
        Get the pristine-tar commit of package I{package} in version I{version}
        and compression type I{comp_type}

        @param archive_regexp: archive name to look for (regexp wildcards allowed)
        @type archive_regexp: C{str}
        s   pristine-tar .* %si˙˙˙˙s!   Found pristine-tar commit at '%s'N(   R   t   has_pristine_tar_brancht   Nonet   grep_logt   brancht   gbpt   logt   debug(   R   R   t   regext   commitst   commit(    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyR	   *   s    

c         C   s0   d t  j j |  |  _ |  j d | g  d S(   s   
        Checkout an orig archive from pristine-tar branch

        @param archive: the name of the orig archive
        @type archive: C{str}
        s   Couldn't checkout "%s"t   checkoutN(   t   osR   t   basenamet	   run_errort   __call__(   R   t   archive(    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyR   =   s    c         C   s:   d | } d |  j  | f |  _ |  j d | | g  d S(   s  
        Commit an archive I{archive} to the pristine tar branch using upstream
        branch ${upstream}.

        @param archive: the archive to commit
        @type archive: C{str}
        @param upstream: the upstream branch to diff against
        @type upstream: C{str}
        s   refs/heads/%ss*   Couldn't commit to '%s' with upstream '%s'R   N(   R   R   R   (   R   R   t   upstreamt   ref(    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyR   G   s    

(
   t   __name__t
   __module__t   __doc__R   R   R   R   R	   R   R   (    (    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyR      s   		
		
(   R"   R   t   gbp.logR   t   gbp.command_wrappersR    R   (    (    (    s7   /usr/lib/python2.7/dist-packages/gbp/pkg/pristinetar.pyt   <module>   s   