[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

cvs2svn and strptime

From: Max Bowsher <maxb_at_ukf.net>
Date: 2003-10-22 02:52:44 CEST

Index: run-tests.py
===================================================================
--- run-tests.py (revision 7470)
+++ run-tests.py (working copy)
@@ -116,6 +116,15 @@
     rpath = '/' + rpath
   return 'file://%s' % string.replace(rpath, os.sep, '/')

+if hasattr(time, 'strptime'):
+ def svn_strptime(timestr):
+ return time.strptime(timestr, '%Y-%m-%d %H:%M:%S')
+else:
+ _re_rev_date = re.compile(r'([\d]{4})-([\d]{2})-([\d]{2}) '
+ r'([\d]{2}):([\d]{2}):([\d]{2})')
+ def svn_strptime(timestr):
+ matches = _re_rev_date.match(timestr).groups()
+ return tuple(map(int, matches)) + (0, 1, -1)

 class Log:
   def __init__(self, revision, author, date):
@@ -129,7 +138,7 @@
     #
     # and time.mktime() converts from localtime, it all works out very
     # happily.
- self.date = time.mktime(time.strptime(date[0:19], "%Y-%m-%d %H:%M:%S"))
+ self.date = time.mktime(svn_strptime(date[0:19]))

     # The changed paths will be accumulated later, as log data is read.
     # Keys here are paths such as '/trunk/foo/bar', values are letter

Here is a modified version of the strptime section of Russell Yanofsky's
issue-1360 patch.

I've made the regexp shorter by making use of \d and {2}, and changed
tm_isdst from 0 to -1, which seems to be more correct in my testing.

By the way, when is this compatibility code activated?

Max.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Oct 22 02:53:34 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.