class Repository::SubversionRepository

Implements AbstractRepository for Subversion repositories It implements the following paradigm:

1. Repositories are created by using SubversionRepository.create()
2. Existing repositories are opened by using either SubversionRepository.open()
   or SubversionRepository.new()

Constants

CLOSEABLE_VERSION

Public Class Methods

__parse_authz_file(authz_string) click to toggle source

Semi-private class method: Parses a subversion authz file passed in as a string

# File lib/repo/subversion_repository.rb, line 573
def self.__parse_authz_file(authz_string)
  permissions_mapping = {}

  permissions_array = authz_string.scan(/\[(.+):\/\]\n([\w\s=]+)/)
  permissions_array.each do |permissions_group|
    # The first match is the group repository name
    user_permissions = {}
    raw_users_permissions = permissions_group[1].scan(/\s*(\w+)\s*=\s*(\w+)\s*/)
    raw_users_permissions.each do |raw_user_permissions|
      user_permissions[raw_user_permissions[0]] = self.__translate_perms_from_file(raw_user_permissions[1])
    end
    permissions_mapping[permissions_group[0]] = user_permissions
  end
  return permissions_mapping
end
__prepare_authz_string(permissions) click to toggle source

Semi-private class method: Transforms passed in permissions into subversion authz file syntax

# File lib/repo/subversion_repository.rb, line 591
def self.__prepare_authz_string(permissions)
  result = ""
  permissions.each do |repository_name, users_permissions|
    result += "[#{repository_name}:/]\n"
    users_permissions.each do |user_id, user_permissions|
      user_permissions_string = self.__translate_to_svn_perms(user_permissions)
      result += "#{user_id} = #{user_permissions_string}\n"
    end
    result += "\n"
  end
  return result
end
__read_in_authz_file() click to toggle source

Semi-private class method: Reads in Repository.conf

# File lib/repo/subversion_repository.rb, line 527
def self.__read_in_authz_file()
  # Check if configuration is in order
  if Repository.conf[:REPOSITORY_PERMISSION_FILE].nil?
    raise ConfigurationError.new("Required config 'REPOSITORY_PERMISSION_FILE' not set")
  end
  if !File.exist?(Repository.conf[:REPOSITORY_PERMISSION_FILE])
    File.open(Repository.conf[:REPOSITORY_PERMISSION_FILE], "w").close() # create file if not existent
  end
  # Load up the Permissions:
  file_content = ""
  File.open(Repository.conf[:REPOSITORY_PERMISSION_FILE], "r+") do |auth_file|
    auth_file.flock(File::LOCK_EX)
    file_content = auth_file.read()
    auth_file.flock(File::LOCK_UN) # release lock
  end
  return file_content
end
__translate_perms_from_file(perm_string) click to toggle source

Helper method to translate Subversion permissions to internal permissions

# File lib/repo/subversion_repository.rb, line 703
def self.__translate_perms_from_file(perm_string)
  case (perm_string)
  when "r"
    return Repository::Permission::READ
  when "rw"
    return Repository::Permission::READ_WRITE
  else raise "Unknown permissions"
  end # end case
end
__translate_to_svn_perms(permissions) click to toggle source

Helper method to translate internal permissions to Subversion permissions

# File lib/repo/subversion_repository.rb, line 691
def self.__translate_to_svn_perms(permissions)
  case (permissions)
  when Repository::Permission::READ
    return "r"
  when Repository::Permission::READ_WRITE
    return "rw"
  else raise "Unknown permissions"
  end # end case
end
__write_out_authz_file(authz_file_contents) click to toggle source

Semi-private class method: Writes out Repository.conf

# File lib/repo/subversion_repository.rb, line 546
def self.__write_out_authz_file(authz_file_contents)
  # Check if configuration is in order
  if Repository.conf[:IS_REPOSITORY_ADMIN].nil?
    raise ConfigurationError.new("Required config 'IS_REPOSITORY_ADMIN' not set")
  end
  if Repository.conf[:REPOSITORY_PERMISSION_FILE].nil?
    raise ConfigurationError.new("Required config 'REPOSITORY_PERMISSION_FILE' not set")
  end
  # If we're not in authoritative mode, bail out
  if !Repository.conf[:IS_REPOSITORY_ADMIN] # Are we admin?
    raise NotAuthorityError.new("Unable to write out repo permissions:  Not in authoritative mode!");
  end

  if !File.exist?(Repository.conf[:REPOSITORY_PERMISSION_FILE])
    File.open(Repository.conf[:REPOSITORY_PERMISSION_FILE], "w").close() # create file if not existent
  end
  result = false
  File.open(Repository.conf[:REPOSITORY_PERMISSION_FILE], "w+") do |auth_file|
    auth_file.flock(File::LOCK_EX)
    # Blast out the string to the file
    result = (auth_file.write(authz_file_contents) == authz_file_contents.length)
    auth_file.flock(File::LOCK_UN) # release lock
  end
  return result
