[merge] Bundles handle non-integer timezones

Aaron Bentley aaron.bentley at utoronto.ca
Tue Jul 11 00:08:09 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel wrote:
> Attached is a patch to handle 2 bugs in the current bundle code.
> 
> 1) More graceful handling of 'bzr pull sftp://host/path' (no trailing
> slash). I submitted this a while ago, but haven't gotten any feedback.

The implementation stuff looks okay, but the mutter lines look longer
than 79 chars.  I'm torn about whether the serializer should convert the
SFTP error into a NotABundle.  I guess it's fine where it is.

> 2) Handle timezones that are not integer hour differences. This involves
> 1 test to show that unpack_highres_date is doing the right thing
> (doctest), and 1 test to prove that bundle is using the right function
> (there used to be 2 functions).


+            mutter('bundle date %s => %s, %s', self.date,
self.timestamp, self.timezone)

This is the kind of thing that looks like >79 chars.


=== modified file bzrlib/bundle/serializer/__init__.py //
last-changed:john at arb
... ash-meinel.com-20060709070901-f39f56fc35695ed9
- --- bzrlib/bundle/serializer/__init__.py
+++ bzrlib/bundle/serializer/__init__.py
@@ -124,6 +124,8 @@
     'Thu 2005-06-30 12:38:52.350850105 -0500'
     >>> format_highres_date(1120153132.350850105, 7200)
     'Thu 2005-06-30 19:38:52.350850105 +0200'
+    >>> format_highres_date(1152428738.867522, 19800)
+    'Sun 2006-07-09 12:35:38.867522001 +0530'
     """
     import time
     assert isinstance(t, float)
@@ -155,6 +157,8 @@
     (1120153132.3508501, 0)
     >>> unpack_highres_date('Thu 2005-06-30 19:38:52.350850105 +0200')
     (1120153132.3508501, 7200)
+    >>> unpack_highres_date('Sun 2006-07-09 12:35:38.867522001 +0530')
+    (1152428738.867522, 19800)
     >>> from bzrlib.osutils import local_time_offset
     >>> t = time.time()
     >>> o = local_time_offset()
@@ -186,7 +190,7 @@
     fract_seconds, offset = date[dot_loc:].split()
     fract_seconds = float(fract_seconds)
     offset = int(offset)
- -    offset = int(offset / 100) * 3600 + offset % 100
+    offset = int(offset / 100) * 3600 + (offset%100) * 60

It might be clearer to do

hours = int(offset / 100)
minutes = int(offset % 100)
offset = hours * 3600 + minutes * 60

Either way, some spaces around the % would be welcome.  Note also that
the int around offset/100 is redundant.

+1 with either spaces around the % or hours/minutes.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEst3Z0F+nu1YWqI0RAjUlAJ0dDlSFDRfkCbClJuVEHYEMv1FpFwCfakN+
wvXY2BnhyrJ1BSxWAXfs8W4=
=oml0
-----END PGP SIGNATURE-----




More information about the bazaar mailing list