/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/timestamp.py

  • Committer: James Westby
  • Date: 2007-09-18 18:55:00 UTC
  • mto: (2866.1.1 james.westby)
  • mto: This revision was merged to the branch mainline in revision 2867.
  • Revision ID: jw+debian@jameswestby.net-20070918185500-91alkjx8zolds1v8
Fix log against smart server branches that don't support tags. (#140615)

Add get_reverse_tag_dict to DisabledTags for branches that falsely
claim that they support tags (namely smart server branches). When the
remote branch was an old format without tags this caused log to fail.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import calendar
18
18
import time
47
47
    >>> format_highres_date(1152428738.867522, 19800)
48
48
    'Sun 2006-07-09 12:35:38.867522001 +0530'
49
49
    """
50
 
    if not isinstance(t, float):
51
 
        raise ValueError(t)
 
50
    assert isinstance(t, float)
52
51
 
53
52
    # This has to be formatted for "original" date, so that the
54
53
    # revision XML entry will be reproduced faithfully.
56
55
        offset = 0
57
56
    tt = time.gmtime(t + offset)
58
57
 
59
 
    return (osutils.weekdays[tt[6]] +
60
 
            time.strftime(" %Y-%m-%d %H:%M:%S", tt)
 
58
    return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
61
59
            # Get the high-res seconds, but ignore the 0
62
60
            + ('%.9f' % (t - int(t)))[1:]
63
61
            + ' %+03d%02d' % (offset / 3600, (offset / 60) % 60))
101
99
    ...      break
102
100
 
103
101
    """
104
 
    # Weekday parsing is locale sensitive, so drop the weekday
105
 
    space_loc = date.find(' ')
106
 
    if space_loc == -1 or date[:space_loc] not in osutils.weekdays:
107
 
        raise ValueError(
108
 
            'Date string does not contain a day of week: %r' % date)
109
102
    # Up until the first period is a datestamp that is generated
110
103
    # as normal from time.strftime, so use time.strptime to
111
104
    # parse it
113
106
    if dot_loc == -1:
114
107
        raise ValueError(
115
108
            'Date string does not contain high-precision seconds: %r' % date)
116
 
    base_time = time.strptime(date[space_loc:dot_loc], " %Y-%m-%d %H:%M:%S")
 
109
    base_time = time.strptime(date[:dot_loc], "%a %Y-%m-%d %H:%M:%S")
117
110
    fract_seconds, offset = date[dot_loc:].split()
118
111
    fract_seconds = float(fract_seconds)
119
112
 
136
129
 
137
130
    Inverse of parse_patch_date.
138
131
    """
139
 
    if offset % 60 != 0:
140
 
        raise ValueError(
141
 
        "can't represent timezone %s offset by fractional minutes" % offset)
142
 
    # so that we don't need to do calculations on pre-epoch times,
 
132
    assert offset % 60 == 0, \
 
133
        "can't represent timezone %s offset by fractional minutes" % offset
 
134
    # so that we don't need to do calculations on pre-epoch times, 
143
135
    # which doesn't work with win32 python gmtime, we always
144
136
    # give the epoch in utc
145
137
    if secs == 0:
159
151
    """
160
152
    secs_str = date_str[:-6]
161
153
    offset_str = date_str[-5:]
162
 
    if len(offset_str) != 5:
163
 
        raise ValueError(
164
 
            "invalid timezone %r" % offset_str)
 
154
    assert len(offset_str) == 5, \
 
155
            "invalid timezone %r" % offset_str
165
156
    offset_hours, offset_mins = offset_str[:3], offset_str[3:]
166
157
    offset = int(offset_hours) * 3600 + int(offset_mins) * 60
167
158
    tm_time = time.strptime(secs_str, '%Y-%m-%d %H:%M:%S')