Edgewall Software

Opened 11 years ago

Last modified 7 years ago

#10118 new enhancement

(almost patch) make browser quickjump dropdown context sensitive

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 (last modified by Christian Boos)

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:

  • versioncontrol/web_ui/browser.py

    diff -r -U5 /root/src/Trac-0.12.2/trac/versioncontrol/web_ui/browser.py ./versioncontrol/web_ui/browser.py
    old new  
    397398        quickjump_data = properties_data = None                                                         
    398399        if node and not xhr:                                                                             
    399400            properties_data = self.render_properties(                                                   
    400401                    'browser', context, node.get_properties())                                           
    401             quickjump_data = list(repos.get_quickjump_entries(rev))
     402            quickjump_data = list(repos.get_quickjump_entries(rev,path))
    403404        data = {
    404405            'context': context, 'reponame': reponame, 'repos': repos,
    405406            'repoinfo': all_repositories.get(reponame or ''),
    406407            'path': path, 'rev': node and node.rev, 'stickyrev': rev,
  • versioncontrol/svn_fs.py

    diff -r -U5 /root/src/Trac-0.12.2/trac/versioncontrol/svn_fs.py ./versioncontrol/svn_fs.py 
    old new  
    399399        self.repos = self.fs_ptr = self.pool = None                                       
    401401    def get_base(self):                                                                   
    402402        return self.base                                                                 
    404     def _get_tags_or_branches(self, paths):                                              
     404    def _get_tags_or_branches(self, paths, showpath = None):                             
    405405        """Retrieve known branches or tags."""                                           
    406         for path in self.params.get(paths, []):                                           
     406       mypaths=self.params.get(paths,[])                                                 
     407       if( showpath and showpath.startswith("trunk") ):                                   
     408           npath=showpath.replace("trunk",paths)                                         
     409           if( not npath.endswith("/") ):                                                 
     410               npath += "/"                                                               
     411           npath += "*"                                                                   
     412           mypaths.append(npath)                                                         
     413       for path in mypaths:                                                               
    407414            if path.endswith('*'):                                                       
    408415                folder = posixpath.dirname(path)                                         
    409416                try:                                                                     
    410417                    entries = [n for n in self.get_node(folder).get_entries()]           
    411418                    for node in sorted(entries, key=lambda n:                             
    418425                try:                                                                     
    419426                    yield self.get_node(path)                                             
    420427                except: # no right                                                       
    421428                    pass                                                                 
    423     def get_quickjump_entries(self, rev):                                                
     430    def get_quickjump_entries(self, rev, showpath = None):                               
    424431        """Retrieve known branches, as (name, id) pairs.                                 
    426433        Purposedly ignores `rev` and always takes the last revision.                     
    427434        """                                                                               
    428         for n in self._get_tags_or_branches('branches'):                                  
     435        for n in self._get_tags_or_branches('branches',showpath):                         
    429436            yield 'branches', n.path, n.path, None                                       
    430         for n in self._get_tags_or_branches('tags'):                                      
     437        for n in self._get_tags_or_branches('tags',showpath):                             
    431438            yield 'tags', n.path, n.created_path, n.created_rev                           
    433440    def get_path_url(self, path, rev):                                                   
    434441        url = self.params.get('url', '').rstrip('/')                                     
    435442        if url:                   

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

Attachments (0)

Change History (6)

comment:1 by Christian Boos, 11 years ago

Component: generalversion control/browser
Milestone: next-major-0.1X

I fail to see what the patch does (or how it could work…showpath.replace("trunk", paths) where paths is a list?), so please provide us with an example instead.

I do see a few possible enhancements for the quickjump features though:

  • switch the current path to what it looks below one of the listed branches / tags
  • actually don't do a "go" but fill a field with the selected value, and have two buttons: |View| and |Diff| (the latter related to #9824)

comment:2 by anonymous, 11 years ago

the patch assumes a structure of the svn like trunk/XXX/YYY and when you are looking at that in the browser, it automatically adds to the quickjump menu a list of things present in /branches/XXX/YYY/* and /tags/XXX/YYY/* so you can quickly jump to one of the tags/branches made out of the currently viewed trunk. Of course not everyone will have this struture or wants this feature, so to be a real feature it would need to be configureable.

comment:3 by Christian Boos, 10 years ago

Description: modified (diff)
Milestone: next-major-releasesunscheduled
Version: 0.12.2

comment:4 by Christian Boos, 10 years ago

[OT] not sure what's going on in the description for the styling of the second file…

comment:5 by Christian Boos, 10 years ago

Summary: (almost patch) make browser quickjum dropdown context sensitive(almost patch) make browser quickjump dropdown context sensitive

comment:6 by figaro, 7 years ago

Keywords: patch added

Modify Ticket

Change Properties
Set your email in Preferences
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.