Class: Repository::Mercurial
- Inherits:
-
- Object
- ActiveRecord::Base
- Repository::Mercurial
- Defined in:
- app/models/repository/mercurial.rb
Class Method Summary
Instance Method Summary
Methods inherited from
available_scm, #branches, #cat, #committer_ids=, #committers, #default_branch, #diff, #entry, factory, fetch_changesets, #find_changeset_by_name, #find_committer_user, #latest_changeset, #latest_changesets, #properties, #relative_path, #root_url=, #scan_changesets_for_issue_ids, scan_changesets_for_issue_ids, #scm, #scm_name, #supports_annotate?, #supports_cat?, #tags, #url=
Methods inherited from ActiveRecord::Base
Class Method Details
+ (Object) scm_name
28 29 30 |
# File 'app/models/repository/mercurial.rb', line 28 def self.scm_name 'Mercurial' end |
Instance Method Details
- (Object) entries(path = nil, identifier = nil)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/repository/mercurial.rb', line 32 def entries(path=nil, identifier=nil) entries=scm.entries(path, identifier) if entries entries.each do |entry| next unless entry.is_file? # Set the filesize unless browsing a specific revision if identifier.nil? full_path = File.join(root_url, entry.path) entry.size = File.stat(full_path).size if File.file?(full_path) end # Search the DB for the entry's last change change = changes.find(:first, :conditions => ["path = ?", scm.with_leading_slash(entry.path)], :order => "#{Changeset.table_name}.committed_on DESC") if change entry.lastrev.identifier = change.changeset.revision entry.lastrev.name = change.changeset.revision entry.lastrev. = change.changeset.committer entry.lastrev.revision = change.revision end end end entries end |
- (Object) fetch_changesets
55 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 88 89 |
# File 'app/models/repository/mercurial.rb', line 55 def fetch_changesets scm_info = scm.info if scm_info # latest revision found in database db_revision = latest_changeset ? latest_changeset.revision.to_i : -1 # latest revision in the repository latest_revision = scm_info.lastrev return if latest_revision.nil? scm_revision = latest_revision.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 100 identifier_to = [identifier_from + 99, scm_revision].min revisions = scm.revisions('', identifier_from, identifier_to, :with_paths => true) transaction do revisions.each do |revision| changeset = Changeset.create(:repository => self, :revision => revision.identifier, :scmid => revision.scmid, :committer => revision., :committed_on => revision.time, :comments => revision.) revision.paths.each do |change| changeset.create_change(change) end end end unless revisions.nil? identifier_from = identifier_to + 1 end end end end |
- (Object) scm_adapter
24 25 26 |
# File 'app/models/repository/mercurial.rb', line 24 def scm_adapter Redmine::Scm::Adapters::MercurialAdapter end |