[owners] Add BatchListOwners

BatchListOwners uses git_common's ScopedPool method to run
ListOwnersForFile in parallel for multiple paths.

Change-Id: I545072e16181407665c8b009f87fccfb7355d7d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2585657
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Gavin Mak
2020-12-11 20:56:03 +00:00
committed by LUCI CQ
parent c94b21d60c
commit 99399caeac
2 changed files with 24 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import os
import random
import gerrit_util
import git_common
import owners as owners_db
import scm
@@ -66,6 +67,12 @@ class OwnersClient(object):
"""
raise Exception('Not implemented')
def BatchListOwners(self, project, branch, paths):
"""Returns a dictionary {path: [owners]}."""
with git_common.ScopedPool(kind='threads') as pool:
return dict(pool.imap_unordered(
lambda p: (p, self.ListOwnersForFile(project, branch, p)), paths))
def GetChangeApprovalStatus(self, change_id):
"""Check the approval status for the latest revision_id in a change.