pvn 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +38 -0
- data/bin/pvn +12 -0
- data/bin/pvndiff +10 -0
- data/lib/pvn/app.rb +144 -0
- data/lib/pvn/base/textlines.rb +35 -0
- data/lib/pvn/base/util.rb +14 -0
- data/lib/pvn/cmddoc.rb +77 -0
- data/lib/pvn/config.rb +65 -0
- data/lib/pvn/describe.rb +40 -0
- data/lib/pvn/diff/diffcmd.rb +49 -0
- data/lib/pvn/diff/differ.rb +67 -0
- data/lib/pvn/diff/diffopts.rb +58 -0
- data/lib/pvn/doc.rb +34 -0
- data/lib/pvn/io/element.rb +113 -0
- data/lib/pvn/io/fselement.rb +22 -0
- data/lib/pvn/log/formatter/color_formatter.rb +29 -0
- data/lib/pvn/log/formatter/entries_formatter.rb +33 -0
- data/lib/pvn/log/formatter/entry_formatter.rb +57 -0
- data/lib/pvn/log/formatter/log_formatter.rb +59 -0
- data/lib/pvn/log/formatter/message_formatter.rb +19 -0
- data/lib/pvn/log/formatter/path_formatter.rb +41 -0
- data/lib/pvn/log/formatter/summary_formatter.rb +49 -0
- data/lib/pvn/log/logcmd.rb +136 -0
- data/lib/pvn/log/logentry.rb +116 -0
- data/lib/pvn/log/logfactory.rb +101 -0
- data/lib/pvn/log/logoptions.rb +43 -0
- data/lib/pvn/pct/linecount.rb +33 -0
- data/lib/pvn/pct/pctcmd.rb +204 -0
- data/lib/pvn/pct/statcmd.rb +13 -0
- data/lib/pvn/revision/entry.rb +94 -0
- data/lib/pvn/revision.rb +119 -0
- data/lib/pvn/subcommands/base/clargs.rb +53 -0
- data/lib/pvn/subcommands/base/command.rb +60 -0
- data/lib/pvn/subcommands/base/doc.rb +94 -0
- data/lib/pvn/subcommands/base/options.rb +22 -0
- data/lib/pvn/subcommands/log/command.rb +70 -0
- data/lib/pvn/subcommands/log/options.rb +43 -0
- data/lib/pvn/subcommands/pct/clargs.rb +33 -0
- data/lib/pvn/subcommands/pct/command.rb +57 -0
- data/lib/pvn/subcommands/revision/multiple_revisions_option.rb +43 -0
- data/lib/pvn/subcommands/revision/revision_option.rb +74 -0
- data/lib/pvn/subcommands/revision/revision_regexp_option.rb +39 -0
- data/lib/pvn/svn/command/svncmd.rb +39 -0
- data/lib/pvn/svn/environment.rb +23 -0
- data/lib/pvn/svn/svnelement.rb +89 -0
- data/lib/pvn/svn/svninfo.rb +42 -0
- data/lib/pvn/svn/svnroot.rb +29 -0
- data/lib/pvn/upp/uppcmd.rb +112 -0
- data/lib/pvn/wherecmd.rb +55 -0
- data/lib/pvn.rb +8 -0
- data/lib/svnx/command.rb +60 -0
- data/lib/svnx/entry.rb +34 -0
- data/lib/svnx/info/command.rb +21 -0
- data/lib/svnx/info/entries.rb +27 -0
- data/lib/svnx/info/entry.rb +34 -0
- data/lib/svnx/log/command.rb +93 -0
- data/lib/svnx/log/entries.rb +57 -0
- data/lib/svnx/log/entry.rb +54 -0
- data/lib/svnx/status/command.rb +21 -0
- data/lib/svnx/status/entries.rb +22 -0
- data/lib/svnx/status/entry.rb +33 -0
- data/lib/synoption/base_option.rb +149 -0
- data/lib/synoption/boolean_option.rb +21 -0
- data/lib/synoption/doc.rb +81 -0
- data/lib/synoption/fixnum_option.rb +13 -0
- data/lib/synoption/match.rb +47 -0
- data/lib/synoption/option.rb +10 -0
- data/lib/synoption/optionable.rb +66 -0
- data/lib/synoption/set.rb +114 -0
- data/lib/system/cachecmd.rb +65 -0
- data/lib/system/cmdexec.rb +13 -0
- data/lib/system/cmdline.rb +70 -0
- data/lib/system/command/arg.rb +12 -0
- data/lib/system/command/cachefile.rb +39 -0
- data/lib/system/command/caching.rb +36 -0
- data/lib/system/command/line.rb +47 -0
- data/lib/system/command.rb +72 -0
- data/test/integration/svnx/log/test.rb +43 -0
- data/test/unit/pvn/app_test.rb +22 -0
- data/test/unit/pvn/io/element/log/log_test.rb +35 -0
- data/test/unit/pvn/log/formatter/entry_formatter_test.rb +90 -0
- data/test/unit/pvn/revision/entry_test.rb +123 -0
- data/test/unit/pvn/subcommands/log/command_test.rb +22 -0
- data/test/unit/pvn/subcommands/log/options_test.rb +85 -0
- data/test/unit/pvn/subcommands/revision/multiple_revisions_option_test.rb +67 -0
- data/test/unit/pvn/subcommands/revision/revision_option_test.rb +57 -0
- data/test/unit/pvn/subcommands/revision/revision_regexp_option_test.rb +69 -0
- data/test/unit/svnx/info/entry_test.rb +52 -0
- data/test/unit/svnx/log/cmargs_test.rb +22 -0
- data/test/unit/svnx/log/entries_test.rb +73 -0
- data/test/unit/svnx/log/entry_test.rb +21 -0
- data/test/unit/svnx/status/entry_test.rb +39 -0
- data/test/unit/synoption/base_option_test.rb +182 -0
- data/test/unit/synoption/match_test.rb +61 -0
- data/test/unit/synoption/option_test.rb +15 -0
- data/test/unit/synoption/set_test.rb +37 -0
- data/test/unit/system/command/caching_test.rb +97 -0
- data/test/unit/system/command/line_test.rb +33 -0
- metadata +199 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'system/command/line'
|
5
|
+
|
6
|
+
module System
|
7
|
+
class CacheFile
|
8
|
+
include Loggable
|
9
|
+
|
10
|
+
def initialize cache_dir, args
|
11
|
+
# pwd = Pathname.pwd.split_path.join('')
|
12
|
+
# info "pwd: #{pwd}"
|
13
|
+
@args = args
|
14
|
+
@pn = Pathname.new(cache_dir) + args.join('-').gsub('/', '\/')
|
15
|
+
info "pn: #{@pn}".yellow
|
16
|
+
end
|
17
|
+
|
18
|
+
def readlines
|
19
|
+
if @pn.exist?
|
20
|
+
info "reading from cache file: #{@pn}".cyan
|
21
|
+
@pn.readlines
|
22
|
+
else
|
23
|
+
cl = CommandLine.new @args
|
24
|
+
output = cl.execute
|
25
|
+
|
26
|
+
@pn.parent.mkpath
|
27
|
+
info "saving output to cache file: #{@pn}"
|
28
|
+
File.put_via_temp_file @pn.to_s do
|
29
|
+
output
|
30
|
+
end
|
31
|
+
output
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
@pn.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'system/command/line'
|
5
|
+
require 'system/command/cachefile'
|
6
|
+
|
7
|
+
module System
|
8
|
+
class CachingCommandLine < CommandLine
|
9
|
+
# caches its input and values.
|
10
|
+
@@cache_dir = '/tmp' + Pathname.new($0).expand_path
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def cache_dir
|
14
|
+
@@cache_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
def cache_dir= dir
|
18
|
+
@@cache_dir = dir
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def cache_dir
|
23
|
+
@@cache_dir
|
24
|
+
end
|
25
|
+
|
26
|
+
def cache_file
|
27
|
+
pwd = Pathname.pwd.split_path.join('')
|
28
|
+
CacheFile.new cache_dir, @args
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute
|
32
|
+
cachefile = cache_file
|
33
|
+
@output = cachefile.readlines
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'system/command/arg'
|
5
|
+
require 'open3'
|
6
|
+
|
7
|
+
module System
|
8
|
+
class CommandLine
|
9
|
+
include Loggable
|
10
|
+
|
11
|
+
attr_reader :output
|
12
|
+
|
13
|
+
def initialize args = Array.new
|
14
|
+
@args = args.dup
|
15
|
+
end
|
16
|
+
|
17
|
+
def << arg
|
18
|
+
# @args << Argument.new(arg)
|
19
|
+
@args << arg
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute
|
23
|
+
cmd = to_command
|
24
|
+
|
25
|
+
# cmd << " 2>&1"
|
26
|
+
|
27
|
+
# I want to use popen3, but the version that works (sets $?) is in 1.9.x,
|
28
|
+
# not 1.8.x:
|
29
|
+
IO.popen(cmd + " 2>&1") do |io|
|
30
|
+
@output = io.readlines
|
31
|
+
end
|
32
|
+
|
33
|
+
if $? && $?.exitstatus != 0
|
34
|
+
info "cmd: #{cmd}".red
|
35
|
+
info "$?: #{$?.inspect}".red
|
36
|
+
info "$?.exitstatus: #{$? && $?.exitstatus}".red
|
37
|
+
raise "ERROR running command '#{cmd}': #{@output[-1]}"
|
38
|
+
end
|
39
|
+
|
40
|
+
@output
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_command
|
44
|
+
@args.join ' '
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'system/cmdexec'
|
5
|
+
require 'synoption/optionable'
|
6
|
+
require 'pvn/subcommands/revision/revision_option'
|
7
|
+
|
8
|
+
module PVN
|
9
|
+
class Command
|
10
|
+
include Optionable
|
11
|
+
include Loggable
|
12
|
+
|
13
|
+
def self.has_revision_option revopts = Hash.new
|
14
|
+
options << RevisionRegexpOption.new(revopts)
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :output
|
18
|
+
|
19
|
+
def initialize args = Hash.new
|
20
|
+
debug "args: #{args}"
|
21
|
+
@execute = args[:execute].nil? || args[:execute]
|
22
|
+
@executor = args[:executor] || CommandExecutor.new
|
23
|
+
|
24
|
+
if options
|
25
|
+
options.process self, args, args[:command_args] || Array.new
|
26
|
+
end
|
27
|
+
|
28
|
+
execute
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_command_line args
|
32
|
+
fullcmdargs = options.to_command_line + options.arguments
|
33
|
+
info "fullcmdargs: #{fullcmdargs}"
|
34
|
+
|
35
|
+
fullcmdargs
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute
|
39
|
+
# see SVNCommand#execute
|
40
|
+
raise "abstract method invoked"
|
41
|
+
end
|
42
|
+
|
43
|
+
def command
|
44
|
+
raise "abstract method invoked"
|
45
|
+
end
|
46
|
+
|
47
|
+
def run args
|
48
|
+
info "self.class: #{self.class}"
|
49
|
+
info "@command : #{command}"
|
50
|
+
info "@execute : #{@execute}"
|
51
|
+
|
52
|
+
if @execute
|
53
|
+
info "@executor : #{@executor}"
|
54
|
+
@output = @executor.run command
|
55
|
+
else
|
56
|
+
debug "not executing: #{command}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def option optname
|
61
|
+
self.class.find_option optname
|
62
|
+
end
|
63
|
+
|
64
|
+
def has_entries?
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def options
|
69
|
+
# self.class.options
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'integration/tc'
|
5
|
+
require 'svnx/log/tc'
|
6
|
+
require 'svnx/log/command'
|
7
|
+
require 'svnx/log/entry'
|
8
|
+
|
9
|
+
module SVNx::Log
|
10
|
+
class EntryTestCase < PVN::IntegrationTestCase
|
11
|
+
include Loggable
|
12
|
+
|
13
|
+
def assert_log_entry_equals entry, expdata
|
14
|
+
assert_equal expdata[0], entry.revision
|
15
|
+
assert_equal expdata[1], entry.author
|
16
|
+
assert_equal expdata[2], entry.date
|
17
|
+
assert_equal expdata[3], entry.message
|
18
|
+
entry.paths.each_with_index do |path, idx|
|
19
|
+
info path.inspect.yellow
|
20
|
+
assert_equal expdata[4 + idx][:kind], path.kind
|
21
|
+
assert_equal expdata[4 + idx][:action], path.action
|
22
|
+
assert_equal expdata[4 + idx][:name], path.name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_entry_from_command
|
27
|
+
lcargs = LogCommandArgs.new :limit => 2, :verbose => false, :use_cache => false
|
28
|
+
lc = LogCommand.new lcargs
|
29
|
+
|
30
|
+
lc.execute
|
31
|
+
output = lc.output
|
32
|
+
info "output: #{output}"
|
33
|
+
|
34
|
+
expdata = '1947', 'reiern70', '2011-11-14T12:24:45.757124Z', 'added a convenience method to set the range'
|
35
|
+
expdata << { :kind => 'file', :action => 'M', :name => '/trunk/wiquery-jquery-ui/src/test/java/org/odlabs/wiquery/ui/slider/SliderTestCase.java' }
|
36
|
+
|
37
|
+
doc = REXML::Document.new output.join('')
|
38
|
+
|
39
|
+
entry = Entry.new :xmlelement => doc.elements[1].elements[2]
|
40
|
+
assert_log_entry_equals entry, expdata
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'tc'
|
2
|
+
require 'pvn/app'
|
3
|
+
|
4
|
+
class TestPVNCli < PVN::TestCase
|
5
|
+
def setup
|
6
|
+
PVN::App::Runner.execute @stdout_io = StringIO.new, Array.new
|
7
|
+
@stdout_io.rewind
|
8
|
+
@stdout = @stdout_io.read
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_print_default_output
|
12
|
+
# assert_match(/To update this executable/, @stdout)
|
13
|
+
end
|
14
|
+
|
15
|
+
def xxx_test_help
|
16
|
+
io = StringIO.new
|
17
|
+
PVN::App::Runner.execute io, %w{ --help }
|
18
|
+
io.rewind
|
19
|
+
io = io.read
|
20
|
+
# assert_match(/To update this executable/, io)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/log/tc'
|
5
|
+
require 'svnx/log/entries'
|
6
|
+
require 'pvn/io/element'
|
7
|
+
|
8
|
+
module PVN::IO::IOElement
|
9
|
+
class LogTestCase ###$$$ < PVN::Log::TestCase
|
10
|
+
def assert_log_entries_size expsize, dirlog
|
11
|
+
assert_equal expsize, dirlog.entries.size
|
12
|
+
end
|
13
|
+
|
14
|
+
def assert_log_command exp_n_entries, localpath, args = Hash.new
|
15
|
+
dir = PVN::IO::Element.new :local => localpath
|
16
|
+
cmdargs = SVNx::LogCommandArgs.new args
|
17
|
+
|
18
|
+
dirlog = dir.log cmdargs
|
19
|
+
# info "dirlog: #{dirlog}".yellow
|
20
|
+
dirlog.entries.each do |entry|
|
21
|
+
# info "entry: #{entry}".blue
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_log_entries_size exp_n_entries, dirlog
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_options_none
|
28
|
+
assert_log_command 163, '/Programs/wiquery/trunk'
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_option_limit
|
32
|
+
assert_log_command 15, '/Programs/wiquery/trunk', :limit => 15
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'svnx/log/entries'
|
6
|
+
require 'pvn/io/element'
|
7
|
+
require 'pvn/log/formatter/entry_formatter'
|
8
|
+
|
9
|
+
require 'resources'
|
10
|
+
|
11
|
+
module PVN; module Log; end; end
|
12
|
+
|
13
|
+
module PVN::Log
|
14
|
+
class EntryFormatTestCase < PVN::TestCase
|
15
|
+
TEST_LINES = Resources.instance.test_lines '/Programs/wiquery/trunk', "svn", "log", "-l", "15", "-v", "--xml"
|
16
|
+
ENTRIES = SVNx::Log::Entries.new :xmllines => TEST_LINES
|
17
|
+
|
18
|
+
def show_all entries, from_head, from_tail
|
19
|
+
ef = EntriesFormatter.new true, entries, from_head, from_tail
|
20
|
+
puts ef.format
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_format explines, entry, use_colors, idx, from_head, from_tail, total
|
24
|
+
ef = EntryFormatter.new use_colors, entry, idx, from_head, from_tail, total
|
25
|
+
|
26
|
+
fmtlines = ef.format
|
27
|
+
assert_equal explines, fmtlines
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_colors_from_head_not_from_tail_index_0
|
31
|
+
entries = ENTRIES
|
32
|
+
explines = [
|
33
|
+
"\e[1m1950\e[0m \e[1m-1\e[0m \e[36m\e[1mjpace\e[0m\e[0m \e[35m\e[1m2011-12-05T12:41:52.385786Z\e[0m\e[0m",
|
34
|
+
"",
|
35
|
+
"\e[37mTesting.\e[0m",
|
36
|
+
"",
|
37
|
+
" \e[33m/trunk/buildNumber.properties\e[0m"
|
38
|
+
]
|
39
|
+
assert_format explines, entries[0], true, 0, true, false, 15
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_colors_from_head_not_from_tail_index_4
|
43
|
+
entries = ENTRIES
|
44
|
+
explines = [
|
45
|
+
"\e[1m1950\e[0m \e[1m-5\e[0m \e[36m\e[1mjpace\e[0m\e[0m \e[35m\e[1m2011-12-05T12:41:52.385786Z\e[0m\e[0m",
|
46
|
+
"",
|
47
|
+
"\e[37mTesting.\e[0m",
|
48
|
+
"",
|
49
|
+
" \e[33m/trunk/buildNumber.properties\e[0m"
|
50
|
+
]
|
51
|
+
assert_format explines, entries[0], true, 4, true, false, 15
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_no_colors_from_head_from_tail_index_4
|
55
|
+
entries = ENTRIES
|
56
|
+
explines = [
|
57
|
+
"1950 -5 +10 jpace 2011-12-05T12:41:52.385786Z",
|
58
|
+
"",
|
59
|
+
"Testing.",
|
60
|
+
"",
|
61
|
+
" /trunk/buildNumber.properties"
|
62
|
+
]
|
63
|
+
assert_format explines, entries[0], false, 4, true, true, 15
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_colors_from_head_from_tail_index_4
|
67
|
+
entries = ENTRIES
|
68
|
+
explines = [
|
69
|
+
"\e[1m1950\e[0m \e[1m-5\e[0m \e[1m+10\e[0m \e[36m\e[1mjpace\e[0m\e[0m \e[35m\e[1m2011-12-05T12:41:52.385786Z\e[0m\e[0m",
|
70
|
+
"",
|
71
|
+
"\e[37mTesting.\e[0m",
|
72
|
+
"",
|
73
|
+
" \e[33m/trunk/buildNumber.properties\e[0m"
|
74
|
+
]
|
75
|
+
assert_format explines, entries[0], true, 4, true, true, 15
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_no_colors_from_head_not_from_tail_index_4
|
79
|
+
entries = ENTRIES
|
80
|
+
explines = [
|
81
|
+
"1950 -5 jpace 2011-12-05T12:41:52.385786Z",
|
82
|
+
"",
|
83
|
+
"Testing.",
|
84
|
+
"",
|
85
|
+
" /trunk/buildNumber.properties"
|
86
|
+
]
|
87
|
+
assert_format explines, entries[0], false, 4, true, false, 15
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'svnx/log/entries'
|
6
|
+
require 'pvn/revision/entry'
|
7
|
+
|
8
|
+
require 'resources'
|
9
|
+
|
10
|
+
module PVN::Revision
|
11
|
+
class TestCase < PVN::TestCase
|
12
|
+
def setup
|
13
|
+
@xmllines = Resources.instance.test_lines '/Programs/wiquery/trunk', "svn", "log", "--xml", "pom.xml"
|
14
|
+
end
|
15
|
+
|
16
|
+
def assert_revision_entry exp_value, value
|
17
|
+
rev = PVN::Revision::Entry.new :xmllines => @xmllines, :value => value
|
18
|
+
assert_equal exp_value, rev.value
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_absolute_midrange
|
22
|
+
assert_revision_entry 733, 733
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_absolute_most_recent
|
26
|
+
assert_revision_entry 1907, 1907
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_absolute_least_recent
|
30
|
+
assert_revision_entry 412, 412
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_absolute_midrange_as_string
|
34
|
+
assert_revision_entry 733, '733'
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_absolute_most_recent_as_string
|
38
|
+
assert_revision_entry 1907, '1907'
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_absolute_least_recent_as_string
|
42
|
+
assert_revision_entry 412, '412'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_svn_word
|
46
|
+
assert_revision_entry 'HEAD', 'HEAD'
|
47
|
+
%w{ HEAD BASE COMMITTED PREV }.each do |word|
|
48
|
+
assert_revision_entry word, word
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_negative_most_recent
|
53
|
+
assert_revision_entry 1907, -1
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_negative_second_most_recent
|
57
|
+
assert_revision_entry 1887, -2
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_negative_least_recent
|
61
|
+
assert_revision_entry 412, -34
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_negative_too_far_back
|
65
|
+
assert_raises(RuntimeError) do
|
66
|
+
assert_revision_entry nil, -35
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_negative_most_recent_as_string
|
71
|
+
assert_revision_entry 1907, '-1'
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_negative_second_most_recent_as_string
|
75
|
+
assert_revision_entry 1887, '-2'
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_negative_least_recent_as_string
|
79
|
+
assert_revision_entry 412, '-34'
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_negative_too_far_back_as_string
|
83
|
+
assert_raises(RuntimeError) do
|
84
|
+
assert_revision_entry nil, '-35'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_positive_most_recent
|
89
|
+
assert_revision_entry 1907, '+34'
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_positive_second_most_recent
|
93
|
+
assert_revision_entry 1887, '+33'
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_positive_least_recent
|
97
|
+
assert_revision_entry 412, '+1'
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_positive_too_far_forward
|
101
|
+
assert_raises(RuntimeError) do
|
102
|
+
assert_revision_entry nil, '+35'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def xxxtest_range_svn_word_to_number
|
107
|
+
assert_revision_entry 'BASE:1', 'BASE:1'
|
108
|
+
end
|
109
|
+
|
110
|
+
# def test_end
|
111
|
+
# class File
|
112
|
+
# def initialize args
|
113
|
+
# rev = args[:revision]
|
114
|
+
# reventry = Revision.new name, rev
|
115
|
+
# @revision = reventry.number
|
116
|
+
# end
|
117
|
+
# end
|
118
|
+
|
119
|
+
# dir = PVN::IO::File :name => "pom.xml", :revision => "-3"
|
120
|
+
# assert_equal 190, dir.revision
|
121
|
+
# end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'pvn/subcommands/log/command'
|
6
|
+
|
7
|
+
module PVN; module App; module Log; end; end; end
|
8
|
+
|
9
|
+
module PVN::App::Log
|
10
|
+
class CommandTest < PVN::TestCase
|
11
|
+
|
12
|
+
def test_path
|
13
|
+
PVN::Subcommands::Log::Command.new %w{ /Programs/wiquery/trunk/pom.xml }
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_invalid_path
|
17
|
+
assert_raises(RuntimeError) do
|
18
|
+
PVN::Subcommands::Log::Command.new %w{ /this/doesnt/exist }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'pvn/subcommands/log/options'
|
6
|
+
|
7
|
+
module PVN; module App; module Log; end; end; end
|
8
|
+
|
9
|
+
module PVN::App::Log
|
10
|
+
class OptionsTest < PVN::TestCase
|
11
|
+
def assert_options exp, args
|
12
|
+
options = PVN::Subcommands::Log::OptionSet.new
|
13
|
+
options.process args
|
14
|
+
|
15
|
+
assert_equal exp[:limit], options.limit
|
16
|
+
assert_equal exp[:revision], options.revision
|
17
|
+
|
18
|
+
exppaths = exp[:path] ? [ exp[:path] ] : exp[:paths]
|
19
|
+
assert_equal exppaths, options.paths
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_default
|
23
|
+
expdata = Hash.new
|
24
|
+
expdata[:limit] = 5
|
25
|
+
expdata[:paths] = Array.new
|
26
|
+
assert_options expdata, Array.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_limit
|
30
|
+
expdata = Hash.new
|
31
|
+
expdata[:limit] = 15
|
32
|
+
expdata[:paths] = Array.new
|
33
|
+
assert_options expdata, %w{ --limit 15 }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_help
|
37
|
+
expdata = Hash.new
|
38
|
+
expdata[:limit] = 5
|
39
|
+
expdata[:revision] = nil
|
40
|
+
expdata[:paths] = Array.new
|
41
|
+
expdata[:help] = true
|
42
|
+
assert_options expdata, %w{ --help }
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_revision_single
|
46
|
+
expdata = Hash.new
|
47
|
+
expdata[:limit] = nil
|
48
|
+
expdata[:revision] = [ '500' ]
|
49
|
+
expdata[:path] = '/Programs/wiquery/trunk'
|
50
|
+
assert_options expdata, %w{ -r500 /Programs/wiquery/trunk }
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_revision_multi
|
54
|
+
expdata = Hash.new
|
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 }
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_revisions_single
|
70
|
+
expdata = Hash.new
|
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 }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'pvn/subcommands/revision/multiple_revisions_option'
|
6
|
+
|
7
|
+
module PVN
|
8
|
+
class MultipleRevisionsRegexpOptionTestCase < PVN::TestCase
|
9
|
+
def test_out_of_range
|
10
|
+
assert_raises(RuntimeError) do
|
11
|
+
ropt = PVN::MultipleRevisionsRegexpOption.new
|
12
|
+
ropt.process [ '-164' ]
|
13
|
+
ropt.post_process nil, [ '/Programs/wiquery/trunk' ]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def assert_post_process exp, vals, path = '/Programs/wiquery/trunk'
|
18
|
+
ropt = PVN::MultipleRevisionsRegexpOption.new
|
19
|
+
vals.each do |val|
|
20
|
+
ropt.set_value val
|
21
|
+
end
|
22
|
+
ropt.post_process nil, [ path ]
|
23
|
+
act = ropt.value
|
24
|
+
assert_equal exp, act, "vals: #{vals}; path: #{path}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_post_process_single_middling
|
28
|
+
assert_post_process [ '1887' ], [ '-7' ]
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_post_process_single_latest
|
32
|
+
assert_post_process [ '1950' ], '-1'
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_post_process_single_oldest
|
36
|
+
assert_post_process [ '412' ], '-163'
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_post_process_single_tagval_unconverted
|
40
|
+
assert_post_process [ '7' ], '-r7'
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_post_process_single_tagrange_unconverted
|
44
|
+
assert_post_process [ '7:177' ], '-r7:177'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_post_process_multiple_middling
|
48
|
+
assert_post_process [ '1887', '1950' ], [ '-7', '-1' ]
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_post_process_multiple_relative_tagval_unconverted
|
52
|
+
assert_post_process [ '1944', '7' ], [ '-5', '-r7' ]
|
53
|
+
end
|
54
|
+
|
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
|
+
def test_process_tag_value
|
64
|
+
assert_process %w{ 317 }, %w{ -r 317 }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|