Bug 1565358: Use Parameters.file_url helper consitently; r=mhentges

Only one place should need to know how to generate VCS URLs. This
makes it easier to support other VCSs.

Differential Revision: https://phabricator.services.mozilla.com/D37772
This commit is contained in:
Tom Prince
2019-07-11 22:00:51 +00:00
parent 3d6495c1f1
commit ec3a02aee4
6 changed files with 15 additions and 17 deletions

View File

@@ -195,14 +195,14 @@ class Parameters(ReadOnlyDict):
"""
return 'try' in self['project'] or self['try_mode'] == 'try_select'
def file_url(self, path, endpoint="file"):
def file_url(self, path, pretty=False):
"""
Determine the VCS URL for viewing a file in the tree, suitable for
viewing by a human.
:param basestring path: The path, relative to the root of the repository.
:param basestring endpoint: The endpoint. Defaults to "file"
:param bool pretty: Whether to return a link to a formatted version of the
file, or the raw file version.
:return basestring: The URL displaying the given path.
"""
if path.startswith('comm/'):
@@ -213,6 +213,7 @@ class Parameters(ReadOnlyDict):
repo = self['head_repository']
rev = self['head_rev']
endpoint = 'file' if pretty else 'raw-file'
return '{}/{}/{}/{}'.format(repo, endpoint, rev, path)
def release_level(self):