fix(hg-items): fixed missing submodules code and add forgotten stats item

This commit is contained in:
RhodeCode Admin 2024-12-02 09:24:32 +01:00
parent 200dfdcf24
commit ea05521e76
6 changed files with 531 additions and 597 deletions

View file

@ -19,7 +19,7 @@
"""
HG commit module
"""
import os
import logging
from zope.cachedescriptors.property import Lazy as LazyProperty
@ -274,16 +274,15 @@ class MercurialCommit(base.BaseCommit):
path_nodes = []
for obj_path, node_kind in self._remote.dir_items(self.raw_id, path):
for obj_path, (node_kind, flags) in self._remote.dir_items(self.raw_id, path):
if node_kind is None:
raise CommitError(f"Requested object type={node_kind} cannot be mapped to a proper type")
# TODO: implement it ??
stat_ = None
# # cache file mode
# if obj_path not in self._path_mode_cache:
# self._path_mode_cache[obj_path] = stat_
stat_ = flags
# cache file mode
if obj_path not in self._path_mode_cache:
self._path_mode_cache[obj_path] = stat_
# cache type
if node_kind not in self._path_type_cache:
@ -301,6 +300,13 @@ class MercurialCommit(base.BaseCommit):
self.nodes[obj_path] = entry
path_nodes.append(entry)
for obj_path, (location, commit, scm_type) in self._submodules.items():
if os.path.dirname(obj_path) == path:
entry = SubModuleNode(obj_path, url=location, commit=commit, alias=scm_type)
self.nodes[obj_path] = entry
path_nodes.append(entry)
path_nodes.sort()
return path_nodes

View file

@ -707,24 +707,23 @@ class SubModuleNode(Node):
size = 0
def __init__(self, name, url=None, commit=None, alias=None):
self.path = name
self.path: bytes = name
self.str_path: str = safe_str(self.path) # we store paths as str
self.kind = NodeKind.SUBMODULE
self.alias = alias
# we have to use EmptyCommit here since this can point to svn/git/hg
# submodules we cannot get from repository
self.commit = EmptyCommit(str(commit), alias=alias)
self.url = url or self._extract_submodule_url()
self.commit = EmptyCommit(safe_str(commit), alias=alias)
self.url = safe_str(url) or self._extract_submodule_url()
def __repr__(self):
short_id = getattr(self.commit, "short_id", "")
return f"<{self.__class__.__name__} {self.str_path!r} @ {short_id}>"
def _extract_submodule_url(self):
# TODO: find a way to parse gits submodule file and extract the
# linking URL
return self.path
# TODO: find a way to parse gits submodule file and extract the linking URL
return safe_str(self.path)
@LazyProperty
def name(self):