forked from nillerusr/source-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathp4sizes.py
37 lines (26 loc) · 858 Bytes
/
p4sizes.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
import sys, re, os
if len( sys.argv ) < 3:
print 'p4sizes.py shows the size of the last N revisions of a file in Perforce'
print 'usage: p4sizes.py filename N'
print 'ex : p4size.py //valvegames/rel/hl2/game/bin/engine.dll 10'
print ' (shows the sizes of the last 10 checkins to engine.dll)'
sys.exit( 1 )
filename = sys.argv[1]
nRevisions = sys.argv[2]
# Get the revisions list.
f = os.popen( 'p4 changes -m %s %s' % (nRevisions, filename) )
str = f.read()
f.close()
changelistNumbers = []
myRE = re.compile( r'change (?P<num>\d+?) on (?P<date>.+?) ', re.IGNORECASE )
while 1:
m = myRE.search( str )
if m:
str = str[m.end():]
changelistNumbers.append( [m.group('num'), m.group('date')] )
else:
break
for x in changelistNumbers:
sys.stdout.write( x[1] + ': ' )
cmd = 'p4 sizes %s@%s' % (filename, x[1])
os.system( cmd )