pvn 0.0.8 → 0.0.9
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/lib/pvn/app/runner.rb +2 -0
- data/lib/pvn/command/command.rb +0 -5
- data/lib/pvn/diff/{path_revision.rb → change.rb} +1 -1
- data/lib/pvn/diff/changed_paths.rb +64 -0
- data/lib/pvn/diff/differ.rb +2 -62
- data/lib/pvn/diff/local_differ.rb +5 -63
- data/lib/pvn/diff/local_path.rb +69 -0
- data/lib/pvn/diff/log_path.rb +145 -0
- data/lib/pvn/diff/log_paths.rb +16 -6
- data/lib/pvn/diff/name.rb +23 -0
- data/lib/pvn/diff/path.rb +51 -19
- data/lib/pvn/diff/repository_differ.rb +15 -123
- data/lib/pvn/diff/status_paths.rb +5 -27
- data/lib/pvn/pct/differ.rb +1 -1
- data/lib/pvn/pct/local_differ.rb +0 -1
- data/lib/pvn/pct/repository_differ.rb +17 -14
- data/lib/pvn/seek/command.rb +111 -0
- data/lib/pvn/seek/options.rb +21 -0
- data/lib/pvn/{pct → util}/diffcount.rb +0 -0
- data/lib/pvn.rb +1 -1
- data/lib/svnx/action.rb +20 -25
- data/test/integration/pvn/diff/changed_paths_test.rb +109 -0
- data/test/integration/pvn/diff/local_differ_test.rb +4 -4
- data/test/integration/pvn/diff/log_paths_test.rb +2 -2
- data/test/integration/pvn/diff/repository_differ_test.rb +4 -13
- data/test/integration/pvn/diff/status_paths_test.rb +7 -7
- data/test/integration/pvn/pct/local_differ_test.rb +21 -0
- data/test/integration/pvn/pct/repository_differ_test.rb +40 -0
- data/test/unit/pvn/diff/change_test.rb +43 -0
- data/test/unit/pvn/diff/path_test.rb +4 -4
- data/test/unit/svnx/action_test.rb +14 -43
- metadata +20 -17
- data/lib/pvn/diff/revision.rb +0 -36
- data/lib/system/cachecmd.rb +0 -65
- data/lib/system/cmdexec.rb +0 -13
- data/lib/system/cmdline.rb +0 -70
- data/lib/system/command.rb +0 -72
- data/test/integration/pvn/pct/command_test.rb +0 -30
- data/test/unit/pvn/diff/path_revision_test.rb +0 -45
- data/test/unit/pvn/diff/revision_test.rb +0 -35
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'pvn/io/element'
|
5
4
|
require 'pvn/diff/options'
|
6
5
|
require 'pvn/diff/differ'
|
7
6
|
require 'pvn/diff/log_paths'
|
8
7
|
require 'pvn/diff/status_paths'
|
9
|
-
require 'pvn/diff/
|
8
|
+
require 'pvn/diff/changed_paths'
|
10
9
|
|
11
10
|
module PVN::Diff
|
12
11
|
class RepositoryDiffer < Differ
|
@@ -16,138 +15,31 @@ module PVN::Diff
|
|
16
15
|
attr_reader :revision
|
17
16
|
|
18
17
|
def initialize options
|
18
|
+
super
|
19
|
+
|
19
20
|
paths = options.paths
|
20
21
|
paths = %w{ . } if paths.empty?
|
21
22
|
|
22
23
|
# we sort only the sub-entries, so the order in which paths were specified is preserved
|
23
24
|
|
24
|
-
@whitespace = options.whitespace
|
25
25
|
rev = options.revision
|
26
26
|
change = options.change
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
fromrev = if change
|
33
|
-
change.to_i - 1
|
34
|
-
else
|
35
|
-
rev[0].to_i
|
36
|
-
end
|
37
|
-
|
38
|
-
@revision = RevisionRange.new change, rev
|
28
|
+
# this is for getting revisions only later than the given revision
|
29
|
+
# (argument); this only handling revision numbers (not dates) for now.
|
39
30
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if is_revision_later_than? logpath, fromrev
|
45
|
-
diff_logpath logpath
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
return if true
|
31
|
+
rev = change ? [ change.to_i - 1, change.to_i ] : options.revision
|
32
|
+
info "rev: #{rev}"
|
33
|
+
@revision = PVN::Revision::Range.new(*rev)
|
34
|
+
info "@revision: #{@revision}"
|
50
35
|
|
36
|
+
# this indicates that this should be split into two classes:
|
51
37
|
if @revision.working_copy?
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# diff_status_path stpath
|
58
|
-
end
|
59
|
-
# name_to_logpath = logpaths.to_map
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def is_revision_later_than? logpath, revision
|
64
|
-
logpath.path_revisions.detect do |rev|
|
65
|
-
info "rev.revision: #{rev.revision.inspect}".cyan
|
66
|
-
x = PVN::Revision::Argument.new rev.revision
|
67
|
-
y = PVN::Revision::Argument.new revision
|
68
|
-
x > y
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def show_as_modified elmt, path, fromrev, torev
|
73
|
-
info "elmt: #{elmt}"
|
74
|
-
fromlines = elmt.cat fromrev
|
75
|
-
tolines = elmt.cat torev
|
76
|
-
fromrev = @revision.from.value.to_i
|
77
|
-
run_diff path, fromlines, fromrev, tolines, @revision.to
|
78
|
-
end
|
79
|
-
|
80
|
-
def show_as_added elmt, path
|
81
|
-
info "elmt: #{elmt}"
|
82
|
-
tolines = elmt.cat @revision.to
|
83
|
-
run_diff path, nil, 0, tolines, @revision.to
|
84
|
-
end
|
85
|
-
|
86
|
-
def show_as_deleted elmt, path
|
87
|
-
info "elmt: #{elmt}"
|
88
|
-
fromrev = @revision.from.value.to_i
|
89
|
-
fromlines = elmt.cat fromrev
|
90
|
-
run_diff path, fromlines, fromrev, nil, @revision.to
|
91
|
-
end
|
92
|
-
|
93
|
-
def diff_logpath logpath
|
94
|
-
info "logpath.name: #{logpath.name}"
|
95
|
-
name = logpath.name
|
96
|
-
|
97
|
-
revisions = logpath.path_revisions
|
98
|
-
|
99
|
-
# all the paths will be the same, so any can be selected (actually, a
|
100
|
-
# logpath should have multiple revisions)
|
101
|
-
svnurl = logpath.url
|
102
|
-
info "svnurl: #{svnurl}"
|
103
|
-
|
104
|
-
svnpath = svnurl + name
|
105
|
-
info "svnpath: #{svnpath}"
|
106
|
-
elmt = PVN::IO::Element.new :svn => svnpath
|
107
|
-
|
108
|
-
displaypath = name[1 .. -1]
|
109
|
-
info "displaypath: #{displaypath}"
|
110
|
-
|
111
|
-
firstrev = revisions[0].revision
|
112
|
-
info "firstrev: #{firstrev}".yellow
|
113
|
-
lastrev = revisions[-1].revision
|
114
|
-
|
115
|
-
action = logpath.action
|
116
|
-
info "action: #{action}".on_blue
|
117
|
-
|
118
|
-
pathrevs = logpath.path_revisions
|
119
|
-
info "pathrevs: #{pathrevs}".green
|
120
|
-
|
121
|
-
info "@revision.from: #{@revision.from}".cyan
|
122
|
-
|
123
|
-
pathrevs = logpath.path_revisions.select do |rev|
|
124
|
-
info "rev.revision: #{rev.revision.inspect}".cyan
|
125
|
-
revarg = PVN::Revision::Argument.new rev.revision
|
126
|
-
revarg > @revision.from
|
127
|
-
end
|
128
|
-
|
129
|
-
info "pathrevs: #{pathrevs}".green
|
130
|
-
|
131
|
-
# we ignore unversioned logpaths
|
132
|
-
|
133
|
-
# I'm sure there is a bunch of permutations here, so this is probably
|
134
|
-
# overly simplistic.
|
135
|
-
firstaction = pathrevs[0].action
|
136
|
-
|
137
|
-
case
|
138
|
-
when firstaction.added?
|
139
|
-
show_as_added elmt, displaypath
|
140
|
-
when firstaction.deleted?
|
141
|
-
show_as_deleted elmt, displaypath
|
142
|
-
when firstaction.modified?
|
143
|
-
fromrev, torev = if firstrev == lastrev
|
144
|
-
[ @revision.from.value.to_i - 1, @revision.to ]
|
145
|
-
else
|
146
|
-
[ firstrev.to_i - 1, lastrev ]
|
147
|
-
end
|
148
|
-
info "firstrev: #{firstrev.inspect}"
|
149
|
-
info "torev: #{torev.inspect}"
|
150
|
-
show_as_modified elmt, displaypath, firstrev, torev
|
38
|
+
chgpaths = ChangedPaths.new paths
|
39
|
+
chgpaths.diff_revision_to_working_copy @revision, @whitespace
|
40
|
+
else
|
41
|
+
logpaths = LogPaths.new @revision, paths
|
42
|
+
logpaths.diff_revision_to_revision @revision, @whitespace
|
151
43
|
end
|
152
44
|
end
|
153
45
|
end
|
@@ -6,7 +6,6 @@ require 'pvn/diff/path'
|
|
6
6
|
require 'pvn/diff/paths'
|
7
7
|
|
8
8
|
module PVN::Diff
|
9
|
-
# represents the log entries from one revision through another.
|
10
9
|
class StatusPaths < Paths
|
11
10
|
include Loggable
|
12
11
|
|
@@ -19,49 +18,28 @@ module PVN::Diff
|
|
19
18
|
|
20
19
|
def add elmt, url
|
21
20
|
status = elmt.find_files_by_status
|
22
|
-
info "status: #{status}"
|
23
21
|
status.entries.each do |entry|
|
24
22
|
# we don't care about unversioned entries for diffing.
|
25
23
|
next if entry.status == 'unversioned'
|
26
24
|
|
27
|
-
info "@revision: #{@revision}"
|
28
|
-
info "entry: #{entry}"
|
29
25
|
# svn log prepends /; svn status does not
|
30
26
|
name = '/' + entry.path
|
31
|
-
info "name: #{name}"
|
32
27
|
rev = :working_copy
|
33
|
-
info "rev: #{rev}"
|
34
28
|
|
35
29
|
# what Status::Entry calls a status, we call an action, unifying it with
|
36
30
|
# svn log representation.
|
37
31
|
action = entry.status
|
38
|
-
info "
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
info "status.revision: #{entry.status_revision}"
|
43
|
-
|
44
|
-
@elements << Path.new(name, entry.status_revision, action, url)
|
32
|
+
info "entry.status_revision: #{entry.status_revision}"
|
33
|
+
path = LocalPath.new entry
|
34
|
+
@elements << path
|
45
35
|
end
|
46
36
|
end
|
47
|
-
|
48
|
-
|
37
|
+
|
38
|
+
### $$$ this may belong in Status::Entry
|
49
39
|
def get_status_revisions status_entry
|
50
40
|
# the printing revision in svn (svn diff -r20) are confusing, but this
|
51
41
|
# is what it looks like:
|
52
42
|
|
53
|
-
# when a file is added locally
|
54
|
-
# the revisions are (0, 0)
|
55
|
-
# when a file is modified:
|
56
|
-
# if the file is modified in other revisions since givenfromrev
|
57
|
-
# the revision is (most recent rev, working copy)
|
58
|
-
# otherwise
|
59
|
-
# the revision is (previous revision, working copy)
|
60
|
-
# when a file is deleted:
|
61
|
-
# the revision is (given from rev, working copy)
|
62
|
-
|
63
|
-
# okay, summary #2:
|
64
|
-
|
65
43
|
# if a file is modified,
|
66
44
|
# if the file existed at fromrev
|
67
45
|
# it is compared with fromrev
|
data/lib/pvn/pct/differ.rb
CHANGED
data/lib/pvn/pct/local_differ.rb
CHANGED
@@ -2,25 +2,24 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'pvn/io/element'
|
5
|
-
require 'pvn/pct/diffcount'
|
6
5
|
require 'pvn/pct/differ'
|
6
|
+
require 'pvn/revision/range'
|
7
7
|
|
8
8
|
module PVN::Pct
|
9
9
|
class RepositoryDiffer < Differ
|
10
|
-
|
10
|
+
#
|
11
11
|
def get_from_to_revisions rev
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
12
|
+
fromrev = nil
|
13
|
+
torev = nil
|
14
|
+
|
15
|
+
if rev.size == 1
|
16
|
+
if md = Regexp.new('(.+):(.+)').match(rev[0])
|
17
|
+
return [ md[1], md[2] ]
|
19
18
|
else
|
20
|
-
return [ rev[0], rev[
|
19
|
+
return [ (rev[0].to_i - 1).to_s, rev[0] ]
|
21
20
|
end
|
22
21
|
else
|
23
|
-
|
22
|
+
return [ rev[0], rev[1] ]
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
@@ -28,14 +27,18 @@ module PVN::Pct
|
|
28
27
|
diff_counts = Array.new
|
29
28
|
|
30
29
|
revision = options.revision
|
30
|
+
|
31
|
+
# revision -r20 is like diff -c20:
|
32
|
+
info "revision: #{revision}".bold.yellow
|
33
|
+
fromrev, torev = get_from_to_revisions revision
|
34
|
+
info "fromrev: #{fromrev}".yellow
|
35
|
+
info "torev: #{torev}".yellow
|
31
36
|
|
32
37
|
elmt = PVN::IO::Element.new :local => path
|
33
|
-
modified = elmt.find_modified_entries
|
38
|
+
modified = elmt.find_modified_entries [ fromrev + ':' + torev ]
|
34
39
|
|
35
40
|
modnames = modified.collect { |m| m.name }.sort.uniq
|
36
41
|
|
37
|
-
fromrev, torev = get_from_to_revisions revision
|
38
|
-
|
39
42
|
reporoot = elmt.repo_root
|
40
43
|
|
41
44
|
direlmt = PVN::IO::Element.new :local => '.'
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/seek/options'
|
5
|
+
require 'pvn/command/command'
|
6
|
+
|
7
|
+
module PVN::Seek
|
8
|
+
class Command < PVN::Command::Command
|
9
|
+
|
10
|
+
subcommands [ "seek" ]
|
11
|
+
description "Searches through revisions for a pattern match."
|
12
|
+
usage "[OPTIONS] FILE..."
|
13
|
+
summary [ "Goes through a set of revisions, looking for when a pattern",
|
14
|
+
"first matched a line within a file." ]
|
15
|
+
|
16
|
+
# summary [ "Goes through a set of revisions, looking for when a pattern",
|
17
|
+
# "matched (the default), or when a pattern does not match.",
|
18
|
+
# "This command therefore shows when a file changed to add",
|
19
|
+
# "or remove something such as a method." ]
|
20
|
+
|
21
|
+
optscls
|
22
|
+
|
23
|
+
example "pvn seek 'raise \w+Exception' foo.rb", "Shows when 'raise \w+Exception was added, through all revisions."
|
24
|
+
# example "pvn seek -r137:211 'raise \w+Exception' foo.rb", "As above, but only between revisions 137 and 211."
|
25
|
+
# example "pvn seek --no-match 'void\s+reinitialize()' *.java", "Looks through Java files for when 'void reinitialize() does _not_ match."
|
26
|
+
|
27
|
+
def init options
|
28
|
+
info "options: #{options.inspect}".red
|
29
|
+
|
30
|
+
paths = options.paths
|
31
|
+
|
32
|
+
pattern = paths.shift
|
33
|
+
info "pattern: #{pattern}"
|
34
|
+
|
35
|
+
paths = %w{ . } if paths.empty?
|
36
|
+
info "paths: #{paths}".cyan
|
37
|
+
|
38
|
+
# can handle only one path for now
|
39
|
+
|
40
|
+
@path = paths[0]
|
41
|
+
|
42
|
+
# should I embed glark in pvn?
|
43
|
+
|
44
|
+
entries = find_log_entries @path
|
45
|
+
seek entries, pattern, 0, entries.size
|
46
|
+
end
|
47
|
+
|
48
|
+
def matches? contents, pattern
|
49
|
+
contents.each_with_index do |line, idx|
|
50
|
+
# info "line: #{line}".cyan
|
51
|
+
if line.index pattern
|
52
|
+
info "line: #{line}".red
|
53
|
+
return [ idx, line ]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
def cat revision
|
60
|
+
info "path: #{@path}"
|
61
|
+
info "revision: #{revision}"
|
62
|
+
catargs = SVNx::CatCommandArgs.new :path => @path, :use_cache => false, :revision => revision
|
63
|
+
cmd = SVNx::CatCommand.new catargs
|
64
|
+
cmd.execute
|
65
|
+
end
|
66
|
+
|
67
|
+
def seek entries, pattern, from, to
|
68
|
+
info "from: #{from}".cyan
|
69
|
+
info "to: #{to}".cyan
|
70
|
+
|
71
|
+
midpt = from + (to - from) / 2
|
72
|
+
return nil if midpt + 1 >= to
|
73
|
+
|
74
|
+
entry = entries[midpt]
|
75
|
+
|
76
|
+
lines = cat entry.revision
|
77
|
+
info "entry.revision: #{entry.revision}"
|
78
|
+
info "lines: #{lines.size}"
|
79
|
+
|
80
|
+
if ref = matches?(lines, pattern)
|
81
|
+
prevrev = entries[midpt + 1].revision
|
82
|
+
info "prevrev: #{prevrev}"
|
83
|
+
prevlines = cat prevrev
|
84
|
+
info "prevlines: #{prevlines.size}"
|
85
|
+
|
86
|
+
if !matches?(prevlines, pattern)
|
87
|
+
info "ref: #{ref}"
|
88
|
+
$io.puts "path: #{@path} revision: #{entry.revision}"
|
89
|
+
$io.puts "#{@path}:#{ref[0]}: #{ref[1]}"
|
90
|
+
else
|
91
|
+
seek entries, pattern, midpt, to
|
92
|
+
end
|
93
|
+
else
|
94
|
+
seek entries, pattern, from, midpt + 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
### $$$ this is sliced from Log::Command, from which many options will apply
|
99
|
+
### here (limit, user, revision)
|
100
|
+
def find_log_entries path
|
101
|
+
cmdargs = Hash.new
|
102
|
+
cmdargs[:path] = path
|
103
|
+
cmdargs[:use_cache] = false
|
104
|
+
|
105
|
+
logargs = SVNx::LogCommandArgs.new cmdargs
|
106
|
+
elmt = PVN::IO::Element.new :local => path || '.'
|
107
|
+
log = elmt.log logargs
|
108
|
+
entries = log.entries
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/revision/revision_regexp_option'
|
5
|
+
require 'pvn/command/options'
|
6
|
+
|
7
|
+
module PVN::Seek
|
8
|
+
class MatchOption < PVN::BooleanOption
|
9
|
+
def initialize optargs = Hash.new
|
10
|
+
opts = Hash.new
|
11
|
+
opts[:negate] = '--nomatch', '-M'
|
12
|
+
super :match, '-m', 'find where the pattern matched', true, opts
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class OptionSet < PVN::Command::OptionSet
|
17
|
+
# has_option :revision, PVN::RevisionRegexpOption
|
18
|
+
# has_option :match, MatchOption
|
19
|
+
has_option :help, PVN::Command::HelpOption
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
data/lib/pvn.rb
CHANGED
data/lib/svnx/action.rb
CHANGED
@@ -5,40 +5,35 @@ require 'rubygems'
|
|
5
5
|
require 'riel'
|
6
6
|
|
7
7
|
module SVNx
|
8
|
-
# $$$ this cries for a little metaprogramming ... tomorrow
|
9
|
-
|
10
8
|
class Action
|
11
|
-
include Loggable, Comparable
|
9
|
+
include Loggable, Comparable
|
12
10
|
|
13
11
|
attr_reader :type
|
14
12
|
|
15
|
-
|
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
|
13
|
+
STATUS_TO_TYPE = Hash.new
|
27
14
|
|
28
|
-
def
|
29
|
-
|
15
|
+
def self.add_type sym, str, char
|
16
|
+
[ sym, str, char ].each do |key|
|
17
|
+
STATUS_TO_TYPE[key] = sym
|
18
|
+
end
|
30
19
|
end
|
31
20
|
|
32
|
-
|
33
|
-
|
21
|
+
add_type :added, 'added', 'A'
|
22
|
+
add_type :deleted, 'deleted', 'D'
|
23
|
+
add_type :modified, 'modified', 'M'
|
24
|
+
add_type :unversioned, 'unversioned', '?'
|
25
|
+
|
26
|
+
STATUS_TO_TYPE.values.uniq.each do |val|
|
27
|
+
methname = val.to_s + '?'
|
28
|
+
define_method methname do
|
29
|
+
instance_eval do
|
30
|
+
@type == STATUS_TO_TYPE[val]
|
31
|
+
end
|
32
|
+
end
|
34
33
|
end
|
35
34
|
|
36
|
-
def
|
37
|
-
@type
|
38
|
-
end
|
39
|
-
|
40
|
-
def unversioned?
|
41
|
-
@type == :unversioned
|
35
|
+
def initialize str
|
36
|
+
@type = STATUS_TO_TYPE[str]
|
42
37
|
end
|
43
38
|
|
44
39
|
def <=> other
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'riel'
|
6
|
+
require 'pvn/diff/changed_paths'
|
7
|
+
require 'integration/pvn/diff/tc'
|
8
|
+
|
9
|
+
module PVN::Diff
|
10
|
+
class ChangedPathsTestCase < TestCase
|
11
|
+
|
12
|
+
def assert_diff paths, revision, whitespace, explines
|
13
|
+
orig_dir = Dir.pwd
|
14
|
+
Dir.chdir '/Programs/pvn/pvntestbed.pending'
|
15
|
+
strio = StringIO.new
|
16
|
+
$io = strio
|
17
|
+
|
18
|
+
cp = ChangedPaths.new paths
|
19
|
+
cp.diff_revision_to_working_copy revision, whitespace
|
20
|
+
|
21
|
+
strio.close
|
22
|
+
puts strio.string
|
23
|
+
|
24
|
+
actlines = strio.string.split "\n"
|
25
|
+
|
26
|
+
assert_arrays_equal explines, actlines
|
27
|
+
|
28
|
+
$io = $stdout
|
29
|
+
Dir.chdir orig_dir
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_revision_against_working_copy
|
33
|
+
explines = Array.new
|
34
|
+
|
35
|
+
explines << "Index: FirstFile.txt"
|
36
|
+
explines << "==================================================================="
|
37
|
+
explines << "--- FirstFile.txt (revision 22)"
|
38
|
+
explines << "+++ FirstFile.txt (working copy)"
|
39
|
+
explines << "@@ -1,3 +1,4 @@"
|
40
|
+
explines << " this is the second line of the first file."
|
41
|
+
explines << "-third line here."
|
42
|
+
explines << "+ third line here."
|
43
|
+
explines << " fourth line this is."
|
44
|
+
explines << "+this is the fifth line."
|
45
|
+
explines << "Index: SecondFile.txt"
|
46
|
+
explines << "==================================================================="
|
47
|
+
explines << "--- SecondFile.txt (revision 20)"
|
48
|
+
explines << "+++ SecondFile.txt (working copy)"
|
49
|
+
explines << "@@ -1,4 +1,6 @@"
|
50
|
+
explines << " line one of file two."
|
51
|
+
explines << "+second line"
|
52
|
+
explines << "+third line"
|
53
|
+
explines << " line four"
|
54
|
+
explines << " line five"
|
55
|
+
explines << " line 6, Six, VI"
|
56
|
+
explines << "Index: SeventhFile.txt"
|
57
|
+
explines << "==================================================================="
|
58
|
+
explines << "--- SeventhFile.txt (revision 0)"
|
59
|
+
explines << "+++ SeventhFile.txt (revision 0)"
|
60
|
+
explines << "@@ -0,0 +1 @@"
|
61
|
+
explines << "+this is the 7th file."
|
62
|
+
|
63
|
+
### $$$ this revision might not be zero in svn-land:
|
64
|
+
explines << "Index: archive/rubies.zip"
|
65
|
+
explines << "==================================================================="
|
66
|
+
explines << "Binary files archive/rubies.zip\t(revision 0) and archive/rubies.zip\t(revision working_copy) differ"
|
67
|
+
|
68
|
+
explines << "Index: dirzero/SixthFile.txt"
|
69
|
+
explines << "==================================================================="
|
70
|
+
explines << "--- dirzero/SixthFile.txt (revision 22)"
|
71
|
+
explines << "+++ dirzero/SixthFile.txt (working copy)"
|
72
|
+
explines << "@@ -1,2 +0,0 @@"
|
73
|
+
explines << "-line one."
|
74
|
+
explines << "-line two."
|
75
|
+
explines << "Index: src/ruby/charlie.rb"
|
76
|
+
explines << "==================================================================="
|
77
|
+
explines << "--- src/ruby/charlie.rb (revision 20)"
|
78
|
+
explines << "+++ src/ruby/charlie.rb (working copy)"
|
79
|
+
explines << "@@ -2,6 +2,7 @@"
|
80
|
+
explines << " # -*- ruby -*-"
|
81
|
+
explines << " "
|
82
|
+
explines << " def charlie x"
|
83
|
+
explines << "+ puts x"
|
84
|
+
explines << " end"
|
85
|
+
explines << " "
|
86
|
+
explines << " charlie 1"
|
87
|
+
explines << "Index: src/ruby/dog.rb"
|
88
|
+
explines << "==================================================================="
|
89
|
+
explines << "--- src/ruby/dog.rb (revision 0)"
|
90
|
+
explines << "+++ src/ruby/dog.rb (revision 0)"
|
91
|
+
explines << "@@ -0,0 +1,7 @@"
|
92
|
+
explines << "+#!/usr/bin/ruby -w"
|
93
|
+
explines << "+# -*- ruby -*-"
|
94
|
+
explines << "+"
|
95
|
+
explines << "+require 'rubygems'"
|
96
|
+
explines << "+require 'riel'"
|
97
|
+
explines << "+"
|
98
|
+
explines << "+puts \"hello, world\""
|
99
|
+
|
100
|
+
# -r20 means -r20:working_copy
|
101
|
+
|
102
|
+
revision = PVN::Revision::Range.new 20, nil
|
103
|
+
whitespace = false
|
104
|
+
paths = %w{ . }
|
105
|
+
|
106
|
+
assert_diff paths, revision, whitespace, explines
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -2,15 +2,15 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'pvn/diff/local_differ'
|
5
|
-
require 'integration/pvn/diff/
|
5
|
+
require 'integration/pvn/diff/tc'
|
6
6
|
|
7
7
|
Log.level = Log::DEBUG
|
8
8
|
|
9
9
|
module PVN::Diff
|
10
|
-
class LocalDifferTestCase <
|
10
|
+
class LocalDifferTestCase < TestCase
|
11
11
|
|
12
|
-
def
|
13
|
-
LocalDiffer
|
12
|
+
def assert_diff_command args, explines
|
13
|
+
super LocalDiffer, args, explines
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_explines comparing_whitespace
|
@@ -7,11 +7,11 @@ require 'pvn/revision/range'
|
|
7
7
|
|
8
8
|
module PVN::Diff
|
9
9
|
class LogPathsTestCase < PVN::IntegrationTestCase
|
10
|
-
def assert_log_path exp_name,
|
10
|
+
def assert_log_path exp_name, exp_nchanges, expurl, logpaths, idx
|
11
11
|
logpath = logpaths[idx]
|
12
12
|
msg = "element[#{idx}]"
|
13
13
|
assert_equal exp_name, logpath.name, msg
|
14
|
-
assert_equal
|
14
|
+
assert_equal exp_nchanges, logpath.changes.size, msg
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_revision_to_revision
|