Added support for private projects.
_gen_* functions are defined in projects.py. This file now looks for
../commit-queue-internal/projects_internal.py for more _gen_* functions.
BUG=336455
Review URL: https://codereview.chromium.org/144163002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/commit-queue@247456 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/commit_queue.py b/commit_queue.py
index fce6c33..17a95ef 100755
--- a/commit_queue.py
+++ b/commit_queue.py
@@ -128,7 +128,7 @@
class SignalInterrupt(Exception):
"""Exception that indicates being interrupted by a caught signal."""
-
+
def __init__(self, signal_set=None, *args, **kwargs):
super(SignalInterrupt, self).__init__(*args, **kwargs)
self.signal_set = signal_set
diff --git a/projects.py b/projects.py
index 8ca0b72..181a1bc 100644
--- a/projects.py
+++ b/projects.py
@@ -39,6 +39,7 @@
import gyp_committers # pylint: disable=F0401
import nacl_committers # pylint: disable=F0401
import skia_committers # pylint: disable=F0401
+ import projects_internal # pylint: disable=F0401
else:
print >> sys.stderr, (
'Failed to find commit-queue-internal; will fail to start!')
@@ -46,7 +47,7 @@
gyp_committers = None
nacl_committers = None
skia_committers = None
-
+ projects_internal = None
# It's tricky here because 'chrome' is remapped to 'svn' on src.chromium.org but
# the other repositories keep their repository name. So don't list it here.
@@ -759,14 +760,45 @@
verifiers)
+def _get_supported_projects():
+ """Return project names and corresponding functions in a dict.
+
+ Projects functions start with '_gen_' and are searched for in the present
+ file and in commit-queue-internal/projects_internal.py.
+ """
+ projects = {}
+ for name in dir(sys.modules[__name__]):
+ if name.startswith('_gen_'):
+ projects[name[5:]] = getattr(sys.modules[__name__], name)
+
+ if projects_internal:
+ for name in dir(sys.modules['projects_internal']):
+ if name.startswith('_gen_'):
+ if name[5:] in projects:
+ raise errors.ConfigurationError(
+ 'public project function %s overriden by private one'
+ % name)
+ projects[name[5:]] = getattr(sys.modules['projects_internal'], name)
+
+ return projects
+
+
def supported_projects():
"""List the projects that can be managed by the commit queue."""
- return sorted(
- x[5:] for x in dir(sys.modules[__name__]) if x.startswith('_gen_'))
+ return sorted(_get_supported_projects().keys())
def load_project(project, user, root_dir, rietveld_obj, no_try):
- """Loads the specified project."""
+ """Loads the specified project.
+
+ Args:
+ project (string): project name (suffix of _gen_* functions above)
+ user (string): email address identifying the commit bot.
+ root_dir (string): working directory (were credentials are stored e.g. .gaia)
+ rietveld_obj (rietveld.Rietveld): object for communicating with Rietveld.
+ no_try (boolean): is True, means "do not send try jobs"
+ """
assert os.path.isabs(root_dir)
- return getattr(sys.modules[__name__], '_gen_' + project)(
- user, root_dir, rietveld_obj, no_try)
+ return _get_supported_projects()[project](
+ user, root_dir, rietveld_obj, no_try)
+