Suggest owners for OWNERS files that only have per-file owners.

If you were creating a new OWNERS file that only had per-file owners
in it (and no catch-all owners for the whole directory), then we
would not look for suggested owners in parent directories, and end up
suggesting nothing. See https://chromiumcodereview.appspot.com/11555036/
for the CL that revealed this.

Also, the unit tests were incorrectly using absolute paths in some cases,
making the code less predictable; I've fixed the unit tests and added
a check for this into owners.py (real changes never used absolute paths,
just paths relative to the checkout root).

R=maruel@chromium.org


Review URL: https://chromiumcodereview.appspot.com/11569018

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@173000 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/owners.py b/owners.py
index 109273e..1b1775f 100644
--- a/owners.py
+++ b/owners.py
@@ -157,7 +157,8 @@
     def _is_under(f, pfx):
       return self.os_path.abspath(self.os_path.join(pfx, f)).startswith(pfx)
     _assert_is_collection(files)
-    assert all(_is_under(f, self.os_path.abspath(self.root)) for f in files)
+    assert all(not self.os_path.isabs(f) and
+                _is_under(f, self.os_path.abspath(self.root)) for f in files)
 
   def _check_reviewers(self, reviewers):
     _assert_is_collection(reviewers)
@@ -256,7 +257,8 @@
     # Get the set of directories from the files.
     dirs = set()
     for f in files:
-      dirs.add(self.os_path.dirname(f))
+      dirs.add(self._enclosing_dir_with_owners(f))
+
 
     owned_dirs = {}
     dir_owners = {}