diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-12-03 17:40:43 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-12-03 17:40:43 +0000 |
commit | 056e3703da194ade315004e7d91ce318eaf1e6b2 (patch) | |
tree | 2194839b5c68650cfcb4b9f467fce07dea800c65 /app | |
parent | 92a23c05bb71e62426cec2298d90b39fadd0eb52 (diff) | |
download | redmine-056e3703da194ade315004e7d91ce318eaf1e6b2.tar.gz redmine-056e3703da194ade315004e7d91ce318eaf1e6b2.zip |
Added Bazaar adapter.
Fixed 'quick jump to a revision' form on the revisions list.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@950 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/repositories_helper.rb | 4 | ||||
-rw-r--r-- | app/models/repository/bazaar.rb | 86 | ||||
-rw-r--r-- | app/views/repositories/revisions.rhtml | 6 |
3 files changed, 93 insertions, 3 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 333b30b1c..d2d04604d 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -80,4 +80,8 @@ module RepositoriesHelper content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) + content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) end + + def bazaar_field_tags(form, repository) + content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) + end end diff --git a/app/models/repository/bazaar.rb b/app/models/repository/bazaar.rb new file mode 100644 index 000000000..6e387f957 --- /dev/null +++ b/app/models/repository/bazaar.rb @@ -0,0 +1,86 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require 'redmine/scm/adapters/bazaar_adapter' + +class Repository::Bazaar < Repository + attr_protected :root_url + validates_presence_of :url + + def scm_adapter + Redmine::Scm::Adapters::BazaarAdapter + end + + def self.scm_name + 'Bazaar' + end + + def entries(path=nil, identifier=nil) + entries = scm.entries(path, identifier) + if entries + entries.each do |e| + next if e.lastrev.revision.blank? + c = Change.find(:first, + :include => :changeset, + :conditions => ["#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id], + :order => "#{Changeset.table_name}.revision DESC") + if c + e.lastrev.identifier = c.changeset.revision + e.lastrev.name = c.changeset.revision + e.lastrev.author = c.changeset.committer + end + end + end + end + + def fetch_changesets + scm_info = scm.info + if scm_info + # latest revision found in database + db_revision = latest_changeset ? latest_changeset.revision : 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) + 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 +end diff --git a/app/views/repositories/revisions.rhtml b/app/views/repositories/revisions.rhtml index 882d5ea4f..2a45fc2ef 100644 --- a/app/views/repositories/revisions.rhtml +++ b/app/views/repositories/revisions.rhtml @@ -1,7 +1,7 @@ <div class="contextual"> -<% form_tag do %> -<p><%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> -<%= submit_tag 'OK' %></p> +<% form_tag({:action => 'revision', :id => @project}) do %> +<%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> +<%= submit_tag 'OK' %> <% end %> </div> |