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

Unified Diff: owners.py

Issue 10384099: Readd missing unittests for owners (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix failure to track max_count Created 8 years, 7 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 | tests/owners_unittest.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 d3028a593462177d881456d357f478273c63c831..e51997ccdf74c60a6ff872d8da51bb7796125b8c 100644
--- a/owners.py
+++ b/owners.py
@@ -178,9 +178,8 @@ class Database(object):
current_owners = set()
dirname = current_dir
while dirname in self.owners_for:
- for owner in self.owners_for[dirname]:
- current_owners.add(owner)
- if self._stop_looking(dirname):
+ current_owners |= self.owners_for[dirname]
+ if self._stop_looking(dirname) or dirname == '/':
Dirk Pranke 2012/05/10 18:26:11 I'm a bit troubled by the "dirname == '/'" additio
break
dirname = self.os_path.dirname(dirname)
@@ -189,9 +188,7 @@ class Database(object):
# Add the directory to the list of each owner.
for owner in current_owners:
- if not owner in owned_dirs:
- owned_dirs[owner] = set()
- owned_dirs[owner].add(current_dir)
+ owned_dirs.setdefault(owner, set()).add(current_dir)
final_owners = set()
while dirs:
@@ -205,6 +202,7 @@ class Database(object):
owner_count[owner] = count
if count >= max_count:
max_owner = owner
+ max_count = count
# If no more directories have OWNERS, we're done.
if not max_owner:
@@ -215,7 +213,6 @@ class Database(object):
# Remove all directories owned by the current owner from the remaining
# list.
for dirname in owned_dirs[max_owner]:
- if dirname in dirs:
- dirs.remove(dirname)
+ dirs.discard(dirname)
return final_owners
« no previous file with comments | « no previous file | tests/owners_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698