Edgewall Software

Ticket #6796: unsupported_vcs-r7031.diff

File unsupported_vcs-r7031.diff, 3.9 KB (added by cboos, 8 months ago)

Provide a mechanism by which one can get (slightly) more meaningful messages for this common error

  • trac/versioncontrol/api.py

     
    3434class IRepositoryConnector(Interface): 
    3535    """Provide support for a specific version control system.""" 
    3636 
     37    error = None # place holder for storing relevant error message 
     38 
    3739    def get_supported_types(): 
    3840        """Return the types of version control systems that are supported. 
    3941 
     
    4244         
    4345        If multiple provider match a given type, the `priority` is used to 
    4446        choose between them (highest number is highest priority). 
     47 
     48        If the `priority` returned is negative, this indicates that the  
     49        connector for the given `repotype` indeed exists but can't be 
     50        used for some reason. The `error` property can then be used to  
     51        store an error message or exception relevant to the problem detected. 
    4552        """ 
    4653 
    4754    def get_repository(repos_type, repos_dir, authname): 
     
    7986                self.get_repository(req.authname).sync() 
    8087            except TracError, e: 
    8188                add_warning(req, _("Can't synchronize with the repository " 
    82                               "(%(error)s)", error=e.message)) 
     89                              "(%(error)s). Look in the Trac log for more " 
     90                              "information.", error=e.message)) 
     91                           
    8392        return handler 
    8493 
    8594    def post_process_request(self, req, template, content_type): 
     
    125134                    if repos_type == self.repository_type 
    126135                ] 
    127136                if candidates: 
    128                     self._connector = max(candidates)[1] 
     137                    prio, connector = max(candidates) 
     138                    if prio < 0: # error condition 
     139                        raise TracError( 
     140                            _('Unsupported version control system "%(name)s"' 
     141                              ': "%(error)s" ', name=self.repository_type,  
     142                              error=connector.error)) 
     143                    self._connector = connector 
    129144                else: 
    130145                    raise TracError( 
    131                         _('Unsupported version control system "%(name)s". ' 
    132                           'Check that the Python support libraries for ' 
    133                           '"%(name)s" are correctly installed.', 
     146                        _('Unsupported version control system "%(name)s": ' 
     147                          'Can\'t find an appropriate component, maybe the ' 
     148                          'corresponding plugin was not enabled? ', 
    134149                          name=self.repository_type)) 
    135150            tid = threading._get_ident() 
    136151            if tid in self._cache: 
  • trac/versioncontrol/svn_fs.py

     
    244244        below that path will be included. 
    245245        """) 
    246246 
     247    error = None 
     248 
    247249    def __init__(self): 
    248250        self._version = None 
    249251         
    250252        try: 
    251253            _import_svn() 
    252254            self.log.debug('Subversion bindings imported') 
    253         except ImportError: 
     255        except ImportError, e: 
     256            self.error = e 
    254257            self.log.info('Failed to load Subversion bindings', exc_info=True) 
    255             self.has_subversion = False 
    256258        else: 
    257             self.has_subversion = True 
    258259            Pool() 
    259260 
    260261    def get_supported_types(self): 
    261         if self.has_subversion: 
    262             yield ("direct-svnfs", 4) 
    263             yield ("svnfs", 4) 
    264             yield ("svn", 2) 
     262        prio = 1 
     263        if self.error: 
     264            prio = -1 
     265        yield ("direct-svnfs", prio*4) 
     266        yield ("svnfs", prio*4) 
     267        yield ("svn", prio*2) 
    265268 
    266269    def get_repository(self, type, dir, authname): 
    267270        """Return a `SubversionRepository`.