Mercurial > kallithea
changeset 6481:8df1e9edd68f
indexers: use correct full repository name, which contains group name, at indexing
Before this revision, searching under the specific repository could
cause unexpected result, because repository names used for indexing didn't
contain the group name.
This issue was introduced by 8b7c0ef62427, which uses
repo.name_unicode as repository name instead of
safe_unicode(repo_name) to reduce unicode conversion cost while
repetition at indexing.
To use correct repository name at indexing, this revision replaces
repo.name_unicode by safe_unicode(repo_name). Reducing cost of repeated
unicode conversion cost while will (and should) be addressed in the
future.
This revision also adds a comment to BaseRepository.name property, to
avoid similar misunderstandings in the future.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 30 Jan 2017 19:09:45 +0900 |
parents | de37fcbce8c5 |
children | e81a99f9e365 |
files | kallithea/lib/indexers/daemon.py kallithea/lib/vcs/backends/base.py kallithea/tests/functional/test_search_indexing.py |
diffstat | 3 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/indexers/daemon.py Mon Jan 23 20:54:42 2017 +0100 +++ b/kallithea/lib/indexers/daemon.py Mon Jan 30 19:09:45 2017 +0900 @@ -203,7 +203,7 @@ writer.add_document( fileid=p, owner=unicode(repo.contact), - repository_rawname=repo.name_unicode, + repository_rawname=safe_unicode(repo_name), repository=safe_unicode(repo_name), path=p, content=u_content, @@ -242,7 +242,7 @@ raw_id=unicode(cs.raw_id), owner=unicode(repo.contact), date=cs._timestamp, - repository_rawname=repo.name_unicode, + repository_rawname=safe_unicode(repo_name), repository=safe_unicode(repo_name), author=cs.author, message=cs.message,
--- a/kallithea/lib/vcs/backends/base.py Mon Jan 23 20:54:42 2017 +0100 +++ b/kallithea/lib/vcs/backends/base.py Mon Jan 30 19:09:45 2017 +0900 @@ -97,6 +97,9 @@ @LazyProperty def name(self): + """ + Return repository name (without group name) + """ raise NotImplementedError @property
--- a/kallithea/tests/functional/test_search_indexing.py Mon Jan 23 20:54:42 2017 +0100 +++ b/kallithea/tests/functional/test_search_indexing.py Mon Jan 30 19:09:45 2017 +0900 @@ -125,6 +125,25 @@ {'q': q, 'type': searchtype}) response.mustcontain('>%d results' % hit) + @parametrize('reponame', [ + (u'indexing_test'), + (u'indexing_test-fork'), + (u'group/indexing_test'), + (u'this-is-it'), + ]) + @parametrize('searchtype,query,hit', [ + ('content', 'this_should_be_unique_content', 1), + ('commit', 'this_should_be_unique_commit_log', 1), + ('path', 'this_should_be_unique_filename.txt', 1), + ]) + def test_searching_under_repository(self, reponame, searchtype, query, hit): + self.log_user() + + response = self.app.get(url(controller='search', action='index', + repo_name=reponame), + {'q': query, 'type': searchtype}) + response.mustcontain('>%d results' % hit) + @parametrize('searchtype,query,hit', [ ('content', 'this_should_be_unique_content', 1), ('commit', 'this_should_be_unique_commit_log', 1),