Class: Repository::Subversion

Inherits:
Repository
  • Object
show all
Defined in:
app/models/repository/subversion.rb

Overview

Since:

  • 0.5.1

Constant Summary

Constants inherited from Repository

IDENTIFIER_MAX_LENGTH

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Repository

#<=>, available_scm, #branches, #cat, #committer_ids=, #committers, #default_branch, #diff, #diff_format_revisions, #entries, #entry, #extra_info, factory, fetch_changesets, find_by_identifier_param, #find_changeset_by_name, #find_committer_user, human_attribute_name, #identifier=, #identifier_frozen?, #identifier_param, #latest_changeset, #merge_extra_info, #name, #password, #password=, #properties, #repo_create_validation, #report_last_commit, repository_class, #root_url=, #same_commits_in_scope, scan_changesets_for_issue_ids, #scan_changesets_for_issue_ids, #scm, #scm_adapter, scm_available, scm_command, #scm_name, scm_version_string, #set_as_default?, #stats_by_author, #supports_all_revisions?, #supports_annotate?, #supports_cat?, #supports_revision_graph?, #tags, #url=

Methods included from Redmine::SafeAttributes

#delete_unsafe_attributes, #safe_attribute?, #safe_attribute_names, #safe_attributes=

Methods included from Redmine::Ciphering

cipher_key, decrypt_text, encrypt_text, logger

Class Method Details

.scm_adapter_classObject

Since:

  • 1.2.0



25
26
27
# File 'app/models/repository/subversion.rb', line 25

def self.scm_adapter_class
  Redmine::Scm::Adapters::SubversionAdapter
end

.scm_nameObject



29
30
31
# File 'app/models/repository/subversion.rb', line 29

def self.scm_name
  'Subversion'
end

Instance Method Details

#fetch_changesetsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/models/repository/subversion.rb', line 56

def fetch_changesets
  scm_info = scm.info
  if scm_info
    # latest revision found in database
    db_revision = latest_changeset ? latest_changeset.revision.to_i : 0
    # latest revision in the repository
    scm_revision = scm_info.lastrev.identifier.to_i
    if db_revision < scm_revision
      logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
      identifier_from = db_revision + 1
      while (identifier_from <= scm_revision)
        # loads changesets by batches of 200
        identifier_to = [identifier_from + 199, scm_revision].min
        revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
        revisions.reverse_each do |revision|
          transaction do
            changeset = Changeset.create(:repository   => self,
                                         :revision     => revision.identifier,
                                         :committer    => revision.author,
                                         :committed_on => revision.time,
                                         :comments     => revision.message)

            revision.paths.each do |change|
              changeset.create_change(change)
            end unless changeset.new_record?
          end
        end unless revisions.nil?
        identifier_from = identifier_to + 1
      end
    end
  end
end

#latest_changesets(path, rev, limit = 10) ⇒ Object

Since:

  • 0.9.0



41
42
43
44
45
46
47
48
49
# File 'app/models/repository/subversion.rb', line 41

def latest_changesets(path, rev, limit=10)
  revisions = scm.revisions(path, rev, nil, :limit => limit)
  if revisions
    identifiers = revisions.collect(&:identifier).compact
    changesets.where(:revision => identifiers).reorder("committed_on DESC").includes(:repository, :user).to_a
  else
    []
  end
end

#relative_path(path) ⇒ Object

Returns a path relative to the url of the repository

Since:

  • 0.7.2



52
53
54
# File 'app/models/repository/subversion.rb', line 52

def relative_path(path)
  path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '')
end

#repo_log_encodingObject

Since:

  • 1.2.0



37
38
39
# File 'app/models/repository/subversion.rb', line 37

def repo_log_encoding
  'UTF-8'
end

#supports_directory_revisions?Boolean

Returns:

  • (Boolean)

Since:

  • 1.2.0



33
34
35
# File 'app/models/repository/subversion.rb', line 33

def supports_directory_revisions?
  true
end