end
access(connect_string) { |repository| ... } click to toggle source

Static method: Yields an existing Subversion repository and closes it afterwards

# File lib/repo/subversion_repository.rb, line 86
def self.access(connect_string)
  repository = self.open(connect_string)
  yield repository
  repository.close
end
closeable?() click to toggle source

Static method: Returns whether or not the available Svn library supports closing

# File lib/repo/subversion_repository.rb, line 142
def self.closeable?
  return Svn::Client.version.to_s >= CLOSEABLE_VERSION
end
create(connect_string) click to toggle source

Static method: Creates a new Subversion repository at location ‘connect_string’

# File lib/repo/subversion_repository.rb, line 60
def self.create(connect_string)
  if SubversionRepository.repository_exists?(connect_string)
    raise RepositoryCollision.new("There is already a repository at #{connect_string}")
  end
  if File.exists?(connect_string)
    raise IOError.new("Could not create a repository at #{connect_string}: some directory with same name exists already")
  end

  # create the repository using the ruby bindings
  fs_config = {Svn::Fs::CONFIG_FS_TYPE => Repository::SVN_FS_TYPES[:fsfs]}
  repository = Svn::Repos.create(connect_string, {}, fs_config) #raises exception if not successful

  if SubversionRepository.closeable?
    repository.close
  end

  return true
end
delete(repo_path) click to toggle source

Static method: Deletes an existing Subversion repository

# File lib/repo/subversion_repository.rb, line 93
def self.delete(repo_path)
  Svn::Repos::delete(repo_path)
end
delete_bulk_permissions(repo_names, user_ids) click to toggle source

Deletes permissions over several repositories. Use #remove_user to remove permissions of a single repository.

# File lib/repo/subversion_repository.rb, line 481
def self.delete_bulk_permissions(repo_names, user_ids)
  # Check if configuration is in order
  if Repository.conf[:IS_REPOSITORY_ADMIN].nil?
    raise ConfigurationError.new("Required config 'IS_REPOSITORY_ADMIN' not set")
  end
  # If we're not in authoritative mode, bail out
  if !Repository.conf[:IS_REPOSITORY_ADMIN] # Are we admin?
    raise NotAuthorityError.new("Unable to delete bulk permissions:  Not in authoritative mode!");
  end

  # Read in the authz file
  authz_file_contents = self.__read_in_authz_file()

  # Parse the file contents into to something we can work with
  repo_permissions = self.__parse_authz_file(authz_file_contents)

  # Delete the user_id for each repository
  repo_names.each do |repo_name|
    repo_name = File.basename(repo_name)
    user_ids.each do |user_id|
      repo_permissions[repo_name].delete(user_id)
    end
  end

  # Translate the hash into the svn authz file format
  authz_file_contents = self.__prepare_authz_string(repo_permissions)

  # Write out the authz file
  return self.__write_out_authz_file(authz_file_contents)
end
new(connect_string) click to toggle source

Constructor: Connects to an existing Subversion repository, using Ruby bindings; Note: A repository has to be created using ::create, it it is not yet existent

# File lib/repo/subversion_repository.rb, line 36
def initialize(connect_string)
  # Check if configuration is in order
  if Repository.conf[:IS_REPOSITORY_ADMIN].nil?
    raise ConfigurationError.new("Required config 'IS_REPOSITORY_ADMIN' not set")
  end
  if Repository.conf[:REPOSITORY_PERMISSION_FILE].nil?
    raise ConfigurationError.new("Required config 'REPOSITORY_PERMISSION_FILE' not set")
  end
  begin
    super(connect_string) # dummy call to super
  rescue NotImplementedError; end
  @repos_path = connect_string
  @closed = false
  @repos_auth_file = Repository.conf[:REPOSITORY_PERMISSION_FILE] || File.dirname(connect_string) + "/svn_authz"
  @repos_admin = Repository.conf[:IS_REPOSITORY_ADMIN]
  if (SubversionRepository.repository_exists?(@repos_path))
    @repos = Svn::Repos.open(@repos_path)
  else
    raise "Repository does not exist at path \"" + @repos_path + "\""
  end
