Mercurial > kallithea
changeset 6491:701f0a3f9616
vcs: remove confusing and unnecessary local variable
This removes the "username" local variable, substituting the equivalent
"user.username". The function also has another, unrelated use of the
same local variable name; this OTHER "username" variable is untouched.
The relevant code is duplicated between Hg and Git... and thus also
this change.
author | Søren Løvborg <sorenl@unity3d.com> |
---|---|
date | Mon, 02 Jan 2017 23:16:32 +0100 |
parents | 5b40eb88a46d |
children | b5551ad26fa3 |
files | kallithea/lib/middleware/simplegit.py kallithea/lib/middleware/simplehg.py |
diffstat | 2 files changed, 8 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/middleware/simplegit.py Wed Jan 04 23:05:11 2017 +0100 +++ b/kallithea/lib/middleware/simplegit.py Mon Jan 02 23:16:32 2017 +0100 @@ -96,7 +96,7 @@ # CHECK PERMISSIONS #====================================================================== anonymous_user = User.get_default_user(cache=True) - username = anonymous_user.username + user = anonymous_user if anonymous_user.active: # ONLY check permissions if the user is activated anonymous_perm = self._check_permission(action, anonymous_user, @@ -145,7 +145,6 @@ user = User.get_by_username_or_email(username) if user is None or not user.active: return HTTPForbidden()(environ, start_response) - username = user.username except Exception: log.error(traceback.format_exc()) return HTTPInternalServerError()(environ, start_response) @@ -161,7 +160,7 @@ server_url = get_server_url(environ) extras = { 'ip': ip_addr, - 'username': username, + 'username': user.username, 'action': action, 'repository': repo_name, 'scm': 'git', @@ -178,7 +177,7 @@ log.debug('Repository path is %s', repo_path) # CHECK LOCKING only if it's not ANONYMOUS USER - if username != User.DEFAULT_USER: + if user.username != User.DEFAULT_USER: log.debug('Checking locking on repository') (make_lock, locked, @@ -198,7 +197,7 @@ try: self._handle_githooks(repo_name, action, baseui, environ) log.info('%s action on Git repo "%s" by "%s" from %s', - action, str_repo_name, safe_str(username), ip_addr) + action, str_repo_name, safe_str(user.username), ip_addr) app = self.__make_app(repo_name, repo_path, extras) result = app(environ, start_response) if action == 'push':
--- a/kallithea/lib/middleware/simplehg.py Wed Jan 04 23:05:11 2017 +0100 +++ b/kallithea/lib/middleware/simplehg.py Mon Jan 02 23:16:32 2017 +0100 @@ -104,7 +104,7 @@ # CHECK PERMISSIONS #====================================================================== anonymous_user = User.get_default_user(cache=True) - username = anonymous_user.username + user = anonymous_user if anonymous_user.active: # ONLY check permissions if the user is activated anonymous_perm = self._check_permission(action, anonymous_user, @@ -153,7 +153,6 @@ user = User.get_by_username_or_email(username) if user is None or not user.active: return HTTPForbidden()(environ, start_response) - username = user.username except Exception: log.error(traceback.format_exc()) return HTTPInternalServerError()(environ, start_response) @@ -169,7 +168,7 @@ server_url = get_server_url(environ) extras = { 'ip': ip_addr, - 'username': username, + 'username': user.username, 'action': action, 'repository': repo_name, 'scm': 'hg', @@ -185,7 +184,7 @@ log.debug('Repository path is %s', repo_path) # CHECK LOCKING only if it's not ANONYMOUS USER - if username != User.DEFAULT_USER: + if user.username != User.DEFAULT_USER: log.debug('Checking locking on repository') (make_lock, locked, @@ -204,7 +203,7 @@ try: log.info('%s action on Mercurial repo "%s" by "%s" from %s', - action, str_repo_name, safe_str(username), ip_addr) + action, str_repo_name, safe_str(user.username), ip_addr) app = self.__make_app(repo_path, baseui, extras) result = app(environ, start_response) if action == 'push':