##// END OF EJS Templates
vcs: Minimal change to expose the shadow repository...
johbo -
r887:175782be default
parent child Browse files
Show More
@@ -83,12 +83,15 b' class SimpleVCS(object):'
83
83
84 SCM = 'unknown'
84 SCM = 'unknown'
85
85
86 acl_repo_name = None
87 url_repo_name = None
88 vcs_repo_name = None
89
86 def __init__(self, application, config, registry):
90 def __init__(self, application, config, registry):
87 self.registry = registry
91 self.registry = registry
88 self.application = application
92 self.application = application
89 self.config = config
93 self.config = config
90 # re-populated by specialized middleware
94 # re-populated by specialized middleware
91 self.repo_name = None
92 self.repo_vcs_config = base.Config()
95 self.repo_vcs_config = base.Config()
93
96
94 # base path of repo locations
97 # base path of repo locations
@@ -102,6 +105,11 b' class SimpleVCS(object):'
102 self.ip_addr = '0.0.0.0'
105 self.ip_addr = '0.0.0.0'
103
106
104 @property
107 @property
108 def repo_name(self):
109 # TODO: johbo: Remove, switch to correct repo name attribute
110 return self.acl_repo_name
111
112 @property
105 def scm_app(self):
113 def scm_app(self):
106 custom_implementation = self.config.get('vcs.scm_app_implementation')
114 custom_implementation = self.config.get('vcs.scm_app_implementation')
107 if custom_implementation and custom_implementation != 'pyro4':
115 if custom_implementation and custom_implementation != 'pyro4':
@@ -340,7 +348,8 b' class SimpleVCS(object):'
340 # REQUEST HANDLING
348 # REQUEST HANDLING
341 # ======================================================================
349 # ======================================================================
342 str_repo_name = safe_str(self.repo_name)
350 str_repo_name = safe_str(self.repo_name)
343 repo_path = os.path.join(safe_str(self.basepath), str_repo_name)
351 repo_path = os.path.join(
352 safe_str(self.basepath), safe_str(self.vcs_repo_name))
344 log.debug('Repository path is %s', repo_path)
353 log.debug('Repository path is %s', repo_path)
345
354
346 fix_PATH()
355 fix_PATH()
@@ -350,7 +359,7 b' class SimpleVCS(object):'
350 action, self.SCM, str_repo_name, safe_str(username), ip_addr)
359 action, self.SCM, str_repo_name, safe_str(username), ip_addr)
351
360
352 return self._generate_vcs_response(
361 return self._generate_vcs_response(
353 environ, start_response, repo_path, self.repo_name, extras, action)
362 environ, start_response, repo_path, self.url_repo_name, extras, action)
354
363
355 @initialize_generator
364 @initialize_generator
356 def _generate_vcs_response(
365 def _generate_vcs_response(
@@ -365,7 +374,7 b' class SimpleVCS(object):'
365 the first chunk is produced by the underlying WSGI application.
374 the first chunk is produced by the underlying WSGI application.
366 """
375 """
367 callback_daemon, extras = self._prepare_callback_daemon(extras)
376 callback_daemon, extras = self._prepare_callback_daemon(extras)
368 config = self._create_config(extras, repo_name)
377 config = self._create_config(extras, self.acl_repo_name)
369 log.debug('HOOKS extras is %s', extras)
378 log.debug('HOOKS extras is %s', extras)
370 app = self._create_wsgi_app(repo_path, repo_name, config)
379 app = self._create_wsgi_app(repo_path, repo_name, config)
371
380
@@ -176,18 +176,44 b' class VCSMiddleware(object):'
176 environ['PATH_INFO'] = vcs_handler._get_by_id(environ['PATH_INFO'])
176 environ['PATH_INFO'] = vcs_handler._get_by_id(environ['PATH_INFO'])
177 repo_name = vcs_handler._get_repository_name(environ)
177 repo_name = vcs_handler._get_repository_name(environ)
178
178
179 acl_repo_name = repo_name
180 vcs_repo_name = repo_name
181 url_repo_name = repo_name
182 pr_id = None
183
184 # TODO: johbo: recognize a pull request based on pattern matching
185 if '/pull-request/' in repo_name:
186 acl_repo_name, other = repo_name.split('/pull-request/')
187 # TODO: johbo: Set shadow repo path
188 basename, repo_segment = acl_repo_name.rsplit('/', 1)
189 pr_id = int(other[0:-len('/repository')])
190 vcs_repo_name = '{basename}/.__shadow_{repo_segment}_pr-{pr_id}'.format(
191 basename=basename,
192 repo_segment=repo_segment,
193 pr_id=pr_id)
194
195 log.debug('repo_names %s', {
196 'acl_repo_name': acl_repo_name,
197 'vcs_repo_name': vcs_repo_name,
198 'url_repo_name': url_repo_name,
199 })
200 log.debug('pull_request %s', pr_id)
201
179 # check for type, presence in database and on filesystem
202 # check for type, presence in database and on filesystem
180 if not vcs_handler.is_valid_and_existing_repo(
203 if not vcs_handler.is_valid_and_existing_repo(
181 repo_name, vcs_handler.basepath, vcs_handler.SCM):
204 acl_repo_name, vcs_handler.basepath, vcs_handler.SCM):
182 return HTTPNotFound()(environ, start_response)
205 return HTTPNotFound()(environ, start_response)
183
206
184 # TODO: johbo: Needed for the Pyro4 backend and Mercurial only.
207 # TODO: johbo: Needed for the Pyro4 backend and Mercurial only.
185 # Remove once we fully switched to the HTTP backend.
208 # Remove once we fully switched to the HTTP backend.
186 environ['REPO_NAME'] = repo_name
209 environ['REPO_NAME'] = url_repo_name
187
210
188 # register repo_name and it's config back to the handler
211 # register repo_name and it's config back to the handler
189 vcs_handler.repo_name = repo_name
212 vcs_handler.acl_repo_name = acl_repo_name
190 vcs_handler.repo_vcs_config = self.vcs_config(repo_name)
213 vcs_handler.url_repo_name = url_repo_name
214 vcs_handler.vcs_repo_name = vcs_repo_name
215 vcs_handler.pr_id = pr_id
216 vcs_handler.repo_vcs_config = self.vcs_config(acl_repo_name)
191
217
192 vcs_handler = self.wrap_in_gzip_if_enabled(
218 vcs_handler = self.wrap_in_gzip_if_enabled(
193 vcs_handler, self.config)
219 vcs_handler, self.config)
@@ -44,7 +44,9 b' class StubVCSController(simplevcs.Simple'
44
44
45 def __init__(self, *args, **kwargs):
45 def __init__(self, *args, **kwargs):
46 super(StubVCSController, self).__init__(*args, **kwargs)
46 super(StubVCSController, self).__init__(*args, **kwargs)
47 self.repo_name = HG_REPO
47 self.acl_repo_name = HG_REPO
48 self.url_repo_name = HG_REPO
49 self.vcs_repo_name = HG_REPO
48
50
49 def _get_repository_name(self, environ):
51 def _get_repository_name(self, environ):
50 return HG_REPO
52 return HG_REPO
General Comments 0
You need to be logged in to leave comments. Login now