bug 455369 - Pushlog date parsing screws up on trailing space
authorTed Mielczarek <ted.mielczarek@gmail.com>
Fri, 21 Nov 2008 07:46:39 -0500
changeset 1106 358edb6676dbe4c3fb038d3d6fbe70b15e0011d7
parent 1105 8afaefe3496e42ead72f8ba369b80159a0c50e35
child 1107 4ad648663a2de2bcedf08d5a131d22e0cdb07001
push id159
push usergszorc@mozilla.com
push dateMon, 29 Sep 2014 18:14:30 +0000
treeherderversion-control-tools@e3d700020d5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs455369
bug 455369 - Pushlog date parsing screws up on trailing space
hgext/pushlog-legacy/pushlog-feed.py
hgext/pushlog-legacy/runtests.py
--- a/hgext/pushlog-legacy/pushlog-feed.py
+++ b/hgext/pushlog-legacy/pushlog-feed.py
@@ -96,16 +96,17 @@ def gettotalpushlogentries(conn):
 def localdate(ts):
     t = time.localtime(ts)
     offset = time.timezone
     if t[8] == 1:
         offset = time.altzone
     return (ts, offset)
 
 def doParseDate(datestring):
+    datestring = datestring.strip()
     try:
         date = time.strptime(datestring, "%Y-%m-%d %H:%M:%S")
     except ValueError:
         date, x = cal.parse(datestring)
     return time.mktime(date)
 
 def pushlogSetup(web, req):
     repo = web.repo
--- a/hgext/pushlog-legacy/runtests.py
+++ b/hgext/pushlog-legacy/runtests.py
@@ -52,18 +52,18 @@ class TestPushlog(unittest.TestCase):
         write_hgrc(repodir)
         ensure_templates()
         # read our expected json data
         f = file(os.path.join(mydir, "testdata/test-repo-data.json"))
         self.expectedjson = simplejson.loads(''.join(f.readlines()))
         f.close()
         # now run hg serve on it
         self.hgwebprocess = Popen(["hg", "-R", repodir, "serve"], stdout=devnull, stderr=STDOUT)
-        # give it a few seconds to be ready
-        sleep(2)
+        # give it a second to be ready
+        sleep(1)
         os.environ['TZ'] = "America/New_York"
 
     def tearDown(self):
         # kill hgweb process
         if self.hgwebprocess is not None:
             os.kill(self.hgwebprocess.pid, SIGTERM)
             self.hgwebprocess = None
 
@@ -132,10 +132,16 @@ class TestPushlog(unittest.TestCase):
         self.assertEqualFeeds(testfeed, expectedfeed)
 
     def testchangesetquerytipsonlyatom(self):
         """Get some tipsonly ATOM data via pushlog changeset query."""
         testfeed = feedparser.parse("http://localhost:8000/pushlog?fromchange=4ccee53e18ac&tochange=a79451771352&tipsonly=1")
         expectedfeed = feedparser.parse(os.path.join(mydir, "testdata/test-repo-changeset-query-tipsonly-data.xml"))
         self.assertEqualFeeds(testfeed, expectedfeed)
 
+    def testdatequerytrailingspaceatom(self):
+        """Dates with leading/trailing spaces should work properly."""
+        testfeed = feedparser.parse("http://localhost:8000/pushlog?startdate=%202008-11-20%2010:52:25%20&enddate=%202008-11-20%2010:53:25%20&foo=bar")
+        expectedfeed = feedparser.parse(os.path.join(mydir, "testdata/test-repo-date-query-data.xml"))
+        self.assertEqualFeeds(testfeed, expectedfeed)
+
 if __name__ == '__main__':
     unittest.main()