##// END OF EJS Templates
vcs: Add flag to indicate if repository is a shadow repository.
Martin Bornhold -
r899:3c9ebe4f default
parent child Browse files
Show More
@@ -163,7 +163,8 b' def get_access_path(environ):'
163
163
164
164
165 def vcs_operation_context(
165 def vcs_operation_context(
166 environ, repo_name, username, action, scm, check_locking=True):
166 environ, repo_name, username, action, scm, check_locking=True,
167 is_shadow_repo=False):
167 """
168 """
168 Generate the context for a vcs operation, e.g. push or pull.
169 Generate the context for a vcs operation, e.g. push or pull.
169
170
@@ -200,6 +201,7 b' def vcs_operation_context('
200 'locked_by': locked_by,
201 'locked_by': locked_by,
201 'server_url': utils2.get_server_url(environ),
202 'server_url': utils2.get_server_url(environ),
202 'hooks': get_enabled_hook_classes(ui_settings),
203 'hooks': get_enabled_hook_classes(ui_settings),
204 'is_shadow_repo': is_shadow_repo,
203 }
205 }
204 return extras
206 return extras
205
207
@@ -109,7 +109,7 b' class SimpleVCS(object):'
109 def set_repo_names(self, environ):
109 def set_repo_names(self, environ):
110 """
110 """
111 This will populate the attributes acl_repo_name, url_repo_name,
111 This will populate the attributes acl_repo_name, url_repo_name,
112 vcs_repo_name and pr_id on the current instance.
112 vcs_repo_name and is_shadow_repo on the current instance.
113 """
113 """
114 # TODO: martinb: Move to class or module scope.
114 # TODO: martinb: Move to class or module scope.
115 # TODO: martinb: Check if we have to use re.UNICODE.
115 # TODO: martinb: Check if we have to use re.UNICODE.
@@ -143,14 +143,14 b' class SimpleVCS(object):'
143 workspace_id)
143 workspace_id)
144
144
145 # Store names for later usage.
145 # Store names for later usage.
146 self.pr_id = pr_id
147 self.vcs_repo_name = vcs_repo_name
146 self.vcs_repo_name = vcs_repo_name
148 self.acl_repo_name = pull_request.target_repo.repo_name
147 self.acl_repo_name = pull_request.target_repo.repo_name
148 self.is_shadow_repo = True
149 else:
149 else:
150 # All names are equal for normal (non shadow) repositories.
150 # All names are equal for normal (non shadow) repositories.
151 self.acl_repo_name = self.url_repo_name
151 self.acl_repo_name = self.url_repo_name
152 self.vcs_repo_name = self.url_repo_name
152 self.vcs_repo_name = self.url_repo_name
153 self.pr_id = None
153 self.is_shadow_repo = False
154
154
155 @property
155 @property
156 def scm_app(self):
156 def scm_app(self):
@@ -305,7 +305,7 b' class SimpleVCS(object):'
305 # Check if this is a request to a shadow repository of a pull request.
305 # Check if this is a request to a shadow repository of a pull request.
306 # In this case only pull action is allowed.
306 # In this case only pull action is allowed.
307 # ======================================================================
307 # ======================================================================
308 if self.pr_id is not None and action != 'pull':
308 if self.is_shadow_repo and action != 'pull':
309 reason = 'Only pull action is allowed for shadow repositories.'
309 reason = 'Only pull action is allowed for shadow repositories.'
310 log.debug('User not allowed to proceed, %s', reason)
310 log.debug('User not allowed to proceed, %s', reason)
311 return HTTPNotAcceptable(reason)(environ, start_response)
311 return HTTPNotAcceptable(reason)(environ, start_response)
@@ -393,8 +393,9 b' class SimpleVCS(object):'
393 check_locking = _should_check_locking(environ.get('QUERY_STRING'))
393 check_locking = _should_check_locking(environ.get('QUERY_STRING'))
394 extras = vcs_operation_context(
394 extras = vcs_operation_context(
395 environ, repo_name=self.acl_repo_name, username=username,
395 environ, repo_name=self.acl_repo_name, username=username,
396 action=action, scm=self.SCM,
396 action=action, scm=self.SCM, check_locking=check_locking,
397 check_locking=check_locking)
397 is_shadow_repo=self.is_shadow_repo
398 )
398
399
399 # ======================================================================
400 # ======================================================================
400 # REQUEST HANDLING
401 # REQUEST HANDLING
General Comments 0
You need to be logged in to leave comments. Login now