[PATCH 2 of 6 V3] hgweb: add revsetsearch() function when query can be parsed as a revset

Kevin Bullock kbullock+mercurial at ringworld.org
Sun Sep 1 04:51:37 UTC 2013


On 27 Aug 2013, at 10:07 AM, Augie Fackler wrote:

> On Tue, Aug 27, 2013 at 11:34:51AM +0400, Alexander Plavin wrote:
>> 
>> 26.08.2013, 18:47, "Augie Fackler" <raf at durin42.com>:
>>> On Thu, Aug 22, 2013 at 07:11:13PM +0400, Alexander Plavin wrote:
>>> 
>>>>       def getsearchmode(query):
>>>>           try:
>>>>               ctx = web.repo[query]
>>>>           except (error.RepoError, error.LookupError):
>>>>  +            # query is not an exact revision pointer, need to
>>>>  +            # decide if it's a revset expession or keywords
>>>>  +            pass
>>>>  +        else:
>>>>  +            return 'rev', ctx
>>> 
>>> Why not just return from the try block instead of using try/else?
>> 
>> try/except/else here is actually introduced in an earlier patch (https://hg.plav.in/hg_fork/rev/5407b1e23932), and as for me it looks more symmetrical ('except' and 'else' branches), thus easier to read. Am I wrong here?
> 
> Doesn't bother me much one way or the other. I don't feel strongly.

We generally favor avoiding the 'else' keyword when it's not necessary. This generally applies to 'if' statements, but I'd say it applies here too. The return statement could just as easily go inside the try, and avoid making the reader have to remember what an 'else' clause on a 'try' block precisely does.

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



More information about the Mercurial-devel mailing list