
    6                     j    S r SSKrSSKJrJrJr  \R                  " S/ SQ5      rS rS r	S r
S
S	 jrg)z.Utilities for reading and generating reflogs.
    N)format_timezoneparse_timezoneZERO_SHAEntryold_shanew_sha	committer	timestamptimezonemessagec                     U c  [         n U S-   U-   S-   U-   S-   [        [        U5      5      R                  S5      -   S-   [	        U5      -   S-   U-   $ )zGenerate a single reflog line.

Args:
  old_sha: Old Commit SHA
  new_sha: New Commit SHA
  committer: Committer name and e-mail
  timestamp: Timestamp
  timezone: Timezone
  message: Message
    ascii   	)r   strintencoder   r   s         !lib/third_party/dulwich/reflog.pyformat_reflog_liner   &   s     
	
	 	 		
 	 c)n

$
$W
-	. 	 (
#	$ 		 
	    c           	          U R                  SS5      u  pUR                  SS5      u  p4nUR                  SS5      u  pgn[        UUU[        U5      [	        U5      S   U5      $ )zParse a reflog line.

Args:
  line: Line to parse
Returns: Tuple of (old_sha, new_sha, committer, timestamp, timezone,
    message)
r      r      r   )splitrsplitr   r   r   )	linebeginr   r   r	   restr
   timestamp_strtimezone_strs	            r   parse_reflog_liner"   B   so     zz%+U${{43Wt/3{{4/C,Y|M|$Q' r   c              #   8   #    U  H  n[        U5      v   M     g7f)zORead reflog.

Args:
  f: File-like object
Returns: Iterator over Entry objects
N)r"   )fr   s     r   read_reflogr%   W   s      %% s   c                 0   US:  a  [        SU-  5      e/ nU R                  5       nU  H/  nUR                  U[        U5      45        U R                  5       nM1     [	        U5      U-
  S-
  nX6   S   nU R                  U5        US:X  a  U R                  5         gX6	 U(       az  US:  at  U(       am  US:X  a  [        nOX6S-
     S   R                  nX6   u  pIU[        UU	R                  U	R                  U	R                  U	R                  U	R                  5      4X6'   X6S  H`  u  pU R                  [        U	R                   U	R                  U	R                  U	R                  U	R                  U	R                  5      5        Mb     U R                  5         g)a  Drop the specified reflog entry.

Args:
    f: File-like object
    index: Reflog entry index (in Git reflog reverse 0-indexed order)
    rewrite: If a reflog entry's predecessor is removed, set its
        old SHA to the new SHA of the entry that now precedes it
r   zInvalid reflog index %dr   N)
ValueErrortellappendr"   lenseektruncater   r	   r   r
   r   r   r   writer   r   )r$   indexrewritelogoffsetr   inverse_indexwrite_offsetprevious_newentry_s              r   drop_reflog_entryr7   b   sp    qy2U:;;
CVVXF

F-d345  Hu$q(M%a(LFF<z	

519A#Lq01!4<<L*

 '			
 ( JJLr   )F)__doc__collectionsdulwich.objectsr   r   r   
namedtupler   r   r"   r%   r7    r   r   <module>r=      sE   *   	K	8*&8r   