##// END OF EJS Templates
Add multiple keyword search to hgweb...
mpm@selenic.com -
r538:7140bc78 default
parent child Browse files
Show More
@@ -0,0 +1,28 b''
1 #header#
2 <title>#repo|escape#: searching for #query|escape#</title>
3 </head>
4 <body>
5
6 <div class="buttons">
7 <a href="?cmd=changelog;rev=#rev#">changelog</a>
8 <a href="?cmd=tags">tags</a>
9 <a href="?cmd=manifest;manifest=#manifest#;path=/">manifest</a>
10 </div>
11
12 <h2>searching for #query|escape#</h2>
13
14 <form>
15 search:
16 <input type="hidden" name="cmd" value="changelog">
17 <input name="rev" type="text" width="30" value="#query|escape#">
18 </form>
19
20 #entries#
21
22 <form>
23 search:
24 <input type="hidden" name="cmd" value="changelog">
25 <input name="rev" type="text" width="30">
26 </form>
27
28 #footer#
@@ -0,0 +1,22 b''
1 <div class="parity#parity#">
2 <table width="100%" cellpadding="0" cellspacing="0">
3 <tr>
4 <td align="right" width="15%"><b>#date|age# ago:&nbsp;</b></td>
5 <td><b>#desc|firstline|escape#</b></td></tr>
6 <tr>
7 <td align="right">changeset #rev#:&nbsp;</td>
8 <td><a href="?cmd=changeset;node=#node#">#node|short#</a></td></tr>
9 #parent1#
10 #parent2#
11 <tr>
12 <td align="right">author:&nbsp;</td>
13 <td>#author|obfuscate#</td></tr>
14 <tr>
15 <td align="right">date:&nbsp;</td>
16 <td>#date|date#</td></tr>
17 <tr>
18 <td align="right" valign="top"><a href="?cmd=manifest;manifest=#manifest#;path=/">files</a>:&nbsp;</td>
19 <td>#files#</td></tr>
20 </table>
21 </div>
22
@@ -286,6 +286,68 b' class hgweb:'
286 286 manifest = hex(mf),
287 287 rev = pos, changesets = count, entries = changelist)
288 288
289 def search(self, query):
290
291 def changelist():
292 cl = self.repo.changelog
293 count = 0
294 qw = query.lower().split()
295
296 def revgen():
297 for i in range(cl.count() - 1, 0, -100):
298 l = []
299 for j in range(max(0, i - 100), i):
300 n = cl.node(j)
301 changes = cl.read(n)
302 l.insert(0, (n, j, changes))
303 for e in l:
304 yield e
305
306 for n, i, changes in revgen():
307 miss = 0
308 for q in qw:
309 if not (q in changes[1].lower() or
310 q in changes[4].lower() or
311 q in " ".join(changes[3][:20]).lower()):
312 miss = 1
313 break
314 if miss: continue
315
316 count += 1
317 hn = hex(n)
318 p1, p2 = cl.parents(n)
319 t = float(changes[2].split(' ')[0])
320
321 yield self.t(
322 'searchentry',
323 parity = count & 1,
324 author = changes[1],
325 parent1 = self.parent("changelogparent",
326 hex(p1), cl.rev(p1)),
327 parent2 = self.parent("changelogparent",
328 hex(p2), cl.rev(p2)),
329 p1 = hex(p1), p2 = hex(p2),
330 p1rev = cl.rev(p1), p2rev = cl.rev(p2),
331 manifest = hex(changes[0]),
332 desc = changes[4],
333 date = t,
334 files = self.listfilediffs(changes[3], n),
335 rev = i,
336 node = hn)
337
338 if count >= self.maxchanges: break
339
340 cl = self.repo.changelog
341 mf = cl.read(cl.tip())[0]
342
343 yield self.t('search',
344 header = self.header(),
345 footer = self.footer(),
346 query = query,
347 repo = self.reponame,
348 manifest = hex(mf),
349 entries = changelist)
350
289 351 def changeset(self, nodeid):
290 352 n = bin(nodeid)
291 353 cl = self.repo.changelog
@@ -586,13 +648,16 b' class hgweb:'
586 648 self.t = templater(m, self.filters)
587 649
588 650 if not args.has_key('cmd') or args['cmd'][0] == 'changelog':
589 hi = self.repo.changelog.count() - 1
651 c = self.repo.changelog.count() - 1
652 hi = c
590 653 if args.has_key('rev'):
591 654 hi = args['rev'][0]
592 655 try:
593 656 hi = self.repo.changelog.rev(self.repo.lookup(hi))
594 except KeyError: pass
595
657 except KeyError:
658 write(self.search(hi))
659 return
660
596 661 write(self.changelog(hi))
597 662
598 663 elif args['cmd'][0] == 'changeset':
@@ -1,11 +1,13 b''
1 1 header = header.tmpl
2 2 footer = footer.tmpl
3 search = search.tmpl
3 4 changelog = changelog.tmpl
4 5 naventry = "<a href="?cmd=changelog;rev=#rev#">#label#</a> "
5 6 filedifflink = "<a href="?cmd=filediff;node=#node#;file=#file#">#file#</a> "
6 7 filenodelink = "<a href="?cmd=file;filenode=#filenode#;file=#file#">#file#</a> "
7 8 fileellipses = "..."
8 9 changelogentry = changelogentry.tmpl
10 searchentry = searchentry.tmpl
9 11 changeset = changeset.tmpl
10 12 manifest = manifest.tmpl
11 13 manifestdirentry = "<tr class="parity#parity#"><td><tt>drwxr-xr-x</tt>&nbsp;<td><a href="?cmd=manifest;manifest=#manifest#;path=#path#">#basename#/</a>"
General Comments 0
You need to be logged in to leave comments. Login now