Edgewall Software

Opened 13 years ago

Last modified 8 years ago

#10118 new enhancement

(almost patch) make browser quickjum dropdown context sensitive — at Initial Version

Reported by: anonymous Owned by:
Priority: normal Milestone: unscheduled
Component: version control/browser Version: 0.12.2
Severity: normal Keywords: patch
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Hi, I made my quickjump context menu context sensitive because I have many many projects within the same erpository, and adding them all by hand to the trac.ini would not only be tedious, it would also confuse people since they probably only want to see available tags/branches to whatever server/program/library they are currently looking at.

I made a little patch to my trac 0.12.2 that does exactly what I want, but I guess to make it a full feature it should be configurable in some way (at lest switch it on/off, restrict it to some directory or all that match a pattern, or have some special keyword that gets substituted by the current path, or all at once).

Here are the changes:

diff -r -U5 /root/src/Trac-0.12.2/trac/versioncontrol/web_ui/browser.py ./versioncontrol/web_ui/browser.py
--- /root/src/Trac-0.12.2/trac/versioncontrol/web_ui/browser.py 2011-01-31 23:05:46.000000000 +0100       
+++ ./versioncontrol/web_ui/browser.py  2011-04-05 15:34:29.000000000 +0200                               
@@ -396,11 +397,11 @@                                                                                     
                                                                                                          
         quickjump_data = properties_data = None                                                          
         if node and not xhr:                                                                             
             properties_data = self.render_properties(                                                    
                     'browser', context, node.get_properties())                                           
-            quickjump_data = list(repos.get_quickjump_entries(rev))
+            quickjump_data = list(repos.get_quickjump_entries(rev,path))

         data = {
             'context': context, 'reponame': reponame, 'repos': repos,
             'repoinfo': all_repositories.get(reponame or ''),
             'path': path, 'rev': node and node.rev, 'stickyrev': rev,



diff -r -U5 /root/src/Trac-0.12.2/trac/versioncontrol/svn_fs.py ./versioncontrol/svn_fs.py 
--- /root/src/Trac-0.12.2/trac/versioncontrol/svn_fs.py 2011-01-31 23:05:46.000000000 +0100
+++ ./versioncontrol/svn_fs.py  2011-04-05 15:42:51.000000000 +0200                        
@@ -399,13 +399,20 @@                                                                      
         self.repos = self.fs_ptr = self.pool = None                                       
                                                                                           
     def get_base(self):                                                                   
         return self.base                                                                  
                                                                                           
-    def _get_tags_or_branches(self, paths):                                               
+    def _get_tags_or_branches(self, paths, showpath = None):                              
         """Retrieve known branches or tags."""                                            
-        for path in self.params.get(paths, []):                                           
+       mypaths=self.params.get(paths,[])                                                  
+       if( showpath and showpath.startswith("trunk") ):                                   
+           npath=showpath.replace("trunk",paths)                                          
+           if( not npath.endswith("/") ):                                                 
+               npath += "/"                                                               
+           npath += "*"                                                                   
+           mypaths.append(npath)                                                          
+       for path in mypaths:                                                               
             if path.endswith('*'):                                                        
                 folder = posixpath.dirname(path)                                          
                 try:                                                                      
                     entries = [n for n in self.get_node(folder).get_entries()]            
                     for node in sorted(entries, key=lambda n:                             
@@ -418,18 +425,18 @@                                                                      
                 try:                                                                      
                     yield self.get_node(path)                                             
                 except: # no right                                                        
                     pass                                                                  
                                                                                           
-    def get_quickjump_entries(self, rev):                                                 
+    def get_quickjump_entries(self, rev, showpath = None):                                
         """Retrieve known branches, as (name, id) pairs.                                  
                                                                                           
         Purposedly ignores `rev` and always takes the last revision.                      
         """                                                                               
-        for n in self._get_tags_or_branches('branches'):                                  
+        for n in self._get_tags_or_branches('branches',showpath):                         
             yield 'branches', n.path, n.path, None                                        
-        for n in self._get_tags_or_branches('tags'):                                      
+        for n in self._get_tags_or_branches('tags',showpath):                             
             yield 'tags', n.path, n.created_path, n.created_rev                           
                                                                                           
     def get_path_url(self, path, rev):                                                    
         url = self.params.get('url', '').rstrip('/')                                      
         if url:                    


This should give you an idea of what the feature looks like that I wanted to have.

Change History (0)

Note: See TracTickets for help on using tickets.