diff options
author | Jonathan Corbet <corbet@lwn.net> | 2013-02-08 17:21:25 -0700 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2013-02-08 17:21:25 -0700 |
commit | dd45a96f0a035d10cc12973e9931df3c9d95a781 (patch) | |
tree | a6fe2b4662521c7afe74a48282292cc0a8c646b8 | |
parent | ec35b5940e83219367993e00cc799a6b3a07446f (diff) |
Add percentages to the touched-files report
...oh, and while I'm at it, make that report actually work right so that a
patch touching three driver files only shows up once at the drivers/ level.
-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() |