Skip to content

Instantly share code, notes, and snippets.

@dcb9
Last active August 29, 2015 14:07
Show Gist options
  • Save dcb9/b4c2daaa97fb29c34ee0 to your computer and use it in GitHub Desktop.
Save dcb9/b4c2daaa97fb29c34ee0 to your computer and use it in GitHub Desktop.
查找svn文件的最开始的创始人和创建时间
import os, re, sys
RE =re.compile(ur'r(\d+)\s\|\s(\S+)\s\|\s(\S+\s\S+)')
SVN_LOG="svn log"
def backtrack(file):
fh = os.popen("%s -q %s" % (SVN_LOG, file), "r")
for line in fh:
line = line.strip()
if line != "------------------------------------------------------------------------":
last_info = line
return RE.match(last_info).groups()
def get_last_info(file):
info = backtrack(file)
print file
print '/**'
print ' * @firstREV %s' % info[0]
print ' * @author %s' % info[1]
print ' * @since %s' % info[2]
print ' */'
if __name__ == "__main__":
try:
files = sys.argv[1:]
for file in files:
get_last_info(file)
except ValueError:
print "usage: findfileoriginal.py filename"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment