]> source.dussan.org Git - redmine.git/commitdiff
scm: mercurial: update test repository for path encoding (#2664).
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 4 Mar 2011 04:25:48 +0000 (04:25 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 4 Mar 2011 04:25:48 +0000 (04:25 +0000)
Mercurial (and also Git) treats file names as byte string.
This mercurial test repository contains Latin-1 encoding path.
Be careful on non Latin-1(CP1252) Windows.

If your Windows is not Latin-1 Windows,
in order to checkout(update) Latin-1 path,
You need to use cygwin 1.7 and set LANG=en_US.ISO-8859-1.

Please refer.
http://mercurial.selenic.com/wiki/EncodingStrategy?action=recall&rev=6

Redmine mercurial adapter do not need to checkout(update) repository.
Mercurial does not have "bare" repository such as Git.
You can use "hg update null" for equivalent "bare" repository.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4996 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/fixtures/repositories/mercurial_repository.hg
test/functional/repositories_mercurial_controller_test.rb
test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
test/unit/repository_mercurial_test.rb

index c06844d235c3fad69b6e85f0b743f445f01f0cee..2b4eb62410643ae3c466665bab4f63dd0e7978e6 100644 (file)
Binary files a/test/fixtures/repositories/mercurial_repository.hg and b/test/fixtures/repositories/mercurial_repository.hg differ
index f784d049dc6d9e183871f640d614d6dbf0ac833a..3960285fd0441eb388aae27f17846551cd5ba2f0 100644 (file)
@@ -32,7 +32,11 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
     @request    = ActionController::TestRequest.new
     @response   = ActionController::TestResponse.new
     User.current = nil
-    @repository = Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
+    @repository = Repository::Mercurial.create(
+                      :project => Project.find(3),
+                      :url     => REPOSITORY_PATH,
+                      :path_encoding => 'ISO-8859-1'
+                      )
     assert @repository
     @diff_c_support = true
   end
index d275798c18fee0e1540403558aeb686a1df2b111..b5629841b9b1c20bd40a41a6dff3788bcaf254cc 100644 (file)
@@ -10,10 +10,19 @@ begin
 
     REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
 
+    CHAR_1_HEX = "\xc3\x9c"
+
     if File.directory?(REPOSITORY_PATH)
       def setup
         @adapter = Redmine::Scm::Adapters::MercurialAdapter.new(REPOSITORY_PATH)
         @diff_c_support = true
+
+        @tag_char_1    = "tag-#{CHAR_1_HEX}-00"
+        @branch_char_1 = "branch-#{CHAR_1_HEX}-00"
+        if @tag_char_1.respond_to?(:force_encoding)
+          @tag_char_1.force_encoding('UTF-8')
+          @branch_char_1.force_encoding('UTF-8')
+        end
       end
 
       def test_hgversion
@@ -49,7 +58,7 @@ begin
           adp = Redmine::Scm::Adapters::MercurialAdapter.new(repo)
           repo_path =  adp.info.root_url.gsub(/\\/, "/")
           assert_equal REPOSITORY_PATH, repo_path
-          assert_equal '16', adp.info.lastrev.revision
+          assert_equal '24', adp.info.lastrev.revision
           assert_equal '4cddb4e45f52',adp.info.lastrev.scmid
         end
       end
@@ -97,7 +106,7 @@ begin
 
       def test_diff_made_by_revision
         if @diff_c_support
-          [16, '16', '4cddb4e45f52'].each do |r1|
+          [24, '24', '4cddb4e45f52'].each do |r1|
             diff1 = @adapter.diff(nil, r1)
             assert_equal 5, diff1.size
             buf = diff1[4].gsub(/\r\n|\r|\n/, "")
@@ -219,24 +228,32 @@ begin
       end
 
       def test_tags
-        assert_equal ['tag_test.00', 'tag-init-revision'], @adapter.tags
+        assert_equal [@tag_char_1, 'tag_test.00', 'tag-init-revision'], @adapter.tags
       end
 
       def test_tagmap
-        tm = { 'tag_test.00'       => '6987191f453a',
-               'tag-init-revision' => '0885933ad4f6' }
+        tm = { 
+          @tag_char_1         => 'adf805632193',
+          'tag_test.00'       => '6987191f453a',
+          'tag-init-revision' => '0885933ad4f6',
+          }
         assert_equal tm, @adapter.tagmap
       end
 
       def test_branches
-        assert_equal ['default', 'branch (1)[2]&,%.-3_4', 'test-branch-00'],
-                     @adapter.branches
+        assert_equal ['default', @branch_char_1,
+                      'test_branch.latin-1', 'branch (1)[2]&,%.-3_4', 'test-branch-00'],
+                  @adapter.branches
       end
 
       def test_branchmap
-        bm = { 'default'               => '4cddb4e45f52',
-               'branch (1)[2]&,%.-3_4' => '933ca60293d7',
-               'test-branch-00'        => '3a330eb32958' }
+        bm = {
+           'default'               => '4cddb4e45f52',
+           @branch_char_1          => 'c8d3e4887474',
+           'test_branch.latin-1'   => 'c2ffe7da686a',
+           'branch (1)[2]&,%.-3_4' => '933ca60293d7',
+           'test-branch-00'        => '3a330eb32958'
+         }
         assert_equal bm, @adapter.branchmap
       end
 
index 271ffe43bdc6ada0ffc35c04ec827444c44b59c7..9c3032bf33c9d774a4c090f2b4ccb19f2566cc92 100644 (file)
@@ -25,7 +25,11 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
 
   def setup
     @project = Project.find(3)
-    @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH)
+    @repository = Repository::Mercurial.create(
+                      :project => @project,
+                      :url     => REPOSITORY_PATH,
+                      :path_encoding => 'ISO-8859-1'
+                      )
     assert @repository
   end
 
@@ -33,8 +37,8 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
     def test_fetch_changesets_from_scratch
       @repository.fetch_changesets
       @repository.reload
-      assert_equal 17, @repository.changesets.count
-      assert_equal 25, @repository.changes.count
+      assert_equal 25, @repository.changesets.count
+      assert_equal 32, @repository.changes.count
       assert_equal "Initial import.\nThe repository contains 3 files.",
                    @repository.changesets.find_by_revision('0').comments
     end
@@ -47,7 +51,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
       assert_equal 3, @repository.changesets.count
       
       @repository.fetch_changesets
-      assert_equal 17, @repository.changesets.count
+      assert_equal 25, @repository.changesets.count
     end
 
     def test_isodatesec
@@ -170,7 +174,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
       @repository.fetch_changesets
       @repository.reload
       changesets = @repository.latest_changesets('README', nil)
-      assert_equal %w|8 6 1 0|, changesets.collect(&:revision)
+      assert_equal %w|17 8 6 1 0|, changesets.collect(&:revision)
 
       path = 'sql_escape/percent%dir/percent%file1.txt'
       changesets = @repository.latest_changesets(path, nil)