##// END OF EJS Templates
Add unique boolean argument to history search
Takafumi Arakaki -
Show More
@@ -307,7 +307,7 b' class HistoryAccessor(Configurable):'
307 307
308 308 @catch_corrupt_db
309 309 def search(self, pattern="*", raw=True, search_raw=True,
310 output=False, n=None):
310 output=False, n=None, unique=False):
311 311 """Search the database using unix glob-style matching (wildcards
312 312 * and ?).
313 313
@@ -322,6 +322,8 b' class HistoryAccessor(Configurable):'
322 322 n : None or int
323 323 If an integer is given, it defines the limit of
324 324 returned entries.
325 unique : bool
326 When it is true, return only unique entries.
325 327
326 328 Returns
327 329 -------
@@ -333,9 +335,13 b' class HistoryAccessor(Configurable):'
333 335 self.writeout_cache()
334 336 sqlform = "WHERE %s GLOB ?" % tosearch
335 337 params = (pattern,)
338 if unique:
339 sqlform += ' GROUP BY {0}'.format(tosearch)
336 340 if n is not None:
337 341 sqlform += " ORDER BY session DESC, line DESC LIMIT ?"
338 342 params += (n,)
343 elif unique:
344 sqlform += " ORDER BY session, line"
339 345 cur = self._run_sql(sqlform, params, raw=raw, output=output)
340 346 if n is not None:
341 347 return reversed(list(cur))
General Comments 0
You need to be logged in to leave comments. Login now