##// END OF EJS Templates
Fixed: Issues associated with a locked version are not copied when copying a project (#11207)....
Fixed: Issues associated with a locked version are not copied when copying a project (#11207). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10334 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9885:6a2ca5e03427
r10151:ff86c37ed330
Show More
repositories_helper.rb
313 lines | 11.7 KiB | text/x-ruby | RubyLexer
/ app / helpers / repositories_helper.rb
Jean-Philippe Lang
Added encoding comment to helpers (#9792)....
r8090 # encoding: utf-8
#
Toshi MARUYAMA
remove trailing white-spaces from repositories helper source....
r5710 # Redmine - project management software
Jean-Philippe Lang
Copyright update....
r9453 # Copyright (C) 2006-2012 Jean-Philippe Lang
Jean-Philippe Lang
svn browser merged in trunk...
r103 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces from repositories helper source....
r5710 #
Jean-Philippe Lang
svn browser merged in trunk...
r103 # 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.
Toshi MARUYAMA
remove trailing white-spaces from repositories helper source....
r5710 #
Jean-Philippe Lang
svn browser merged in trunk...
r103 # 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.
Jean-Philippe Lang
Default encodings for repository files can now be set in application settings (Admin -> Settings -> Repositories encodings)....
r803 require 'iconv'
Toshi MARUYAMA
add Redmine::CodesetUtil and move replacing invalid utf8 logic to it....
r5354 require 'redmine/codeset_util'
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638
Jean-Philippe Lang
svn browser merged in trunk...
r103 module RepositoriesHelper
Toshi MARUYAMA
Changing revision label and identifier at SCM adapter level (#3724, #6092)...
r4493 def format_revision(revision)
if revision.respond_to? :format_identifier
revision.format_identifier
else
revision.to_s
end
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4870
Jean-Philippe Lang
Truncate comments on changeset list....
r1898 def truncate_at_line_break(text, length = 255)
if text
text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...')
end
end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4870
Jean-Philippe Lang
Display svn properties in the browser, svn >= 1.5.0 only (#1581)....
r1613 def render_properties(properties)
unless properties.nil? || properties.empty?
content = ''
properties.keys.sort.each do |property|
Toshi MARUYAMA
Rails3: helper: use html_safe at render_properties(properties) of RepositoriesHelper...
r7427 content << content_tag('li', "<b>#{h property}</b>: <span>#{h properties[property]}</span>".html_safe)
Jean-Philippe Lang
Display svn properties in the browser, svn >= 1.5.0 only (#1581)....
r1613 end
Toshi MARUYAMA
Rails3: helper: use html_safe at render_properties(properties) of RepositoriesHelper...
r7427 content_tag('ul', content.html_safe, :class => 'properties')
Jean-Philippe Lang
Display svn properties in the browser, svn >= 1.5.0 only (#1581)....
r1613 end
end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4870
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 def render_changeset_changes
Jean-Philippe Lang
Renamed #changes association to #filechanges (clash with AR::Base.changes that triggers errors with Rails 3.2.5)....
r9576 changes = @changeset.filechanges.find(:all, :limit => 1000, :order => 'path').collect do |change|
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 case change.action
when 'A'
# Detects moved/copied files
if !change.from_path.blank?
Toshi MARUYAMA
scm: code clean up RepositoriesHelper....
r5386 change.action =
Jean-Philippe Lang
Renamed #changes association to #filechanges (clash with AR::Base.changes that triggers errors with Rails 3.2.5)....
r9576 @changeset.filechanges.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 end
change
when 'D'
Jean-Philippe Lang
Renamed #changes association to #filechanges (clash with AR::Base.changes that triggers errors with Rails 3.2.5)....
r9576 @changeset.filechanges.detect {|c| c.from_path == change.path} ? nil : change
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 else
change
end
Toshi MARUYAMA
scm: code clean up RepositoriesHelper....
r5386 end.compact
Toshi MARUYAMA
remove trailing white-spaces from repositories helper source....
r5710
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 tree = { }
changes.each do |change|
p = tree
dirs = change.path.to_s.split('/').select {|d| !d.blank?}
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 path = ''
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 dirs.each do |dir|
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 path += '/' + dir
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 p[:s] ||= {}
p = p[:s]
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 p[path] ||= {}
p = p[path]
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 end
p[:c] = change
end
render_changes_tree(tree[:s])
end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4870
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 def render_changes_tree(tree)
return '' if tree.nil?
output = ''
output << '<ul>'
tree.keys.sort.each do |file|
style = 'change'
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 text = File.basename(h(file))
if s = tree[file][:s]
style << ' folder'
path_param = to_path_param(@repository.relative_path(file))
Toshi MARUYAMA
HTML escape at app/helpers/repositories_helper.rb....
r6235 text = link_to(h(text), :controller => 'repositories',
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 :action => 'show',
:id => @project,
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 :repository_id => @repository.identifier_param,
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 :path => path_param,
Toshi MARUYAMA
Changing revision label and identifier at SCM adapter level (#3724, #6092)...
r4493 :rev => @changeset.identifier)
Jean-Philippe Lang
Fixed invalid html....
r8386 output << "<li class='#{style}'>#{text}"
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 output << render_changes_tree(s)
Jean-Philippe Lang
Fixed invalid html....
r8386 output << "</li>"
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 elsif c = tree[file][:c]
style << " change-#{c.action}"
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 path_param = to_path_param(@repository.relative_path(c.path))
Toshi MARUYAMA
HTML escape at app/helpers/repositories_helper.rb....
r6235 text = link_to(h(text), :controller => 'repositories',
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 :action => 'entry',
:id => @project,
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 :repository_id => @repository.identifier_param,
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 :path => path_param,
Toshi MARUYAMA
Changing revision label and identifier at SCM adapter level (#3724, #6092)...
r4493 :rev => @changeset.identifier) unless c.action == 'D'
Toshi MARUYAMA
HTML escape at app/helpers/repositories_helper.rb....
r6235 text << " - #{h(c.revision)}" unless c.revision.blank?
Toshi MARUYAMA
Rails3: helper: use html_safe at render_changes_tree(tree) of RepositoriesHelper...
r7425 text << ' ('.html_safe + link_to(l(:label_diff), :controller => 'repositories',
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 :action => 'diff',
:id => @project,
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 :repository_id => @repository.identifier_param,
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 :path => path_param,
Toshi MARUYAMA
Rails3: helper: use html_safe at render_changes_tree(tree) of RepositoriesHelper...
r7425 :rev => @changeset.identifier) + ') '.html_safe if c.action == 'M'
text << ' '.html_safe + content_tag('span', h(c.from_path), :class => 'copied-from') unless c.from_path.blank?
Jean-Philippe Lang
Linkify folder names on revision view (#5164)....
r3545 output << "<li class='#{style}'>#{text}</li>"
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 end
end
output << '</ul>'
Toshi MARUYAMA
Rails3: helper: use html_safe at render_changes_tree(tree) of RepositoriesHelper...
r7425 output.html_safe
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4870
Toshi MARUYAMA
scm: Ruby 1.9 compatibility for browsing repository tree (#2664, #2274)....
r4801 def repository_field_tags(form, repository)
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 method = repository.class.name.demodulize.underscore + "_field_tags"
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4865 if repository.is_a?(Repository) &&
respond_to?(method) && method != 'repository_field_tags'
send(method, form, repository)
end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4865
Jean-Philippe Lang
Added project module concept....
r714 def scm_select_tag(repository)
Jean-Philippe Lang
Ability to disable unused SCM adapters in application settings....
r1493 scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
Eric Davis
Converted the REDMINE_SUPPORTED_SCM constant to a class...
r3326 Redmine::Scm::Base.all.each do |scm|
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4865 if Setting.enabled_scm.include?(scm) ||
(repository && repository.class.name.demodulize == scm)
scm_options << ["Repository::#{scm}".constantize.scm_name, scm]
end
Jean-Philippe Lang
Ability to disable unused SCM adapters in application settings....
r1493 end
Toshi MARUYAMA
scm: code clean up RepositoriesHelper....
r5498 select_tag('repository_scm',
Jean-Philippe Lang
Ability to disable unused SCM adapters in application settings....
r1493 options_for_select(scm_options, repository.class.name.demodulize),
Jean-Philippe Lang
Added project module concept....
r714 :disabled => (repository && !repository.new_record?),
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 :data => {:remote => true, :method => 'get'})
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def with_leading_slash(path)
Jean-Philippe Lang
Fixed: single file 'View difference' links do not work because of duplicate slashes in url....
r1310 path.to_s.starts_with?('/') ? path : "/#{path}"
end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822
Jean-Philippe Lang
Fixed: single file 'View difference' links do not work because of duplicate slashes in url....
r1310 def without_leading_slash(path)
path.gsub(%r{^/+}, '')
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
def subversion_field_tags(form, repository)
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822 content_tag('p', form.text_field(:url, :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url')) +
Toshi MARUYAMA
Rails3: helper: use html_safe for Subversion setting...
r7432 '<br />'.html_safe +
'(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 content_tag('p', form.text_field(:login, :size => 30)) +
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4870 content_tag('p', form.password_field(
:password, :size => 30, :name => 'ignore',
:value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
:onfocus => "this.value=''; this.name='repository[password]';",
:onchange => "this.name='repository[password]';"))
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Jean-Philippe Lang
Added Darcs basic support....
r570 def darcs_field_tags(form, repository)
Toshi MARUYAMA
scm: use i18n string at 'Path to repository' setting in Mercurial, Git, Bazaar and Darcs....
r5409 content_tag('p', form.text_field(
Toshi MARUYAMA
scm: darcs: change i18n l() parameter in setting from string to symbol....
r5555 :url, :label => l(:field_path_to_repository),
Toshi MARUYAMA
scm: code clean up RepositoriesHelper....
r5395 :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url'))) +
Toshi MARUYAMA
scm: use i18n string at commit log encoding setting (#1735)....
r5399 content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: darcs: change i18n l() parameter in setting from string to symbol....
r5555 :label => l(:field_commit_logs_encoding), :required => true))
Jean-Philippe Lang
Added Darcs basic support....
r570 end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def mercurial_field_tags(form, repository)
Toshi MARUYAMA
scm: mercurial: change "url" human attribute name from "Root directory" to "Path to repository"....
r5408 content_tag('p', form.text_field(
Toshi MARUYAMA
scm: mercurial: change i18n l() parameter in setting from string to symbol....
r5556 :url, :label => l(:field_path_to_repository),
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822 :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url')
Toshi MARUYAMA
scm: mercurial: change "url" human attribute name from "Root directory" to "Path to repository"....
r5408 ) +
Toshi MARUYAMA
Rails3: helper: use html_safe for Mercurial setting...
r7428 '<br />'.html_safe + l(:text_mercurial_repository_note)) +
Toshi MARUYAMA
scm: mercurial: add path encoding select box at setting (#2664)....
r4881 content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: mercurial: change i18n l() parameter in setting from string to symbol....
r5556 :label => l(:field_scm_path_encoding)
Toshi MARUYAMA
scm: use i18n string at path encoding setting note (#2274, #2664, #3462, #5251)....
r5403 ) +
Toshi MARUYAMA
Rails3: helper: use html_safe for Mercurial setting...
r7428 '<br />'.html_safe + l(:text_scm_path_encoding_note))
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 def git_field_tags(form, repository)
Toshi MARUYAMA
scm: use i18n string at 'Path to repository' setting in Mercurial, Git, Bazaar and Darcs....
r5409 content_tag('p', form.text_field(
Toshi MARUYAMA
scm: git: change i18n l() parameter in setting from string to symbol....
r5557 :url, :label => l(:field_path_to_repository),
Toshi MARUYAMA
scm: git: change select label to 'Path to repository'....
r4763 :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url')
Toshi MARUYAMA
scm: use i18n string at 'Path to repository' setting in Mercurial, Git, Bazaar and Darcs....
r5409 ) +
Toshi MARUYAMA
Rails3: helper: use html_safe for git setting...
r7429 '<br />'.html_safe +
Toshi MARUYAMA
improve git repository note at project setting (#9129)....
r6518 l(:text_git_repository_note)) +
Toshi MARUYAMA
scm: git: add path encoding select box at setting (#5251)....
r4944 content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: git: change i18n l() parameter in setting from string to symbol....
r5557 :label => l(:field_scm_path_encoding)
Toshi MARUYAMA
scm: use i18n string at path encoding setting note (#2274, #2664, #3462, #5251)....
r5403 ) +
Toshi MARUYAMA
Rails3: helper: use html_safe for git setting...
r7429 '<br />'.html_safe + l(:text_scm_path_encoding_note)) +
Toshi MARUYAMA
scm: git: add check box of whether reporting last commit for files and directories in project setting (#8365, #7047)....
r5651 content_tag('p', form.check_box(
:extra_report_last_commit,
Toshi MARUYAMA
scm: git: use symbol instead of string whether reporting last commit in project setting i18n text (#8365)....
r5656 :label => l(:label_git_report_last_commit)
Toshi MARUYAMA
scm: git: add check box of whether reporting last commit for files and directories in project setting (#8365, #7047)....
r5651 ))
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def cvs_field_tags(form, repository)
Toshi MARUYAMA
scm: cvs: use i18n string at 'CVSROOT' and 'Module' setting....
r5415 content_tag('p', form.text_field(
:root_url,
Toshi MARUYAMA
scm: cvs: change i18n l() parameter in setting from string to symbol....
r5558 :label => l(:field_cvsroot),
Toshi MARUYAMA
scm: cvs: use i18n string at 'CVSROOT' and 'Module' setting....
r5415 :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('root_url'))) +
Toshi MARUYAMA
scm: cvs: use i18n string at 'CVSROOT' and 'Module' setting....
r5415 content_tag('p', form.text_field(
:url,
Toshi MARUYAMA
scm: cvs: change i18n l() parameter in setting from string to symbol....
r5558 :label => l(:field_cvs_module),
Toshi MARUYAMA
scm: code clean up RepositoriesHelper....
r5268 :size => 30, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url'))) +
Toshi MARUYAMA
scm: use i18n string at commit log encoding setting (#1735)....
r5399 content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: cvs: change i18n l() parameter in setting from string to symbol....
r5558 :label => l(:field_commit_logs_encoding), :required => true)) +
Toshi MARUYAMA
scm: cvs: add path encoding select box at setting (#3462)....
r5345 content_tag('p', form.select(
Toshi MARUYAMA
scm: use i18n string at path encoding setting note (#2274, #2664, #3462, #5251)....
r5403 :path_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: cvs: change i18n l() parameter in setting from string to symbol....
r5558 :label => l(:field_scm_path_encoding)
Toshi MARUYAMA
scm: use i18n string at path encoding setting note (#2274, #2664, #3462, #5251)....
r5403 ) +
Toshi MARUYAMA
Rails3: helper: use html_safe for cvs setting...
r7430 '<br />'.html_safe + l(:text_scm_path_encoding_note))
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Jean-Philippe Lang
Added Bazaar adapter....
r937
def bazaar_field_tags(form, repository)
Toshi MARUYAMA
scm: use i18n string at 'Path to repository' setting in Mercurial, Git, Bazaar and Darcs....
r5409 content_tag('p', form.text_field(
Toshi MARUYAMA
scm: bazaar: change i18n l() parameter in setting from string to symbol....
r5559 :url, :label => l(:field_path_to_repository),
Toshi MARUYAMA
scm: code clean up RepositoriesHelper....
r5268 :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url'))) +
Toshi MARUYAMA
scm: use i18n string at commit log encoding setting (#1735)....
r5399 content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: bazaar: change i18n l() parameter in setting from string to symbol....
r5559 :label => l(:field_commit_logs_encoding), :required => true))
Jean-Philippe Lang
Added Bazaar adapter....
r937 end
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822
Jean-Philippe Lang
Adds Filesystem adapter (patch #1393 by Paul R)....
r1494 def filesystem_field_tags(form, repository)
Toshi MARUYAMA
scm: filesystem: use i18n string at 'Root directory' setting....
r5412 content_tag('p', form.text_field(
Toshi MARUYAMA
scm: filesystem: change i18n l() parameter in setting from string to symbol....
r5560 :url, :label => l(:field_root_directory),
Toshi MARUYAMA
scm: code clean up repositories_helper.rb....
r4822 :size => 60, :required => true,
Jean-Philippe Lang
Makes repository url read-only after saving....
r9695 :disabled => !repository.safe_attribute?('url'))) +
Toshi MARUYAMA
scm: filesystem: add note "Default: UTF-8" in path encoding setting (#2274)....
r4868 content_tag('p', form.select(
Toshi MARUYAMA
scm: use i18n string at path encoding setting note (#2274, #2664, #3462, #5251)....
r5403 :path_encoding, [nil] + Setting::ENCODINGS,
Toshi MARUYAMA
scm: filesystem: change i18n l() parameter in setting from string to symbol....
r5560 :label => l(:field_scm_path_encoding)
Toshi MARUYAMA
scm: use i18n string at path encoding setting note (#2274, #2664, #3462, #5251)....
r5403 ) +
Toshi MARUYAMA
Rails3: helper: use html_safe for filesysytem scm setting...
r7431 '<br />'.html_safe + l(:text_scm_path_encoding_note))
Jean-Philippe Lang
Adds Filesystem adapter (patch #1393 by Paul R)....
r1494 end
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605
Etienne Massip
Revision graph code cleanup....
r8653 def index_commits(commits, heads)
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 return nil if commits.nil? or commits.first.parents.nil?
Etienne Massip
Revision graph code cleanup....
r8653
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 refs_map = {}
Etienne Massip
Revision graph code cleanup....
r8653 heads.each do |head|
refs_map[head.scmid] ||= []
refs_map[head.scmid] << head
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
Etienne Massip
Revision graph code cleanup....
r8653
commits_by_scmid = {}
commits.reverse.each_with_index do |commit, commit_index|
commits_by_scmid[commit.scmid] = {
:parent_scmids => commit.parents.collect { |parent| parent.scmid },
:rdmid => commit_index,
:refs => refs_map.include?(commit.scmid) ? refs_map[commit.scmid].join(" ") : nil,
:scmid => commit.scmid,
:href => block_given? ? yield(commit.scmid) : commit.scmid
}
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
Etienne Massip
Revision graph code cleanup....
r8653
heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
Etienne Massip
Integrated revision graph into scmid column....
r8730 space = nil
Etienne Massip
Revision graph code cleanup....
r8653 heads.each do |head|
if commits_by_scmid.include? head.scmid
Etienne Massip
Integrated revision graph into scmid column....
r8730 space = index_head((space || -1) + 1, head, commits_by_scmid)
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
end
Etienne Massip
Integrated revision graph into scmid column....
r8730
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 # when no head matched anything use first commit
Etienne Massip
Integrated revision graph into scmid column....
r8730 space ||= index_head(0, commits.first, commits_by_scmid)
return commits_by_scmid, space
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
Etienne Massip
Integrated revision graph into scmid column....
r8730 def index_head(space, commit, commits_by_scmid)
Etienne Massip
Revision graph code cleanup....
r8653
Etienne Massip
Integrated revision graph into scmid column....
r8730 stack = [[space, commits_by_scmid[commit.scmid]]]
max_space = space
Etienne Massip
Revision graph code cleanup....
r8653
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 until stack.empty?
Etienne Massip
Integrated revision graph into scmid column....
r8730 space, commit = stack.pop
commit[:space] = space if commit[:space].nil?
Etienne Massip
Revision graph code cleanup....
r8653
Etienne Massip
Integrated revision graph into scmid column....
r8730 space -= 1
Etienne Massip
Revision graph code cleanup....
r8653 commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
parent_commit = commits_by_scmid[parent_scmid]
Etienne Massip
Integrated revision graph into scmid column....
r8730 if parent_commit and parent_commit[:space].nil?
Etienne Massip
Revision graph code cleanup....
r8653
Etienne Massip
Integrated revision graph into scmid column....
r8730 stack.unshift [space += 1, parent_commit]
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
end
Etienne Massip
Integrated revision graph into scmid column....
r8730 max_space = space if max_space < space
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
Etienne Massip
Integrated revision graph into scmid column....
r8730 max_space
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 end
Jean-Philippe Lang
svn browser merged in trunk...
r103 end