Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1030)

Unified Diff: owners.py

Issue 12326151: Add a way to require approval from owners other than the author. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: fix wording in comment Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: owners.py
diff --git a/owners.py b/owners.py
index c53f0123d09cb9e7edb03d05278b42da9522f112..cc667beea3c575f527470d9bd25269b4e95c6bae 100644
--- a/owners.py
+++ b/owners.py
@@ -115,13 +115,15 @@ class Database(object):
# (This is implicitly true for the root directory).
self.stop_looking = set([''])
- def reviewers_for(self, files):
+ def reviewers_for(self, files, author):
"""Returns a suggested set of reviewers that will cover the files.
- files is a sequence of paths relative to (and under) self.root."""
+ files is a sequence of paths relative to (and under) self.root.
+ If author is nonempty, we ensure it is not included in the set returned
+ in order avoid suggesting the author as a reviewer for their own changes."""
self._check_paths(files)
self._load_data_needed_for(files)
- suggested_owners = self._covering_set_of_owners_for(files)
+ suggested_owners = self._covering_set_of_owners_for(files, author)
if EVERYONE in suggested_owners:
if len(suggested_owners) > 1:
suggested_owners.remove(EVERYONE)
@@ -236,9 +238,9 @@ class Database(object):
('%s is not a "set" directive, "*", '
'or an email address: "%s"' % (line_type, directive)))
- def _covering_set_of_owners_for(self, files):
+ def _covering_set_of_owners_for(self, files, author):
dirs_remaining = set(self._enclosing_dir_with_owners(f) for f in files)
- all_possible_owners = self._all_possible_owners(dirs_remaining)
+ all_possible_owners = self._all_possible_owners(dirs_remaining, author)
suggested_owners = set()
while dirs_remaining:
owner = self.lowest_cost_owner(all_possible_owners, dirs_remaining)
@@ -247,7 +249,7 @@ class Database(object):
dirs_remaining -= dirs_to_remove
return suggested_owners
- def _all_possible_owners(self, dirs):
+ def _all_possible_owners(self, dirs, author):
"""Returns a list of (potential owner, distance-from-dir) tuples; a
distance of 1 is the lowest/closest possible distance (which makes the
subsequent math easier)."""
@@ -257,6 +259,8 @@ class Database(object):
distance = 1
while True:
for owner in self.owners_for.get(dirname, []):
+ if author and owner == author:
+ continue
all_possible_owners.setdefault(owner, [])
# If the same person is in multiple OWNERS files above a given
# directory, only count the closest one.
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698