+++ /dev/null
-#! /usr/bin/env python\r
-\r
-"""Print a list of files that are mentioned in CVS directories.\r
-\r
-Usage: cvsfiles.py [-n file] [directory] ...\r
-\r
-If the '-n file' option is given, only files under CVS that are newer\r
-than the given file are printed; by default, all files under CVS are\r
-printed. As a special case, if a file does not exist, it is always\r
-printed.\r
-"""\r
-\r
-import os\r
-import sys\r
-import stat\r
-import getopt\r
-\r
-cutofftime = 0\r
-\r
-def main():\r
- try:\r
- opts, args = getopt.getopt(sys.argv[1:], "n:")\r
- except getopt.error, msg:\r
- print msg\r
- print __doc__,\r
- return 1\r
- global cutofftime\r
- newerfile = None\r
- for o, a in opts:\r
- if o == '-n':\r
- cutofftime = getmtime(a)\r
- if args:\r
- for arg in args:\r
- process(arg)\r
- else:\r
- process(".")\r
-\r
-def process(dir):\r
- cvsdir = 0\r
- subdirs = []\r
- names = os.listdir(dir)\r
- for name in names:\r
- fullname = os.path.join(dir, name)\r
- if name == "CVS":\r
- cvsdir = fullname\r
- else:\r
- if os.path.isdir(fullname):\r
- if not os.path.islink(fullname):\r
- subdirs.append(fullname)\r
- if cvsdir:\r
- entries = os.path.join(cvsdir, "Entries")\r
- for e in open(entries).readlines():\r
- words = e.split('/')\r
- if words[0] == '' and words[1:]:\r
- name = words[1]\r
- fullname = os.path.join(dir, name)\r
- if cutofftime and getmtime(fullname) <= cutofftime:\r
- pass\r
- else:\r
- print fullname\r
- for sub in subdirs:\r
- process(sub)\r
-\r
-def getmtime(filename):\r
- try:\r
- st = os.stat(filename)\r
- except os.error:\r
- return 0\r
- return st[stat.ST_MTIME]\r
-\r
-if __name__ == '__main__':\r
- main()\r