Mercurial > kallithea
changeset 6579:72db2cd3e99e
lib: slight cleanup of _check_locking_state
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 07 Apr 2017 04:21:32 +0200 |
parents | 0d4dd9380a45 |
children | 8eda7bc543cd |
files | kallithea/lib/base.py |
diffstat | 1 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/base.py Mon Mar 20 21:06:31 2017 +0100 +++ b/kallithea/lib/base.py Fri Apr 07 04:21:32 2017 +0200 @@ -326,12 +326,11 @@ def _check_locking_state(self, environ, action, repo, user_id): """ - Checks locking on this repository, if locking is enabled and lock is - present returns a tuple of make_lock, locked, locked_by. - make_lock can have 3 states None (do nothing) True, make lock - False release lock, This value is later propagated to hooks, which - do the locking. Think about this as signals passed to hooks what to do. - + Checks locking on this repository, if locking is enabled, and if lock + is present. Returns a tuple of make_lock, locked, locked_by. make_lock + can have 3 states: None (do nothing), True (make lock), and False + (release lock). This value is later propagated to hooks, telling them + what to do. """ locked = False # defines that locked error should be thrown to user make_lock = None @@ -346,14 +345,14 @@ locked_by = repo.locked if repo and repo.enable_locking and not obsolete_call: if action == 'push': - #check if it's already locked !, if it is compare users - user_id, _date = repo.locked + # Check if repo already is locked !, if it is compare users + user_id, _date = locked_by if user.user_id == user_id: log.debug('Got push from user %s, now unlocking', user) - # unlock if we have push from user who locked + # Unlock if we have push from the user who locked make_lock = False else: - # we're not the same user who locked, ban with 423 ! + # Another used tried to push - deny access with something like 423 Locked! locked = True if action == 'pull': if repo.locked[0] and repo.locked[1]: @@ -363,7 +362,7 @@ make_lock = True else: - log.debug('Repository %s do not have locking enabled', repo) + log.debug('Repository %s does not have locking enabled', repo) log.debug('FINAL locking values make_lock:%s,locked:%s,locked_by:%s', make_lock, locked, locked_by) return make_lock, locked, locked_by