[PATCH] ChangesetCommentsModel: refactor duplicate code

Mads Kiilerich mads at kiilerich.com
Wed Apr 29 18:44:28 EDT 2015


On 04/29/2015 10:09 PM, Jan Heylen wrote:
> -
> -        q = ChangesetComment.query()\
> -                .filter(ChangesetComment.repo_id == repo_id)\
> -                .filter(ChangesetComment.line_no == None)\
> -                .filter(ChangesetComment.f_path == None)
> -        if revision:
> -            q = q.filter(ChangesetComment.revision == revision)
> -        elif pull_request:

btw: it seems like this chunk of code (that you are de-duplicating but 
not directly touching) could misbehave if revision or pull_request 
somehow was specified as something that was non-null but had false 
value. It should thus use 'if revision is not None' instead (and perhaps 
assert pull_request is None).

/Mads


More information about the kallithea-general mailing list