# HG changeset patch # User Mads Kiilerich # Date 1795727380 -3600 # Thu Nov 26 22:09:40 2026 +0100 # Branch testing # Node ID 832bc90e315ea6533d855b5f8b570cd90c26bb3b # Parent 2a7c3c5ed76cc8310e9abe25b33e9e154e43cb12 vcs: Reset various caches in BaseInMemoryChangeset.reset Enable other changes and improvements by introducing more correct cache invalidation. diff --git a/kallithea/lib/vcs/backends/base.py b/kallithea/lib/vcs/backends/base.py --- a/kallithea/lib/vcs/backends/base.py +++ b/kallithea/lib/vcs/backends/base.py @@ -870,6 +870,27 @@ class BaseInMemoryChangeset(object): self.changed = [] self.removed = [] self.parents = [] + # Clear some LazyAttribute caches for both hg and git + try: + del self.repository.revisions + except AttributeError: + pass + try: + del self.repository._parsed_refs + except AttributeError: + pass + try: + del self.repository.branches + except AttributeError: + pass + try: + del self._commit_ctx + except AttributeError: + pass + try: + del self._repo + except AttributeError: + pass def get_ipaths(self): """ diff --git a/kallithea/lib/vcs/backends/git/inmemory.py b/kallithea/lib/vcs/backends/git/inmemory.py --- a/kallithea/lib/vcs/backends/git/inmemory.py +++ b/kallithea/lib/vcs/backends/git/inmemory.py @@ -7,7 +7,7 @@ from dulwich import objects from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset from kallithea.lib.vcs.exceptions import RepositoryError -from kallithea.lib.vcs.utils import ascii_str, safe_bytes +from kallithea.lib.vcs.utils import safe_bytes from . import repository @@ -150,12 +150,8 @@ class GitInMemoryChangeset(BaseInMemoryC # Update vcs repository object & recreate dulwich repo ref = b'refs/heads/%s' % safe_bytes(branch) repo.refs[ref] = commit.id - self.repository.revisions.append(ascii_str(commit.id)) - # invalidate parsed refs after commit - self.repository._parsed_refs = self.repository._get_parsed_refs() - tip = self.repository.get_changeset() self.reset() - return tip + return self.repository.get_changeset() def _get_missing_trees(self, path, root_tree): """ diff --git a/kallithea/lib/vcs/backends/hg/inmemory.py b/kallithea/lib/vcs/backends/hg/inmemory.py --- a/kallithea/lib/vcs/backends/hg/inmemory.py +++ b/kallithea/lib/vcs/backends/hg/inmemory.py @@ -5,7 +5,7 @@ import mercurial.node from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset from kallithea.lib.vcs.exceptions import RepositoryError -from kallithea.lib.vcs.utils import ascii_str, safe_bytes, safe_str +from kallithea.lib.vcs.utils import safe_bytes, safe_str from . import repository @@ -98,14 +98,5 @@ class MercurialInMemoryChangeset(BaseInM # TODO: Catch exceptions! n = self.repository._repo.commitctx(commit_ctx) - # Returns mercurial node - self._commit_ctx = commit_ctx # For reference - # Update vcs repository object & recreate mercurial _repo - # new_ctx = self.repository._repo[node] - # new_tip = ascii_str(self.repository.get_changeset(new_ctx.hex())) - self.repository.revisions.append(ascii_str(mercurial.node.hex(n))) - self._repo = self.repository._get_repo(create=False) - self.repository.branches = self.repository._get_branches() - tip = self.repository.get_changeset() self.reset() - return tip + return self.repository.get_changeset()