pvn 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/change.rb +50 -0
- data/bin/pvn +8 -4
- data/bin/quote.rb +18 -6
- data/bin/quotes.orig.txt +145 -0
- data/bin/quotes.txt +64 -0
- data/lib/pvn/app/runner.rb +103 -0
- data/lib/pvn/app.rb +1 -142
- data/lib/pvn/{subcommands/base → command}/color_option.rb +1 -1
- data/lib/pvn/{subcommands/base → command}/command.rb +10 -6
- data/lib/pvn/{subcommands/base → command}/doc.rb +2 -2
- data/lib/pvn/{subcommands/base → command}/options.rb +2 -2
- data/lib/pvn/config.rb +14 -1
- data/lib/pvn/{subcommands/diff → diff}/command.rb +6 -6
- data/lib/pvn/diff/differ.rb +60 -44
- data/lib/pvn/diff/local_differ.rb +99 -0
- data/lib/pvn/diff/log_paths.rb +46 -0
- data/lib/pvn/{subcommands/diff → diff}/options.rb +8 -6
- data/lib/pvn/diff/path.rb +52 -0
- data/lib/pvn/diff/path_revision.rb +31 -0
- data/lib/pvn/diff/paths.rb +42 -0
- data/lib/pvn/diff/repository_differ.rb +154 -0
- data/lib/pvn/diff/revision.rb +36 -0
- data/lib/pvn/diff/status_paths.rb +87 -0
- data/lib/pvn/io/element.rb +29 -8
- data/lib/pvn/{subcommands/log → log}/command.rb +4 -4
- data/lib/pvn/log/formatter/log_formatter.rb +1 -1
- data/lib/pvn/{subcommands/log → log}/options.rb +7 -7
- data/lib/pvn/{subcommands/pct → pct}/command.rb +6 -6
- data/lib/pvn/{subcommands/pct → pct}/diffcount.rb +1 -1
- data/lib/pvn/{subcommands/pct → pct}/differ.rb +2 -2
- data/lib/pvn/{subcommands/pct → pct}/local_differ.rb +3 -3
- data/lib/pvn/pct/options.rb +12 -0
- data/lib/pvn/{subcommands/pct → pct}/repository_differ.rb +5 -13
- data/lib/pvn/revision/{entry.rb → argument.rb} +45 -30
- data/lib/pvn/{subcommands/revision → revision}/base_option.rb +2 -2
- data/lib/pvn/revision/error.rb +11 -0
- data/lib/pvn/{subcommands/revision → revision}/multiple_revisions_option.rb +1 -1
- data/lib/pvn/revision/range.rb +49 -0
- data/lib/pvn/{subcommands/revision → revision}/revision_option.rb +1 -8
- data/lib/pvn/{subcommands/revision → revision}/revision_regexp_option.rb +2 -2
- data/lib/pvn/{subcommands/status → status}/command.rb +6 -6
- data/lib/pvn/status/formatter/status_formatter.rb +1 -1
- data/lib/pvn/status/options.rb +12 -0
- data/lib/pvn/{base/util.rb → util/array.rb} +2 -1
- data/lib/pvn.rb +1 -6
- data/lib/svnx/action.rb +52 -0
- data/lib/svnx/entries.rb +9 -1
- data/lib/svnx/log/command.rb +4 -3
- data/lib/svnx/status/entry.rb +30 -13
- data/lib/synoption/base_option.rb +10 -27
- data/lib/synoption/matchers.rb +22 -0
- data/lib/system/command/cachefile.rb +28 -14
- data/lib/system/command.rb +1 -1
- data/test/integration/pvn/diff/command_test.rb +20 -0
- data/test/integration/pvn/diff/local_differ_test.rb +72 -0
- data/test/integration/pvn/diff/log_paths_test.rb +28 -0
- data/test/integration/pvn/diff/repository_differ_test.rb +127 -0
- data/test/integration/pvn/diff/status_paths_test.rb +31 -0
- data/test/integration/pvn/log/command_test.rb +29 -0
- data/test/integration/pvn/pct/command_test.rb +30 -0
- data/test/integration/pvn/status/command_test.rb +26 -0
- data/test/unit/pvn/app_test.rb +7 -5
- data/test/unit/pvn/diff/path_revision_test.rb +45 -0
- data/test/unit/pvn/diff/path_test.rb +38 -0
- data/test/unit/pvn/diff/revision_test.rb +35 -0
- data/test/unit/pvn/io/element/log/log_test.rb +2 -2
- data/test/unit/pvn/log/formatter/entry_formatter_test.rb +40 -29
- data/test/unit/pvn/{subcommands/log → log}/options_test.rb +4 -4
- data/test/unit/pvn/revision/argument_test.rb +157 -0
- data/test/unit/pvn/{subcommands/revision → revision}/multiple_revisions_option_test.rb +10 -11
- data/test/unit/pvn/revision/range_test.rb +26 -0
- data/test/unit/pvn/{subcommands/revision → revision}/revision_option_test.rb +13 -18
- data/test/unit/pvn/{subcommands/revision → revision}/revision_regexp_option_test.rb +8 -10
- data/test/unit/svnx/action_test.rb +67 -0
- data/test/unit/svnx/info/entries_test.rb +10 -10
- data/test/unit/svnx/info/entry_test.rb +7 -10
- data/test/unit/svnx/log/entries_test.rb +31 -29
- data/test/unit/svnx/log/entry_test.rb +3 -7
- data/test/unit/svnx/status/entries_test.rb +7 -6
- data/test/unit/svnx/status/entry_test.rb +2 -23
- data/test/unit/system/command/cachefile_test.rb +53 -0
- data/test/unit/system/command/caching_test.rb +14 -23
- metadata +83 -64
- data/lib/pvn/describe.rb +0 -40
- data/lib/pvn/diff/diffcmd.rb +0 -49
- data/lib/pvn/diff/diffopts.rb +0 -58
- data/lib/pvn/log/logcmd.rb +0 -135
- data/lib/pvn/log/logentry.rb +0 -116
- data/lib/pvn/log/logfactory.rb +0 -101
- data/lib/pvn/log/logoptions.rb +0 -43
- data/lib/pvn/revision.rb +0 -119
- data/lib/pvn/subcommands/diff/differ.rb +0 -65
- data/lib/pvn/subcommands/diff/local_differ.rb +0 -103
- data/lib/pvn/subcommands/diff/repository_differ.rb +0 -145
- data/lib/pvn/subcommands/pct/clargs.rb +0 -33
- data/lib/pvn/subcommands/pct/options.rb +0 -12
- data/lib/pvn/subcommands/status/options.rb +0 -12
- data/lib/pvn/svn/command/svncmd.rb +0 -39
- data/lib/pvn/svn/environment.rb +0 -23
- data/lib/pvn/svn/svnelement.rb +0 -89
- data/lib/pvn/svn/svninfo.rb +0 -42
- data/lib/pvn/svn/svnroot.rb +0 -29
- data/lib/pvn/upp/uppcmd.rb +0 -112
- data/lib/pvn/wherecmd.rb +0 -55
- data/test/integration/pvn/subcommands/diff/command_test.rb +0 -153
- data/test/integration/pvn/subcommands/log/command_test.rb +0 -22
- data/test/integration/svnx/log/test.rb +0 -43
- data/test/unit/pvn/revision/entry_test.rb +0 -110
- /data/lib/pvn/{subcommands/base → command}/clargs.rb +0 -0
- /data/lib/pvn/{base → util}/color_formatter.rb +0 -0
- /data/lib/pvn/{base → util}/textlines.rb +0 -0
data/lib/svnx/action.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'riel'
|
6
|
+
|
7
|
+
module SVNx
|
8
|
+
# $$$ this cries for a little metaprogramming ... tomorrow
|
9
|
+
|
10
|
+
class Action
|
11
|
+
include Loggable, Comparable
|
12
|
+
|
13
|
+
attr_reader :type
|
14
|
+
|
15
|
+
def initialize str
|
16
|
+
@type = case str
|
17
|
+
when 'added', 'A', :added
|
18
|
+
:added
|
19
|
+
when 'deleted', 'D', :deleted
|
20
|
+
:deleted
|
21
|
+
when 'modified', 'M', :modified
|
22
|
+
:modified
|
23
|
+
when 'unversioned', '?', :unversioned
|
24
|
+
:unversioned
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def added?
|
29
|
+
@type == :added
|
30
|
+
end
|
31
|
+
|
32
|
+
def deleted?
|
33
|
+
@type == :deleted
|
34
|
+
end
|
35
|
+
|
36
|
+
def modified?
|
37
|
+
@type == :modified
|
38
|
+
end
|
39
|
+
|
40
|
+
def unversioned?
|
41
|
+
@type == :unversioned
|
42
|
+
end
|
43
|
+
|
44
|
+
def <=> other
|
45
|
+
@type.to_s <=> other.type.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
@type.to_s
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/svnx/entries.rb
CHANGED
@@ -38,8 +38,16 @@ module SVNx
|
|
38
38
|
def create_entry xmlelement
|
39
39
|
end
|
40
40
|
|
41
|
+
# this doesn't handle negative indices
|
41
42
|
def [] idx
|
42
|
-
|
43
|
+
if entry = @entries[idx]
|
44
|
+
return entry
|
45
|
+
end
|
46
|
+
if idx < 0 && idx >= size
|
47
|
+
raise "error: index #{idx} is not in range(0 .. #{size})"
|
48
|
+
end
|
49
|
+
|
50
|
+
@entries[idx] = create_entry(@elements[idx + 1])
|
43
51
|
end
|
44
52
|
|
45
53
|
def each(&blk)
|
data/lib/svnx/log/command.rb
CHANGED
@@ -5,11 +5,12 @@ require 'rubygems'
|
|
5
5
|
require 'riel'
|
6
6
|
require 'system/command/line'
|
7
7
|
require 'system/command/caching'
|
8
|
-
require 'pvn/svn/environment'
|
9
8
|
require 'svnx/command'
|
10
9
|
|
11
10
|
module SVNx
|
12
|
-
|
11
|
+
DEFAULT_CACHE_DIR = '/tmp/svnx'
|
12
|
+
|
13
|
+
TMP_DIR_ENV_VARNAME = 'SVNX_TMP_DIR'
|
13
14
|
|
14
15
|
class LogCommandLine < CommandLine
|
15
16
|
def initialize args = Array.new
|
@@ -25,7 +26,7 @@ module SVNx
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def cache_dir
|
28
|
-
|
29
|
+
ENV[TMP_DIR_ENV_VARNAME] || DEFAULT_CACHE_DIR
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
data/lib/svnx/status/entry.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'svnx/entry'
|
5
|
+
require 'svnx/action'
|
5
6
|
|
6
7
|
module SVNx; module Status; end; end
|
7
8
|
|
@@ -10,27 +11,43 @@ module SVNx::Status
|
|
10
11
|
|
11
12
|
attr_reader :status
|
12
13
|
attr_reader :path
|
14
|
+
attr_reader :status_revision
|
15
|
+
attr_reader :action
|
16
|
+
|
17
|
+
def initialize args = Hash.new
|
18
|
+
super
|
19
|
+
@action = SVNx::Action.new @status
|
20
|
+
end
|
13
21
|
|
14
22
|
def set_from_xml xmldoc
|
15
23
|
stelmt = xmldoc.elements['status']
|
16
24
|
tgt = stelmt.elements['target']
|
17
|
-
|
18
|
-
set_attr_var tgt, 'path'
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
|
26
|
+
set_attr_var tgt, 'path'
|
27
|
+
|
28
|
+
if entry = tgt.elements['entry']
|
29
|
+
set_from_element entry
|
30
|
+
else
|
31
|
+
@status = "unchanged"
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
def set_from_element elmt
|
28
36
|
set_attr_var elmt, 'path'
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
|
38
|
+
wcstatus = elmt.elements['wc-status']
|
39
|
+
@status = wcstatus.attributes['item']
|
40
|
+
@status_revision = wcstatus.attributes['revision']
|
41
|
+
|
42
|
+
if commit = wcstatus.elements['commit']
|
43
|
+
@commit_revision = commit.attributes['revision']
|
44
|
+
else
|
45
|
+
@commit_revision = nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
"path: #{@path}; status: #{@status}"
|
34
51
|
end
|
35
52
|
end
|
36
53
|
end
|
@@ -5,6 +5,7 @@ require 'rubygems'
|
|
5
5
|
require 'riel'
|
6
6
|
require 'synoption/doc'
|
7
7
|
require 'synoption/match'
|
8
|
+
require 'synoption/matchers'
|
8
9
|
|
9
10
|
module PVN
|
10
11
|
class BaseOption
|
@@ -28,16 +29,10 @@ module PVN
|
|
28
29
|
|
29
30
|
@value = @default = default
|
30
31
|
|
31
|
-
@matchers =
|
32
|
-
@matchers[:exact] = OptionExactMatch.new @tag, @name
|
32
|
+
@matchers = Matchers.new @tag, @name, options[:negate], options[:regexp]
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
if @regexp = options[:regexp]
|
39
|
-
@matchers[:regexp] = OptionRegexpMatch.new @regexp
|
40
|
-
end
|
34
|
+
@negate = options[:negate]
|
35
|
+
@regexp = options[:regexp]
|
41
36
|
|
42
37
|
if options.include? :as_cmdline_option
|
43
38
|
if options[:as_cmdline_option].nil?
|
@@ -71,27 +66,15 @@ module PVN
|
|
71
66
|
end
|
72
67
|
|
73
68
|
def exact_match? arg
|
74
|
-
@matchers
|
69
|
+
@matchers.exact.match? arg
|
75
70
|
end
|
76
71
|
|
77
72
|
def negative_match? arg
|
78
|
-
@matchers
|
73
|
+
@matchers.negative and @matchers.negative.match? arg
|
79
74
|
end
|
80
75
|
|
81
76
|
def regexp_match? arg
|
82
|
-
@matchers
|
83
|
-
end
|
84
|
-
|
85
|
-
def match arg
|
86
|
-
return nil unless arg
|
87
|
-
|
88
|
-
@matchers.each do |type, matcher|
|
89
|
-
if matcher.match? arg
|
90
|
-
return [ type, matcher ]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
nil
|
77
|
+
@matchers.regexp and @matchers.regexp.match? arg
|
95
78
|
end
|
96
79
|
|
97
80
|
def unset
|
@@ -117,16 +100,16 @@ module PVN
|
|
117
100
|
end
|
118
101
|
|
119
102
|
def process args
|
120
|
-
if @matchers
|
103
|
+
if @matchers.exact.match? args[0]
|
121
104
|
args.shift
|
122
105
|
val = takes_value? ? next_argument(args) : true
|
123
106
|
set_value val
|
124
107
|
true
|
125
|
-
elsif @matchers
|
108
|
+
elsif @matchers.negative && @matchers.negative.match?(args[0])
|
126
109
|
arg = args.shift
|
127
110
|
set_value false
|
128
111
|
true
|
129
|
-
elsif @matchers
|
112
|
+
elsif @matchers.regexp && (md = @matchers.regexp.match?(args[0]))
|
130
113
|
arg = args.shift
|
131
114
|
set_value md[0]
|
132
115
|
true
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'riel'
|
6
|
+
require 'synoption/match'
|
7
|
+
|
8
|
+
module PVN
|
9
|
+
class Matchers
|
10
|
+
include Loggable
|
11
|
+
|
12
|
+
attr_reader :exact
|
13
|
+
attr_reader :negative
|
14
|
+
attr_reader :regexp
|
15
|
+
|
16
|
+
def initialize tag, name, negate, regexp
|
17
|
+
@exact = OptionExactMatch.new tag, name
|
18
|
+
@negative = negate && OptionNegativeMatch.new(negate)
|
19
|
+
@regexp = regexp && OptionRegexpMatch.new(regexp)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,33 +2,47 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'system/command/line'
|
5
|
+
require 'zlib'
|
5
6
|
|
6
7
|
module System
|
7
8
|
class CacheFile
|
8
9
|
include Loggable
|
10
|
+
|
11
|
+
attr_reader :output
|
9
12
|
|
10
13
|
def initialize cache_dir, args
|
11
|
-
|
12
|
-
# info "pwd: #{pwd}"
|
14
|
+
info "cache_dir: #{cache_dir}"
|
13
15
|
@args = args
|
14
|
-
@pn = Pathname.new(cache_dir) + args.join('-').gsub('/', '
|
15
|
-
info "pn: #{@pn}"
|
16
|
+
@pn = Pathname.new(cache_dir) + (args.join('-').gsub('/', '_slash_') + '.gz')
|
17
|
+
info "pn: #{@pn}"
|
18
|
+
@output = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def save_file
|
22
|
+
@pn.parent.mkpath unless @pn.parent.exist?
|
23
|
+
@pn.unlink if @pn.exist?
|
24
|
+
info "saving output to cache file: #{@pn}"
|
25
|
+
Zlib::GzipWriter.open(@pn.to_s) do |gz|
|
26
|
+
gz.puts @output
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def read_file
|
31
|
+
info "reading from cache file: #{@pn}"
|
32
|
+
Zlib::GzipReader.open(@pn.to_s) do |gz|
|
33
|
+
@output = gz.readlines
|
34
|
+
end
|
35
|
+
@output
|
16
36
|
end
|
17
37
|
|
18
38
|
def readlines
|
19
39
|
if @pn.exist?
|
20
|
-
|
21
|
-
@pn.readlines
|
40
|
+
read_file
|
22
41
|
else
|
23
42
|
cl = CommandLine.new @args
|
24
|
-
output = cl.execute
|
25
|
-
|
26
|
-
@
|
27
|
-
info "saving output to cache file: #{@pn}"
|
28
|
-
File.put_via_temp_file @pn.to_s do
|
29
|
-
output
|
30
|
-
end
|
31
|
-
output
|
43
|
+
@output = cl.execute
|
44
|
+
save_file
|
45
|
+
@output
|
32
46
|
end
|
33
47
|
end
|
34
48
|
|
data/lib/system/command.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'pvn/diff/command'
|
6
|
+
require 'resources'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
Log.level = Log::DEBUG
|
10
|
+
|
11
|
+
module PVN::Diff
|
12
|
+
class CommandTest < PVN::TestCase
|
13
|
+
|
14
|
+
# the tests previously herewith have been moved to local and repository
|
15
|
+
# differ tests.
|
16
|
+
|
17
|
+
def test_nothing
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/diff/local_differ'
|
5
|
+
require 'integration/pvn/diff/differ_tc'
|
6
|
+
|
7
|
+
Log.level = Log::DEBUG
|
8
|
+
|
9
|
+
module PVN::Diff
|
10
|
+
class LocalDifferTestCase < DifferTestCase
|
11
|
+
|
12
|
+
def create_differ opts
|
13
|
+
LocalDiffer.new opts
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_explines comparing_whitespace
|
17
|
+
explines = Array.new
|
18
|
+
|
19
|
+
explines << "Index: FirstFile.txt"
|
20
|
+
explines << "==================================================================="
|
21
|
+
explines << "--- FirstFile.txt (revision 22)"
|
22
|
+
explines << "+++ FirstFile.txt (working copy)"
|
23
|
+
explines << "@@ -1,3 +1,4 @@"
|
24
|
+
explines << " this is the second line of the first file."
|
25
|
+
|
26
|
+
if comparing_whitespace
|
27
|
+
explines << "-third line here."
|
28
|
+
explines << "+ third line here."
|
29
|
+
else
|
30
|
+
explines << " third line here."
|
31
|
+
end
|
32
|
+
|
33
|
+
explines << " fourth line this is."
|
34
|
+
explines << "+this is the fifth line."
|
35
|
+
explines << "Index: SeventhFile.txt"
|
36
|
+
explines << "==================================================================="
|
37
|
+
explines << "--- SeventhFile.txt (revision 0)"
|
38
|
+
explines << "+++ SeventhFile.txt (revision 0)"
|
39
|
+
explines << "@@ -0,0 +1 @@"
|
40
|
+
explines << "+this is the 7th file."
|
41
|
+
explines << "Index: dirzero/SixthFile.txt"
|
42
|
+
explines << "==================================================================="
|
43
|
+
explines << "--- dirzero/SixthFile.txt (revision 22)"
|
44
|
+
explines << "+++ dirzero/SixthFile.txt (working copy)"
|
45
|
+
explines << "@@ -1,2 +0,0 @@"
|
46
|
+
explines << "-line one."
|
47
|
+
explines << "-line two."
|
48
|
+
explines << "Index: src/ruby/dog.rb"
|
49
|
+
explines << "==================================================================="
|
50
|
+
explines << "--- src/ruby/dog.rb (revision 0)"
|
51
|
+
explines << "+++ src/ruby/dog.rb (revision 0)"
|
52
|
+
explines << "@@ -0,0 +1,7 @@"
|
53
|
+
explines << "+#!/usr/bin/ruby -w"
|
54
|
+
explines << "+# -*- ruby -*-"
|
55
|
+
explines << "+"
|
56
|
+
explines << "+require 'rubygems'"
|
57
|
+
explines << "+require 'riel'"
|
58
|
+
explines << "+"
|
59
|
+
explines << "+puts \"hello, world\""
|
60
|
+
|
61
|
+
explines
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_default
|
65
|
+
assert_diff_command %w{ }, get_explines(true)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_no_whitespace
|
69
|
+
assert_diff_command %w{ -w }, get_explines(false)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'integration/pvn/diff/differ_tc'
|
5
|
+
require 'pvn/diff/log_paths'
|
6
|
+
require 'pvn/revision/range'
|
7
|
+
|
8
|
+
module PVN::Diff
|
9
|
+
class LogPathsTestCase < PVN::IntegrationTestCase
|
10
|
+
def assert_log_path exp_name, exp_nrevisions, expurl, logpaths, idx
|
11
|
+
logpath = logpaths[idx]
|
12
|
+
msg = "element[#{idx}]"
|
13
|
+
assert_equal exp_name, logpath.name, msg
|
14
|
+
assert_equal exp_nrevisions, logpath.path_revisions.size, msg
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_revision_to_revision
|
18
|
+
revision = PVN::Revision::Range.new '15', '16'
|
19
|
+
paths = %w{ . }
|
20
|
+
logpaths = LogPaths.new revision, paths
|
21
|
+
assert_equal 3, logpaths.size
|
22
|
+
|
23
|
+
assert_log_path "/SecondFile.txt", 1, nil, logpaths, 0
|
24
|
+
assert_log_path "/src/java/Bravo.java", 1, nil, logpaths, 1
|
25
|
+
assert_log_path "/src/java/Alpha.java", 1, nil, logpaths, 2
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/diff/repository_differ'
|
5
|
+
require 'integration/pvn/diff/differ_tc'
|
6
|
+
|
7
|
+
module PVN::Diff
|
8
|
+
class RepositoryDifferTestCase < DifferTestCase
|
9
|
+
|
10
|
+
def create_differ opts
|
11
|
+
RepositoryDiffer.new opts
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_adds
|
15
|
+
explines = Array.new
|
16
|
+
|
17
|
+
explines << "Index: src/java/Alpha.java"
|
18
|
+
explines << "==================================================================="
|
19
|
+
explines << "--- src/java/Alpha.java (revision 0)"
|
20
|
+
explines << "+++ src/java/Alpha.java (revision 16)"
|
21
|
+
explines << "@@ -0,0 +1,6 @@"
|
22
|
+
explines << "+package org.incava.pvntest;"
|
23
|
+
explines << "+"
|
24
|
+
explines << "+public class Alpha {"
|
25
|
+
explines << "+ public Alpha() {"
|
26
|
+
explines << "+ }"
|
27
|
+
explines << "+}"
|
28
|
+
explines << "Index: src/java/Bravo.java"
|
29
|
+
explines << "==================================================================="
|
30
|
+
explines << "--- src/java/Bravo.java (revision 0)"
|
31
|
+
explines << "+++ src/java/Bravo.java (revision 16)"
|
32
|
+
explines << "@@ -0,0 +1,10 @@"
|
33
|
+
explines << "+/**"
|
34
|
+
explines << "+ * This describes this interface."
|
35
|
+
explines << "+ */"
|
36
|
+
explines << "+interface Bravo "
|
37
|
+
explines << "+{"
|
38
|
+
explines << "+ /**"
|
39
|
+
explines << "+ * This describes this method."
|
40
|
+
explines << "+ */"
|
41
|
+
explines << "+ public int size();"
|
42
|
+
explines << "+}"
|
43
|
+
|
44
|
+
assert_diff_command %w{ -r15:16 }, explines
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_one_add_one_delete
|
48
|
+
explines = Array.new
|
49
|
+
|
50
|
+
explines << "Index: FifthFile.txt"
|
51
|
+
explines << "==================================================================="
|
52
|
+
explines << "--- FifthFile.txt (revision 0)"
|
53
|
+
explines << "+++ FifthFile.txt (revision 7)"
|
54
|
+
explines << "@@ -0,0 +1 @@"
|
55
|
+
explines << "+uno"
|
56
|
+
explines << "Index: SecondFile.txt"
|
57
|
+
explines << "==================================================================="
|
58
|
+
explines << "--- SecondFile.txt (revision 6)"
|
59
|
+
explines << "+++ SecondFile.txt (revision 7)"
|
60
|
+
explines << "@@ -1,4 +0,0 @@"
|
61
|
+
explines << "-line one of file two."
|
62
|
+
explines << "-# file two, line two"
|
63
|
+
explines << "-# line three"
|
64
|
+
explines << "-line four"
|
65
|
+
|
66
|
+
assert_diff_command %w{ -r6:7 }, explines
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_only_changes
|
70
|
+
explines = Array.new
|
71
|
+
|
72
|
+
explines << "Index: FirstFile.txt"
|
73
|
+
explines << "==================================================================="
|
74
|
+
explines << "--- FirstFile.txt (revision 2)"
|
75
|
+
explines << "+++ FirstFile.txt (revision 3)"
|
76
|
+
explines << "@@ -1,2 +1,3 @@"
|
77
|
+
explines << " This is the first line of the first file in the testbed."
|
78
|
+
explines << " This is the second line of the first file."
|
79
|
+
explines << "+Third line here."
|
80
|
+
explines << "Index: SecondFile.txt"
|
81
|
+
explines << "==================================================================="
|
82
|
+
explines << "--- SecondFile.txt (revision 2)"
|
83
|
+
explines << "+++ SecondFile.txt (revision 3)"
|
84
|
+
explines << "@@ -1,2 +1,3 @@"
|
85
|
+
explines << " line one of file two."
|
86
|
+
explines << "+file two, line two"
|
87
|
+
explines << " "
|
88
|
+
|
89
|
+
assert_diff_command %w{ -r2:3 }, explines
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_multiple_changes
|
93
|
+
explines = Array.new
|
94
|
+
|
95
|
+
explines << "Index: FirstFile.txt"
|
96
|
+
explines << "==================================================================="
|
97
|
+
explines << "--- FirstFile.txt (revision 1)"
|
98
|
+
explines << "+++ FirstFile.txt (revision 4)"
|
99
|
+
explines << "@@ -1 +1,3 @@"
|
100
|
+
explines << " This is the first line of the first file in the testbed."
|
101
|
+
explines << "+This is the second line of the first file."
|
102
|
+
explines << "+Third line here."
|
103
|
+
explines << "Index: SecondFile.txt"
|
104
|
+
explines << "==================================================================="
|
105
|
+
explines << "--- SecondFile.txt (revision 0)"
|
106
|
+
explines << "+++ SecondFile.txt (revision 4)"
|
107
|
+
explines << "@@ -0,0 +1,3 @@"
|
108
|
+
explines << "+line one of file two."
|
109
|
+
explines << "+# file two, line two"
|
110
|
+
explines << "+line three"
|
111
|
+
explines << "Index: ThirdFile.tar.gz"
|
112
|
+
explines << "==================================================================="
|
113
|
+
explines << "Binary files ThirdFile.tar.gz (revision 0) and ThirdFile.tar.gz (revision 4) differ"
|
114
|
+
|
115
|
+
assert_diff_command %w{ -r1:4 }, explines
|
116
|
+
end
|
117
|
+
|
118
|
+
# still broken
|
119
|
+
def xxxtest_revision_against_working_copy
|
120
|
+
explines = Array.new
|
121
|
+
|
122
|
+
# -r20 means -r20:working_copy
|
123
|
+
|
124
|
+
assert_diff_command %w{ -r20 src/ruby/charlie.rb }, explines
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/diff/status_paths'
|
5
|
+
require 'pvn/revision/range'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
module PVN::Diff
|
9
|
+
class StatusPathsTestCase < PVN::IntegrationTestCase
|
10
|
+
def assert_status_path exp_name, exp_nrevisions, exp_url, statuspaths, idx
|
11
|
+
statuspath = statuspaths[idx]
|
12
|
+
msg = "element[#{idx}]"
|
13
|
+
assert_equal exp_name, statuspath.name, msg
|
14
|
+
assert_equal exp_nrevisions, statuspath.path_revisions.size, msg
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_to_working_copy
|
18
|
+
# revision doesn't matter:
|
19
|
+
revision = PVN::Revision::Range.new '20'
|
20
|
+
paths = %w{ . }
|
21
|
+
statuspaths = StatusPaths.new revision, paths
|
22
|
+
pp statuspaths
|
23
|
+
assert_equal 4, statuspaths.size
|
24
|
+
|
25
|
+
assert_status_path "/FirstFile.txt", 1, nil, statuspaths, 0
|
26
|
+
assert_status_path "/src/ruby/dog.rb", 1, nil, statuspaths, 1
|
27
|
+
assert_status_path "/SeventhFile.txt", 1, nil, statuspaths, 2
|
28
|
+
assert_status_path "/dirzero/SixthFile.txt", 1, nil, statuspaths, 3
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'integration/tc'
|
5
|
+
require 'pvn/log/command'
|
6
|
+
|
7
|
+
module PVN; module App; module Log; end; end; end
|
8
|
+
|
9
|
+
module PVN::App::Log
|
10
|
+
class CommandTest < PVN::IntegrationTestCase
|
11
|
+
|
12
|
+
def test_path
|
13
|
+
PVN::Log::Command.new [ PT_DIRNAME ]
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_invalid_path
|
17
|
+
assert_raises(RuntimeError) do
|
18
|
+
PVN::Log::Command.new %w{ /this/doesnt/exist }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_user
|
23
|
+
# filter_for_user
|
24
|
+
# fetch_log_in_pieces (-n LIMIT, LIMIT * 2, LIMIT * 4, LIMIT * 8 ... )
|
25
|
+
# PVN::Log::Command.new [ PT_DIRNAME ]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'integration/tc'
|
5
|
+
require 'pvn/pct/command'
|
6
|
+
|
7
|
+
Log.level = Log::DEBUG
|
8
|
+
|
9
|
+
module PVN::Pct
|
10
|
+
class CommandTest < PVN::IntegrationTestCase
|
11
|
+
|
12
|
+
def test_working_copy
|
13
|
+
explines = Array.new
|
14
|
+
|
15
|
+
explines << " 3 4 1 33.3% FirstFile.txt"
|
16
|
+
explines << " 3 4 1 33.3% total"
|
17
|
+
|
18
|
+
assert_command_output PVN::Pct::Command, %w{ }, explines
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_revision_to_working_copy
|
22
|
+
explines = Array.new
|
23
|
+
|
24
|
+
explines << " 3 5 2 66.7% SecondFile.txt"
|
25
|
+
explines << " 3 5 2 66.7% total"
|
26
|
+
|
27
|
+
assert_command_output PVN::Pct::Command, %w{ -r20 }, explines
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|