def get_repository(self, repos_type, repos_dir, authname): assert repos_type == "perforce" options = dict(self.config.options("perforce")) if "port" not in options: raise TracError( message="Missing 'port' value in [perforce] config section.", title="TracPerforce configuration error" ) # Try to connect to the Perforce server from perforce import Connection, ConnectionFailed p4 = Connection(port=options["port"], api="58") # Limit to 2005.2 behaviour try: from trac import __version__ as tracVersion p4.connect(prog="Trac", version=tracVersion) except ConnectionFailed: raise TracError(message="Could not connect to Perforce repository.", title="Perforce connection error") if "user" not in options: raise TracError( message="Missing 'user' value in [perforce] config section.", title="Perforce configuration error" ) p4.user = options["user"] if "password" in options: p4.password = options["password"] else: p4.password = "" if "unicode" in options: if options["unicode"] == "1": p4.charset = "utf8" elif options["unicode"] == "0": p4.charset = "none" else: raise TracError( message="Invalid 'unicode' value in [perforce] config " "section.", title="Perforce configuration error", ) else: p4.charset = "none" if "language" in options: p4.language = options["language"] else: p4.language = "" p4.client = "" repos = PerforceRepository(p4, self.log) from trac.versioncontrol.cache import CachedRepository return PerforceCachedRepository(self.env.get_db_cnx(), repos, None, self.log)
def get_repository(self, repos_type, repos_dir, params): """Return a `PerforceRepository`. The repository is wrapped in a `CachedRepository`. """ assert repos_type == 'perforce' self.log.debug("get_repository dir : %s" % (repos_dir)) options = dict(self.config.options('perforce')) self.log.debug("get_repository options : %s" % (options)) # Try to connect to the Perforce server from perforce import Connection, ConnectionFailed p4 = Connection(port=self.port, api='58') # Limit to 2005.2 behaviour try: from trac import __version__ as tracVersion p4.connect(prog='Trac', version=tracVersion) except ConnectionFailed: raise TracError( message="Could not connect to Perforce repository.", title="Perforce connection error") if self.user == '': raise TracError( message="Missing 'user' value in [perforce] config section.", title="Perforce configuration error") p4.user = self.user p4.password = self.password p4.charset = self.charset p4.language = self.language jobPrefixLength = len(options.get('job_prefix', 'job')) p4.client = self.workspace params.update(labels=self.labels, branches=self.branches) # Calling CachedRepository depending on version # (for backward-compatibility with 0.11) p4_repos = PerforceRepository(p4, None, self.log, jobPrefixLength, params) repos = CachedRepository(self.env, p4_repos, self.log) return repos
def get_repository(self, repos_type, repos_dir, authname): """Return a `PerforceRepository`. The repository is wrapped in a `CachedRepository`. """ assert repos_type == 'perforce' self.log.debug("get_repository dir : %s" % (repos_dir)) options = dict(self.config.options('perforce')) self.log.debug("get_repository options : %s" % (options)) # Try to connect to the Perforce server from perforce import Connection, ConnectionFailed p4 = Connection(port=self.port, api='58') # Limit to 2005.2 behaviour try: from trac import __version__ as tracVersion p4.connect(prog='Trac', version=tracVersion) except ConnectionFailed: raise TracError( message="Could not connect to Perforce repository.", title="Perforce connection error") if self.user == '': raise TracError( message="Missing 'user' value in [perforce] config section.", title="Perforce configuration error") p4.user = self.user p4.password = self.password p4.charset = self.charset p4.language = self.language jobPrefixLength = len(options.get('job_prefix', 'job')) p4.client = self.workspace p4_repos = PerforceRepository(p4, None, self.log, jobPrefixLength, {'labels': self.labels, 'branches': self.branches}) repos = CachedRepository(self.env.get_db_cnx(), p4_repos, None, self.log) if authname: pass return repos
def get_repository(self, repos_type, repos_dir, authname): assert repos_type == 'perforce' import urllib urltype, url = urllib.splittype(repos_dir) assert urltype == 'p4' or url == 'p4' options = dict(self.config.options('perforce')) if urltype != None: machine, path_query = urllib.splithost(url) user_passwd, host_port = urllib.splituser(machine) user, password = urllib.splitpasswd(user_passwd) self._update_option(options, 'port', host_port) self._update_option(options, 'password', password) self._update_option(options, 'user', user) path, query = urllib.splitquery(path_query) if path and path != '': for attr in self._splitattributes(query): key, val = urllib.splitvalue(attr) self._update_option(options, key, val) self._update_option(options, 'path', path) self.log.debug("get_repository options : %s" % (options)) if 'port' not in options: raise TracError( message="Missing 'port' value in [perforce] config section.", title="TracPerforce configuration error", ) # Try to connect to the Perforce server from perforce import Connection, ConnectionFailed p4 = Connection(port=options['port'], api='58', # Limit to 2005.2 behaviour ) try: from trac import __version__ as tracVersion p4.connect(prog='Trac', version=tracVersion) except ConnectionFailed: raise TracError( message="Could not connect to Perforce repository.", title="Perforce connection error", ) if 'user' not in options: raise TracError( message="Missing 'user' value in [perforce] config section.", title="Perforce configuration error", ) p4.user = options['user'] if 'password' in options: p4.password = options['password'] else: p4.password = '' if 'unicode' in options: if options['unicode'] == '1': p4.charset = 'utf8' elif options['unicode'] == '0': p4.charset = 'none' else: raise TracError( message="Invalid 'unicode' value in [perforce] config " \ "section.", title="Perforce configuration error", ) else: p4.charset = 'none' if 'language' in options: p4.language = options['language'] else: p4.language = '' jobPrefixLength = 3 # default value because by default prefix is 'job' if 'job_prefix' in options: jobPrefixLength = len(options['job_prefix']) p4.client = '' repos = PerforceRepository(p4, self.log, jobPrefixLength) from trac.versioncontrol.cache import CachedRepository return PerforceCachedRepository(self.env.get_db_cnx(), repos, None, self.log)
def get_repository(self, repos_type, repos_dir, authname): assert repos_type == 'perforce' options = dict(self.config.options('perforce')) if 'port' not in options: raise TracError( message="Missing 'port' value in [perforce] config section.", title="TracPerforce configuration error", ) # Try to connect to the Perforce server from perforce import Connection, ConnectionFailed p4 = Connection(port=options['port'], api='58', # Limit to 2005.2 behaviour ) try: from trac import __version__ as tracVersion p4.connect(prog='Trac', version=tracVersion) except ConnectionFailed: raise TracError( message="Could not connect to Perforce repository.", title="Perforce connection error", ) if 'user' not in options: raise TracError( message="Missing 'user' value in [perforce] config section.", title="Perforce configuration error", ) p4.user = options['user'] if 'password' in options: p4.password = options['password'] else: p4.password = '' if 'unicode' in options: if options['unicode'] == '1': p4.charset = 'utf8' elif options['unicode'] == '0': p4.charset = 'none' else: raise TracError( message="Invalid 'unicode' value in [perforce] config " \ "section.", title="Perforce configuration error", ) else: p4.charset = 'none' if 'language' in options: p4.language = options['language'] else: p4.language = '' p4.client = '' repos = PerforceRepository(p4, self.log) from trac.versioncontrol.cache import CachedRepository return PerforceCachedRepository(self.env.get_db_cnx(), repos, None, self.log)
def get_repository(self, repos_type, repos_dir, authname): assert repos_type == 'perforce' import urllib urltype, url = urllib.splittype(repos_dir) assert urltype == 'p4' or url == 'p4' options = dict(self.config.options('perforce')) if urltype != None: machine, path_query = urllib.splithost(url) user_passwd, host_port = urllib.splituser(machine) user, password = urllib.splitpasswd(user_passwd) self._update_option(options, 'port', host_port) self._update_option(options, 'password', password) self._update_option(options, 'user', user) path, query = urllib.splitquery(path_query) if path and path != '': for attr in self._splitattributes(query): key, val = urllib.splitvalue(attr) self._update_option(options, key, val) self._update_option(options, 'path', path) self.log.debug("get_repository options : %s" % (options)) if 'port' not in options: raise TracError( message="Missing 'port' value in [perforce] config section.", title="TracPerforce configuration error", ) # Try to connect to the Perforce server from perforce import Connection, ConnectionFailed p4 = Connection( port=options['port'], api='58', # Limit to 2005.2 behaviour ) try: from trac import __version__ as tracVersion p4.connect(prog='Trac', version=tracVersion) except ConnectionFailed: raise TracError( message="Could not connect to Perforce repository.", title="Perforce connection error", ) if 'user' not in options: raise TracError( message="Missing 'user' value in [perforce] config section.", title="Perforce configuration error", ) p4.user = options['user'] if 'password' in options: p4.password = options['password'] else: p4.password = '' if 'unicode' in options: if options['unicode'] == '1': p4.charset = 'utf8' elif options['unicode'] == '0': p4.charset = 'none' else: raise TracError( message="Invalid 'unicode' value in [perforce] config " \ "section.", title="Perforce configuration error", ) else: p4.charset = 'none' if 'language' in options: p4.language = options['language'] else: p4.language = '' jobPrefixLength = 3 # default value because by default prefix is 'job' if 'job_prefix' in options: jobPrefixLength = len(options['job_prefix']) p4.client = '' repos = PerforceRepository(p4, None, self.log, jobPrefixLength) crepos = CachedRepository(self.env.get_db_cnx(), repos, None, self.log) return crepos