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