def __init__(self, path, params, log): self.log = log self.pool = Pool() # Remove any trailing slash or else subversion might abort if isinstance(path, unicode): path_utf8 = path.encode('utf-8') else: # note that this should usually not happen (unicode arg expected) path_utf8 = to_unicode(path).encode('utf-8') path_utf8 = os.path.normpath(path_utf8).replace('\\', '/') self.path = path_utf8.decode('utf-8') root_path_utf8 = repos.svn_repos_find_root_path(path_utf8, self.pool()) if root_path_utf8 is None: raise TracError( _("%(path)s does not appear to be a Subversion " "repository.", path=to_unicode(path_utf8))) try: self.repos = repos.svn_repos_open(root_path_utf8, self.pool()) except core.SubversionException, e: raise TracError( _( "Couldn't open Subversion repository %(path)s: " "%(svn_error)s", path=to_unicode(path_utf8), svn_error=exception_to_unicode(e)))
def __init__(self, path, authz): Repository.__init__(self, authz) if core.SVN_VER_MAJOR < 1: raise TracError("Subversion >= 1.0 required: Found %d.%d.%d" % \ (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO)) self.repos = None self.fs_ptr = None self.path = path # Remove any trailing slash or else subversion might abort if not os.path.split(path)[1]: path = os.path.split(path)[0] self.path = repos.svn_repos_find_root_path(path) if self.path is None: raise TracError( "%s does not appear to be a Subversion repository." % (path, )) if self.path != path: self.scope = path[len(self.path):] if not self.scope[-1:] == b'/': self.scope += b'/' else: self.scope = b'/' self.repos = repos.svn_repos_open(self.path) self.fs_ptr = repos.svn_repos_fs(self.repos) self.rev = fs.youngest_rev(self.fs_ptr) self.history = None if self.scope != b'/': self.history = [] for path, rev in _get_history(self.scope[1:], self.authz, self.fs_ptr, 0, self.rev): self.history.append(rev)
def __init__(self, path, authz, log, options={}): self.log = log self.options = options self.pool = Pool() if isinstance(path, unicode): path = path.encode('utf-8') path = os.path.normpath(path).replace('\\', '/') self.path = repos.svn_repos_find_root_path(path, self.pool()) if self.path is None: raise Exception('%(path)s does not appear to be a Subversion' 'Repository.' % {'path': path}) self.repos = repos.svn_repos_open(self.path, self.pool()) self.fs_ptr = repos.svn_repos_fs(self.repos) uuid = fs.get_uuid(self.fs_ptr, self.pool()) name = 'svn:%s:%s' % (uuid, _from_svn(path)) if self.path != path: self.scope = path[len(self.path):] if not self.scope[-1] == '/': self.scope += '/' else: self.scope = '/' assert self.scope[0] == '/' self.clear() self.youngest_rev = property(lambda x: x.get_youngest_rev())
def __init__(self, path, authz, log): self.path = path # might be needed by __del__()/close() self.log = log if core.SVN_VER_MAJOR < 1: raise TracError("Subversion >= 1.0 required: Found %d.%d.%d" % \ (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO)) self.pool = Pool() # Remove any trailing slash or else subversion might abort if isinstance(path, unicode): path = path.encode('utf-8') path = os.path.normpath(path).replace('\\', '/') self.path = repos.svn_repos_find_root_path(path, self.pool()) if self.path is None: raise TracError("%s does not appear to be a Subversion repository." \ % path) self.repos = repos.svn_repos_open(self.path, self.pool()) self.fs_ptr = repos.svn_repos_fs(self.repos) uuid = fs.get_uuid(self.fs_ptr, self.pool()) name = 'svn:%s:%s' % (uuid, _from_svn(path)) Repository.__init__(self, name, authz, log) if self.path != path: self.scope = path[len(self.path):] if not self.scope[-1] == '/': self.scope += '/' else: self.scope = '/' assert self.scope[0] == '/' self.clear()
def __init__(self, path, authz, log, options={}): self.log = log self.options = options self.pool = Pool() # Remove any trailing slash or else subversion might abort if isinstance(path, unicode): self.path = path path_utf8 = path.encode("utf-8") else: # note that this should usually not happen (unicode arg expected) self.path = to_unicode(path) path_utf8 = self.path.encode("utf-8") path_utf8 = os.path.normpath(path_utf8).replace("\\", "/") root_path_utf8 = repos.svn_repos_find_root_path(path_utf8, self.pool()) if root_path_utf8 is None: raise TracError(_("%(path)s does not appear to be a Subversion " "repository.", path=to_unicode(path_utf8))) try: self.repos = repos.svn_repos_open(root_path_utf8, self.pool()) except core.SubversionException, e: raise TracError( _( "Couldn't open Subversion repository %(path)s: " "%(svn_error)s", path=to_unicode(path_utf8), svn_error=exception_to_unicode(e), ) )
def __init__(self, path, authz): Repository.__init__(self, authz) if core.SVN_VER_MAJOR < 1: raise TracError, \ "Subversion >= 1.0 required: Found %d.%d.%d" % \ (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO) self.repos = None self.fs_ptr = None self.path = path # Remove any trailing slash or else subversion might abort if not os.path.split(path)[1]: path = os.path.split(path)[0] self.path = repos.svn_repos_find_root_path(path) if self.path is None: raise TracError, "%s does not appear to be a Subversion repository." % (path, ) if self.path != path: self.scope = path[len(self.path):] if not self.scope[-1] == '/': self.scope += '/' else: self.scope = '/' self.repos = repos.svn_repos_open(self.path) self.fs_ptr = repos.svn_repos_fs(self.repos) self.rev = fs.youngest_rev(self.fs_ptr) self.history = None if self.scope != '/': self.history = [] for path,rev in _get_history(self.scope[1:], self.authz, self.fs_ptr, 0, self.rev): self.history.append(rev)
def __init__(self, path, params, log): self.log = log self.pool = Pool() # Remove any trailing slash or else subversion might abort if isinstance(path, unicode): path_utf8 = path.encode('utf-8') else: # note that this should usually not happen (unicode arg expected) path_utf8 = to_unicode(path).encode('utf-8') path_utf8 = core.svn_path_canonicalize( os.path.normpath(path_utf8).replace('\\', '/')) self.path = path_utf8.decode('utf-8') root_path_utf8 = repos.svn_repos_find_root_path(path_utf8, self.pool()) if root_path_utf8 is None: raise TracError(_("%(path)s does not appear to be a Subversion " "repository.", path=to_unicode(path_utf8))) try: self.repos = repos.svn_repos_open(root_path_utf8, self.pool()) except core.SubversionException, e: raise TracError(_("Couldn't open Subversion repository %(path)s: " "%(svn_error)s", path=to_unicode(path_utf8), svn_error=exception_to_unicode(e)))
def __init__(self, path, params, log): self.log = log self.pool = Pool() # Remove any trailing slash or else subversion might abort if isinstance(path, unicode): path_utf8 = path.encode('utf-8') else: # note that this should usually not happen (unicode arg expected) path_utf8 = to_unicode(path).encode('utf-8') path_utf8 = core.svn_path_canonicalize( os.path.normpath(path_utf8).replace('\\', '/')) self.path = path_utf8.decode('utf-8') root_path_utf8 = repos.svn_repos_find_root_path(path_utf8, self.pool()) if root_path_utf8 is None: raise InvalidRepository( _("%(path)s does not appear to be a Subversion repository.", path=to_unicode(path_utf8))) try: self.repos = repos.svn_repos_open(root_path_utf8, self.pool()) except core.SubversionException as e: raise InvalidRepository( _("Couldn't open Subversion repository %(path)s: " "%(svn_error)s", path=to_unicode(path_utf8), svn_error=exception_to_unicode(e))) self.fs_ptr = repos.svn_repos_fs(self.repos) self.uuid = fs.get_uuid(self.fs_ptr, self.pool()) self.base = 'svn:%s:%s' % (self.uuid, _from_svn(root_path_utf8)) name = 'svn:%s:%s' % (self.uuid, self.path) Repository.__init__(self, name, params, log) # if root_path_utf8 is shorter than the path_utf8, the difference is # this scope (which always starts with a '/') if root_path_utf8 != path_utf8: self.scope = path_utf8[len(root_path_utf8):].decode('utf-8') if not self.scope[-1] == '/': self.scope += '/' else: self.scope = '/' assert self.scope[0] == '/' # we keep root_path_utf8 for RA ra_prefix = 'file:///' if os.name == 'nt' else 'file://' self.ra_url_utf8 = _svn_uri_canonicalize(ra_prefix + quote(root_path_utf8)) self.clear()
def get_entries(self, path): # lots of conversions from and to utf-8 disk_url = directory(self.name).encode('utf-8') root_path_utf8 = repos.svn_repos_find_root_path(disk_url) if root_path_utf8 is None or not os.path.exists(root_path_utf8): if os.path.exists(disk_url): raise EncodingError(disk_url) raise DoesNotExistError(disk_url) try: repository = repos.svn_repos_open(root_path_utf8) except SubversionException as e: # check for messages like the following: # "Expected FS Format 'x'; found format 'y'" # there are different errorcodes for each version, so do a string # match instead of errorcode match errstr = str(e) if "Expected" in errstr and "format" in errstr and "found" in errstr: raise VersionError raise PermissionError fs_ptr = repos.svn_repos_fs(repository) path_utf8 = path youngest_revision_number = fs.youngest_rev(fs_ptr) try: root = fs.revision_root(fs_ptr, youngest_revision_number) except SubversionException as e: raise PermissionError entries = fs.dir_entries(root, path_utf8) # returns list of bytes-strings dirs = [] for entry in entries.keys(): entry_utf8 = entry.decode('utf-8') d = {} node_type = fs.check_path(root, os.path.join(path_utf8, entry_utf8)) if (node_type == core.svn_node_dir): d['kind'] = 'dir' elif (node_type == core.svn_node_file): d['kind'] = 'file' else: d['kind'] = 'unknown' d['name'] = entry_utf8 dirs.append(d) return dirs
def get_entries(self, path): # lots of conversions from and to utf-8 disk_url = directory(self.name) root_path_utf8 = repos.svn_repos_find_root_path(disk_url) if root_path_utf8 is None or not os.path.exists(root_path_utf8): raise DoesNotExistError(disk_url) try: repository = repos.svn_repos_open(root_path_utf8) except SubversionException as e: # check for messages like the following: # "Expected FS Format 'x'; found format 'y'" # there are different errorcodes for each version, so do a string # match instead of errorcode match errstr = str(e) if "Expected" in errstr and "format" in errstr and "found" in errstr: raise VersionError raise PermissionError fs_ptr = repos.svn_repos_fs(repository) path_utf8 = uc_to_svn(uc_str(path)) youngest_revision_number = fs.youngest_rev(fs_ptr) try: root = fs.revision_root(fs_ptr, youngest_revision_number) except SubversionException as e: raise PermissionError entries = fs.dir_entries(root, path_utf8) dirs = [] for entry in entries.keys(): d = {} node_type = fs.check_path(root, os.path.join(path_utf8, entry)) if (node_type == core.svn_node_dir): d['kind'] = 'dir' elif (node_type == core.svn_node_file): d['kind'] = 'file' else: d['kind'] = 'unknown' d['name'] = uc_from_svn(entry) dirs.append(d) return dirs
def __init__(self, path, authz, log): if core.SVN_VER_MAJOR < 1: raise TracError, \ "Subversion >= 1.0 required: Found %d.%d.%d" % \ (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO) self.pool = Pool() # Remove any trailing slash or else subversion might abort if not os.path.split(path)[1]: path = os.path.split(path)[0] self.path = repos.svn_repos_find_root_path(path, self.pool()) if self.path is None: raise TracError, \ "%s does not appear to be a Subversion repository." % path self.repos = repos.svn_repos_open(self.path, self.pool()) self.fs_ptr = repos.svn_repos_fs(self.repos) uuid = fs.get_uuid(self.fs_ptr, self.pool()) name = 'svn:%s:%s' % (uuid, path) Repository.__init__(self, name, authz, log) if self.path != path: self.scope = path[len(self.path):] if not self.scope[-1] == '/': self.scope += '/' else: self.scope = '/' self.log.debug("Opening subversion file-system at %s with scope %s" \ % (self.path, self.scope)) self.rev = fs.youngest_rev(self.fs_ptr, self.pool()) self.history = None if self.scope != '/': self.history = [] for path, rev in _get_history(self.scope[1:], self.authz, self.fs_ptr, self.pool, 0, self.rev): self.history.append(rev)