diff --git a/vcsserver/git.py b/vcsserver/git.py --- a/vcsserver/git.py +++ b/vcsserver/git.py @@ -129,6 +129,15 @@ class GitRemote(object): return params @reraise_safe_exceptions + def is_empty(self, wire): + repo = self._factory.repo(wire) + try: + return not repo.head() + except Exception: + log.exception("failed to read object_store") + return True + + @reraise_safe_exceptions def add_object(self, wire, content): repo = self._factory.repo(wire) blob = objects.Blob() diff --git a/vcsserver/hg.py b/vcsserver/hg.py --- a/vcsserver/hg.py +++ b/vcsserver/hg.py @@ -172,6 +172,16 @@ class HgRemote(object): return util.version() @reraise_safe_exceptions + def is_empty(self, wire): + repo = self._factory.repo(wire) + + try: + return len(repo) == 0 + except Exception: + log.exception("failed to read object_store") + return False + + @reraise_safe_exceptions def archive_repo(self, archive_path, mtime, file_info, kind): if kind == "tgz": archiver = archival.tarit(archive_path, mtime, "gz") diff --git a/vcsserver/svn.py b/vcsserver/svn.py --- a/vcsserver/svn.py +++ b/vcsserver/svn.py @@ -139,6 +139,16 @@ class SvnRemote(object): svn_ver = None return svn_ver + @reraise_safe_exceptions + def is_empty(self, wire): + repo = self._factory.repo(wire) + + try: + return self.lookup(wire, -1) == 0 + except Exception: + log.exception("failed to read object_store") + return False + def check_url(self, url, config_items): # this can throw exception if not installed, but we detect this from hgsubversion import svnrepo