summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2013-02-08 17:21:25 -0700
committerJonathan Corbet <corbet@lwn.net>2013-02-08 17:21:25 -0700
commitdd45a96f0a035d10cc12973e9931df3c9d95a781 (patch)
treea6fe2b4662521c7afe74a48282292cc0a8c646b8
parentec35b5940e83219367993e00cc799a6b3a07446f (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-xgitdm27
-rw-r--r--reports.py5
2 files changed, 21 insertions, 11 deletions
diff --git a/gitdm b/gitdm
index d794d2f..14dc88e 100755
--- a/gitdm
+++ b/gitdm
@@ -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)
diff --git a/reports.py b/reports.py
index 78800bd..084089e 100644
--- a/reports.py
+++ b/reports.py
@@ -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()