1997-08-14 17:14:54 -03:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
1997-11-24 19:49:35 -04:00
|
|
|
"""Print a list of files that are mentioned in CVS directories.
|
|
|
|
|
|
|
|
Usage: cvsfiles.py [-n file] [directory] ...
|
|
|
|
|
|
|
|
If the '-n file' option is given, only files under CVS that are newer
|
|
|
|
than the given file are printed; by default, all files under CVS are
|
|
|
|
printed. As a special case, if a file does not exist, it is always
|
|
|
|
printed.
|
|
|
|
"""
|
1997-08-14 17:14:54 -03:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
1997-11-24 19:49:35 -04:00
|
|
|
import stat
|
|
|
|
import getopt
|
1997-08-14 17:14:54 -03:00
|
|
|
|
1997-11-24 19:49:35 -04:00
|
|
|
cutofftime = 0
|
|
|
|
|
1997-08-14 17:14:54 -03:00
|
|
|
def main():
|
1997-11-24 19:49:35 -04:00
|
|
|
try:
|
1998-03-24 01:30:29 -04:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "n:")
|
1997-11-24 19:49:35 -04:00
|
|
|
except getopt.error, msg:
|
1998-03-24 01:30:29 -04:00
|
|
|
print msg
|
|
|
|
print __doc__,
|
|
|
|
return 1
|
1997-11-24 19:49:35 -04:00
|
|
|
global cutofftime
|
|
|
|
newerfile = None
|
|
|
|
for o, a in opts:
|
1998-03-24 01:30:29 -04:00
|
|
|
if o == '-n':
|
|
|
|
cutofftime = getmtime(a)
|
1997-08-14 17:14:54 -03:00
|
|
|
if args:
|
1998-03-24 01:30:29 -04:00
|
|
|
for arg in args:
|
|
|
|
process(arg)
|
1997-08-14 17:14:54 -03:00
|
|
|
else:
|
1998-03-24 01:30:29 -04:00
|
|
|
process(".")
|
1997-08-14 17:14:54 -03:00
|
|
|
|
|
|
|
def process(dir):
|
|
|
|
cvsdir = 0
|
|
|
|
subdirs = []
|
|
|
|
names = os.listdir(dir)
|
|
|
|
for name in names:
|
1998-03-24 01:30:29 -04:00
|
|
|
fullname = os.path.join(dir, name)
|
|
|
|
if name == "CVS":
|
|
|
|
cvsdir = fullname
|
|
|
|
else:
|
|
|
|
if os.path.isdir(fullname):
|
|
|
|
if not os.path.islink(fullname):
|
|
|
|
subdirs.append(fullname)
|
1997-08-14 17:14:54 -03:00
|
|
|
if cvsdir:
|
1998-03-24 01:30:29 -04:00
|
|
|
entries = os.path.join(cvsdir, "Entries")
|
|
|
|
for e in open(entries).readlines():
|
2002-09-11 17:36:02 -03:00
|
|
|
words = e.split('/')
|
1998-03-24 01:30:29 -04:00
|
|
|
if words[0] == '' and words[1:]:
|
|
|
|
name = words[1]
|
|
|
|
fullname = os.path.join(dir, name)
|
|
|
|
if cutofftime and getmtime(fullname) <= cutofftime:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
print fullname
|
1997-08-14 17:14:54 -03:00
|
|
|
for sub in subdirs:
|
1998-03-24 01:30:29 -04:00
|
|
|
process(sub)
|
1997-08-14 17:14:54 -03:00
|
|
|
|
1997-11-24 19:49:35 -04:00
|
|
|
def getmtime(filename):
|
|
|
|
try:
|
1998-03-24 01:30:29 -04:00
|
|
|
st = os.stat(filename)
|
1997-11-24 19:49:35 -04:00
|
|
|
except os.error:
|
1998-03-24 01:30:29 -04:00
|
|
|
return 0
|
1997-11-24 19:49:35 -04:00
|
|
|
return st[stat.ST_MTIME]
|
|
|
|
|
2004-08-09 14:27:55 -03:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|