tests/test-rename.t
changeset 37088 08890706366e
parent 35393 4441705b7111
child 39348 cde75233c415
equal deleted inserted replaced
37087:e4640ec346ac 37088:08890706366e
   655   $ (cd d1/d11; hg rename ../../d2/b ../../../foo)
   655   $ (cd d1/d11; hg rename ../../d2/b ../../../foo)
   656   abort: ../../../foo not under root '$TESTTMP'
   656   abort: ../../../foo not under root '$TESTTMP'
   657   [255]
   657   [255]
   658   $ hg status -C
   658   $ hg status -C
   659 
   659 
       
   660 check that stat information such as mtime is preserved on rename - it's unclear
       
   661 whether the `touch` and `stat` commands are portable, so we mimic them using
       
   662 python.  Not all platforms support precision of even one-second granularity, so
       
   663 we allow a rather generous fudge factor here; 1234567890 is 2009, and the
       
   664 primary thing we care about is that it's not the machine's current time;
       
   665 hopefully it's really unlikely for a machine to have such a broken clock that
       
   666 this test fails. :)
       
   667 
       
   668   $ mkdir mtime
       
   669 Create the file (as empty), then update its mtime and atime to be 1234567890.
       
   670   >>> import os
       
   671   >>> filename = "mtime/f"
       
   672   >>> mtime = 1234567890
       
   673   >>> open(filename, "w").close()
       
   674   >>> os.utime(filename, (mtime, mtime))
       
   675   $ hg ci -qAm 'add mtime dir'
       
   676 "hg cp" does not preserve the mtime, so it should be newer than the 2009
       
   677 timestamp.
       
   678   $ hg cp -q mtime mtime_cp
       
   679   >>> from __future__ import print_function
       
   680   >>> import os
       
   681   >>> filename = "mtime_cp/f"
       
   682   >>> print(os.stat(filename).st_mtime < 1234567999)
       
   683   False
       
   684 "hg mv" preserves the mtime, so it should be ~equal to the 2009 timestamp
       
   685 (modulo some fudge factor due to not every system supporting 1s-level
       
   686 precision).
       
   687   $ hg mv -q mtime mtime_mv
       
   688   >>> from __future__ import print_function
       
   689   >>> import os
       
   690   >>> filename = "mtime_mv/f"
       
   691   >>> print(os.stat(filename).st_mtime < 1234567999)
       
   692   True