Skip to content

Instantly share code, notes, and snippets.

@preshing
Created August 28, 2017 16:44
Show Gist options
  • Save preshing/2eb1f7f8f5ea115e00bea0117af40f0d to your computer and use it in GitHub Desktop.
Save preshing/2eb1f7f8f5ea115e00bea0117af40f0d to your computer and use it in GitHub Desktop.
import datetime
import re
import os
badTimeStamp = datetime.datetime.strptime("2010-03-08 15:02:59 -0500", "%Y-%m-%d %H:%M:%S %z")
desiredTimeStamp = datetime.datetime.strptime("2017-08-28 11:15:59 -0400", "%Y-%m-%d %H:%M:%S %z")
delta = desiredTimeStamp - badTimeStamp
for line in open("../backup.log", "r"):
m = re.match("r(\\d+) \\| jeff \\| (.*) \(", line)
if m:
rev, ts = m.groups()
if (int(rev) >= 54):
badSvnTime = datetime.datetime.strptime(ts, "%Y-%m-%d %H:%M:%S %z")
fixedSvnTime = (badSvnTime + delta).astimezone(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000000Z")
os.system('svn propset -r%s --revprop svn:date "%s"' % (rev, fixedSvnTime))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment