# HG changeset patch # User Mads Kiilerich # Date 2020-11-09 15:58:52 # Node ID f01bad8101e41e3504e7f780cbdc6551d7524449 # Parent 07e664871e981ac08c29173eb2c9139ea5f8c1cf lib: drop is_hg and is_git It is just as simple to be explicit. diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -72,7 +72,7 @@ def _get_reviewer(user_id): 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 @@ class PullrequestsController(BaseRepoCon # 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: diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -374,26 +374,6 @@ def show_id(cs): 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 diff --git a/kallithea/templates/changeset/changeset_range.html b/kallithea/templates/changeset/changeset_range.html --- a/kallithea/templates/changeset/changeset_range.html +++ b/kallithea/templates/changeset/changeset_range.html @@ -79,7 +79,7 @@ ${self.repo_context_bar('changelog')} %if len(cs.parents)>1: ${_('Merge')} %endif - %if h.is_hg(c.db_repo_scm_instance): + %if c.db_repo_scm_instance.alias == 'hg': %for book in cs.bookmarks: ${h.link_to(book,h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))} diff --git a/kallithea/templates/changeset/patch_changeset.html b/kallithea/templates/changeset/patch_changeset.html --- a/kallithea/templates/changeset/patch_changeset.html +++ b/kallithea/templates/changeset/patch_changeset.html @@ -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} diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -105,9 +105,9 @@ ${self.repo_context_bar('showpullrequest %if c.cs_ranges:
## 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': hg pull ${c.pull_request.org_repo.clone_url(clone_uri_tmpl=c.clone_uri_tmpl)} -r ${c.cs_ranges[-1].short_id} - %elif h.is_git(c.pull_request.org_repo): + %elif c.pull_request.org_repo.repo_type == 'git': git pull ${c.pull_request.org_repo.clone_url(clone_uri_tmpl=c.clone_uri_tmpl)} ${c.pull_request.org_ref_parts[1]} %endif
diff --git a/kallithea/templates/summary/summary.html b/kallithea/templates/summary/summary.html --- a/kallithea/templates/summary/summary.html +++ b/kallithea/templates/summary/summary.html @@ -203,12 +203,12 @@ ${self.repo_context_bar('summary')} ${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

${_('Existing repository?')}

-                %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: