]> thyrsus.com Git - src.git/commitdiff
A solution for te timestamp race. Regression test passes.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 10 Nov 2014 21:36:41 +0000 (16:36 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 10 Nov 2014 21:36:41 +0000 (16:36 -0500)
src
srctest

diff --git a/src b/src
index b5b7ff2fb0ae47c3218dc16b6801151b6a59f291..f501299dbacb8cd7a18e497acb6435c946f5ec40 100755 (executable)
--- a/src
+++ b/src
@@ -526,10 +526,12 @@ def checkout_method(*args):
             revision = metadata.revno_to_rcs(ctx.start)
         with backend.lifter(arg):
             backend.checkout(arg, revision)
-            # Changes the access and modification times
-            # Later, src status will see this.  Alas,
-            # there's a tiny race window here.
-            os.utime(backend.master(arg), None)
+            # We change access and modification times of
+            # both history and workfile to avoid a race
+            # condition if src status is donw within a second.
+            st = os.stat(backend.master(arg))
+            os.utime(backend.master(arg), (st.st_atime, st.st_mtime))
+            os.utime(arg, (st.st_atime-1, st.st_mtime-1))
         if not quiet and len(args) > 1:
             announce("%s <- %d" % (arg, ctx.start))
 
@@ -686,8 +688,7 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method):
         with backend.lifter(arg):
             set_method(name, revision, metadata, arg)
             if not quiet and len(args) > 1:
-                # FIXME: Misleading message when creating a branch.
-                #announce("%s %s = %s in " % (legend, name, revno, arg))
+                announce("%s %s = %s in " % (legend, name, revno, arg))
                 pass
 
 def tag_method(*args):
diff --git a/srctest b/srctest
index 20d897f033635189b28da29af686939ec03f357a..58c5c8ac9fc01c0d9963997ab1a6d47984a983d4 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -213,7 +213,6 @@ src $TESTOPTS commit -m "Another sample" testfile16
 src $TESTOPTS status testfile16 | grep "^U" >/dev/null
 check "U status check after first commit"
 
-sleep 2     # ensures the timestamp changes
 echo "Add a second line" >>testfile16
 src $TESTOPTS status testfile16 | grep "^M" >/dev/null
 check "M status check after modification"