From c8d68f93588825295d99fb26c01c12bd44d36788 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Sun, 17 Aug 2014 15:17:34 -0700 Subject: [PATCH] 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 --- gertty.yaml-sample | 2 +- gertty/app.py | 1 + gertty/commentlink.py | 2 +- gertty/search/tokenizer.py | 5 ++++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gertty.yaml-sample b/gertty.yaml-sample index 16e36c5..6942710 100644 --- a/gertty.yaml-sample +++ b/gertty.yaml-sample @@ -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 diff --git a/gertty/app.py b/gertty/app.py index 98b4da6..19488cb 100644 --- a/gertty/app.py +++ b/gertty/app.py @@ -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 diff --git a/gertty/commentlink.py b/gertty/commentlink.py index 5ab9b9a..4be27b3 100644 --- a/gertty/commentlink.py +++ b/gertty/commentlink.py @@ -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): diff --git a/gertty/search/tokenizer.py b/gertty/search/tokenizer.py index d86c379..f5a0668 100644 --- a/gertty/search/tokenizer.py +++ b/gertty/search/tokenizer.py @@ -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")