Class: Repository::Bazaar

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

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_annotate?, #supports_cat?, #supports_directory_revisions?, #supports_history?, #supports_revision_graph?, #tags, #url=, #valid_name?

Methods included from Redmine::SafeAttributes

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

Methods included from Redmine::Ciphering

cipher_key, decrypt_text, encrypt_text, included, logger

Class Method Details

.human_attribute_name(attribute_key_name, *args) ⇒ Object



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

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



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

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

.scm_nameObject



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

def self.scm_name
  'Bazaar'
end

Instance Method Details

#annotate(path, identifier = nil) ⇒ Object



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

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

#cat(path, identifier = nil) ⇒ Object



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

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

#diff(path, rev, rev_to) ⇒ Object



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

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



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

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

#fetch_changesetsObject



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
124
125
126
127
# File 'app/models/repository/bazaar.rb', line 89

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)
        unless revisions.nil?
          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
        end
        identifier_from = identifier_to + 1
      end
    end
  end
end