Correct some search problems

* correct the syntax in the example yaml file to use "change:"
* an error caused it to attempt to sync by number when using a change id
* define the change_id token with a function so that it is ordered
  in the lexer and takes precedence over strings

Change-Id: Ic48193ffd0a16f84b83f7c045ab990699fd8c755
This commit is contained in:
James E. Blair 2014-08-17 15:17:34 -07:00
parent 3d93f7a13a
commit c8d68f9358
4 changed files with 7 additions and 3 deletions

View File

@ -29,7 +29,7 @@ commentlinks:
replacements:
- search:
text: "{id}"
query: "changeid:{id}"
query: "change:{id}"
# This is the query used for the list of changes when a project is
# selected. The default is "status:open"; if you don't want to see

View File

@ -226,6 +226,7 @@ class App(object):
try:
number = int(number)
except ValueError:
number = None
changeid = query.split(':')[1].strip()
if not (number or changeid):
return

View File

@ -51,7 +51,7 @@ class SearchReplacement(object):
def replace(self, app, data):
link = mywid.Link(self.text.format(**data), 'link', 'focused-link')
urwid.connect_signal(link, 'selected',
lambda link:app.search(self.query.format(**data)))
lambda link:app.doSearch(self.query.format(**data)))
return link
class CommentLink(object):

View File

@ -68,7 +68,6 @@ tokens = [
] + operators.values()
def SearchTokenizer():
t_CHANGE_ID = r'I[a-fA-F0-9]{7,40}'
t_LPAREN = r'\('
t_RPAREN = r'\)'
t_NEG = r'!'
@ -78,6 +77,10 @@ def SearchTokenizer():
t.type = operators.get(t.value[:-1], 'OP')
return t
def t_CHANGE_ID(t):
r'I[a-fA-F0-9]{7,40}'
return t
def t_SSTRING(t):
r"'([^\\']+|\\'|\\\\)*'"
t.value=t.value[1:-1].decode("string-escape")