# HG changeset patch # User RhodeCode Admin # Date 2024-10-22 16:23:02 # Node ID 6c127320959dfc058ba3ddabfdf00c78654adf4a # Parent 9cc7dfc4cd193367a091226ce951c0309e7ec9bd vcs: added similar assert_path method as other backend have for API consistency diff --git a/vcsserver/remote/hg_remote.py b/vcsserver/remote/hg_remote.py --- a/vcsserver/remote/hg_remote.py +++ b/vcsserver/remote/hg_remote.py @@ -23,6 +23,7 @@ import sys import urllib.request import urllib.parse import hashlib +import traceback from hgext import largefiles, rebase @@ -759,6 +760,24 @@ class HgRemote(RemoteBase): self._factory.repo(wire, create=create) @reraise_safe_exceptions + def assert_correct_path(self, wire): + cache_on, context_uid, repo_id = self._cache_on(wire) + region = self._region(wire) + + @region.conditional_cache_on_arguments(condition=cache_on) + def _assert_correct_path(_context_uid, _repo_id): + try: + self._factory.repo(wire, create=False) + except Exception: + path = wire.get('path') + tb = traceback.format_exc() + log.debug("Invalid Mercurial path `%s`, tb: %s", path, tb) + return False + return True + + return _assert_correct_path(context_uid, repo_id) + + @reraise_safe_exceptions def lookup(self, wire, revision, both): cache_on, context_uid, repo_id = self._cache_on(wire) region = self._region(wire)