# HG changeset patch # User Alessio Caiazza # Date 1269016621 -3600 # Node ID fbdac3f51698151c9f2a7c534939b4d52e1ccb84 # Parent f9ecae6c34248e9be8f2f49c0db6bcb99f2d84cb imported merutosi's changesets c72be5239f70a5bf1e5ffe38a15e509866442778 and 5d1236c439e30bf1d4b7e4e5c1622ccb84378966 diff -r f9ecae6c34248e9be8f2f49c0db6bcb99f2d84cb -r fbdac3f51698151c9f2a7c534939b4d52e1ccb84 marutosi.diff --- a/marutosi.diff Fri Mar 19 11:10:42 2010 +0100 +++ b/marutosi.diff Fri Mar 19 17:37:01 2010 +0100 @@ -1,8 +1,6 @@ # HG changeset patch -# Parent afc53258c0b8992af1e3aa5960d0df9fab5ec358 -Summarized marutosi patches till -http://github.com/marutosi/redmine/commit/765fd0b3dbba8b8282d03a9edc157a581b91c84f -from http://github.com/marutosi/redmine/tree/hg-overhaul-0.9 +# Parent 0dc60afda5722afecf6f7fc5c13552d3f008bdf2 +Summarized marutosi's patches from http://github.com/marutosi/redmine/tree/hg-overhaul-0.9 diff --git a/.gitignore b/.gitignore --- a/.gitignore @@ -154,7 +152,7 @@ diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb -@@ -18,77 +18,364 @@ +@@ -18,77 +18,365 @@ require 'redmine/scm/adapters/mercurial_adapter' class Repository::Mercurial < Repository @@ -307,9 +305,6 @@ + # return if ( scm_info.nil? ) + return if ( scm_info.nil? || ( scm_info && scm_info.lastrev.nil? ) ) + -+ # last_rev = scm.lastrev('','tip','tip') -+ # return if ( last_rev.nil? ) -+ + transaction do + Changeset.update_all( + "scm_order = -1" , @@ -379,6 +374,10 @@ end + + scm_revision = scm.num_revisions - 1 ++ if (identifier_from <= scm_revision) ++ # Mercurial branch and tag are changeset. ++ scm.reset_branch_tag ++ end + # Reffered from Subversion logic. + while (identifier_from <= scm_revision) + transaction do @@ -805,7 +804,7 @@ # The hg version is expressed either as a # release number (eg 0.9.5 or 1.0) or as a revision # id composed of 12 hexa characters. -@@ -42,46 +49,153 @@ +@@ -42,46 +49,149 @@ theversion.split(".").collect(&:to_i) end end @@ -843,6 +842,11 @@ end - + ++ def reset_branch_tag ++ @branches = nil ++ @tags = nil ++ end ++ + # Mercurial default branch is "default". + # But, Mercurial has multipile heads. + def default_branch @@ -885,15 +889,6 @@ + tags + end + -+ def info_simple -+ lrev = lastrev('',nil) -+ if lrev -+ Info.new(:root_url => url, :lastrev => lrev) -+ else -+ nil -+ end -+ end -+ + # This method needs for "entries" method. def info - cmd = "#{HG_BIN} -R #{target('')} root" @@ -977,7 +972,7 @@ shellout(cmd) do |io| io.each_line do |line| # HG uses antislashs as separator on Windows -@@ -89,34 +203,82 @@ +@@ -89,34 +199,82 @@ if path.empty? or e = line.gsub!(%r{^#{with_trailling_slash(path)}},'') e ||= line e = e.chomp.split(%r{[\/\\]}) @@ -1071,7 +1066,7 @@ doc.elements.each("log/logentry") do |logentry| paths = [] copies = logentry.get_elements('paths/path-copied') -@@ -124,7 +286,7 @@ +@@ -124,7 +282,7 @@ # Detect if the added file is a copy if path.attributes['action'] == 'A' and c = copies.find{ |e| e.text == path.text } from_path = c.attributes['copyfrom-path'] @@ -1080,7 +1075,7 @@ end paths << {:action => path.attributes['action'], :path => "/#{path.text}", -@@ -132,15 +294,18 @@ +@@ -132,15 +290,18 @@ :from_revision => from_rev ? from_rev : nil } end @@ -1108,7 +1103,7 @@ end rescue logger.debug($!) -@@ -149,15 +314,14 @@ +@@ -149,15 +310,14 @@ return nil if $? && $?.exitstatus != 0 revisions end @@ -1127,7 +1122,7 @@ cmd << " -I #{target(path)}" unless path.empty? diff = [] shellout(cmd) do |io| -@@ -168,11 +332,11 @@ +@@ -168,11 +328,11 @@ return nil if $? && $?.exitstatus != 0 diff end @@ -1142,7 +1137,7 @@ cat = nil shellout(cmd) do |io| io.binmode -@@ -181,19 +345,38 @@ +@@ -181,19 +341,38 @@ return nil if $? && $?.exitstatus != 0 cat end @@ -1191,7 +1186,7 @@ diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake -@@ -26,11 +26,26 @@ +@@ -26,10 +26,29 @@ system "svnadmin create #{repo_path}" system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}" end @@ -1200,11 +1195,15 @@ + + desc "Creates a test mercurial repository" + task :mercurial => :create_dir do -+ repo_path = "tmp/test/mercurial_repository" ++ repo_path = "tmp/test/mercurial_repository" ++ hgrc_src = "test/fixtures/repositories/mercurial/hgrc" + size_ext_path = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + "/extra/mercurial/size.py" + system "hg init #{repo_path}" -+ system "cp -f test/fixtures/repositories/mercurial/hgrc #{repo_path}/.hg/hgrc " -+ system "echo size = #{size_ext_path} >> #{repo_path}/.hg/hgrc " ++ hgrc_dest = File.open(repo_path + "/.hg/hgrc",'w') ++ File::open(hgrc_src) {|f| ++ f.each {|line| hgrc_dest.print line.sub('SIZE_EXT_PATH', size_ext_path) } ++ } ++ hgrc_dest.close + + system "hg -R #{repo_path} pull test/fixtures/repositories/mercurial/default.r0.bundle" + system "hg -R #{repo_path} pull test/fixtures/repositories/mercurial/branch01.r1.bundle" @@ -1215,12 +1214,10 @@ + (supported_scms - [:subversion, :mercurial]).each do |scm| desc "Creates a test #{scm} repository" task scm => :create_dir do -- system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" -+ # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" -+ system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" ++ # system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" + system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" end end - diff --git a/test/fixtures/changes.yml b/test/fixtures/changes.yml --- a/test/fixtures/changes.yml +++ b/test/fixtures/changes.yml @@ -1560,7 +1557,7 @@ new file mode 100644 --- /dev/null +++ b/test/fixtures/repositories/mercurial/hgrc -@@ -0,0 +1,20 @@ +@@ -0,0 +1,26 @@ + +[ui] +username = test00 @@ -1568,6 +1565,7 @@ +[extensions] +# MQ extention needs for unit test of check history editing. +hgext.mq = ++hgext.size = SIZE_EXT_PATH + +# share = +# hgext.convert = @@ -1581,6 +1579,11 @@ +# hggit = +# svn = + ++[redmine] ++# http://mercurial.selenic.com/wiki/BugzillaExtension ++ ++ ++ diff --git a/test/fixtures/repositories/mercurial_repository.tar.gz b/test/fixtures/repositories/mercurial_repository.tar.gz deleted file mode 100644 Binary file test/fixtures/repositories/mercurial_repository.tar.gz has changed @@ -1841,7 +1844,7 @@ diff --git a/test/unit/repository_mercurial_test.rb b/test/unit/repository_mercurial_test.rb --- a/test/unit/repository_mercurial_test.rb +++ b/test/unit/repository_mercurial_test.rb -@@ -26,46 +26,118 @@ +@@ -26,46 +26,129 @@ def setup @project = Project.find(1) assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH) @@ -1971,6 +1974,17 @@ + assert_equal 375, @repository.scm.size_from_ext("README", 'a76b95b2519c') + end + ++ def test_tag_count ++ @repository.fetch_changesets ++ @repository.reload ++ assert_equal 1, @repository.scm.tags.size ++ %x{hg -R #{REPOSITORY_PATH} update default} ++ %x{hg -R #{REPOSITORY_PATH} tag tag_test00} ++ @repository.fetch_changesets ++ @repository.reload ++ assert_equal 2, @repository.scm.tags.size ++ end ++ + def test_invalid_repo_url + @repository.url = REPOSITORY_PATH + "_invalid" + @repository.fetch_changesets