# HG changeset patch # User Marcin Kuzminski # Date 2019-06-05 11:30:26 # Node ID 267daa274741a7d6fca2c2fb82e0443e369fb18a # Parent 2b58a8d9a61c1395d8ac1d63f434d32b73a79c49 repositories: use remote function to check if repo is empty - changed 2 cases where we want to check for None instead of __bool__ of repo object diff --git a/rhodecode/apps/_base/__init__.py b/rhodecode/apps/_base/__init__.py --- a/rhodecode/apps/_base/__init__.py +++ b/rhodecode/apps/_base/__init__.py @@ -244,7 +244,10 @@ class RepoAppView(BaseAppView): c.repository_requirements_missing = {} try: self.rhodecode_vcs_repo = self.db_repo.scm_instance() - if self.rhodecode_vcs_repo: + # NOTE(marcink): + # comparison to None since if it's an object __bool__ is expensive to + # calculate + if self.rhodecode_vcs_repo is not None: path_perms = self.rhodecode_vcs_repo.get_path_permissions( c.auth_user.username) self.path_filter = PathFilter(path_perms) diff --git a/rhodecode/lib/vcs/backends/base.py b/rhodecode/lib/vcs/backends/base.py --- a/rhodecode/lib/vcs/backends/base.py +++ b/rhodecode/lib/vcs/backends/base.py @@ -383,7 +383,7 @@ class BaseRepository(object): return commit.size def is_empty(self): - return not bool(self.commit_ids) + return self._remote.is_empty() @staticmethod def check_url(url, config): diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -2307,7 +2307,7 @@ class Repository(Base, BaseModel): # use no-cache version here scm_repo = self.scm_instance(cache=False, config=config) - empty = not scm_repo or scm_repo.is_empty() + empty = scm_repo is None or scm_repo.is_empty() if not empty: cs_cache = scm_repo.get_commit( pre_load=["author", "date", "message", "parents"])