Changeset - f01bad8101e4
[Not reviewed]
default
0 6 0
Mads Kiilerich (mads) - 5 years ago 2020-11-09 15:58:52
mads@kiilerich.com
Grafted from: 0baf4e62d244
lib: drop is_hg and is_git

It is just as simple to be explicit.
6 files changed with 10 insertions and 29 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -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:
kallithea/lib/helpers.py
Show inline comments
 
@@ -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
kallithea/templates/changeset/changeset_range.html
Show inline comments
 
@@ -79,7 +79,7 @@ ${self.repo_context_bar('changelog')}
 
                %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))}
kallithea/templates/changeset/patch_changeset.html
Show inline comments
 
%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}
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -105,9 +105,9 @@ ${self.repo_context_bar('showpullrequest
 
            %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>
kallithea/templates/summary/summary.html
Show inline comments
 
@@ -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
 
                </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:
0 comments (0 inline, 0 general)