Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca83f01

Browse files
committed
Added "-n file" option to only print files newer than the given file.
1 parent e2d4dd1 commit ca83f01

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

Tools/scripts/cvsfiles.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
#! /usr/bin/env python
22

3-
"""Create a list of files that are mentioned in CVS directories."""
3+
"""Print a list of files that are mentioned in CVS directories.
4+
5+
Usage: cvsfiles.py [-n file] [directory] ...
6+
7+
If the '-n file' option is given, only files under CVS that are newer
8+
than the given file are printed; by default, all files under CVS are
9+
printed. As a special case, if a file does not exist, it is always
10+
printed.
11+
"""
412

513
import os
614
import sys
15+
import stat
16+
import getopt
717
import string
818

19+
cutofftime = 0
20+
921
def main():
10-
args = sys.argv[1:]
22+
try:
23+
opts, args = getopt.getopt(sys.argv[1:], "n:")
24+
except getopt.error, msg:
25+
print msg
26+
print __doc__,
27+
return 1
28+
global cutofftime
29+
newerfile = None
30+
for o, a in opts:
31+
if o == '-n':
32+
cutofftime = getmtime(a)
1133
if args:
1234
for arg in args:
1335
process(arg)
@@ -32,8 +54,19 @@ def process(dir):
3254
words = string.split(e, '/')
3355
if words[0] == '' and words[1:]:
3456
name = words[1]
35-
print os.path.join(dir, name)
57+
fullname = os.path.join(dir, name)
58+
if cutofftime and getmtime(fullname) <= cutofftime:
59+
pass
60+
else:
61+
print fullname
3662
for sub in subdirs:
3763
process(sub)
3864

39-
main()
65+
def getmtime(filename):
66+
try:
67+
st = os.stat(filename)
68+
except os.error:
69+
return 0
70+
return st[stat.ST_MTIME]
71+
72+
sys.exit(main())

0 commit comments

Comments
 (0)