end
open(connect_string) click to toggle source

Static method: Opens an existing Subversion repository at location ‘connect_string’

# File lib/repo/subversion_repository.rb, line 81
def self.open(connect_string)
  return SubversionRepository.new(connect_string)
end
repository_exists?(repos_path) click to toggle source

Static method: Reports if a Subversion repository exists It’s in fact a pretty hacky method checking for files typical for Subversion repositories

# File lib/repo/subversion_repository.rb, line 166
def self.repository_exists?(repos_path)
  repos_meta_files_exist = false
  if File.exist?(File.join(repos_path, "conf"))
    if File.exist?(File.join(repos_path, "conf/svnserve.conf"))
      if File.exist?(File.join(repos_path, "format"))
        repos_meta_files_exist = true
      end
    end
  end
  return repos_meta_files_exist
end
set_bulk_permissions(repo_names, user_id_permissions_map) click to toggle source

Sets permissions over several repositories. Use #set_permissions to set permissions on a single repository.

# File lib/repo/subversion_repository.rb, line 446
def self.set_bulk_permissions(repo_names, user_id_permissions_map)
  # Check if configuration is in order
  if Repository.conf[:IS_REPOSITORY_ADMIN].nil?
    raise ConfigurationError.new("Required config 'IS_REPOSITORY_ADMIN' not set")
  end
  # If we're not in authoritative mode, bail out
  if !Repository.conf[:IS_REPOSITORY_ADMIN] # Are we admin?
    raise NotAuthorityError.new("Unable to set bulk permissions:  Not in authoritative mode!");
  end

  # Read in the authz file
  authz_file_contents = self.__read_in_authz_file()

  # Parse the file contents into to something we can work with
  repo_permissions = self.__parse_authz_file(authz_file_contents)
  # Set / clobber permissions on each group for this user
  repo_names.each do |repo_name|
    repo_name = File.basename(repo_name)
    user_id_permissions_map.each do |user_id, permissions|
      if repo_permissions[repo_name].nil?
        repo_permissions[repo_name] = {}
      end
      repo_permissions[repo_name][user_id] = permissions
    end
  end

  # Translate the hash into the svn authz file format
  authz_file_contents = self.__prepare_authz_string(repo_permissions)

  # Write out the authz file
  return self.__write_out_authz_file(authz_file_contents)
end

Public Instance Methods

__get_file_property(prop, path, revision_number) click to toggle source

Not (!) part of the AbstractRepository API: Returns

prop

of Subversion repository file

# File lib/repo/subversion_repository.rb, line 646
def __get_file_property(prop, path, revision_number)
  return @repos.fs.root(revision_number).node_prop(path, Repository::SVN_CONSTANTS[prop])
end
__get_files(path="/", revision_number=nil) click to toggle source

Not (!) part of the AbstractRepository API: Returns a hash of files/directories part of the requested revision; Don’t use it directly, use SubversionRevision’s ‘files_at_path’ instead

# File lib/repo/subversion_repository.rb, line 621
def __get_files(path="/", revision_number=nil)
  begin
    entries = @repos.fs.root(revision_number).dir_entries(path)
  rescue Exception
    raise FileDoesNotExist.new("#{path} does not exist in the repository for revision #{revision_number}")
  end
  entries.each do |key, value|
    entries[key] = (value.kind == 1) ? :file : :directory
  end
  return entries
end
__get_history(paths, starting_revision=nil, ending_revision=nil) { |path, revision| ... } click to toggle source

Not (!) part of the AbstractRepository API: This function is very similar to @repos.fs.history(); however, it’s been altered a little to return only an array of revision numbers. This function, in contrast to the original, takes multiple paths and returns one large history for all paths given.

# File lib/repo/subversion_repository.rb, line 663
def __get_history(paths, starting_revision=nil, ending_revision=nil)
  # We do the to_i's because we want to leave the value nil if it is.
  if (starting_revision.to_i < 0)
    raise "Invalid starting revision " + starting_revision.to_i.to_s + "."
  end
  revision_numbers = []
  paths = [paths].flatten
  paths.each do |path|
    hist = []
    history_function = Proc.new do |path, revision|
      yield(path, revision) if block_given?
      hist << revision
    end
    begin
      Svn::Repos.history2(@repos.fs, path, history_function, nil, starting_revision || 0,
                          ending_revision || @repos.fs.youngest_rev, true)
    rescue Svn::Error::FS_NOT_FOUND => e
      raise Repository::FileDoesNotExistConflict.new(path)
    rescue Svn::Error::FS_NO_SUCH_REVISION => e
      raise "Ending revision " + ending_revision.to_s + " does not exist."
    end
    revision_numbers.concat hist
  end
  return revision_numbers.sort.uniq
