diff options
-rwxr-xr-x | gitdm | 27 | ||||
-rw-r--r-- | reports.py | 5 |
2 files changed, 21 insertions, 11 deletions
@@ -134,14 +134,24 @@ def AddAccess(path): except KeyError: FileAccesses[path] = 1 -def NoteFileAccess(path): - if path.startswith('a/') or path.startswith('b/'): - path = path[2:] - AddAccess(path) - path, last = os.path.split(path) - while path and path not in ['a', 'b', '/']: +def NoteFileAccess(paths): + # + # Keep separate track of what we've noted in this set so that each level + # of the tree only gets a single note from one patch. + # + noted = [ ] + for path in paths: + if path.startswith('a/') or path.startswith('b/'): + path = path[2:] AddAccess(path) + noted.append(path) path, last = os.path.split(path) + while path and path not in ['a', 'b', '/']: + if path in noted: + break + noted.append(path) + AddAccess(path) + path, last = os.path.split(path) @@ -491,8 +501,7 @@ for logpatch in patches: # Now note the file accesses if need be. # if FileReport: - for file in p.files: - NoteFileAccess(file) + NoteFileAccess(p.files) # # Record some global information - but only if this patch had # stuff which wasn't ignored. @@ -567,4 +576,4 @@ if ReportByFileType and Numstat: reports.ReportByFileType(hlist) if FileReport: - reports.FileAccessReport(FileReport, FileAccesses) + reports.FileAccessReport(FileReport, FileAccesses, CSCount) @@ -455,10 +455,11 @@ def ReportByFileType(hacker_list): # # The file access report is a special beast. # -def FileAccessReport(name, accesses): +def FileAccessReport(name, accesses, total): outf = open(name, 'w') files = accesses.keys() files.sort() for file in files: - outf.write('%6d %s\n' % (accesses[file], file)) + a = accesses[file] + outf.write('%6d %6.1f%% %s\n' % (a, (100.0*a)/total, file)) outf.close() |