pvn 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +5 -1
- data/lib/pvn/app.rb +3 -0
- data/lib/pvn/{log/formatter → base}/color_formatter.rb +0 -0
- data/lib/pvn/io/element.rb +36 -29
- data/lib/pvn/log/formatter/log_formatter.rb +1 -10
- data/lib/pvn/log/formatter/summary_formatter.rb +0 -2
- data/lib/pvn/log/logcmd.rb +0 -1
- data/lib/pvn/revision/entry.rb +7 -2
- data/lib/pvn/status/formatter/entries_formatter.rb +27 -0
- data/lib/pvn/status/formatter/entry_formatter.rb +27 -0
- data/lib/pvn/status/formatter/status_formatter.rb +31 -0
- data/lib/pvn/subcommands/base/color_option.rb +12 -0
- data/lib/pvn/subcommands/base/command.rb +21 -2
- data/lib/pvn/subcommands/base/options.rb +1 -0
- data/lib/pvn/subcommands/log/command.rb +26 -30
- data/lib/pvn/subcommands/log/options.rb +2 -7
- data/lib/pvn/subcommands/pct/command.rb +71 -91
- data/lib/pvn/subcommands/pct/diffcount.rb +26 -0
- data/lib/pvn/subcommands/revision/revision_option.rb +7 -5
- data/lib/pvn/subcommands/status/command.rb +42 -0
- data/lib/pvn/subcommands/status/options.rb +16 -0
- data/lib/svnx/info/command.rb +14 -0
- data/lib/svnx/log/entry.rb +4 -0
- data/lib/synoption/fixnum_option.rb +1 -1
- data/test/{unit → integration}/pvn/subcommands/log/command_test.rb +0 -0
- data/test/unit/pvn/io/element/log/log_test.rb +3 -2
- data/test/unit/pvn/log/formatter/entry_formatter_test.rb +1 -1
- data/test/unit/pvn/revision/entry_test.rb +10 -10
- data/test/unit/pvn/subcommands/log/options_test.rb +12 -31
- data/test/unit/pvn/subcommands/revision/multiple_revisions_option_test.rb +14 -21
- data/test/unit/pvn/subcommands/revision/revision_option_test.rb +20 -13
- data/test/unit/pvn/subcommands/revision/revision_regexp_option_test.rb +17 -15
- metadata +15 -11
- data/lib/pvn/pct/linecount.rb +0 -33
- data/lib/pvn/pct/pctcmd.rb +0 -204
- data/lib/pvn/pct/statcmd.rb +0 -13
@@ -7,31 +7,10 @@ require 'pvn/subcommands/base/command'
|
|
7
7
|
require 'svnx/info/command'
|
8
8
|
require 'svnx/status/command'
|
9
9
|
require 'svnx/cat/command'
|
10
|
+
require 'pvn/subcommands/pct/diffcount'
|
10
11
|
require 'set'
|
11
12
|
|
12
13
|
module PVN::Subcommands::Pct
|
13
|
-
class DiffCount
|
14
|
-
attr_reader :from
|
15
|
-
attr_reader :to
|
16
|
-
|
17
|
-
def initialize from = 0, to = 0
|
18
|
-
@from = from
|
19
|
-
@to = to
|
20
|
-
end
|
21
|
-
|
22
|
-
def print name
|
23
|
-
diff = to - from
|
24
|
-
diffpct = diff == 0 ? 0 : 100.0 * diff / from
|
25
|
-
|
26
|
-
printf "%8d %8d %8d %8.1f%% %s\n", from, to, diff, diffpct, name
|
27
|
-
end
|
28
|
-
|
29
|
-
def << diff
|
30
|
-
@from += diff.from
|
31
|
-
@to += diff.to
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
14
|
class Command < PVN::Subcommands::Base::Command
|
36
15
|
|
37
16
|
DEFAULT_LIMIT = 15
|
@@ -59,27 +38,57 @@ module PVN::Subcommands::Pct
|
|
59
38
|
example "pvn pct -r117", "Prints the changes between revision 117 and the previous revision. (not yet supported)"
|
60
39
|
example "pvn pct -7", "Prints the changes between relative revision -7 and the previous revision. (not yet supported)"
|
61
40
|
example "pvn pct -r31 -4", "Prints the changes between revision 31 and relative revision -4. (not yet supported)"
|
62
|
-
|
63
|
-
def initialize args
|
64
|
-
options = PVN::Subcommands::Pct::OptionSet.new
|
65
|
-
options.process args
|
66
41
|
|
67
|
-
|
42
|
+
class << self
|
43
|
+
# base command aliases new to init, so we're aliasing init to init2
|
44
|
+
alias_method :init2, :init
|
45
|
+
|
46
|
+
def init options
|
47
|
+
if options.revision && !options.revision.empty?
|
48
|
+
CommandRepository.init2 options
|
49
|
+
else
|
50
|
+
CommandLocal.init2 options
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
68
54
|
|
69
|
-
|
55
|
+
def initialize options = nil
|
56
|
+
end
|
57
|
+
end
|
70
58
|
|
71
|
-
|
72
|
-
|
59
|
+
class CommandLocal < Command
|
60
|
+
def initialize options
|
61
|
+
# do we support multiple paths?
|
62
|
+
path = options.paths[0] || '.'
|
73
63
|
|
74
|
-
|
64
|
+
elmt = PVN::IO::Element.new :local => path || '.'
|
65
|
+
modified = elmt.find_modified_files
|
66
|
+
info "modified: #{modified}".blue
|
75
67
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
68
|
+
total = PVN::DiffCount.new
|
69
|
+
|
70
|
+
modified = modified.sort_by { |n| n.path }
|
71
|
+
|
72
|
+
modified.each do |entry|
|
73
|
+
catcmd = SVNx::CatCommand.new entry.path
|
74
|
+
info "catcmd: #{catcmd}"
|
75
|
+
|
76
|
+
svn_count = catcmd.execute.size
|
77
|
+
info "svn_count: #{svn_count}"
|
78
|
+
|
79
|
+
local_count = Pathname.new(entry.path).readlines.size
|
80
|
+
info "local_count: #{local_count}"
|
81
|
+
|
82
|
+
dc = PVN::DiffCount.new svn_count, local_count
|
83
|
+
total << dc
|
84
|
+
dc.print entry.path
|
80
85
|
end
|
86
|
+
|
87
|
+
total.print 'total'
|
81
88
|
end
|
89
|
+
end
|
82
90
|
|
91
|
+
class CommandRepository < Command
|
83
92
|
### $$$ this belongs in Revision
|
84
93
|
def get_from_to_revisions rev
|
85
94
|
if rev.kind_of? Array
|
@@ -97,89 +106,60 @@ module PVN::Subcommands::Pct
|
|
97
106
|
end
|
98
107
|
end
|
99
108
|
|
100
|
-
def
|
109
|
+
def get_line_count path, revision
|
110
|
+
cmdargs = SVNx::CatCommandArgs.new :path => path, :revision => revision
|
111
|
+
catcmd = SVNx::CatCommand.new cmdargs
|
112
|
+
catcmd.execute.size
|
113
|
+
end
|
114
|
+
|
115
|
+
def initialize options
|
101
116
|
# what was modified between the revisions?
|
102
117
|
|
103
118
|
path = options.paths[0] || "."
|
119
|
+
info "path: #{path}"
|
104
120
|
|
105
121
|
elmt = PVN::IO::Element.new :local => path || '.'
|
106
122
|
modified = elmt.find_modified_entries options.revision
|
107
123
|
|
108
|
-
modnames = modified.collect { |m| m.name }
|
109
|
-
|
110
|
-
info "modnames: #{modnames.inspect}".yellow
|
111
|
-
|
112
|
-
rev = options.revision
|
113
|
-
|
114
|
-
info "rev: #{rev}; #{rev.class}".blue.on_yellow
|
115
|
-
info "rev: #{rev.inspect}; #{rev.class}".blue.on_yellow
|
124
|
+
modnames = modified.collect { |m| m.name }.sort.uniq
|
116
125
|
|
117
126
|
fromrev, torev = get_from_to_revisions options.revision
|
118
127
|
|
119
|
-
|
120
|
-
info "fromrev: #{fromrev.class}; torev: #{torev.class}".black.on_green
|
121
|
-
|
122
|
-
total = DiffCount.new
|
128
|
+
total = PVN::DiffCount.new
|
123
129
|
|
124
130
|
reporoot = elmt.repo_root
|
125
131
|
|
126
|
-
|
127
|
-
|
132
|
+
direlmt = PVN::IO::Element.new :local => '.'
|
133
|
+
svninfo = direlmt.get_info
|
128
134
|
|
135
|
+
filter = svninfo.url.dup
|
136
|
+
filter.slice! svninfo.root
|
137
|
+
info "filter: #{filter}"
|
138
|
+
filterre = Regexp.new '^' + filter + '/'
|
139
|
+
|
140
|
+
modnames.each do |mod|
|
129
141
|
fullpath = reporoot + mod
|
130
|
-
|
131
|
-
|
132
|
-
|
142
|
+
elmt = PVN::IO::Element.new :path => fullpath
|
143
|
+
|
144
|
+
next unless elmt.has_revision? fromrev
|
145
|
+
next unless elmt.has_revision? torev
|
146
|
+
next if elmt.get_info.kind == 'dir'
|
133
147
|
|
148
|
+
from_count = get_line_count fullpath, fromrev
|
134
149
|
to_count = get_line_count fullpath, torev
|
135
|
-
info "to_count: #{to_count}".red
|
136
150
|
|
137
|
-
dc = DiffCount.new from_count, to_count
|
151
|
+
dc = PVN::DiffCount.new from_count, to_count
|
138
152
|
total << dc
|
153
|
+
mod.slice! filterre
|
139
154
|
dc.print mod
|
140
155
|
end
|
141
156
|
|
142
157
|
total.print 'total'
|
143
158
|
end
|
144
159
|
|
145
|
-
def get_line_count path, revision
|
146
|
-
cmdargs = SVNx::CatCommandArgs.new :path => path, :revision => revision
|
147
|
-
catcmd = SVNx::CatCommand.new cmdargs
|
148
|
-
info "catcmd: #{catcmd}"
|
149
|
-
|
150
|
-
count = catcmd.execute.size
|
151
|
-
info "count: #{count}"
|
152
|
-
|
153
|
-
count
|
154
|
-
end
|
155
|
-
|
156
|
-
def compare_local_to_base options
|
157
|
-
# do we support multiple paths?
|
158
|
-
path = options.paths[0] || '.'
|
159
|
-
|
160
|
-
elmt = PVN::IO::Element.new :local => path || '.'
|
161
|
-
modified = elmt.find_modified_files
|
162
|
-
|
163
|
-
total = DiffCount.new
|
164
160
|
|
165
|
-
modified.each do |entry|
|
166
|
-
catcmd = SVNx::CatCommand.new entry.path
|
167
|
-
info "catcmd: #{catcmd}"
|
168
|
-
|
169
|
-
svn_count = catcmd.execute.size
|
170
|
-
info "svn_count: #{svn_count}"
|
171
|
-
|
172
|
-
local_count = Pathname.new(entry.path).readlines.size
|
173
|
-
info "local_count: #{local_count}"
|
174
|
-
|
175
|
-
dc = DiffCount.new svn_count, local_count
|
176
|
-
total << dc
|
177
|
-
dc.print entry.path
|
178
|
-
end
|
179
|
-
|
180
|
-
total.print 'total'
|
181
|
-
end
|
182
161
|
end
|
162
|
+
|
183
163
|
end
|
184
164
|
|
185
165
|
__END__
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
module PVN
|
5
|
+
class DiffCount
|
6
|
+
attr_reader :from
|
7
|
+
attr_reader :to
|
8
|
+
|
9
|
+
def initialize from = 0, to = 0
|
10
|
+
@from = from
|
11
|
+
@to = to
|
12
|
+
end
|
13
|
+
|
14
|
+
def print name
|
15
|
+
diff = to - from
|
16
|
+
diffpct = diff == 0 ? 0 : 100.0 * diff / from
|
17
|
+
|
18
|
+
printf "%8d %8d %8d %8.1f%% %s\n", from, to, diff, diffpct, name
|
19
|
+
end
|
20
|
+
|
21
|
+
def << diff
|
22
|
+
@from += diff.from
|
23
|
+
@to += diff.to
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -62,17 +62,19 @@ module PVN
|
|
62
62
|
|
63
63
|
def relative_to_absolute rel, path
|
64
64
|
limit = rel[0, 1] == '-' ? rel.to_i.abs : nil
|
65
|
-
|
66
|
-
cmdargs = SVNx::LogCommandArgs.new :limit => limit, :path => path, :use_cache => false
|
67
|
-
|
68
|
-
cmd = SVNx::LogCommand.new cmdargs
|
69
|
-
xmllines = cmd.execute
|
65
|
+
xmllines = run_log_command limit, path
|
70
66
|
|
71
67
|
reventry = PVN::Revision::Entry.new :value => rel, :xmllines => xmllines
|
72
68
|
revval = reventry.value.to_s
|
73
69
|
revval
|
74
70
|
end
|
75
71
|
|
72
|
+
def run_log_command limit, path
|
73
|
+
cmdargs = SVNx::LogCommandArgs.new :limit => limit, :path => path, :use_cache => false
|
74
|
+
cmd = SVNx::LogCommand.new cmdargs
|
75
|
+
cmd.execute
|
76
|
+
end
|
77
|
+
|
76
78
|
def entry
|
77
79
|
end
|
78
80
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/io/element'
|
5
|
+
require 'pvn/subcommands/base/command'
|
6
|
+
require 'pvn/subcommands/status/options'
|
7
|
+
require 'pvn/status/formatter/entries_formatter'
|
8
|
+
|
9
|
+
module PVN::Subcommands::Status
|
10
|
+
class Command < PVN::Subcommands::Base::Command
|
11
|
+
|
12
|
+
DEFAULT_LIMIT = 15
|
13
|
+
|
14
|
+
subcommands [ "status" ]
|
15
|
+
description "Prints the status for locally changed files."
|
16
|
+
usage "[OPTIONS] FILE..."
|
17
|
+
summary [ "Prints the status for the given files, with colorized",
|
18
|
+
"output, and names sorted."
|
19
|
+
]
|
20
|
+
|
21
|
+
optscls
|
22
|
+
|
23
|
+
example "pvn status foo.rb", "Prints the status of foo.rb."
|
24
|
+
example "pvn status", "Prints the status for locally changed files."
|
25
|
+
example "pvn status --no-color", "Prints the status, uncolorized, for locally changed files."
|
26
|
+
|
27
|
+
def initialize options = nil
|
28
|
+
return unless options
|
29
|
+
|
30
|
+
# do we support multiple paths?
|
31
|
+
path = options.paths[0] || '.'
|
32
|
+
|
33
|
+
elmt = PVN::IO::Element.new :local => path || '.'
|
34
|
+
entries = elmt.find_files_by_status
|
35
|
+
|
36
|
+
entries = entries.sort_by { |n| n.path }
|
37
|
+
|
38
|
+
fmtr = PVN::Status::EntriesFormatter.new options.color, entries
|
39
|
+
puts fmtr.format
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/subcommands/base/options'
|
5
|
+
require 'pvn/subcommands/base/color_option'
|
6
|
+
|
7
|
+
module PVN::Subcommands::Status
|
8
|
+
class OptionSet < PVN::Subcommands::Base::OptionSet
|
9
|
+
has_option :color, PVN::Subcommands::Base::ColorOption
|
10
|
+
has_option :help, PVN::Subcommands::Base::HelpOption
|
11
|
+
|
12
|
+
def paths
|
13
|
+
unprocessed
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/svnx/info/command.rb
CHANGED
@@ -11,8 +11,22 @@ module SVNx
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class InfoCommandArgs < CommandArgs
|
14
|
+
attr_reader :revision
|
15
|
+
|
16
|
+
def initialize args = Hash.new
|
17
|
+
@revision = args[:revision]
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
14
21
|
def to_a
|
15
22
|
ary = Array.new
|
23
|
+
|
24
|
+
if @revision
|
25
|
+
@revision.each do |rev|
|
26
|
+
ary << "-r#{rev}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
16
30
|
if @path
|
17
31
|
ary << @path
|
18
32
|
end
|
data/lib/svnx/log/entry.rb
CHANGED
File without changes
|
@@ -4,6 +4,7 @@
|
|
4
4
|
require 'pvn/log/tc'
|
5
5
|
require 'svnx/log/entries'
|
6
6
|
require 'pvn/io/element'
|
7
|
+
require 'resources'
|
7
8
|
|
8
9
|
module PVN::IO::IOElement
|
9
10
|
class LogTestCase ###$$$ < PVN::Log::TestCase
|
@@ -25,11 +26,11 @@ module PVN::IO::IOElement
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_options_none
|
28
|
-
assert_log_command 163,
|
29
|
+
assert_log_command 163, Resources::WIQTR_PATH
|
29
30
|
end
|
30
31
|
|
31
32
|
def test_option_limit
|
32
|
-
assert_log_command 15,
|
33
|
+
assert_log_command 15, Resources::WIQTR_PATH, :limit => 15
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -12,7 +12,7 @@ module PVN; module Log; end; end
|
|
12
12
|
|
13
13
|
module PVN::Log
|
14
14
|
class EntryFormatTestCase < PVN::TestCase
|
15
|
-
TEST_LINES = Resources.
|
15
|
+
TEST_LINES = Resources::WIQTR_LOG_L_15_V.readlines
|
16
16
|
ENTRIES = SVNx::Log::Entries.new :xmllines => TEST_LINES
|
17
17
|
|
18
18
|
def show_all entries, from_head, from_tail
|
@@ -10,7 +10,7 @@ require 'resources'
|
|
10
10
|
module PVN::Revision
|
11
11
|
class TestCase < PVN::TestCase
|
12
12
|
def setup
|
13
|
-
@xmllines = Resources.
|
13
|
+
@xmllines = Resources::WIQTR_LOG_POM_XML.readlines
|
14
14
|
end
|
15
15
|
|
16
16
|
def assert_revision_entry exp_value, value
|
@@ -18,6 +18,12 @@ module PVN::Revision
|
|
18
18
|
assert_equal exp_value, rev.value
|
19
19
|
end
|
20
20
|
|
21
|
+
def assert_revision_entry_raises value
|
22
|
+
assert_raises(PVN::Revision::RevisionError) do
|
23
|
+
assert_revision_entry nil, value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
21
27
|
def test_absolute_midrange
|
22
28
|
assert_revision_entry 733, 733
|
23
29
|
end
|
@@ -62,9 +68,7 @@ module PVN::Revision
|
|
62
68
|
end
|
63
69
|
|
64
70
|
def test_negative_too_far_back
|
65
|
-
|
66
|
-
assert_revision_entry nil, -35
|
67
|
-
end
|
71
|
+
assert_revision_entry_raises -35
|
68
72
|
end
|
69
73
|
|
70
74
|
def test_negative_most_recent_as_string
|
@@ -80,9 +84,7 @@ module PVN::Revision
|
|
80
84
|
end
|
81
85
|
|
82
86
|
def test_negative_too_far_back_as_string
|
83
|
-
|
84
|
-
assert_revision_entry nil, '-35'
|
85
|
-
end
|
87
|
+
assert_revision_entry_raises '-35'
|
86
88
|
end
|
87
89
|
|
88
90
|
def test_positive_most_recent
|
@@ -98,9 +100,7 @@ module PVN::Revision
|
|
98
100
|
end
|
99
101
|
|
100
102
|
def test_positive_too_far_forward
|
101
|
-
|
102
|
-
assert_revision_entry nil, '+35'
|
103
|
-
end
|
103
|
+
assert_revision_entry_raises '+35'
|
104
104
|
end
|
105
105
|
|
106
106
|
def xxxtest_range_svn_word_to_number
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'tc'
|
5
5
|
require 'pvn/subcommands/log/options'
|
6
|
+
require 'resources'
|
6
7
|
|
7
8
|
module PVN; module App; module Log; end; end; end
|
8
9
|
|
@@ -19,6 +20,14 @@ module PVN::App::Log
|
|
19
20
|
assert_equal exppaths, options.paths
|
20
21
|
end
|
21
22
|
|
23
|
+
def run_revision_test arg, *rev
|
24
|
+
expdata = Hash.new
|
25
|
+
expdata[:limit] = nil
|
26
|
+
expdata[:revision] = rev
|
27
|
+
expdata[:path] = Resources::WIQTR_PATH
|
28
|
+
assert_options expdata, [ arg, Resources::WIQTR_PATH ].flatten
|
29
|
+
end
|
30
|
+
|
22
31
|
def test_default
|
23
32
|
expdata = Hash.new
|
24
33
|
expdata[:limit] = 5
|
@@ -43,43 +52,15 @@ module PVN::App::Log
|
|
43
52
|
end
|
44
53
|
|
45
54
|
def test_revision_single
|
46
|
-
|
47
|
-
expdata[:limit] = nil
|
48
|
-
expdata[:revision] = [ '500' ]
|
49
|
-
expdata[:path] = '/Programs/wiquery/trunk'
|
50
|
-
assert_options expdata, %w{ -r500 /Programs/wiquery/trunk }
|
55
|
+
run_revision_test '-r500', '500'
|
51
56
|
end
|
52
57
|
|
53
58
|
def test_revision_multi
|
54
|
-
|
55
|
-
expdata[:limit] = nil
|
56
|
-
expdata[:revision] = [ '500:600' ]
|
57
|
-
expdata[:path] = '/Programs/wiquery/trunk'
|
58
|
-
assert_options expdata, %w{ -r500:600 /Programs/wiquery/trunk }
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_revision_relative
|
62
|
-
expdata = Hash.new
|
63
|
-
expdata[:limit] = nil
|
64
|
-
expdata[:revision] = [ '1944' ]
|
65
|
-
expdata[:path] = '/Programs/wiquery/trunk'
|
66
|
-
assert_options expdata, %w{ -5 /Programs/wiquery/trunk }
|
59
|
+
run_revision_test '-r500:600', '500:600'
|
67
60
|
end
|
68
61
|
|
69
62
|
def test_revisions_single
|
70
|
-
|
71
|
-
expdata[:limit] = nil
|
72
|
-
expdata[:revision] = [ '1', '3' ]
|
73
|
-
expdata[:path] = '/Programs/wiquery/trunk'
|
74
|
-
assert_options expdata, %w{ -r1 -r3 /Programs/wiquery/trunk }
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_revisions_relative
|
78
|
-
expdata = Hash.new
|
79
|
-
expdata[:limit] = nil
|
80
|
-
expdata[:revision] = [ '1944', '1848' ]
|
81
|
-
expdata[:path] = '/Programs/wiquery/trunk'
|
82
|
-
assert_options expdata, %w{ -5 -10 /Programs/wiquery/trunk }
|
63
|
+
run_revision_test %w{ -r1 -r3 }, '1', '3'
|
83
64
|
end
|
84
65
|
end
|
85
66
|
end
|
@@ -3,25 +3,26 @@
|
|
3
3
|
|
4
4
|
require 'tc'
|
5
5
|
require 'pvn/subcommands/revision/multiple_revisions_option'
|
6
|
+
require 'pvn/subcommands/revision/tc'
|
6
7
|
|
7
8
|
module PVN
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
class MockMultipleRevisionsRegexpOption < MultipleRevisionsRegexpOption
|
10
|
+
include MockBaseRevisionOption
|
11
|
+
end
|
12
|
+
|
13
|
+
class MultipleRevisionsRegexpOptionTestCase < BaseRevisionOptionTestCase
|
14
|
+
def create_option
|
15
|
+
PVN::MockMultipleRevisionsRegexpOption.new
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
ropt = PVN::MultipleRevisionsRegexpOption.new
|
18
|
+
def set_value opt, vals
|
19
19
|
vals.each do |val|
|
20
|
-
|
20
|
+
opt.set_value val
|
21
21
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_out_of_range
|
25
|
+
assert_revision_option_raises '-164'
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_post_process_single_middling
|
@@ -52,14 +53,6 @@ module PVN
|
|
52
53
|
assert_post_process [ '1944', '7' ], [ '-5', '-r7' ]
|
53
54
|
end
|
54
55
|
|
55
|
-
def assert_process exp, args, path = '/Programs/wiquery/trunk'
|
56
|
-
ropt = PVN::MultipleRevisionsRegexpOption.new
|
57
|
-
ropt.process args
|
58
|
-
ropt.post_process nil, [ path ]
|
59
|
-
act = ropt.value
|
60
|
-
assert_equal exp, act, "args: #{args}; path: #{path}"
|
61
|
-
end
|
62
|
-
|
63
56
|
def test_process_tag_value
|
64
57
|
assert_process %w{ 317 }, %w{ -r 317 }
|
65
58
|
end
|
@@ -3,12 +3,27 @@
|
|
3
3
|
|
4
4
|
require 'tc'
|
5
5
|
require 'pvn/subcommands/revision/revision_option'
|
6
|
+
require 'pvn/subcommands/revision/tc'
|
7
|
+
require 'resources'
|
6
8
|
|
7
9
|
module PVN
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
class MockRevisionOption < RevisionOption
|
11
|
+
include MockBaseRevisionOption
|
12
|
+
end
|
13
|
+
|
14
|
+
class RevisionOptionTestCase < BaseRevisionOptionTestCase
|
15
|
+
def create_option
|
16
|
+
PVN::MockRevisionOption.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_value opt, val
|
20
|
+
opt.set_value val
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_relative_to_absolute exp, val
|
24
|
+
ropt = MockRevisionOption.new
|
25
|
+
act = ropt.relative_to_absolute val, Resources::WIQTR_PATH
|
26
|
+
info "act: #{act}".cyan
|
12
27
|
assert_equal exp, act, "val: #{val}; path: #{val}"
|
13
28
|
end
|
14
29
|
|
@@ -25,19 +40,11 @@ module PVN
|
|
25
40
|
end
|
26
41
|
|
27
42
|
def test_out_of_range
|
28
|
-
assert_raises(
|
43
|
+
assert_raises(PVN::Revision::RevisionError) do
|
29
44
|
assert_relative_to_absolute '1944', '-164'
|
30
45
|
end
|
31
46
|
end
|
32
47
|
|
33
|
-
def assert_post_process exp, val, path = '/Programs/wiquery/trunk'
|
34
|
-
ropt = PVN::RevisionOption.new
|
35
|
-
ropt.set_value val
|
36
|
-
ropt.post_process nil, [ path ]
|
37
|
-
act = ropt.value
|
38
|
-
assert_equal exp, act, "val: #{val}; path: #{path}"
|
39
|
-
end
|
40
|
-
|
41
48
|
def test_post_process_absolute_middling
|
42
49
|
assert_post_process '1887', '1887'
|
43
50
|
end
|