changeset 359:fb0b0165350a

Unit tests for :hg:`timestamps --restore` and :hg:`timestamps --save`
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 17 Feb 2019 23:00:54 +0100
parents ac94061c6816
children 1d657f86eb72
files tests/test-timestamps.t
diffstat 1 files changed, 97 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-timestamps.t	Sun Feb 17 15:26:00 2019 +0100
+++ b/tests/test-timestamps.t	Sun Feb 17 23:00:54 2019 +0100
@@ -156,11 +156,102 @@
   $ cd ..
 
 
-3. Test a merge with conflicts
-==============================
+3. Test restoring
+=================
 
   $ prepare_repo "ts3"
   $ cd ts3
+  $ cat .hgtimestamps.db
+  version=1
+  encoding=binary
+  files/test1.txt,2017-12-01T02:03:04Z
+  files/test2.txt,2017-12-01T08:09:10Z
+  files/test3.txt,2017-12-01T05:06:07Z
+  $ touch -d 2018-01-01T00:01:02Z files/test2.txt
+  $ touch -d 2018-02-03T00:01:02Z files/test3.txt
+  $ touch -d 2018-02-03T00:01:02Z files/test-not-in-db.txt
+  $ hg timestamps --restore
+
+The timestamps database must be the same ...
+
+  $ cat .hgtimestamps.db
+  version=1
+  encoding=binary
+  files/test1.txt,2017-12-01T02:03:04Z
+  files/test2.txt,2017-12-01T08:09:10Z
+  files/test3.txt,2017-12-01T05:06:07Z
+
+... and the mtimes of the tracked files should be "reverted"
+
+  $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2017-12-01T02:03:04Z files/test1.txt
+  $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2017-12-01T08:09:10Z files/test2.txt
+  $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2017-12-01T05:06:07Z files/test3.txt
+
+.. and other files are leaved alone
+
+  $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2018-02-03T00:01:02Z files/test-not-in-db.txt
+
+  $ cd ..
+
+
+4. Test saving
+==============
+
+  $ prepare_repo "ts4"
+  $ cd "ts4"
+
+Change the database to a some other values
+
+  $ cat >.hgtimestamps.db  <<EOF
+  > version=1
+  > encoding=binary
+  > files/test1.txt,2018-03-02T01:02:03Z
+  > files/test2.txt,2018-04-05T06:07:08Z
+  > files/test3.txt,2017-12-01T05:06:07Z
+  > EOF
+
+  $ cat .hgtimestamps.db
+  version=1
+  encoding=binary
+  files/test1.txt,2018-03-02T01:02:03Z
+  files/test2.txt,2018-04-05T06:07:08Z
+  files/test3.txt,2017-12-01T05:06:07Z
+
+After saving timestamps ...
+
+  $ hg timestamps --save
+
+... database should be "reverted" because no files have changed
+
+  $ cat .hgtimestamps.db
+  version=1
+  encoding=binary
+  files/test1.txt,2017-12-01T02:03:04Z
+  files/test2.txt,2017-12-01T08:09:10Z
+  files/test3.txt,2017-12-01T05:06:07Z
+
+When touching files the timestamps database should reflect that when saving
+
+  $ touch -d 2018-10-11T14:15:16Z files/test2.txt
+  $ touch -d 2018-12-13T17:18:19Z files/test3.txt
+
+  $ hg timestamps --save
+
+  $ cat .hgtimestamps.db
+  version=1
+  encoding=binary
+  files/test1.txt,2017-12-01T02:03:04Z
+  files/test2.txt,2018-10-11T14:15:16Z
+  files/test3.txt,2018-12-13T17:18:19Z
+
+  $ cd ..
+
+
+5. Test a merge with conflicts
+==============================
+
+  $ prepare_repo "ts5"
+  $ cd ts5
   $ hg merge -r7 --tool=:merge3
   merging .hgtimestamps.db
   merging files/test2.txt
@@ -249,18 +340,18 @@
   $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2017-12-01T02:03:04Z files/test1.txt
   $ "$TSPY" "$TESTDIR/lib-stat.py" --differs=2017-12-01T08:09:10Z files/test2.txt
   $ "$TSPY" "$TESTDIR/lib-stat.py" --differs=2017-12-01T07:08:09Z files/test2.txt
-  $ "$TSPY" "$TESTDIR/lib-stat.py" --differs=2017-12-01T04:05:06Z files/test2.txt  
+  $ "$TSPY" "$TESTDIR/lib-stat.py" --differs=2017-12-01T04:05:06Z files/test2.txt
   $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2017-12-01T05:06:07Z files/test3.txt
   $ "$TSPY" "$TESTDIR/lib-stat.py" --check=2017-12-01T06:07:08Z files/test4-2.txt
 
   $ cd ..
 
 
-4. Test the merge with conflicts the other way round
+6. Test the merge with conflicts the other way round
 ====================================================
 
-  $ prepare_repo "ts4"
-  $ cd ts4
+  $ prepare_repo "ts6"
+  $ cd ts6
   $ hg update --quiet -r7
   $ hg merge -r8 --tool=:merge3
   merging .hgtimestamps.db