"""
Greg Pinero (gregpinero@gmail.com)
A simple script to get the latest revision info from your working copy
and insert it into each of your files (except this one)
Usage:
Just write $Name: $ patterns shown below anywhere in each file and they will
be filled in with the correct revision information when you run this script.
--------------------------------------------
$Revision: $
$Date: $
$Modified: $
"""
import os,sys
import re
SubWCRev_Path=r"C:\Program Files\TortoiseSVN\bin\SubWCRev.exe"
filetypes2lookat=['.py','.txt','.bat','.cmd','.in']
print os.system('"%s" . revisioninfo.in revisioninfo.py' % SubWCRev_Path)
from revisioninfo import *
reRevision=re.compile(r'\$Revision:[^\$\+]*\$')
reDate=re.compile(r'\$Date:[^\$\+]*\$')
reModified=re.compile(r'\$Modified:[^\$\+]*\$')
listfiles=[fil for fil in os.listdir(os.path.dirname(sys.argv[0]))
if os.path.splitext(fil)[1] in filetypes2lookat and
fil<>os.path.basename(sys.argv[0])]
for fil in listfiles:
content=file(fil,'r').read()
content=reRevision.sub(r'$Revision: '+WCREV+r' $',content)
content=reDate.sub(r'$Date: '+WCDATe+r' $',content)
content=reModified.sub(r'$Modified: '+WCMODS+r' $',content)
file(fil,'w').write(content)