[PATCH 1 of 2 V2] hgweb: search() function supports direct pointing to revision
Alexander Plavin
alexander at plav.in
Tue Aug 6 16:55:58 CDT 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1374187271 -14400
# Fri Jul 19 02:41:11 2013 +0400
# Node ID 6519709f0402a4ca4d28b0f2c0e96e79fa41763b
# Parent e273fa3d540fb888ee6c260ee30b9e9b2b0f4d65
hgweb: search() function supports direct pointing to revision
This doesn't change the behavior, as queries directly pointing to revisions
are not delegated to the search() function now.
diff -r e273fa3d540f -r 6519709f0402 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py Fri Jul 19 02:08:19 2013 +0400
+++ b/mercurial/hgweb/webcommands.py Fri Jul 19 02:41:11 2013 +0400
@@ -110,6 +110,9 @@
def _search(web, req, tmpl):
+ def revsearch():
+ yield web.repo[query]
+
def keywordsearch():
lower = encoding.lower
qw = lower(query).split()
@@ -138,10 +141,15 @@
yield ctx
+ searchfuncs = {
+ 'rev': revsearch,
+ 'kw': keywordsearch,
+ }
+
def changelist(**map):
count = 0
- for ctx in keywordsearch():
+ for ctx in searchfunc():
count += 1
n = ctx.node()
showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
@@ -181,6 +189,14 @@
morevars['revcount'] = revcount * 2
morevars['rev'] = query
+ try:
+ web.repo[query]
+ modename = 'rev'
+ except (error.RepoError, error.LookupError):
+ modename = 'kw'
+
+ searchfunc = searchfuncs[modename]
+
tip = web.repo['tip']
parity = paritygen(web.stripecount)
More information about the Mercurial-devel
mailing list