Edgewall Software
Modify

Opened 16 years ago

Last modified 4 years ago

#3906 new enhancement

Request for a files search (no indexing just plain find like search)

Reported by: sineer@… Owned by:
Priority: normal Milestone: next-major-releases
Component: version control/browser Version: 0.10
Severity: normal Keywords: bitesized
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I would like a /usr/bin/find like file search to look for a specific filename in the repository recursively (ie, some*.pdf)

I've seen the RepoSearch hack but I would like a simple file search (perhaps in Browse source or in Search directly with a files checkbox) that would let me search for a file or files in particular strictly based on the files in the repository.

This is a simple feature, I'm surprised it hasn't been implemented yet ;)

perhaps a simple hack would be in order…

Attachments (0)

Change History (10)

in reply to:  description ; comment:1 by Christian Boos, 16 years ago

Milestone: 0.11

Replying to sineer@gmail.com:

This is a simple feature, I'm surprised it hasn't been implemented yet ;)

Perhaps because it's simpler to describe than to implement ;)

Looking in all files in the repository is out of question, as this would imply going recursively in the tree, which in case of Subversion is always something huge (due to the tag/branch by copying principle).

So we'd have to use the database, and the node_change table. There, it's a bit better, as we will get the filenames, but we'd have to sort through the revisions to get the latest one (or the previous to last, in case the last is a Delete!). And that's not easily done for all backends, at least for now. See also #3837.

On the other hand, in Mercurial for example, you could simply search through the latest "manifest" (i.e. the list of all files).

But yes, it's a good idea.

comment:2 by sineer@…, 16 years ago

Sweet :)

Your right, it's probably not that simple to implement…

Thanks for the hard work! TRAC ROCK!!

comment:3 by Noah Kantrowitz (coderanger) <coderanger@…>, 16 years ago

Resolution: fixed
Status: newclosed

This is now implemented in the Filename Search plugin.

comment:4 by Christian Boos, 15 years ago

Milestone: 0.11

(not in trac core, so clearing the milestone)

comment:5 by Christian Boos, 12 years ago

Keywords: bitesized added
Resolution: fixed
Status: closedreopened

Would be nice to get this to work in a backend neutral way, as outlined in comment:1. The filter itself could eventually be a tracopt. component but there will also probably be trac.versioncontrol.api changes that need to be done.

Nice bitesized feature for an upcoming release.

comment:6 by Remy Blank, 12 years ago

Milestone: next-major-0.1X

comment:7 by Ryan J Ollos, 7 years ago

Owner: Christian Boos removed
Status: reopenednew

in reply to:  3 ; comment:8 by anonymous, 4 years ago

This is now implemented in the Filename Search plugin.

This was deleted.

in reply to:  8 comment:9 by Jun Omae, 4 years ago

Replying to anonymous:

This is now implemented in the Filename Search plugin.

This was deleted.

I'm not sure reason of the removal but it is able to export by giving revision number.

$ svn export https://trac-hacks.org/svn/filenamesearchplugin/0.10@13221 filenamesearchplugin

Also, the plugin supports only default repository.

in reply to:  1 comment:10 by Peter Suter, 4 years ago

Replying to Christian Boos:

in Mercurial for example, you could simply search through the latest "manifest" (i.e. the list of all files).

Proof-of-concept seems to work well:

from trac.core import Component, implements
from trac.search import ISearchSource
from trac.resource import Resource
from trac.versioncontrol.api import RepositoryManager


class MercurialFilenameSearch(Component):
    """Search Mercurial filenames."""

    implements(ISearchSource)

    def get_search_filters(self, req):
        if 'FILE_VIEW' in req.perm:
            yield ('hgfilenames', 'Mercurial Filenames', False)

    def get_search_results(self, req, terms, filters):
        if not 'hgfilenames' in filters:
            return
        rm = RepositoryManager(self.env)
        for repos in rm.get_real_repositories():
            if repos.params.get('type') != 'hg':
                continue
            root = repos.get_node('/')
            for raw_filename in root.manifest:
                filename = repos.to_u(raw_filename)
                if not all(term in filename for term in terms):
                    continue
                node = repos.get_node(filename)
                changeset = repos.get_changeset(node.created_rev)
                resource = Resource(node.realm, node.path, parent=repos.resource)
                if 'FILE_VIEW' not in req.perm(resource):
                    continue
                url = rm.get_resource_url(resource, req.href)
                author = changeset.author
                date = changeset.date
                summary = rm.get_resource_description(resource, 'summary')
                yield url, summary, date, author, ''

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.