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 @@ -909,3 +909,48 @@ class BaseInMemoryChangeset(object): :raises ``CommitError``: if any error occurs while committing """ raise NotImplementedError + + +class EmptyChangeset(BaseChangeset): + """ + An dummy empty changeset. It's possible to pass hash when creating + an EmptyChangeset + """ + + def __init__(self, cs='0' * 40, repo=None, requested_revision=None, + alias=None): + self._empty_cs = cs + self.revision = -1 + self.message = '' + self.author = '' + self.date = '' + self.repository = repo + self.requested_revision = requested_revision + self.alias = alias + + @LazyProperty + def raw_id(self): + """ + Returns raw string identifying this changeset, useful for web + representation. + """ + + return self._empty_cs + + @LazyProperty + def branch(self): + from rhodecode.lib.vcs.backends import get_backend + return get_backend(self.alias).DEFAULT_BRANCH_NAME + + @LazyProperty + def short_id(self): + return self.raw_id[:12] + + def get_file_changeset(self, path): + return self + + def get_file_content(self, path): + return u'' + + def get_file_size(self, path): + return 0 \ No newline at end of file diff --git a/rhodecode/lib/vcs/nodes.py b/rhodecode/lib/vcs/nodes.py --- a/rhodecode/lib/vcs/nodes.py +++ b/rhodecode/lib/vcs/nodes.py @@ -19,7 +19,7 @@ from rhodecode.lib.vcs.utils.lazy import from rhodecode.lib.vcs.utils import safe_unicode, safe_str from rhodecode.lib.vcs.exceptions import NodeError from rhodecode.lib.vcs.exceptions import RemovedFileNodeError -from rhodecode.lib.utils import EmptyChangeset +from rhodecode.lib.vcs.backends.base import EmptyChangeset class NodeKind: