OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """A database of OWNERS files.""" | 5 """A database of OWNERS files.""" |
6 | 6 |
7 import re | 7 import re |
8 | 8 |
9 | 9 |
10 # If this is present by itself on a line, this means that everyone can review. | 10 # If this is present by itself on a line, this means that everyone can review. |
(...skipping 26 matching lines...) Expand all Loading... |
37 """Args: | 37 """Args: |
38 root: the path to the root of the Repository | 38 root: the path to the root of the Repository |
39 open: function callback to open a text file for reading | 39 open: function callback to open a text file for reading |
40 os_path: module/object callback with fields for 'abspath', 'dirname', | 40 os_path: module/object callback with fields for 'abspath', 'dirname', |
41 'exists', and 'join' | 41 'exists', and 'join' |
42 """ | 42 """ |
43 self.root = root | 43 self.root = root |
44 self.fopen = fopen | 44 self.fopen = fopen |
45 self.os_path = os_path | 45 self.os_path = os_path |
46 | 46 |
47 # TODO: Figure out how to share the owners email addr format w/ | 47 # Pick a default email regexp to use; callers can override as desired. |
48 # tools/commit-queue/projects.py, especially for per-repo whitelists. | |
49 self.email_regexp = re.compile(BASIC_EMAIL_REGEXP) | 48 self.email_regexp = re.compile(BASIC_EMAIL_REGEXP) |
50 | 49 |
51 # Mapping of owners to the paths they own. | 50 # Mapping of owners to the paths they own. |
52 self.owned_by = {EVERYONE: set()} | 51 self.owned_by = {EVERYONE: set()} |
53 | 52 |
54 # Mapping of paths to authorized owners. | 53 # Mapping of paths to authorized owners. |
55 self.owners_for = {} | 54 self.owners_for = {} |
56 | 55 |
57 # Set of paths that stop us from looking above them for owners. | 56 # Set of paths that stop us from looking above them for owners. |
58 # (This is implicitly true for the root directory). | 57 # (This is implicitly true for the root directory). |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 # short combinations of owners. | 154 # short combinations of owners. |
156 every_owner = set() | 155 every_owner = set() |
157 for f in files: | 156 for f in files: |
158 dirname = self.os_path.dirname(f) | 157 dirname = self.os_path.dirname(f) |
159 while dirname in self.owners_for: | 158 while dirname in self.owners_for: |
160 every_owner |= self.owners_for[dirname] | 159 every_owner |= self.owners_for[dirname] |
161 if self._stop_looking(dirname): | 160 if self._stop_looking(dirname): |
162 break | 161 break |
163 dirname = self.os_path.dirname(dirname) | 162 dirname = self.os_path.dirname(dirname) |
164 return every_owner | 163 return every_owner |
OLD | NEW |