
    q&fV                     x    d dl Z d dlZd dlZddlmZ dZe j                   G d de             Zd Z	d Z
d	 Zd
 Zy)    N   )erroric                   .     e Zd ZdZ fdZd Zd Z xZS )	timestampa  
    A Unix timestamp with optional nanoseconds precision,
    modulo 2**31 seconds.

    A 3-tuple containing:

    `truncated_seconds`: seconds since the Unix epoch,
    truncated to its lower 31 bits

    `subsecond_nanoseconds`: number of nanoseconds since `truncated_seconds`.
    When this is zero, the sub-second precision is considered unknown.

    `second_ambiguous`: whether this timestamp is still "reliable"
    (see `reliable_mtime_of`) if we drop its sub-second component.
    c                 P    |\  }}}|t         z  ||f}t        t        |   | |      S )N)	rangemasksuperr   __new__)clsvaluetruncated_secondssubsec_nanossecond_ambiguous	__class__s        C/usr/lib/python3/dist-packages/mercurial/dirstateutils/timestamp.pyr
   ztimestamp.__new__#   s7    <A9<)9"Y.>NOY,S%88    c                 ,    t        j                  d      Nz+timestamp should never be compared directlyr   ProgrammingErrorselfothers     r   __eq__ztimestamp.__eq__(       $$9
 	
r   c                 ,    t        j                  d      r   r   r   s     r   __gt__ztimestamp.__gt__-   r   r   )__name__
__module____qualname____doc__r
   r   r   __classcell__)r   s   @r   r   r      s     9



r   r   c                    | j                         \  }}	 t        t        j                  |            t        j                  |       | j                  |       S # t        j                  |       | j                  |       w xY w)z~return a timestamp for "now" in the current vfs

    This will raise an exception if no temporary files could be created.
    )mkstempmtime_ofosfstatcloseunlink)vfstmpfdtmpnames      r   
get_fs_nowr-   3   sZ    
 [[]NE7(


7 	

7s   A (Bc                  6    t         j                  t        d      S )z4
    Returns the `timestamp` at the Unix epoch.
    )r   r   )tupler
   r    r   r   zeror1   @   s     ==F++r   c                     	 | j                   }t        d      }||z  }||z  }t        ||df      S # t        $ r | t        j                     }d}Y .w xY w)zo
    Takes an `os.stat_result`-like object and returns a `timestamp` object
    for its modification time.
    g    eAr   F)st_mtime_nsintAttributeErrorstatST_MTIMEr   )stat_resultnanosbillionsecsr   s        r   r%   r%   G   sj    
'
 '' c(wdL%011   4==)s   1 AAc                     t        |       }|d   }|d   }|d   }|d   }||k(  r|r|r||k  rt        ||df      S y||cxk  rd|z   k  ry |S |S )a4  Same as `mtime_of`, but return `None` or a `Timestamp` with
    `second_ambiguous` set if the date might be ambiguous.

    A modification time is reliable if it is older than "present_time" (or
    sufficiently in the future).

    Otherwise a concurrent modification might happens with the same mtime.
    r      TNiQ )r%   r   )r8   present_mtime
file_mtimefile_secondfile_nsboundary_secondboundary_nss          r   reliable_mtime_ofrD   a   s     +&JQ-KmG#A&O"K +%{$ +w!=>>	;	F)o*E	F 
G zr   )	functoolsr&   r6    r   r   total_orderingr/   r   r-   r1   r%   rD   r0   r   r   <module>rH      sP     	   	 
 
 
B
,24r   