changeset 41716:570e62f1dcf2

phabricator: make user searches case-insensitive User names in conduit are case insensitive, but when looking for "FOO" it would return "foo" instead and we'd think the user didn't exist. So lower case both the query and the response when comparing them. Differential Revision: https://phab.mercurial-scm.org/D5934
author Julien Cristau <jcristau@mozilla.com>
date Mon, 11 Feb 2019 16:27:20 +0100
parents 3b0ba4575c8c
children 7396508ad92b
files hgext/phabricator.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Fri Feb 15 11:31:17 2019 -0800
+++ b/hgext/phabricator.py	Mon Feb 11 16:27:20 2019 +0100
@@ -450,12 +450,13 @@
 
 def userphids(repo, names):
     """convert user names to PHIDs"""
+    names = [name.lower() for name in names]
     query = {b'constraints': {b'usernames': names}}
     result = callconduit(repo, b'user.search', query)
     # username not found is not an error of the API. So check if we have missed
     # some names here.
     data = result[r'data']
-    resolved = set(entry[r'fields'][r'username'] for entry in data)
+    resolved = set(entry[r'fields'][r'username'].lower() for entry in data)
     unresolved = set(names) - resolved
     if unresolved:
         raise error.Abort(_(b'unknown username: %s')