Changeset 1323

Show
Ignore:
Timestamp:
09/30/06 04:04:35 (2 years ago)
Author:
ttressieres
Message:

PerforcePlugin:

Perforce settings read in variable repository_dir from [trac] section (adresses #632)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • perforceplugin/trunk/p4trac/api.py

    r1215 r1323  
    5757            yield ('perforce', 4) 
    5858 
     59    def _update_option(self, options, key, value): 
     60        """Update options dictionary with (key, value)""" 
     61 
     62        if value == None: 
     63            if key in options: del options[key] 
     64        else: 
     65            options[key] = value 
     66         
    5967    def get_repository(self, repos_type, repos_dir, authname): 
    6068 
    6169        assert repos_type == 'perforce' 
    6270 
     71        import urllib 
     72        urltype, url = urllib.splittype(repos_dir) 
     73        assert urltype == 'p4' or url == 'p4' 
     74 
    6375        options = dict(self.config.options('perforce')) 
    64          
     76        if urltype != None: 
     77            machine, path = urllib.splithost(url) 
     78            user_passwd, host_port = urllib.splituser(machine) 
     79            user, password = urllib.splitpasswd(user_passwd) 
     80            host, port = urllib.splitport(host_port) 
     81            self._update_option(options, 'port', port) 
     82            self._update_option(options, 'password', password) 
     83            self._update_option(options, 'user', user) 
     84            self._update_option(options, 'host', host) 
     85 
    6586        if 'port' not in options: 
    6687            raise TracError( 
     
    275296 
    276297    def get_name(self): 
    277         return 'p4://%s' % self._connection.port 
     298        return 'p4://%s:%s@%s:%s' % (self._connection.user, self._connection.password, self._connection.host, self._connection.port) 
    278299    name = property(get_name) 
    279300