Explorar el Código

Reverted gitstats to revision 76d1dc7a8be6523fde1252850790494442220e0c.

This reverts "Attempt to optimize file counting." and related commits.

(commit c257429c561af8b99bb0a0daa65871a80a9fedb2)
Heikki Hokkanen hace 18 años
padre
commit
29040361ca
Se han modificado 1 ficheros con 14 adiciones y 16 borrados
  1. 14
    16
      gitstats

+ 14
- 16
gitstats Ver fichero

@@ -128,17 +128,9 @@ class GitDataCollector(DataCollector):
128 128
 			pass
129 129
 
130 130
 		# Collect revision statistics
131
-		# "commit <hash>"
132
-		# "<stamp> <author>"
133
-		self.files_by_stamp = {} # stamp -> files
134
-		lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD').split('\n')
135
-		self.total_commits = len(lines) / 2
136
-		commit = '0'
131
+		# Outputs "<stamp> <author>"
132
+		lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD |grep -v ^commit').split('\n')
137 133
 		for line in lines:
138
-			if line[0] == 'c':
139
-				commit = line[7:]
140
-				continue
141
-			
142 134
 			# linux-2.6 says "<unknown>" for one line O_o
143 135
 			parts = line.split(' ')
144 136
 			author = ''
@@ -226,14 +218,20 @@ class GitDataCollector(DataCollector):
226 218
 			else:
227 219
 				self.commits_by_year[yy] = 1
228 220
 
229
-			# file statistics
230
-			# "<stamp> <files>"
221
+		# TODO Optimize this, it's the worst bottleneck
222
+		# outputs "<stamp> <files>" for each revision
223
+		self.files_by_stamp = {} # stamp -> files
224
+		lines = getoutput('git-rev-list --pretty=format:"%at %H" HEAD |grep -v ^commit |while read line; do set $line; echo "$1 $(git-ls-tree -r "$2" |wc -l)"; done').split('\n')
225
+		self.total_commits = len(lines)
226
+		for line in lines:
227
+			parts = line.split(' ')
228
+			if len(parts) != 2:
229
+				continue
230
+			(stamp, files) = parts[0:2]
231 231
 			try:
232
-				files = int(getoutput('git-ls-tree -r "%s" |wc -l' % commit, quiet = True))
232
+				self.files_by_stamp[int(stamp)] = int(files)
233 233
 			except ValueError:
234
-				files = 0
235
-				print 'Warning: failed to collect file statistics for commit "%s"' % commit
236
-			self.files_by_stamp[stamp] = files
234
+				print 'Warning: failed to parse line "%s"' % line
237 235
 
238 236
 		# extensions
239 237
 		self.extensions = {} # extension -> files, lines