D5934: phabricator: make user searches case-insensitive

jcristau (Julien Cristau) phabricator at mercurial-scm.org
Mon Feb 11 15:28:34 UTC 2019


jcristau created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5934

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -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')



To: jcristau, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list