Class: Repository::Bazaar

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

Overview

Since:

  • 0.6.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, #committer_ids=, #committers, #default_branch, #diff_format_revisions, #entries, #extra_info, factory, fetch_changesets, find_by_identifier_param, #find_changeset_by_name, #find_committer_user, #identifier=, #identifier_frozen?, #identifier_param, #latest_changeset, #latest_changesets, #merge_extra_info, #name, #password, #password=, #properties, #relative_path, #repo_create_validation, #repo_log_encoding, #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_directory_revisions?, #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

.human_attribute_name(attribute_key_name, *args) ⇒ Object

Since:

  • 1.2.0



24
25
26
27
28
29
30
# File 'app/models/repository/bazaar.rb', line 24

def self.human_attribute_name(attribute_key_name, *args)
  attr_name = attribute_key_name.to_s
  if attr_name == "url"
    attr_name = "path_to_repository"
  end
  super(attr_name, *args)
end

.scm_adapter_classObject

Since:

  • 1.2.0



32
33
34
# File 'app/models/repository/bazaar.rb', line 32

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

.scm_nameObject



36
37
38
# File 'app/models/repository/bazaar.rb', line 36

def self.scm_name
  'Bazaar'
end

Instance Method Details

#annotate(path, identifier = nil) ⇒ Object

Since:

  • 2.2.0



50
51
52
53
# File 'app/models/repository/bazaar.rb', line 50

def annotate(path, identifier=nil)
  scm.bzr_path_encodig = log_encoding
  scm.annotate(path, identifier)
end

#cat(path, identifier = nil) ⇒ Object

Since:

  • 2.2.0



45
46
47
48
# File 'app/models/repository/bazaar.rb', line 45

def cat(path, identifier=nil)
  scm.bzr_path_encodig = log_encoding
  scm.cat(path, identifier)
end

#diff(path, rev, rev_to) ⇒ Object

Since:

  • 2.2.0



55
56
57
58
# File 'app/models/repository/bazaar.rb', line 55

def diff(path, rev, rev_to)
  scm.bzr_path_encodig = log_encoding
  scm.diff(path, rev, rev_to)
end

#entry(path = nil, identifier = nil) ⇒ Object

Since:

  • 2.2.0



40
41
42
43
# File 'app/models/repository/bazaar.rb', line 40

def entry(path=nil, identifier=nil)
  scm.bzr_path_encodig = log_encoding
  scm.entry(path, identifier)
end

#fetch_changesetsObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/models/repository/bazaar.rb', line 87

def fetch_changesets
  scm.bzr_path_encodig = log_encoding
  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)
        transaction do
          revisions.reverse_each do |revision|
            changeset = Changeset.create(:repository   => self,
                                         :revision     => revision.identifier,
                                         :committer    => revision.author,
                                         :committed_on => revision.time,
                                         :scmid        => revision.scmid,
                                         :comments     => revision.message)

            revision.paths.each do |change|
              Change.create(:changeset => changeset,
                            :action    => change[:action],
                            :path      => change[:path],
                            :revision  => change[:revision])
            end
          end
        end unless revisions.nil?
        identifier_from = identifier_to + 1
      end
    end
  end
end