end
__get_node_last_modified_date(path, revision_number) click to toggle source

Not (!) part of the AbstractRepository API: Returns

The last modified date

of a Subversion repository file or directory

# File lib/repo/subversion_repository.rb, line 655
def __get_node_last_modified_date(path, revision_number)
  return @repos.fs.root(revision_number).stat(path).time2
end
__get_property(prop, rev=nil) click to toggle source

Not (!) part of the AbstractRepository API: Returns

prop

of Subversion repository

# File lib/repo/subversion_repository.rb, line 637
def __get_property(prop, rev=nil)
  return @repos.prop(Repository::SVN_CONSTANTS[prop] || prop.to_s, rev)
end
__path_exists?(path, revision=nil) click to toggle source

Not (!) part of the AbstractRepository API: Check if given file or path exists in repository beeing member of the provided revision

# File lib/repo/subversion_repository.rb, line 613
def __path_exists?(path, revision=nil)
  return @repos.fs.root(revision).check_path(path) != 0
end
add_user(user_id, permissions) click to toggle source

Adds a user with given permissions to the repository

# File lib/repo/subversion_repository.rb, line 295
def add_user(user_id, permissions)
  if @repos_admin # Are we admin?
    if !File.exist?(@repos_auth_file)
      File.open(@repos_auth_file, "w").close() # create file if not existent
    end

    retval = false
    repo_permissions = {}
    File.open(@repos_auth_file, "r+") do |auth_file|
      auth_file.flock(File::LOCK_EX)
      # get current permissions from file
      file_content = auth_file.read()
      if (file_content.length != 0)
        repo_permissions = get_repo_permissions_from_file_string(file_content)
      end
      if repo_permissions.key?(user_id)
        raise UserAlreadyExistent.new(user_id + " already existent")
      end
      svn_permissions = self.class.__translate_to_svn_perms(permissions)
      repo_permissions[user_id] = svn_permissions
      # inject new permissions into file string
      write_string = inject_permissions(repo_permissions, defined?(file_content)? file_content: "")
      # rewind, so that mime-type is preserved
      auth_file.rewind
      auth_file.truncate(0) # truncate file
      retval = (auth_file.write(write_string) == write_string.length)
      auth_file.flock(File::LOCK_UN) # release lock
    end
    return retval
  else
    raise NotAuthorityError.new("Unable to modify permissions: Not in authoritative mode!")
  end
end
close() click to toggle source

Closes the repository

# File lib/repo/subversion_repository.rb, line 147
def close
  if self.class.closeable?
    @repos.close
  end
  @closed = true
end
closed?() click to toggle source

Returns whether or not repository is closed

# File lib/repo/subversion_repository.rb, line 155
def closed?
  if self.class.closeable?
    return @repos.closed?
  end
  return @closed
end
commit(transaction) click to toggle source

Carries out actions on a Subversion repository stored in ‘transaction’. In case of certain conflicts corresponding Repositor::Conflict(s) are added to the transaction object

# File lib/repo/subversion_repository.rb, line 254
def commit(transaction)
  jobs = transaction.jobs
  txn = @repos.fs.transaction # transaction date is set implicitly
  txn.set_prop(Repository::SVN_CONSTANTS[:author], transaction.user_id)
  jobs.each do |job|
    case job[:action]
    when :add_path
      begin
        txn = make_directory(txn, job[:path])
      rescue Repository::Conflict => e
        transaction.add_conflict(e)
      end
    when :add
      begin
        txn = add_file(txn, job[:path], job[:file_data], job[:mime_type])
      rescue Repository::Conflict => e
        transaction.add_conflict(e)
      end
    when :remove
      begin
        txn = remove_file(txn, job[:path], job[:expected_revision_number])
      rescue Repository::Conflict => e
        transaction.add_conflict(e)
      end
    when :replace
      begin
        txn = replace_file(txn, job[:path], job[:file_data], job[:mime_type], job[:expected_revision_number])
      rescue Repository::Conflict => e
        transaction.add_conflict(e)
      end
    end
  end

  if transaction.conflicts?
    return false
  end
  txn.commit
  return true
