summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2016-08-17 12:06:28 +0200
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-09-17 10:09:36 -0300
commit3e6ffd57be90445f46254379d71bd3a66b2b9a71 (patch)
tree8566df9f897971cf04ff5fce7666a3efd0fdba12
parente6950e10eb93fe197eb6d39f8ea2fcec8416865c (diff)
git-phab: Use repository.query for all repository queries
Instead of downloading the entire list of repositories and manually searching through by remote URI. Signed-off-by: Philip Withnall <philip.withnall@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com> Differential Revision: https://phabricator.freedesktop.org/D1284
-rwxr-xr-xgit-phab26
1 files changed, 16 insertions, 10 deletions
diff --git a/git-phab b/git-phab
index 7943564..69a457a 100755
--- a/git-phab
+++ b/git-phab
@@ -580,19 +580,25 @@ Paste API Token from that page and press <enter>: """ % self.phabricator_uri)
if "repository.callsign" in self.arcconfig:
reply = self.phabricator.repository.query(
callsigns=[self.arcconfig["repository.callsign"]])
- assert(len(reply) == 1)
- self.phab_repo = reply[0]
+
+ if len(reply) > 1:
+ self.die("Multiple repositories returned for callsign ‘{}’.\n"
+ "You should check your Phabricator "
+ "configuration.".format(
+ self.arcconfig["repository.callsign"]))
else:
- for phab_repo in self.phabricator.repository.query(limit=10000):
- if self.phab_repo:
- break
+ uris = [remote.url for remote in self.repo.remotes]
+ reply = self.phabricator.repository.query(
+ remoteURIs=uris)
- for remote in self.repo.remotes:
- if phab_repo['remoteURI'] == remote.url:
- self.phab_repo = phab_repo
- break
+ if len(reply) > 1:
+ self.die("Multiple repositories returned for remote URIs "
+ "({}).\nYou should check your Phabricator "
+ "configuration.".format(', '.join(uris)))
- if not self.phab_repo:
+ try:
+ self.phab_repo = reply[0]
+ except IndexError:
self.die("Could not determine Phabricator repository\n"
"You should check your git remote URIs match those "
"in Phabricator, or set 'repository.callsign' in "