CVS Keywords
Every VCS has some way of describing the history of a file: who changed it last, when and how. Similarly, they all have some way of embedding this information inside the file which is under revision control. Generally, they use the set of tags first developed by CVS. Since this is useful information, it should be present in all non-binary files.
This is another area where a bit of process definition is enforceable/monitored through python. The following script will crawl through all .java and .jsp files and check if any cvs keywords are present. You can then produce reports based upon the an organization-wide defined policy (for instance, all files should have the $Header: $ keyword).
"""
This script will crawl through the code to verify that each .java
and .jsp script has a required set of cvs keywords. See
http://badgertronics.com/writings/cvs/keywords.html for a full list
"""
import os, copy
java_head = "C:\\work\\cvs\\TestModule"
magic = r"= 0:
if not m_keywords.has_key(ct):
h_keywords[ct] = []
if not curr_file in m_keywords[ct]:
h_keywords[ct].append(curr_file)
# does not
else:
if not m_keywords.has_key(ct):
m_keywords[ct] = []
if not curr_file in m_keywords[ct]:
m_keywords[ct].append(curr_file)
commented = """
print "Files which do not have any cvs keywords"
if len(m_keywords) == 0:
print "All .java and .jsp files have a cvs keyword"
else:
for ct in cvs_tags:
print "TAG: %s" % ct
for f in m_keywords[ct]:
print "\\t%s" %f
"""
# specific keyword policy checks can go here
# header
print "Files which do not have the '$Header: $' cvs keyword"
if len(m_keywords) == 0:
print "All .java and .jsp files have the '$Header: $' cvs keyword"
else:
for f in m_keywords["$Header:"]:
print "\\t%s" % f