summaryrefslogtreecommitdiff
path: root/devtools/p4sizes.py
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/p4sizes.py')
-rw-r--r--devtools/p4sizes.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/devtools/p4sizes.py b/devtools/p4sizes.py
new file mode 100644
index 0000000..7e7a5ab
--- /dev/null
+++ b/devtools/p4sizes.py
@@ -0,0 +1,37 @@
+
+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 )
+
+