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)
580 if "repository.callsign" in self.arcconfig: 580 if "repository.callsign" in self.arcconfig:
581 reply = self.phabricator.repository.query( 581 reply = self.phabricator.repository.query(
582 callsigns=[self.arcconfig["repository.callsign"]]) 582 callsigns=[self.arcconfig["repository.callsign"]])
583 assert(len(reply) == 1) 583
584 self.phab_repo = reply[0] 584 if len(reply) > 1:
585 self.die("Multiple repositories returned for callsign ‘{}’.\n"
586 "You should check your Phabricator "
587 "configuration.".format(
588 self.arcconfig["repository.callsign"]))
585 else: 589 else:
586 for phab_repo in self.phabricator.repository.query(limit=10000): 590 uris = [remote.url for remote in self.repo.remotes]
587 if self.phab_repo: 591 reply = self.phabricator.repository.query(
588 break 592 remoteURIs=uris)
589 593
590 for remote in self.repo.remotes: 594 if len(reply) > 1:
591 if phab_repo['remoteURI'] == remote.url: 595 self.die("Multiple repositories returned for remote URIs "
592 self.phab_repo = phab_repo 596 "({}).\nYou should check your Phabricator "
593 break 597 "configuration.".format(', '.join(uris)))
594 598
595 if not self.phab_repo: 599 try:
600 self.phab_repo = reply[0]
601 except IndexError:
596 self.die("Could not determine Phabricator repository\n" 602 self.die("Could not determine Phabricator repository\n"
597 "You should check your git remote URIs match those " 603 "You should check your git remote URIs match those "
598 "in Phabricator, or set 'repository.callsign' in " 604 "in Phabricator, or set 'repository.callsign' in "