end
download_as_string(files) click to toggle source
Alias for: stringify_files
expand_path(file_name, dir_string = "/") click to toggle source

Converts a pathname to an absolute pathname

# File lib/repo/subversion_repository.rb, line 513
def expand_path(file_name, dir_string = "/")
  expanded = File.expand_path(file_name, dir_string)
  if RUBY_PLATFORM =~ /(:?mswin|mingw)/ #only if the platform is Windows
    expanded = expanded[2..-1]#remove the drive letter
  end
  return expanded
end
export(repo_dest_dir, filepath=nil, revision_number=nil) click to toggle source

method : Export an existing Subversion repository to a new folder

If a filepath is given, the repo_dest_dir needs to point to a file, and all the repository on that path need to exist, or the export will fail.

# File lib/repo/subversion_repository.rb, line 101
def export(repo_dest_dir, filepath=nil, revision_number=nil)
  # Modify the path of the repository
  # If libsvn-ruby raise a segfault, check the first argument of
  # Svn::Client::export which must be an URI (ex : file:///home/...)

  if !filepath.nil?
    repo_path_dir = "file://" + File.join(expand_path(@repos_path),
                                          filepath)
  else
    repo_path_dir = "file://" + expand_path(@repos_path)
  end

  ctx = Svn::Client::Context.new

  # don't fail on non CA signed ssl server
  ctx.add_ssl_server_trust_file_provider
  setup_auth_baton(ctx.auth_baton)
  ctx.add_username_provider

  # username and password
  ctx.add_simple_prompt_provider(0) do |cred, realm, username, may_save|
    cred.username = "markus"
    cred.password = "markus"
    cred.may_save = false
  end

  # Raise an error if the destination repository already exists
  if (File.exists?(repo_dest_dir))
    raise(ExportRepositoryAlreadyExists,
          "Exported repository already exists")
  end

  begin
    result = ctx.export(repo_path_dir, repo_dest_dir, revision_number, nil)
  end

  return result
end
get_latest_revision() click to toggle source

Returns a Repository::SubversionRevision instance holding the latest Subversion repository revision number

# File lib/repo/subversion_repository.rb, line 207
def get_latest_revision
  return get_revision(latest_revision_number())
end
get_permissions(user_id) click to toggle source

Gets permissions of a particular user

# File lib/repo/subversion_repository.rb, line 357
def get_permissions(user_id)
  if svn_auth_file_checks() # do basic file checks
    repo_permissions = {}
    File.open(@repos_auth_file) do |auth_file|

      auth_file.flock(File::LOCK_EX)
      file_content = auth_file.read()
      if (file_content.length != 0)
        repo_permissions = get_repo_permissions_from_file_string(file_content)
      end
      auth_file.flock(File::LOCK_UN) # release lock
    end
    if !repo_permissions.key?(user_id)
      raise UserNotFound.new(user_id + " not found")
    end
    return self.class.__translate_perms_from_file(repo_permissions[user_id])
  end
end
get_revision(revision_number) click to toggle source

Returns revision_number wrapped as a SubversionRevision instance

# File lib/repo/subversion_repository.rb, line 213
def get_revision(revision_number)
  return Repository::SubversionRevision.new(revision_number, self)
end
get_revision_by_timestamp(target_timestamp, path = nil) click to toggle source

Returns a SubversionRevision instance representing a revision at a current timestamp

target_timestamp

should be a Ruby Time instance

# File lib/repo/subversion_repository.rb, line 221
def get_revision_by_timestamp(target_timestamp, path = nil)
  if !target_timestamp.kind_of?(Time)
    raise "Was expecting a timestamp of type Time"
  end
  target_timestamp = target_timestamp.utc
  if !path.nil?
    # latest_revision_number will fail if the path does not exist at the given revision number or less than
    # the revision number.  The begin and ensure statement is to ensure that there is a revision return.
    # Default is set to revision 0.
    revision_number = 0
    begin
      revision_number = latest_revision_number(path, get_revision_number_by_timestamp(target_timestamp))
    ensure
      return get_revision(revision_number)
    end
  else
    return get_revision(get_revision_number_by_timestamp(target_timestamp))
  end

end
get_transaction(user_id, comment="") click to toggle source

Returns a Repository::TransAction object, to work with. Do operations, like ‘add’, ‘remove’, etc. on the transaction instead of the repository

