mercurial/dirstateutils/timestamp.py
changeset 48379 08b060abd658
parent 48263 83d0bd45b662
child 48395 9ae0353c9f5d
equal deleted inserted replaced
48378:3d6eb119200d 48379:08b060abd658
     4 # GNU General Public License version 2 or any later version.
     4 # GNU General Public License version 2 or any later version.
     5 
     5 
     6 from __future__ import absolute_import
     6 from __future__ import absolute_import
     7 
     7 
     8 import functools
     8 import functools
       
     9 import os
     9 import stat
    10 import stat
    10 
    11 
    11 
    12 
    12 rangemask = 0x7FFFFFFF
    13 rangemask = 0x7FFFFFFF
    13 
    14 
    52             # they are considered equal, so not "greater than"
    53             # they are considered equal, so not "greater than"
    53             return False
    54             return False
    54         return self_subsec_nanos > other_subsec_nanos
    55         return self_subsec_nanos > other_subsec_nanos
    55 
    56 
    56 
    57 
       
    58 def get_fs_now(vfs):
       
    59     """return a timestamp for "now" in the current vfs
       
    60 
       
    61     This will raise an exception if no temporary files could be created.
       
    62     """
       
    63     tmpfd, tmpname = vfs.mkstemp()
       
    64     try:
       
    65         return mtime_of(os.fstat(tmpfd))
       
    66     finally:
       
    67         os.close(tmpfd)
       
    68         vfs.unlink(tmpname)
       
    69 
       
    70 
    57 def zero():
    71 def zero():
    58     """
    72     """
    59     Returns the `timestamp` at the Unix epoch.
    73     Returns the `timestamp` at the Unix epoch.
    60     """
    74     """
    61     return tuple.__new__(timestamp, (0, 0))
    75     return tuple.__new__(timestamp, (0, 0))