Changeset 1385
- Timestamp:
- 10/15/06 17:18:31 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
filenamesearchplugin/0.10/filenamesearch/web_ui.py
r1384 r1385 3 3 from trac.Search import ISearchSource 4 4 from trac.perm import IPermissionRequestor 5 from trac.config import BoolOption 5 6 6 7 from fnmatch import fnmatchcase … … 8 9 class FilenameSearchModule(Component): 9 10 """Search source for filenames in the repository.""" 11 12 check_gone = BoolOption('filenamesearch', 'check_gone', default=True, 13 doc='Check if files are present in the youngest rev before returning.') 14 show_gone = BoolOption('filenamesearch', 'show_gone', default=True, 15 doc='Show files that are in the DB, but not in the youngest rev. (These may indicate moved files)') 10 16 11 17 implements(ISearchSource, IPermissionRequestor) … … 22 28 cursor = db.cursor() 23 29 repo = self.env.get_repository(req.authname) 24 #youngest_rev = repo.get_youngest_rev()30 youngest_rev = repo.get_youngest_rev() 25 31 26 32 cursor.execute("""SELECT max("""+db.cast('rev','int')+"""), path FROM node_change … … 33 39 for term in terms: 34 40 for rev, path in all_files: 35 if fnmatchcase(path, term): 41 match = None 42 if '/' in term: 43 match = fnmatchcase(path, term.lstrip('/')) 44 else: 45 match = sum([fnmatchcase(x, term) for x in path.split('/')]) 46 if match: 36 47 cset = cset_cache.setdefault(rev, repo.get_changeset(rev)) 37 yield (req.href.browser(path, rev=rev), path, cset.date, cset.author, '') 48 msg = '' 49 if self.check_gone and not repo.has_node(path, youngest_rev): 50 if self.show_gone: 51 msg = 'Not in the youngest revision, file has possibly been moved.' 52 else: 53 continue 54 yield (req.href.browser(path, rev=rev), path, cset.date, cset.author, msg) 38 55 39 56 # IPermissionRequestor methods