From: Eric S. Raymond Date: Mon, 10 Nov 2014 21:36:41 +0000 (-0500) Subject: A solution for te timestamp race. Regression test passes. X-Git-Tag: 0.4~4 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=627cce5584ddd73d6eea3a81dff981cbe4c1c02b;p=src.git A solution for te timestamp race. Regression test passes. --- diff --git a/src b/src index b5b7ff2..f501299 100755 --- 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 20d897f..58c5c8a 100755 --- 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"