Handle change id in simple searches

Accept the full change id in addition to the change number as a
simple search query.  Also be more lenient about leading or trailing
whitespace (which is useful when copy/pasting change ids when
searching).

Change-Id: If8e6186e3487a468ef945408fe46bd8c57875a3b
This commit is contained in:
James E. Blair 2015-03-13 16:53:28 -07:00
parent edf0322043
commit 6a812bdb7a
1 changed files with 6 additions and 5 deletions

View File

@ -18,6 +18,7 @@ import dateutil
import logging
import os
import Queue
import re
import subprocess
import sys
import threading
@ -155,6 +156,8 @@ class BackgroundBrowser(webbrowser.GenericBrowser):
return False
class App(object):
simple_change_search= re.compile('^(\d+|I[a-fA-F0-9]{40})$')
def __init__(self, server=None, palette='default', keymap='default',
debug=False, verbose=False, disable_sync=False,
fetch_missing_refs=False, path=config.DEFAULT_CONFIG_PATH):
@ -401,11 +404,9 @@ class App(object):
def _searchDialog(self, dialog):
self.backScreen()
query = dialog.entry.edit_text
try:
query = 'change:%s' % int(query)
except ValueError:
pass
query = dialog.entry.edit_text.strip()
if self.simple_change_search.match(query):
query = 'change:%s' % query
self.doSearch(query)
def error(self, message):