# HG changeset patch # User Bryan O'Sullivan # Date 1125815295 25200 # Node ID 3738e85ead07d2a8b83b345c3132443c5c2bfe6f # Parent f92af8d533309924925c2c6076f65949747913f3 Make date/timezone validation in changelog.add more robust. Add test. diff -r f92af8d53330 -r 3738e85ead07 mercurial/changelog.py --- a/mercurial/changelog.py Sat Sep 03 23:08:39 2005 -0700 +++ b/mercurial/changelog.py Sat Sep 03 23:28:15 2005 -0700 @@ -32,7 +32,10 @@ def add(self, manifest, list, desc, transaction, p1=None, p2=None, user=None, date=None): if date: - when, offset = map(int, date.split()) + # validate explicit (probably user-specified) date and + # time zone offset + when, offset = map(int, date.split(' ')) + time.localtime(when) assert abs(offset) < 43200, 'bad time zone offset: %d' % offset else: if time.daylight: offset = time.altzone diff -r f92af8d53330 -r 3738e85ead07 tests/test-commit --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-commit Sat Sep 03 23:28:15 2005 -0700 @@ -0,0 +1,13 @@ +#!/bin/sh + +hg init test +cd test +echo foo > foo +hg add foo +hg commit -d '0 0' -m commit-1 +echo foo >> foo +hg commit -d '1 4444444' -m commit-3 +hg commit -d '1 15.1' -m commit-4 +hg commit -d 'foo bar' -m commit-5 +hg commit -d ' 1 4444' -m commit-6 +hg commit -d '111111111111 0' -m commit-7