Philip Martin wrote on Tue, Jun 25, 2013 at 10:08:38 +0100: > Daniel Shahaf <danie...@apache.org> writes: > > >> - # note the current time to use it as peg revision date. > >> - current_time = time.strftime("%Y-%m-%dT%H:%M:%S") > >> + exit_code, output, errput = svntest.main.run_svn(None, 'propget', > >> 'svn:date', > >> + '--revprop', '-r1', > >> + '--strict', > >> + sbox.repo_url) > >> + if exit_code or errput != [] or len(output) != 1: > >> + raise svntest.Failure("svn:date propget failed") > >> + r1_time = output[0] > > > This tests updating to a {time} equal to the svn:date property, shouldn't it > > try updating to a slightly later time to test that resolution works in the > > common case too? > > I thought about that. > > Commit times are not limited by the filesystem timestamp resolution so > svn:date will always have sub-second resolution, however Python 2.5 > appears to be a bit limited when converting sub-second times to/from > strings as datetime doesn't have %f. > > There is a 1.1 second sleep between r1 and r2 and we want to construct a > date that is strictly after the r1 svn:date and strictly before the r2 > svn:date. How do we do something like the following without %f support? > > fmt = "%Y-%m-%dT%H:%M:%S.%fZ" > r1_dt = datetime.datetime.strptime(r1_time, fmt) > still_r1_time = (r1_dt + datetime.timedelta(seconds=1)).strftime(fmt) > > If we do have %f we could probably use a shorter sleep and a smaller delta.
We could just treat %s.%f as an 8-digit decimal number, so long as it doesn't wrap around? Take it, increment the ones place, and stitch it back onto the string. In one run out of 6.0e7, the %S.%f will be 59.999999 and we'll need to do something else (or raise Skip). Does that make sense? It's a bit hacky, if I have a better idea I'll add it to this thread.