fix(hg-items): fixed missing submodules code and add forgotten stats item
This commit is contained in:
parent
200dfdcf24
commit
ea05521e76
6 changed files with 531 additions and 597 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
34
rhodecode/tests/fixtures/fixture_utils.py
vendored
34
rhodecode/tests/fixtures/fixture_utils.py
vendored
|
|
@ -185,18 +185,13 @@ def baseapp(request, ini_config, http_environ_session, available_port_factory, v
|
|||
|
||||
# start vcsserver
|
||||
_vcsserver_port = available_port_factory()
|
||||
vcsserver_instance = vcsserver_factory(
|
||||
request,
|
||||
store_dir=store_dir,
|
||||
port=_vcsserver_port,
|
||||
info_prefix="base-app-"
|
||||
)
|
||||
vcsserver_instance = vcsserver_factory(request, store_dir=store_dir, port=_vcsserver_port, info_prefix="base-app-")
|
||||
|
||||
settings["vcs.server"] = vcsserver_instance.bind_addr
|
||||
|
||||
# we skip setting store_dir for baseapp, it's internally set via testing rhodecode.ini
|
||||
# settings['repo_store.path'] = str(store_dir)
|
||||
console_printer(f' :warning: [green]pytest-setup[/green] Starting base pyramid-app: {ini_config}')
|
||||
console_printer(f" :warning: [green]pytest-setup[/green] Starting base pyramid-app: {ini_config}")
|
||||
pyramid_baseapp = make_pyramid_app({"__file__": ini_config}, **settings)
|
||||
|
||||
# start celery
|
||||
|
|
@ -206,10 +201,10 @@ def baseapp(request, ini_config, http_environ_session, available_port_factory, v
|
|||
port=None,
|
||||
info_prefix="base-app-",
|
||||
overrides=(
|
||||
{'handler_console': {'level': 'DEBUG'}},
|
||||
{'app:main': {'vcs.server': vcsserver_instance.bind_addr}},
|
||||
{'app:main': {'repo_store.path': store_dir}}
|
||||
)
|
||||
{"handler_console": {"level": "DEBUG"}},
|
||||
{"app:main": {"vcs.server": vcsserver_instance.bind_addr}},
|
||||
{"app:main": {"repo_store.path": store_dir}},
|
||||
),
|
||||
)
|
||||
|
||||
return pyramid_baseapp
|
||||
|
|
@ -401,7 +396,7 @@ def backend_base(request, backend_alias, test_repo):
|
|||
utils.check_xfail_backends(request.node, backend_alias)
|
||||
utils.check_skip_backends(request.node, backend_alias)
|
||||
|
||||
repo_name = "vcs_test_%s" % (backend_alias,)
|
||||
repo_name = f"vcs_test_{backend_alias}"
|
||||
backend = Backend(
|
||||
alias=backend_alias, repo_name=repo_name, test_name=request.node.name, test_repo_container=test_repo
|
||||
)
|
||||
|
|
@ -698,7 +693,7 @@ class VcsBackend(object):
|
|||
repo = repo_class(self._repo_path, create=True, src_url=src_url, bare=bare)
|
||||
self._cleanup_repos.append(repo)
|
||||
|
||||
commits = commits or [{"message": "Commit %s of %s" % (x, repo_name)} for x in range(number_of_commits)]
|
||||
commits = commits or [{"message": f"Commit {x} of {repo_name}"} for x in range(number_of_commits)]
|
||||
_add_commits_to_repo(repo, commits)
|
||||
return repo
|
||||
|
||||
|
|
@ -729,7 +724,7 @@ class VcsBackend(object):
|
|||
|
||||
def vcsbackend_base(request, backend_alias, tests_tmp_path, baseapp, test_repo) -> VcsBackend:
|
||||
if backend_alias not in request.config.getoption("--backends"):
|
||||
pytest.skip("Backend %s not selected." % (backend_alias,))
|
||||
pytest.skip(f"Backend {backend_alias} not selected.")
|
||||
|
||||
utils.check_xfail_backends(request.node, backend_alias)
|
||||
utils.check_skip_backends(request.node, backend_alias)
|
||||
|
|
@ -843,7 +838,7 @@ class RepoServer(object):
|
|||
|
||||
def serve(self, vcsrepo):
|
||||
if vcsrepo.alias != "svn":
|
||||
raise TypeError("Backend %s not supported" % vcsrepo.alias)
|
||||
raise TypeError(f"Backend {vcsrepo.alias} not supported")
|
||||
|
||||
proc = subprocess.Popen(
|
||||
["svnserve", "-d", "--foreground", "--listen-host", "localhost", "--root", vcsrepo.path]
|
||||
|
|
@ -1125,14 +1120,14 @@ class UserUtility(object):
|
|||
return name
|
||||
|
||||
def create_repo_group(self, owner=TEST_USER_ADMIN_LOGIN, auto_cleanup=True):
|
||||
group_name = "{prefix}_repogroup_{count}".format(prefix=self._test_name, count=len(self.repo_group_ids))
|
||||
group_name = f"{self._test_name}_repogroup_{len(self.repo_group_ids)}"
|
||||
repo_group = self.fixture.create_repo_group(group_name, cur_user=owner)
|
||||
if auto_cleanup:
|
||||
self.repo_group_ids.append(repo_group.group_id)
|
||||
return repo_group
|
||||
|
||||
def create_repo(self, owner=TEST_USER_ADMIN_LOGIN, parent=None, auto_cleanup=True, repo_type="hg", bare=False):
|
||||
repo_name = "{prefix}_repository_{count}".format(prefix=self._test_name, count=len(self.repos_ids))
|
||||
repo_name = f"{self._test_name}_repository_{len(self.repos_ids)}"
|
||||
|
||||
repository = self.fixture.create_repo(
|
||||
repo_name, cur_user=owner, repo_group=parent, repo_type=repo_type, bare=bare
|
||||
|
|
@ -1142,7 +1137,7 @@ class UserUtility(object):
|
|||
return repository
|
||||
|
||||
def create_user(self, auto_cleanup=True, **kwargs):
|
||||
user_name = "{prefix}_user_{count}".format(prefix=self._test_name, count=len(self.user_ids))
|
||||
user_name = f"{self._test_name}_user_{len(self.user_ids)}"
|
||||
user = self.fixture.create_user(user_name, **kwargs)
|
||||
if auto_cleanup:
|
||||
self.user_ids.append(user.user_id)
|
||||
|
|
@ -1158,7 +1153,7 @@ class UserUtility(object):
|
|||
return user, user_group
|
||||
|
||||
def create_user_group(self, owner=TEST_USER_ADMIN_LOGIN, members=None, auto_cleanup=True, **kwargs):
|
||||
group_name = "{prefix}_usergroup_{count}".format(prefix=self._test_name, count=len(self.user_group_ids))
|
||||
group_name = f"{self._test_name}_usergroup_{len(self.user_group_ids)}"
|
||||
user_group = self.fixture.create_user_group(group_name, cur_user=owner, **kwargs)
|
||||
|
||||
if auto_cleanup:
|
||||
|
|
@ -1694,4 +1689,3 @@ def repo_groups(request):
|
|||
fixture.destroy_repo_group(parent_group)
|
||||
|
||||
return zombie_group, parent_group, child_group
|
||||
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ class AssertResponse(object):
|
|||
sel = CSSSelector('a[href]')
|
||||
elements = [
|
||||
e for e in sel(doc) if e.text_content().strip() == link_text]
|
||||
assert len(elements) == 1, "Did not find link or found multiple links"
|
||||
assert len(elements) == 1, f"Did not find link or found multiple links, found={len(elements)}"
|
||||
self._ensure_url_equal(elements[0].attrib.get('href'), href)
|
||||
|
||||
def contains_one_anchor(self, anchor_id):
|
||||
|
|
@ -309,14 +309,14 @@ class AssertResponse(object):
|
|||
doc = fromstring(self.response.body)
|
||||
sel = CSSSelector('#' + anchor_id)
|
||||
elements = sel(doc)
|
||||
assert len(elements) == 1, 'cannot find 1 element {}'.format(anchor_id)
|
||||
assert len(elements) == 1, f'cannot find 1 element {anchor_id}'
|
||||
|
||||
def _ensure_url_equal(self, found, expected):
|
||||
assert _Url(found) == _Url(expected)
|
||||
|
||||
def get_element(self, css_selector):
|
||||
elements = self._get_elements(css_selector)
|
||||
assert len(elements) == 1, 'cannot find 1 element {}'.format(css_selector)
|
||||
assert len(elements) == 1, f'cannot find 1 element {css_selector}'
|
||||
return elements[0]
|
||||
|
||||
def get_elements(self, css_selector):
|
||||
|
|
|
|||
|
|
@ -162,7 +162,22 @@ class TestFileNodesListingAndCaches:
|
|||
b"tox.ini": 2,
|
||||
b"vcs": 1,
|
||||
}
|
||||
assert commit._path_mode_cache == {}
|
||||
assert commit._path_mode_cache == {
|
||||
b".gitignore": 33188,
|
||||
b".hgignore": 33188,
|
||||
b".hgtags": 33188,
|
||||
b".travis.yml": 33188,
|
||||
b"MANIFEST.in": 33188,
|
||||
b"README": 40960,
|
||||
b"README.rst": 33188,
|
||||
b"docs": 33188,
|
||||
b"run_test_and_report.sh": 33261,
|
||||
b"setup.cfg": 33188,
|
||||
b"setup.py": 33188,
|
||||
b"test_and_report.sh": 33261,
|
||||
b"tox.ini": 33188,
|
||||
b"vcs": 33188,
|
||||
}
|
||||
|
||||
if repo.alias == "git":
|
||||
assert list(commit.nodes.keys()) == [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue