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()
class SubversionRepository(Repository): """Repository implementation based on the svn.fs API.""" has_linear_changesets = True 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))) 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 + root_path_utf8) self.clear()
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 __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)
def test_get_uuid(self): ra_uuid = ra.get_uuid(self.ra_ctx) fs_uuid = fs.get_uuid(self.fs) self.assertEqual(ra_uuid,fs_uuid)
def test_get_uuid(self): ra_uuid = ra.get_uuid(self.ra_ctx) fs_uuid = fs.get_uuid(self.fs) self.assertEqual(ra_uuid, fs_uuid)