Mercurial > kallithea
changeset 8784:f01bad8101e4
lib: drop is_hg and is_git
It is just as simple to be explicit.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 09 Nov 2020 15:58:52 +0100 |
parents | 07e664871e98 |
children | 6d2b7e320512 |
files | kallithea/controllers/pullrequests.py kallithea/lib/helpers.py kallithea/templates/changeset/changeset_range.html kallithea/templates/changeset/patch_changeset.html kallithea/templates/pullrequests/pullrequest_show.html kallithea/templates/summary/summary.html |
diffstat | 6 files changed, 10 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py Mon Nov 09 16:17:26 2020 +0100 +++ b/kallithea/controllers/pullrequests.py Mon Nov 09 15:58:52 2020 +0100 @@ -72,7 +72,7 @@ class PullrequestsController(BaseRepoController): def _get_repo_refs(self, repo, rev=None, branch=None, branch_rev=None): - """return a structure with repo's interesting changesets, suitable for + """return a structure with scm repo's interesting changesets, suitable for the selectors in pullrequest.html rev: a revision that must be in the list somehow and selected by default @@ -154,13 +154,14 @@ # prio 4: tip revision if not selected: - if h.is_hg(repo): + if repo.alias == 'hg': if tipbranch: selected = 'branch:%s:%s' % (tipbranch, tiprev) else: selected = 'tag:null:' + repo.EMPTY_CHANGESET tags.append((selected, 'null')) else: # Git + assert repo.alias == 'git' if not repo.branches: selected = '' # doesn't make sense, but better than nothing elif 'master' in repo.branches:
--- a/kallithea/lib/helpers.py Mon Nov 09 16:17:26 2020 +0100 +++ b/kallithea/lib/helpers.py Mon Nov 09 15:58:52 2020 +0100 @@ -374,26 +374,6 @@ return raw_id -def is_git(repository): - if hasattr(repository, 'alias'): - _type = repository.alias - elif hasattr(repository, 'repo_type'): - _type = repository.repo_type - else: - _type = repository - return _type == 'git' - - -def is_hg(repository): - if hasattr(repository, 'alias'): - _type = repository.alias - elif hasattr(repository, 'repo_type'): - _type = repository.repo_type - else: - _type = repository - return _type == 'hg' - - @cache_region('long_term', 'user_attr_or_none') def user_attr_or_none(author, show_attr): """Try to match email part of VCS committer string with a local user and return show_attr
--- a/kallithea/templates/changeset/changeset_range.html Mon Nov 09 16:17:26 2020 +0100 +++ b/kallithea/templates/changeset/changeset_range.html Mon Nov 09 15:58:52 2020 +0100 @@ -79,7 +79,7 @@ %if len(cs.parents)>1: <span class="label label-merge">${_('Merge')}</span> %endif - %if h.is_hg(c.db_repo_scm_instance): + %if c.db_repo_scm_instance.alias == 'hg': %for book in cs.bookmarks: <span class="label label-bookmark" title="${_('Bookmark %s') % book}"> ${h.link_to(book,h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}
--- a/kallithea/templates/changeset/patch_changeset.html Mon Nov 09 16:17:26 2020 +0100 +++ b/kallithea/templates/changeset/patch_changeset.html Mon Nov 09 15:58:52 2020 +0100 @@ -1,4 +1,4 @@ -%if h.is_hg(c.db_repo_scm_instance): +%if c.db_repo_scm_instance.alias == 'hg': # ${c.db_repo_scm_instance.alias.upper()} changeset patch # User ${c.changeset.author |n} # Date ${c.changeset.date} @@ -6,7 +6,7 @@ ${c.parent_tmpl} ${c.changeset.message |n} -%elif h.is_git(c.db_repo_scm_instance): +%elif c.db_repo_scm_instance.alias == 'git': From ${c.changeset.raw_id} ${c.changeset.date} From: ${c.changeset.author |n} Date: ${c.changeset.date}
--- a/kallithea/templates/pullrequests/pullrequest_show.html Mon Nov 09 16:17:26 2020 +0100 +++ b/kallithea/templates/pullrequests/pullrequest_show.html Mon Nov 09 15:58:52 2020 +0100 @@ -105,9 +105,9 @@ %if c.cs_ranges: <div> ## TODO: use cs_ranges[-1] or org_ref_parts[1] in both cases? - %if h.is_hg(c.pull_request.org_repo): + %if c.pull_request.org_repo.repo_type == 'hg': <span>hg pull ${c.pull_request.org_repo.clone_url(clone_uri_tmpl=c.clone_uri_tmpl)} -r ${c.cs_ranges[-1].short_id}</span> - %elif h.is_git(c.pull_request.org_repo): + %elif c.pull_request.org_repo.repo_type == 'git': <span>git pull ${c.pull_request.org_repo.clone_url(clone_uri_tmpl=c.clone_uri_tmpl)} ${c.pull_request.org_ref_parts[1]}</span> %endif </div>
--- a/kallithea/templates/summary/summary.html Mon Nov 09 16:17:26 2020 +0100 +++ b/kallithea/templates/summary/summary.html Mon Nov 09 15:58:52 2020 +0100 @@ -203,12 +203,12 @@ ${c.db_repo_scm_instance.alias} clone ${c.clone_repo_url} ${c.db_repo_scm_instance.alias} add README # add first file ${c.db_repo_scm_instance.alias} commit -m "Initial" # commit with message -${c.db_repo_scm_instance.alias} push ${'origin master' if h.is_git(c.db_repo_scm_instance) else ''} # push changes back +${c.db_repo_scm_instance.alias} push ${'origin master' if c.db_repo_scm_instance.alias == 'git' else ''} # push changes back </pre> <h4>${_('Existing repository?')}</h4> <pre> - %if h.is_git(c.db_repo_scm_instance): + %if c.db_repo_scm_instance.alias == 'git': git remote add origin ${c.clone_repo_url} git push -u origin master %else: