43
class ChangesetTree(object):
44
"""This class is designed to take a base tree, and re-create
45
a final tree based on the information contained within a
49
def __init__(self, branch, changeset_info):
50
"""Initialize this ChangesetTree.
52
:param branch: This is where information will be acquired
54
:param changeset_info: Information about a given changeset,
55
so that we can identify the base,
56
and other information.
59
self.changeset_info = changeset_info
63
def _build_tree(self):
64
"""Build the final description of the tree, based on
65
the changeset_info object.
68
def format_highres_date(t, offset=0):
69
"""Format a date, such that it includes higher precision in the
72
:param t: UTC time in fractional seconds
74
:param offset: The timezone offset in integer seconds
77
>>> from bzrlib.osutils import format_date
78
>>> format_date(1120153132.350850105, 0)
79
'Thu 2005-06-30 17:38:52 +0000'
80
>>> format_highres_date(1120153132.350850105, 0)
81
'Thu 2005-06-30 17:38:52.350850105 +0000'
82
>>> format_date(1120153132.350850105, -5*3600)
83
'Thu 2005-06-30 12:38:52 -0500'
84
>>> format_highres_date(1120153132.350850105, -5*3600)
85
'Thu 2005-06-30 12:38:52.350850105 -0500'
87
from bzrlib.errors import BzrError
89
assert isinstance(t, float)
91
# This has to be formatted for "original" date, so that the
92
# revision XML entry will be reproduced faithfully.
95
tt = time.gmtime(t + offset)
97
return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
98
+ ('%.9f' % (t - int(t)))[1:] # Get the high-res seconds, but ignore the 0
99
+ ' %+03d%02d' % (offset / 3600, (offset / 60) % 60))
101
def unpack_highres_date(date):
102
"""This takes the high-resolution date stamp, and
103
converts it back into the tuple (timestamp, timezone)
104
Where timestamp is in real seconds, and timezone is an integer
105
number of seconds offset.
107
:param date: A date formated by format_highres_date
112
if __name__ == '__main__':