Mercurial > kallithea
comparison rhodecode/lib/hooks.py @ 3625:260a7a01b054 beta
follow Python conventions for boolean values
True and False might be singletons and the "default" values for "boolean"
expressions, but "all" values in Python has a boolean value and should be
evaluated as such. Checking with 'is True' and 'is False' is thus confusing,
error prone and unnessarily complex.
If we anywhere rely and nullable boolean fields from the database layer and
don't want the null value to be treated as False then we should check
explicitly for null with 'is None'.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 28 Mar 2013 01:10:45 +0100 |
parents | 47631be9f449 |
children | 55585c86be83 |
comparison
equal
deleted
inserted
replaced
3624:4dddb7ee8865 | 3625:260a7a01b054 |
---|---|
141 if isfunction(callback): | 141 if isfunction(callback): |
142 kw = {} | 142 kw = {} |
143 kw.update(ex) | 143 kw.update(ex) |
144 callback(**kw) | 144 callback(**kw) |
145 | 145 |
146 if ex.make_lock is True: | 146 if ex.make_lock: |
147 Repository.lock(Repository.get_by_repo_name(ex.repository), user.user_id) | 147 Repository.lock(Repository.get_by_repo_name(ex.repository), user.user_id) |
148 #msg = 'Made lock on repo `%s`' % repository | 148 #msg = 'Made lock on repo `%s`' % repository |
149 #sys.stdout.write(msg) | 149 #sys.stdout.write(msg) |
150 | 150 |
151 if ex.locked_by[0]: | 151 if ex.locked_by[0]: |
200 if isfunction(callback): | 200 if isfunction(callback): |
201 kw = {'pushed_revs': revs} | 201 kw = {'pushed_revs': revs} |
202 kw.update(ex) | 202 kw.update(ex) |
203 callback(**kw) | 203 callback(**kw) |
204 | 204 |
205 if ex.make_lock is False: | 205 if not ex.make_lock: |
206 Repository.unlock(Repository.get_by_repo_name(ex.repository)) | 206 Repository.unlock(Repository.get_by_repo_name(ex.repository)) |
207 msg = 'Released lock on repo `%s`\n' % ex.repository | 207 msg = 'Released lock on repo `%s`\n' % ex.repository |
208 sys.stdout.write(msg) | 208 sys.stdout.write(msg) |
209 | 209 |
210 if ex.locked_by[0]: | 210 if ex.locked_by[0]: |