# File lib/repo/subversion_repository.rb, line 244
def get_transaction(user_id, comment="")
  if user_id.nil?
    raise "Expected a user_id (Repository.get_transaction(user_id))"
  end
  return Repository::Transaction.new(user_id, comment)
end
get_users(permissions) click to toggle source

Gets a list of users with AT LEAST the provided permissions. Returns nil if there aren’t any.

# File lib/repo/subversion_repository.rb, line 331
def get_users(permissions)
  if svn_auth_file_checks() # do basic file checks
    repo_permissions = {}
    File.open(@repos_auth_file) do |auth_file|
      auth_file.flock(File::LOCK_EX)
      file_content = auth_file.read()
      if (file_content.length != 0)
        repo_permissions = get_repo_permissions_from_file_string(file_content)
      end
      auth_file.flock(File::LOCK_UN) # release lock
    end
    result_list = []
    repo_permissions.each do |user, perm|
      if self.class.__translate_perms_from_file(perm) >= permissions
        result_list.push(user)
      end
    end
    if !result_list.empty?
      return result_list
    else
      return nil
    end
  end
end
remove_user(user_id) click to toggle source

Delete user from access list

# File lib/repo/subversion_repository.rb, line 412
def remove_user(user_id)
  if @repos_admin # Are we admin?
    if !File.exist?(@repos_auth_file)
      File.open(@repos_auth_file, "w").close() # create file if not existent
    end

    retval = false
    File.open(@repos_auth_file, "r+") do |auth_file|
      auth_file.flock(File::LOCK_EX)
      # get current permissions from file
      file_content = auth_file.read()
      if (file_content.length != 0)
        repo_permissions = get_repo_permissions_from_file_string(file_content)
      end
      if !repo_permissions.key?(user_id)
        raise UserNotFound.new(user_id + " not found")
      end
      repo_permissions.delete(user_id) # delete user_id
      # inject new permissions into file string
      write_string = inject_permissions(repo_permissions, defined?(file_content)? file_content: "")
      # rewind, so that mime-type is preserved
      auth_file.rewind
      auth_file.truncate(0) # truncate file
      retval = (auth_file.write(write_string) == write_string.length)
      auth_file.flock(File::LOCK_UN) # release lock
    end
    return retval
  else
    raise NotAuthorityError.new("Unable to modify permissions: Not in authoritative mode!")
  end
end
set_permissions(user_id, permissions) click to toggle source

Set permissions for a given user

# File lib/repo/subversion_repository.rb, line 377
def set_permissions(user_id, permissions)
  if @repos_admin # Are we admin?
    if !File.exist?(@repos_auth_file)
      File.open(@repos_auth_file, "w").close() # create file if not existent
    end

    retval = false
    repo_permissions = {}
    File.open(@repos_auth_file, "r+") do |auth_file|
      auth_file.flock(File::LOCK_EX)
      # get current permissions from file
      file_content = auth_file.read()
      if (file_content.length != 0)
        repo_permissions = get_repo_permissions_from_file_string(file_content)
      end
      if !repo_permissions.key?(user_id)
        raise UserNotFound.new(user_id + " not found")
      end
      svn_permissions = self.class.__translate_to_svn_perms(permissions)
      repo_permissions[user_id] = svn_permissions
      # inject new permissions into file string
      write_string = inject_permissions(repo_permissions, defined?(file_content)? file_content: "")
      # rewind, so that mime-type is preserved
      auth_file.rewind
      auth_file.truncate(0) # truncate file
      retval = (auth_file.write(write_string) == write_string.length)
      auth_file.flock(File::LOCK_UN) # release lock
    end
    return retval
  else
    raise NotAuthorityError.new("Unable to modify permissions: Not in authoritative mode!")
  end
end
stringify_files(files) click to toggle source

Given a single object, or an array of objects of type RevisionFile, try to find the file in question, and return it as a string

# File lib/repo/subversion_repository.rb, line 181
def stringify_files(files)
  expects_array = files.kind_of? Array
  if (!expects_array)
    files = [files]
  end
  files.collect! {|file|
    if (!file.kind_of? Repository::RevisionFile)
      raise TypeError.new("Expected a Repository::RevisionFile")
    end
    begin
      @repos.fs.root(file.from_revision).file_contents(File.join(file.path, file.name)){|f| f.read}
    rescue Svn::Error::FS_NOT_FOUND => e
      raise FileDoesNotExistConflict.new(File.join(file.path, file.name))
    end
  }
  if (!expects_array)
    return files.first
  else
    return files
  end
end
Also aliased as: download_as_string