Add [Builtin Hooks Exclude Paths] section

There is currently no convenient option to enable a hook globally if
some projects will fail the processing. The recommended setup is to
enable the hook within each project's repository (using PREUPLOAD.cfg).
This creates inconsistencies for large codebase. Adds a new
configuration section to explicitly exclude some projects during the
processing of a hook.

The intent of this change is to enable rustfmt globally in AOSP,
except for some paths (e.g. external/, vendor/).

Test: Modified GLOBAL-PREUPLOAD.cfg to enable the new option,
  manually creates changes and review output of pre-upload.py
Bug: 160223496
Change-Id: I94dbbf0ce2e6b58c4d4b4fc89c56a2a87543d878
diff --git a/pre-upload.py b/pre-upload.py
index 94bb961..e7ef564 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -274,16 +274,17 @@
                      (e,))
         return False
 
+    project = rh.Project(name=project_name, dir=proj_dir, remote=remote)
+    rel_proj_dir = os.path.relpath(proj_dir, rh.git.find_repo_root())
+
     os.environ.update({
         'REPO_LREV': rh.git.get_commit_for_ref(upstream_branch),
-        'REPO_PATH': os.path.relpath(proj_dir, rh.git.find_repo_root()),
+        'REPO_PATH': rel_proj_dir,
         'REPO_PROJECT': project_name,
         'REPO_REMOTE': remote,
         'REPO_RREV': rh.git.get_remote_revision(upstream_branch, remote),
     })
 
-    project = rh.Project(name=project_name, dir=proj_dir, remote=remote)
-
     if not commit_list:
         commit_list = rh.git.get_commits(
             ignore_merged_commits=config.ignore_merged_commits)
@@ -301,8 +302,10 @@
         commit_summary = desc.split('\n', 1)[0]
         output.commit_start(commit=commit, commit_summary=commit_summary)
 
-        for name, hook in hooks:
+        for name, hook, exclusion_scope in hooks:
             output.hook_start(name)
+            if rel_proj_dir in exclusion_scope:
+                break
             hook_results = hook(project, commit, desc, diff)
             (error, warning) = _process_hook_results(hook_results)
             if error is not None or warning is not None: