/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/__init__.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# (C) 2005 Canonical Development Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
31
CHANGESET_OLD_HEADER_RE = re.compile(r'^# Bazaar-NG changeset v(?P<version>\d+[\w.]*)\n$')
32
32
 
33
33
 
34
 
_serializers = {} 
 
34
_serializers = {}
35
35
 
36
36
 
37
37
def _get_filename(f):
124
124
    'Thu 2005-06-30 12:38:52.350850105 -0500'
125
125
    >>> format_highres_date(1120153132.350850105, 7200)
126
126
    'Thu 2005-06-30 19:38:52.350850105 +0200'
 
127
    >>> format_highres_date(1152428738.867522, 19800)
 
128
    'Sun 2006-07-09 12:35:38.867522001 +0530'
127
129
    """
128
130
    import time
129
131
    assert isinstance(t, float)
155
157
    (1120153132.3508501, 0)
156
158
    >>> unpack_highres_date('Thu 2005-06-30 19:38:52.350850105 +0200')
157
159
    (1120153132.3508501, 7200)
 
160
    >>> unpack_highres_date('Sun 2006-07-09 12:35:38.867522001 +0530')
 
161
    (1152428738.867522, 19800)
158
162
    >>> from bzrlib.osutils import local_time_offset
159
163
    >>> t = time.time()
160
164
    >>> o = local_time_offset()
185
189
    base_time = time.strptime(date[:dot_loc], "%a %Y-%m-%d %H:%M:%S")
186
190
    fract_seconds, offset = date[dot_loc:].split()
187
191
    fract_seconds = float(fract_seconds)
 
192
 
188
193
    offset = int(offset)
189
 
    offset = int(offset / 100) * 3600 + offset % 100
 
194
 
 
195
    hours = int(offset / 100)
 
196
    minutes = (offset % 100)
 
197
    seconds_offset = (hours * 3600) + (minutes * 60)
190
198
    
191
199
    # time.mktime returns localtime, but calendar.timegm returns UTC time
192
200
    timestamp = calendar.timegm(base_time)
193
 
    timestamp -= offset
 
201
    timestamp -= seconds_offset
194
202
    # Add back in the fractional seconds
195
203
    timestamp += fract_seconds
196
 
    return (timestamp, offset)
 
204
    return (timestamp, seconds_offset)
197
205
 
198
206
 
199
207
class BundleSerializer(object):