@@ -1,12 +1,12 | |||||
1 | changeset = 'This template must be used with --debug option\n' |
|
1 | changeset = 'This template must be used with --debug option\n' | |
2 | changeset_quiet = 'This template must be used with --debug option\n' |
|
2 | changeset_quiet = 'This template must be used with --debug option\n' | |
3 | changeset_verbose = 'This template must be used with --debug option\n' |
|
3 | changeset_verbose = 'This template must be used with --debug option\n' | |
4 | changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodate}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n{tags}</logentry>\n\n' |
|
4 | changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodatesec}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n{tags}</logentry>\n\n' | |
5 |
|
5 | |||
6 | file_mod = '<path action="M">{file_mod|escape}</path>\n' |
|
6 | file_mod = '<path action="M">{file_mod|escape}</path>\n' | |
7 | file_add = '<path action="A">{file_add|escape}</path>\n' |
|
7 | file_add = '<path action="A">{file_add|escape}</path>\n' | |
8 | file_del = '<path action="D">{file_del|escape}</path>\n' |
|
8 | file_del = '<path action="D">{file_del|escape}</path>\n' | |
9 | file_copy = '<path-copied copyfrom-path="{source|escape}">{name|urlescape}</path-copied>\n' |
|
9 | file_copy = '<path-copied copyfrom-path="{source|escape}">{name|urlescape}</path-copied>\n' | |
10 | tag = '<tag>{tag|escape}</tag>\n' |
|
10 | tag = '<tag>{tag|escape}</tag>\n' | |
11 | header='<?xml version="1.0" encoding="UTF-8" ?>\n<log>\n\n' |
|
11 | header='<?xml version="1.0" encoding="UTF-8" ?>\n<log>\n\n' | |
12 | # footer="</log>" |
|
12 | # footer="</log>" |
@@ -1,75 +1,83 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RepositoryMercurialTest < ActiveSupport::TestCase |
|
20 | class RepositoryMercurialTest < ActiveSupport::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects | |
22 |
|
22 | |||
23 | # No '..' in the repository path |
|
23 | # No '..' in the repository path | |
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' |
|
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' | |
25 |
|
25 | |||
26 | def setup |
|
26 | def setup | |
27 | @project = Project.find(1) |
|
27 | @project = Project.find(1) | |
28 | assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH) |
|
28 | assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH) | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | if File.directory?(REPOSITORY_PATH) |
|
31 | if File.directory?(REPOSITORY_PATH) | |
32 | def test_fetch_changesets_from_scratch |
|
32 | def test_fetch_changesets_from_scratch | |
33 | @repository.fetch_changesets |
|
33 | @repository.fetch_changesets | |
34 | @repository.reload |
|
34 | @repository.reload | |
35 |
|
35 | |||
36 | assert_equal 6, @repository.changesets.count |
|
36 | assert_equal 6, @repository.changesets.count | |
37 | assert_equal 11, @repository.changes.count |
|
37 | assert_equal 11, @repository.changes.count | |
38 | assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments |
|
38 | assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_fetch_changesets_incremental |
|
41 | def test_fetch_changesets_incremental | |
42 | @repository.fetch_changesets |
|
42 | @repository.fetch_changesets | |
43 | # Remove changesets with revision > 2 |
|
43 | # Remove changesets with revision > 2 | |
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} |
|
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} | |
45 | @repository.reload |
|
45 | @repository.reload | |
46 | assert_equal 3, @repository.changesets.count |
|
46 | assert_equal 3, @repository.changesets.count | |
47 |
|
47 | |||
48 | @repository.fetch_changesets |
|
48 | @repository.fetch_changesets | |
49 | assert_equal 6, @repository.changesets.count |
|
49 | assert_equal 6, @repository.changesets.count | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def test_entries |
|
52 | def test_entries | |
53 | assert_equal 2, @repository.entries("sources", 2).size |
|
53 | assert_equal 2, @repository.entries("sources", 2).size | |
54 | assert_equal 1, @repository.entries("sources", 3).size |
|
54 | assert_equal 1, @repository.entries("sources", 3).size | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_locate_on_outdated_repository |
|
57 | def test_locate_on_outdated_repository | |
58 | # Change the working dir state |
|
58 | # Change the working dir state | |
59 | %x{hg -R #{REPOSITORY_PATH} up -r 0} |
|
59 | %x{hg -R #{REPOSITORY_PATH} up -r 0} | |
60 | assert_equal 1, @repository.entries("images", 0).size |
|
60 | assert_equal 1, @repository.entries("images", 0).size | |
61 | assert_equal 2, @repository.entries("images").size |
|
61 | assert_equal 2, @repository.entries("images").size | |
62 | assert_equal 2, @repository.entries("images", 2).size |
|
62 | assert_equal 2, @repository.entries("images", 2).size | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 |
|
||||
66 | def test_cat |
|
65 | def test_cat | |
67 | assert @repository.scm.cat("sources/welcome_controller.rb", 2) |
|
66 | assert @repository.scm.cat("sources/welcome_controller.rb", 2) | |
68 | assert_nil @repository.scm.cat("sources/welcome_controller.rb") |
|
67 | assert_nil @repository.scm.cat("sources/welcome_controller.rb") | |
69 | end |
|
68 | end | |
70 |
|
69 | |||
|
70 | def test_isodatesec | |||
|
71 | # Template keyword 'isodatesec' supported in Mercurial 1.0 and higher | |||
|
72 | if @repository.scm.class.client_version_above?([1, 0]) | |||
|
73 | @repository.fetch_changesets | |||
|
74 | @repository.reload | |||
|
75 | rev0_committed_on = Time.gm(2007, 12, 14, 9, 22, 52) | |||
|
76 | assert_equal @repository.changesets.find_by_revision('0').committed_on, rev0_committed_on | |||
|
77 | end | |||
|
78 | end | |||
71 | else |
|
79 | else | |
72 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" |
|
80 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" | |
73 | def test_fake; assert true end |
|
81 | def test_fake; assert true end | |
74 | end |
|
82 | end | |
75 | end |
|
83 | end |
General Comments 0
You need to be logged in to leave comments.
Login now