Support revision without any message in Mercurial repositories (#36258).

Patch by salman mp and Yuichi HARADA.


git-svn-id: https://svn.redmine.org/redmine/trunk@21792 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2022-09-01 05:16:38 +00:00
parent 45fafc7e44
commit 6755063664
5 changed files with 22 additions and 8 deletions

View File

@@ -230,7 +230,7 @@ module Redmine
end end
), ),
:time => Time.parse(le['date']['__content__']), :time => Time.parse(le['date']['__content__']),
:message => CGI.unescape(le['msg']['__content__']), :message => CGI.unescape(le['msg']['__content__'] || ''),
:paths => paths, :paths => paths,
:parents => parents_ary) :parents => parents_ary)
end end

View File

@@ -27,7 +27,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
PRJ_ID = 3 PRJ_ID = 3
NUM_REV = 40 NUM_REV = 43
def setup def setup
super super

View File

@@ -87,8 +87,8 @@ class MercurialAdapterTest < ActiveSupport::TestCase
adp = Redmine::Scm::Adapters::MercurialAdapter.new(repo) adp = Redmine::Scm::Adapters::MercurialAdapter.new(repo)
repo_path = adp.info.root_url.tr('\\', "/") repo_path = adp.info.root_url.tr('\\', "/")
assert_equal REPOSITORY_PATH, repo_path assert_equal REPOSITORY_PATH, repo_path
assert_equal '39', adp.info.lastrev.revision assert_equal '42', adp.info.lastrev.revision
assert_equal '04aed9840e9266e535f5f20f7e42c9f9f84f9cf4', adp.info.lastrev.scmid assert_equal 'ba20ebce08dbd2f0320b93faf7bba7c86186a1f7', adp.info.lastrev.scmid
end end
end end
@@ -113,6 +113,14 @@ class MercurialAdapterTest < ActiveSupport::TestCase
assert_equal "ctrl-s\u0013message", revisions[0].message assert_equal "ctrl-s\u0013message", revisions[0].message
end end
def test_empty_message
revisions = @adapter.revisions(nil, '05b4c556a8a1', '05b4c556a8a1')
assert_equal 1, revisions.size
assert_equal '41', revisions[0].revision
assert_equal 'jsmith <jsmith@foo.bar>', revisions[0].author
assert_equal '', revisions[0].message
end
def test_parents def test_parents
revs1 = @adapter.revisions(nil, 0, 0) revs1 = @adapter.revisions(nil, 0, 0)
assert_equal 1, revs1.size assert_equal 1, revs1.size
@@ -349,7 +357,12 @@ class MercurialAdapterTest < ActiveSupport::TestCase
@adapter.branches.each do |b| @adapter.branches.each do |b|
branches << b branches << b
end end
assert_equal 9, branches.length assert_equal 10, branches.length
branch = branches[-10]
assert_equal 'branch-empty-message', branch.to_s
assert_equal '42', branch.revision
assert_equal 'ba20ebce08dbd2f0320b93faf7bba7c86186a1f7', branch.scmid
branch = branches[-9] branch = branches[-9]
assert_equal 'double"quote"branch', branch.to_s assert_equal 'double"quote"branch', branch.to_s
@@ -400,6 +413,7 @@ class MercurialAdapterTest < ActiveSupport::TestCase
def test_branchmap def test_branchmap
bm = bm =
{ {
'branch-empty-message' => 'ba20ebce08dbd2f0320b93faf7bba7c86186a1f7',
'double"quote"branch' => '04aed9840e9266e535f5f20f7e42c9f9f84f9cf4', 'double"quote"branch' => '04aed9840e9266e535f5f20f7e42c9f9f84f9cf4',
'issue-23055-ctrl-char' => '3e998343166a1b8273973bcd46dd2bad74344d74', 'issue-23055-ctrl-char' => '3e998343166a1b8273973bcd46dd2bad74344d74',
'default' => '31eeee7395c8c78e66dd54c50addd078d10b2355', 'default' => '31eeee7395c8c78e66dd54c50addd078d10b2355',

View File

@@ -25,7 +25,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
include Redmine::I18n include Redmine::I18n
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
NUM_REV = 40 NUM_REV = 43
def setup def setup
User.current = nil User.current = nil
@@ -170,7 +170,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
@repository.fetch_changesets @repository.fetch_changesets
@project.reload @project.reload
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
assert_equal 51, @repository.filechanges.count assert_equal 53, @repository.filechanges.count
rev0 = @repository.changesets.find_by_revision('0') rev0 = @repository.changesets.find_by_revision('0')
assert_equal "Initial import.\nThe repository contains 3 files.", assert_equal "Initial import.\nThe repository contains 3 files.",
rev0.comments rev0.comments
@@ -597,7 +597,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
@repository.fetch_changesets @repository.fetch_changesets
@project.reload @project.reload
assert_equal NUM_REV, @repository.changesets.count assert_equal NUM_REV, @repository.changesets.count
[(NUM_REV - 1).to_s, "04aed9840e92", "04aed"].each do |r1| [(NUM_REV - 1).to_s, "ba20ebce08db", "ba20e"].each do |r1|
changeset = @repository.find_changeset_by_name(r1) changeset = @repository.find_changeset_by_name(r1)
assert_nil changeset.next assert_nil changeset.next
end end