[PATCH 1 of 2 V2] hgweb: search() function supports direct pointing to revision

Alexander Plavin alexander at plav.in
Thu Aug 22 10:21:27 CDT 2013



20.08.2013, 06:08, "Kevin Bullock" <kbullock+mercurial at ringworld.org>:
> On 6 Aug 2013, at 4:55 PM, Alexander Plavin wrote:
>
>>  # 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'
>
> As this stands, you're calling web.repo.__getitem__ twice. Not keen on that.

Fixed that (in the three new series, flagged with V3). Although change is conceptually simple, it affected multiple patches in all these series. And the "microarchitecture" became better as for me :)

>
> pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
> Kevin R. Bullock


More information about the Mercurial-devel mailing list