[PATCH] test_pack_revision_5 failure on Windows
Martin Pool
mbp at canonical.com
Wed Nov 8 03:32:43 GMT 2006
On 7 Nov 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
> Henri Wiechers wrote:
> > I've been looking at some of the selftest failures on Windows. One
> > such failure is:
>
> ...
>
> >
> > I did a little checking and it seems that this isn't regarded as a
> > bug. Floats are
> > really only good for 17 significant digits and the timestamp attribute
> > is holding 19.
> > (Even repr(float) rounds to 17 first.)
> >
> > The attached patch gets the right timestamp attribute by using
> > "%i" % float_ + ("%.9f" % (float_ - int(float_)))[1:]
> > Ideally, though, I think that repr(rev.timestamp) should be used instead
> > of a
> > format with fixed decimal places.
>
> New versions of bzr actually always round to milliseconds. So what if we
> just change the time to:
>
> timestamp = 1125907235.212000000
>
> We've talked about changing the field to some sort of integer. But I'm
> pretty sure milliseconds is stable enough. Floats should be able to
> represent timestamp down to milliseconds, which is only 13 significant
> places. And it will be a long time before we get anywhere near 16
> significant places. (If I did the math right, it is some time in the
> year 316,880).
Thanks Henri,
John, how about just writing it out as milliseconds?
=== modified file 'bzrlib/tests/test_xml.py'
--- bzrlib/tests/test_xml.py 2006-10-11 23:08:27 +0000
+++ bzrlib/tests/test_xml.py 2006-11-08 02:37:59 +0000
@@ -46,7 +46,7 @@
_revision_v5 = """<revision committer="Martin Pool <mbp at sourcefrog.net>"
inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
revision_id="mbp at sourcefrog.net-20050905080035-e0439293f8b6b9f9"
- timestamp="1125907235.211783886"
+ timestamp="1125907235.211"
timezone="36000">
<message>- start splitting code for xml (de)serialization away from objects
preparatory to supporting multiple formats by a single library
@@ -61,7 +61,7 @@
<revision committer="Martin Pool <mbp at sourcefrog.net>"
inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41"
revision_id="mbp at sourcefrog.net-20050905080035-e0439293f8b6b9f9"
- timestamp="1125907235.211783886"
+ timestamp="1125907235.211"
timezone="0">
<message>- start splitting code for xml (de)serialization away from objects
preparatory to supporting multiple formats by a single library
@@ -102,7 +102,7 @@
# DO NOT REFLOW THIS. Its the exact revision we want.
-_expected_rev_v5 = """<revision committer="Martin Pool <mbp at sourcefrog.net>" format="5" inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41" revision_id="mbp at sourcefrog.net-20050905080035-e0439293f8b6b9f9" timestamp="1125907235.211783886" timezone="36000">
+_expected_rev_v5 = """<revision committer="Martin Pool <mbp at sourcefrog.net>" format="5" inventory_sha1="e79c31c1deb64c163cf660fdedd476dd579ffd41" revision_id="mbp at sourcefrog.net-20050905080035-e0439293f8b6b9f9" timestamp="1125907235.211" timezone="36000">
<message>- start splitting code for xml (de)serialization away from objects
preparatory to supporting multiple formats by a single library
</message>
=== modified file 'bzrlib/xml5.py'
--- bzrlib/xml5.py 2006-09-10 02:18:31 +0000
+++ bzrlib/xml5.py 2006-11-08 02:36:06 +0000
@@ -180,7 +180,7 @@
"""Revision object -> xml tree"""
root = Element('revision',
committer = rev.committer,
- timestamp = '%.9f' % rev.timestamp,
+ timestamp = '%.3f' % rev.timestamp,
revision_id = rev.revision_id,
inventory_sha1 = rev.inventory_sha1,
format='5',
--
Martin
More information about the bazaar
mailing list