- Notifications
You must be signed in to change notification settings - Fork 31.8k
/
Copy pathcvsfiles.py
executable file
·72 lines (63 loc) · 1.75 KB
/
cvsfiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env python
"""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.
"""
importos
importsys
importstat
importgetopt
cutofftime=0
defmain():
try:
opts, args=getopt.getopt(sys.argv[1:], "n:")
exceptgetopt.error, msg:
printmsg
print__doc__,
return1
globalcutofftime
newerfile=None
foro, ainopts:
ifo=='-n':
cutofftime=getmtime(a)
ifargs:
forarginargs:
process(arg)
else:
process(".")
defprocess(dir):
cvsdir=0
subdirs= []
names=os.listdir(dir)
fornameinnames:
fullname=os.path.join(dir, name)
ifname=="CVS":
cvsdir=fullname
else:
ifos.path.isdir(fullname):
ifnotos.path.islink(fullname):
subdirs.append(fullname)
ifcvsdir:
entries=os.path.join(cvsdir, "Entries")
foreinopen(entries).readlines():
words=e.split('/')
ifwords[0] ==''andwords[1:]:
name=words[1]
fullname=os.path.join(dir, name)
ifcutofftimeandgetmtime(fullname) <=cutofftime:
pass
else:
printfullname
forsubinsubdirs:
process(sub)
defgetmtime(filename):
try:
st=os.stat(filename)
exceptos.error:
return0
returnst[stat.ST_MTIME]
if__name__=='__main__':
main()