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
data/lib/pvn/app/runner.rb
CHANGED
@@ -11,6 +11,7 @@ require 'pvn/log/command'
|
|
11
11
|
require 'pvn/pct/command'
|
12
12
|
require 'pvn/status/command'
|
13
13
|
require 'pvn/diff/command'
|
14
|
+
require 'pvn/seek/command'
|
14
15
|
|
15
16
|
# the old ones:
|
16
17
|
# require 'pvn/diff/diffcmd'
|
@@ -31,6 +32,7 @@ module PVN::App
|
|
31
32
|
PVN::Pct::Command,
|
32
33
|
PVN::Status::Command,
|
33
34
|
PVN::Diff::Command,
|
35
|
+
PVN::Seek::Command,
|
34
36
|
# DescribeCommand,
|
35
37
|
# WhereCommand,
|
36
38
|
# UndeleteCommand,
|
data/lib/pvn/command/command.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/diff/log_paths'
|
5
|
+
require 'pvn/diff/status_paths'
|
6
|
+
require 'pvn/diff/local_path'
|
7
|
+
require 'pvn/revision/range'
|
8
|
+
|
9
|
+
module PVN::Diff
|
10
|
+
# represents both LogPaths and StatusPaths
|
11
|
+
class ChangedPaths
|
12
|
+
include Loggable
|
13
|
+
|
14
|
+
def initialize paths
|
15
|
+
@paths = paths
|
16
|
+
end
|
17
|
+
|
18
|
+
def diff_revision_to_working_copy revision, whitespace
|
19
|
+
fromrev = revision.from.value
|
20
|
+
|
21
|
+
info "revision: #{revision}".cyan
|
22
|
+
rev = PVN::Revision::Range.new revision.to_s, 'HEAD'
|
23
|
+
info "rev: #{rev}".cyan
|
24
|
+
|
25
|
+
logpaths = LogPaths.new rev, @paths
|
26
|
+
name_to_logpath = logpaths.to_map
|
27
|
+
|
28
|
+
statuspaths = StatusPaths.new revision, @paths
|
29
|
+
name_to_statuspath = statuspaths.to_map
|
30
|
+
|
31
|
+
### $$$ log names and status names should have a Name class
|
32
|
+
|
33
|
+
names = Set.new
|
34
|
+
names.merge name_to_logpath.keys.collect { |name| name[1 .. -1] }
|
35
|
+
info "names: #{names.inspect}"
|
36
|
+
|
37
|
+
names.merge name_to_statuspath.keys
|
38
|
+
info "names: #{names.inspect}"
|
39
|
+
|
40
|
+
names.sort.each do |name|
|
41
|
+
info "name: #{name}"
|
42
|
+
|
43
|
+
### $$$ silliness because I don't have Diff::Name integrated:
|
44
|
+
logname = '/' + name
|
45
|
+
|
46
|
+
logpath = name_to_logpath[logname]
|
47
|
+
info "logpaths: #{logpaths}"
|
48
|
+
|
49
|
+
stpath = name_to_statuspath[name]
|
50
|
+
info "stpath: #{stpath}"
|
51
|
+
|
52
|
+
frrev = nil
|
53
|
+
|
54
|
+
if logpath
|
55
|
+
chgrevs = logpath.revisions_later_than fromrev
|
56
|
+
logpath.diff_revision_to_working_copy revision, whitespace
|
57
|
+
else
|
58
|
+
# it's a local file only
|
59
|
+
stpath.show_diff whitespace
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/pvn/diff/differ.rb
CHANGED
@@ -16,68 +16,8 @@ module PVN::Diff
|
|
16
16
|
attr_reader :revision
|
17
17
|
|
18
18
|
def initialize options
|
19
|
-
|
20
|
-
|
21
|
-
def to_revision_string rev
|
22
|
-
rev ? "revision #{rev}" : "working copy"
|
23
|
-
end
|
24
|
-
|
25
|
-
def write_to_temp entry, lines
|
26
|
-
Tempfile.open('pvn') do |to|
|
27
|
-
topath = to.path
|
28
|
-
to.puts lines
|
29
|
-
to.close
|
30
|
-
cmd = "diff -u"
|
31
|
-
label = " -L '#{entry.path} (revision 0)'"
|
32
|
-
2.times do
|
33
|
-
cmd << label
|
34
|
-
end
|
35
|
-
cmd << " #{frpath}"
|
36
|
-
cmd << " #{entry.path}"
|
37
|
-
IO.popen(cmd) do |io|
|
38
|
-
puts io.readlines
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def run_diff_command displaypath, fromrev, torev, frompath, topath
|
44
|
-
cmd = "diff -u"
|
45
|
-
if whitespace
|
46
|
-
cmd << " -w"
|
47
|
-
end
|
48
|
-
|
49
|
-
[ fromrev, torev ].each do |rev|
|
50
|
-
revstr = to_revision_string rev
|
51
|
-
cmd << " -L '#{displaypath}\t(#{revstr})'"
|
52
|
-
end
|
53
|
-
cmd << " #{frompath}"
|
54
|
-
cmd << " #{topath}"
|
55
|
-
|
56
|
-
info "cmd: #{cmd}"
|
57
|
-
|
58
|
-
$io.puts "Index: #{displaypath}"
|
59
|
-
$io.puts "==================================================================="
|
60
|
-
IO.popen(cmd) do |io|
|
61
|
-
$io.puts io.readlines
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def run_diff displaypath, fromlines, fromrev, tolines, torev
|
66
|
-
Tempfile.open('pvn') do |from|
|
67
|
-
if fromlines
|
68
|
-
from.puts fromlines
|
69
|
-
end
|
70
|
-
from.close
|
71
|
-
|
72
|
-
Tempfile.open('pvn') do |to|
|
73
|
-
if tolines
|
74
|
-
to.puts tolines
|
75
|
-
end
|
76
|
-
to.close
|
77
|
-
|
78
|
-
run_diff_command displaypath, fromrev, torev, from.path, to.path
|
79
|
-
end
|
80
|
-
end
|
19
|
+
@whitespace = options.whitespace
|
20
|
+
@options = options
|
81
21
|
end
|
82
22
|
end
|
83
23
|
end
|
@@ -4,6 +4,8 @@
|
|
4
4
|
require 'pvn/io/element'
|
5
5
|
require 'pvn/diff/options'
|
6
6
|
require 'pvn/diff/differ'
|
7
|
+
require 'pvn/diff/local_path'
|
8
|
+
# require 'pvn/diff/status_path'
|
7
9
|
|
8
10
|
module PVN::Diff
|
9
11
|
class LocalDiffer < Differ
|
@@ -18,29 +20,16 @@ module PVN::Diff
|
|
18
20
|
# we sort only the sub-entries, so the order in which paths were specified
|
19
21
|
# is preserved
|
20
22
|
|
21
|
-
@whitespace = options.whitespace
|
22
|
-
|
23
23
|
paths.each do |path|
|
24
24
|
elmt = PVN::IO::Element.new :local => path
|
25
25
|
entries = elmt.find_files_by_status
|
26
|
-
|
27
26
|
allentries.concat entries.sort_by { |n| n.path }
|
28
27
|
end
|
29
28
|
|
30
29
|
allentries.each do |entry|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def show_entry entry
|
36
|
-
info "entry: #{entry.inspect}"
|
37
|
-
case entry.status
|
38
|
-
when 'modified'
|
39
|
-
show_as_modified entry
|
40
|
-
when 'deleted'
|
41
|
-
show_as_deleted entry
|
42
|
-
when 'added'
|
43
|
-
show_as_added entry
|
30
|
+
next if entry.status == 'unversioned'
|
31
|
+
path = LocalPath.new entry
|
32
|
+
path.show_diff @whitespace
|
44
33
|
end
|
45
34
|
end
|
46
35
|
|
@@ -48,52 +37,5 @@ module PVN::Diff
|
|
48
37
|
def use_cache?
|
49
38
|
super && !against_head?
|
50
39
|
end
|
51
|
-
|
52
|
-
def against_head?
|
53
|
-
@options.change.value.nil? && @options.revision.head?
|
54
|
-
end
|
55
|
-
|
56
|
-
def read_working_copy entry
|
57
|
-
pn = Pathname.new entry.path
|
58
|
-
pn.readlines
|
59
|
-
end
|
60
|
-
|
61
|
-
def create_element entry
|
62
|
-
PVN::IO::Element.new :local => entry.path
|
63
|
-
end
|
64
|
-
|
65
|
-
def cat elmt
|
66
|
-
elmt = PVN::IO::Element.new :local => elmt.local
|
67
|
-
elmt.cat nil, :use_cache => false
|
68
|
-
end
|
69
|
-
|
70
|
-
def show_as_added entry
|
71
|
-
fromlines = nil
|
72
|
-
tolines = read_working_copy entry
|
73
|
-
|
74
|
-
run_diff entry.path, fromlines, 0, tolines, 0
|
75
|
-
end
|
76
|
-
|
77
|
-
def get_latest_revision elmt
|
78
|
-
svninfo = elmt.get_info
|
79
|
-
svninfo.revision
|
80
|
-
end
|
81
|
-
|
82
|
-
def show_as_deleted entry
|
83
|
-
elmt = create_element entry
|
84
|
-
|
85
|
-
fromrev = get_latest_revision elmt
|
86
|
-
lines = cat elmt
|
87
|
-
|
88
|
-
run_diff entry.path, lines, fromrev, nil, nil
|
89
|
-
end
|
90
|
-
|
91
|
-
def show_as_modified entry
|
92
|
-
elmt = create_element entry
|
93
|
-
remotelines = cat elmt
|
94
|
-
fromrev = get_latest_revision elmt
|
95
|
-
wclines = read_working_copy entry
|
96
|
-
run_diff entry.path, remotelines, fromrev, wclines, nil
|
97
|
-
end
|
98
40
|
end
|
99
41
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/io/element'
|
5
|
+
require 'pvn/diff/path'
|
6
|
+
|
7
|
+
module PVN::Diff
|
8
|
+
class LocalPath < Path
|
9
|
+
# that's a Status::Entry
|
10
|
+
def initialize entry
|
11
|
+
@entry = entry
|
12
|
+
@elmt = create_element
|
13
|
+
name = entry.path
|
14
|
+
action = SVNx::Action.new @entry.status
|
15
|
+
revision = action.added? ? 0 : @elmt.get_info.revision
|
16
|
+
super name, revision, action, nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def show_diff whitespace = nil
|
20
|
+
case @entry.status
|
21
|
+
when 'modified'
|
22
|
+
show_as_modified whitespace
|
23
|
+
when 'deleted'
|
24
|
+
show_as_deleted
|
25
|
+
when 'added'
|
26
|
+
show_as_added
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
### $$$ todo: integrate these, from old diff/diffcmd
|
31
|
+
def use_cache?
|
32
|
+
super && !against_head?
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_working_copy
|
36
|
+
pn = Pathname.new @entry.path
|
37
|
+
pn.readlines
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_element
|
41
|
+
PVN::IO::Element.new :local => @entry.path
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_latest_revision
|
45
|
+
svninfo = @elmt.get_info
|
46
|
+
svninfo.revision
|
47
|
+
end
|
48
|
+
|
49
|
+
def show_as_added
|
50
|
+
fromlines = nil
|
51
|
+
tolines = read_working_copy
|
52
|
+
run_diff @entry.path, fromlines, 0, tolines, 0, nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def show_as_deleted
|
56
|
+
fromrev = changes[0].revision
|
57
|
+
# revision = nil; use_cache = false
|
58
|
+
lines = @elmt.cat nil, false
|
59
|
+
run_diff @entry.path, lines, fromrev, nil, nil, nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def show_as_modified whitespace
|
63
|
+
remotelines = @elmt.cat nil, false
|
64
|
+
fromrev = changes[0].revision
|
65
|
+
wclines = read_working_copy
|
66
|
+
run_diff @entry.path, remotelines, fromrev, wclines, nil, whitespace
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/io/element'
|
5
|
+
require 'pvn/diff/path'
|
6
|
+
|
7
|
+
module PVN::Diff
|
8
|
+
# this is a path wrapping a log entry; it could also be a RemotePath or a
|
9
|
+
# RepoPath.
|
10
|
+
class LogPath < Path
|
11
|
+
|
12
|
+
# the "path" parameter is the displayed name; "logpath" is the LogPath.
|
13
|
+
# These are in the process of refactoring.
|
14
|
+
def show_as_modified elmt, path, fromrev, torev, revision, whitespace
|
15
|
+
fromlines = elmt.cat fromrev
|
16
|
+
tolines = elmt.cat torev
|
17
|
+
fromrev = revision.from.value.to_i
|
18
|
+
run_diff path, fromlines, fromrev, tolines, revision.to, whitespace
|
19
|
+
end
|
20
|
+
|
21
|
+
def show_as_added elmt, path, revision, whitespace
|
22
|
+
info "path: #{path}".on_blue
|
23
|
+
tolines = elmt.cat revision.to
|
24
|
+
info "tolines: #{tolines}".blue
|
25
|
+
run_diff path, nil, 0, tolines, revision.to, whitespace
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_as_deleted elmt, path, revision, whitespace
|
29
|
+
fromrev = revision.from.value.to_i
|
30
|
+
fromlines = elmt.cat fromrev
|
31
|
+
run_diff path, fromlines, fromrev, nil, revision.to, whitespace
|
32
|
+
end
|
33
|
+
|
34
|
+
# log entries have names of the form /foo/bar.rb, relative to the URL.
|
35
|
+
def get_display_path
|
36
|
+
name[1 .. -1]
|
37
|
+
end
|
38
|
+
|
39
|
+
def diff_revision_to_revision revision, whitespace
|
40
|
+
logpath = self
|
41
|
+
info "name: #{name}"
|
42
|
+
|
43
|
+
# all the paths will be the same, so any can be selected (actually, a
|
44
|
+
# logpath should have multiple changes)
|
45
|
+
svnpath = url + name
|
46
|
+
info "svnpath: #{svnpath}"
|
47
|
+
elmt = PVN::IO::Element.new :svn => svnpath
|
48
|
+
|
49
|
+
displaypath = get_display_path
|
50
|
+
|
51
|
+
info "revision.from: #{revision.from}".cyan
|
52
|
+
|
53
|
+
rev_change = changes.detect do |chg|
|
54
|
+
revarg = PVN::Revision::Argument.new chg.revision
|
55
|
+
revarg > revision.from
|
56
|
+
end
|
57
|
+
|
58
|
+
info "rev_change: #{rev_change}".green
|
59
|
+
|
60
|
+
# we ignore unversioned logpaths
|
61
|
+
|
62
|
+
# I'm sure there is a bunch of permutations here, so this is probably
|
63
|
+
# overly simplistic.
|
64
|
+
action = rev_change.action
|
65
|
+
|
66
|
+
case
|
67
|
+
when action.added?
|
68
|
+
show_as_added elmt, displaypath, revision, whitespace
|
69
|
+
when action.deleted?
|
70
|
+
show_as_deleted elmt, displaypath, revision, whitespace
|
71
|
+
when action.modified?
|
72
|
+
firstrev = changes[0].revision
|
73
|
+
lastrev = changes[-1].revision
|
74
|
+
fromrev, torev = if firstrev == lastrev
|
75
|
+
[ revision.from.value.to_i - 1, revision.to ]
|
76
|
+
else
|
77
|
+
[ firstrev.to_i - 1, lastrev ]
|
78
|
+
end
|
79
|
+
show_as_modified elmt, displaypath, firstrev, torev, revision, whitespace
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_diff_revision change, revision
|
84
|
+
info "change: #{change}"
|
85
|
+
info "revision: #{revision}"
|
86
|
+
# find the first revision where logpath was in svn, no earlier than the
|
87
|
+
# revision.from value
|
88
|
+
if change.action.added?
|
89
|
+
return change.revision.to_i
|
90
|
+
elsif change.revision.to_i >= revision.from.value
|
91
|
+
return revision.from.value
|
92
|
+
else
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def diff_revision_to_working_copy revision, whitespace
|
98
|
+
fromrev = revision.from.value.to_i
|
99
|
+
|
100
|
+
### $$$ this doesn't handle the case where a file has been added, then
|
101
|
+
### modified.
|
102
|
+
|
103
|
+
change = revisions_later_than(fromrev).first
|
104
|
+
info "change: #{change}".red
|
105
|
+
|
106
|
+
# revision should be a class here, not a primitive
|
107
|
+
diffrev = get_diff_revision change, revision
|
108
|
+
|
109
|
+
display_path = get_display_path
|
110
|
+
|
111
|
+
pn = Pathname.new display_path
|
112
|
+
|
113
|
+
svnpath = url + name
|
114
|
+
info "svnpath: #{svnpath}"
|
115
|
+
elmt = PVN::IO::Element.new :svn => svnpath
|
116
|
+
|
117
|
+
if change.action.added?
|
118
|
+
show_as_added elmt, display_path, revision, whitespace
|
119
|
+
else
|
120
|
+
fromlines = elmt.cat diffrev
|
121
|
+
info "fromlines.size: #{fromlines.size}"
|
122
|
+
pp fromlines
|
123
|
+
|
124
|
+
tolines = pn.readlines
|
125
|
+
info "tolines.size: #{tolines.size}"
|
126
|
+
pp tolines
|
127
|
+
|
128
|
+
run_diff display_path, fromlines, diffrev, tolines, nil, whitespace
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def is_revision_later_than? revision
|
133
|
+
revisions_later_than(revision).first
|
134
|
+
end
|
135
|
+
|
136
|
+
def revisions_later_than revision
|
137
|
+
changes.select do |chg|
|
138
|
+
info "chg: #{chg.revision.inspect}"
|
139
|
+
x = PVN::Revision::Argument.new chg.revision
|
140
|
+
y = PVN::Revision::Argument.new revision
|
141
|
+
x > y
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
data/lib/pvn/diff/log_paths.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'pvn/io/element'
|
5
5
|
require 'pvn/diff/paths'
|
6
|
-
require 'pvn/diff/
|
6
|
+
require 'pvn/diff/log_path'
|
7
7
|
|
8
8
|
module PVN::Diff
|
9
9
|
# represents the log entries from one revision through another.
|
@@ -30,17 +30,27 @@ module PVN::Diff
|
|
30
30
|
action = logentrypath.action
|
31
31
|
url = pathinfo.url
|
32
32
|
|
33
|
-
info "action: #{action}"
|
33
|
+
info "action: #{action}"
|
34
34
|
|
35
35
|
path = @elements.detect { |element| element.name == name }
|
36
36
|
if path
|
37
|
-
info "path: #{path}"
|
38
|
-
path.
|
37
|
+
info "path: #{path}"
|
38
|
+
path.add_change logentry.revision, action
|
39
39
|
else
|
40
|
-
path =
|
41
|
-
info "path: #{path}"
|
40
|
+
path = LogPath.new(name, logentry.revision, action, url)
|
41
|
+
info "path: #{path}"
|
42
42
|
@elements << path
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
def diff_revision_to_revision revision, whitespace
|
47
|
+
name_to_logpath = to_map
|
48
|
+
|
49
|
+
name_to_logpath.sort.each do |name, logpath|
|
50
|
+
if logpath.is_revision_later_than? revision.from.value
|
51
|
+
logpath.diff_revision_to_revision revision, whitespace
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'riel'
|
6
|
+
|
7
|
+
module PVN; module Diff; end; end
|
8
|
+
|
9
|
+
module PVN::Diff
|
10
|
+
# represents names in LogPaths and StatusPaths.
|
11
|
+
### $$$ todo: integrate with those classes.
|
12
|
+
class Name
|
13
|
+
include Loggable
|
14
|
+
|
15
|
+
def initialize namestr
|
16
|
+
@namestr = namestr
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
@namestr
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/pvn/diff/path.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'svnx/action'
|
5
|
-
require 'pvn/diff/
|
5
|
+
require 'pvn/diff/change'
|
6
6
|
|
7
7
|
module PVN; module Diff; end; end
|
8
8
|
|
@@ -11,32 +11,20 @@ module PVN::Diff
|
|
11
11
|
include Loggable
|
12
12
|
|
13
13
|
attr_reader :name
|
14
|
-
# attr_reader :revisions
|
15
|
-
attr_reader :action
|
16
14
|
attr_reader :url
|
17
|
-
|
18
|
-
attr_reader :path_revisions
|
15
|
+
attr_reader :changes
|
19
16
|
|
20
17
|
# that's the root url
|
21
18
|
def initialize name, revision, action, url
|
22
19
|
@name = name
|
23
|
-
@
|
24
|
-
|
25
|
-
add_revision revision, action
|
26
|
-
@action = action.kind_of?(SVNx::Action) || SVNx::Action.new(action)
|
20
|
+
@changes = Array.new
|
21
|
+
add_change revision, action
|
27
22
|
@url = url
|
28
23
|
end
|
29
24
|
|
30
|
-
def
|
31
|
-
info "rev: #{rev}"
|
32
|
-
|
33
|
-
rev.each do |rv|
|
34
|
-
@revisions << to_revision(rv)
|
35
|
-
end
|
36
|
-
else
|
37
|
-
@revisions << to_revision(rev)
|
38
|
-
end
|
39
|
-
@path_revisions << PathRevision.new(to_revision(rev), action)
|
25
|
+
def add_change rev, action
|
26
|
+
info "rev: #{rev}"
|
27
|
+
@changes << Change.new(to_revision(rev), action)
|
40
28
|
end
|
41
29
|
|
42
30
|
def to_revision rev
|
@@ -48,5 +36,49 @@ module PVN::Diff
|
|
48
36
|
def to_s
|
49
37
|
inspect
|
50
38
|
end
|
39
|
+
|
40
|
+
def to_revision_string rev
|
41
|
+
rev ? "revision #{rev}" : "working copy"
|
42
|
+
end
|
43
|
+
|
44
|
+
def run_diff_command displaypath, fromrev, torev, frompath, topath, whitespace
|
45
|
+
cmd = "diff -u"
|
46
|
+
if whitespace
|
47
|
+
cmd << " -w"
|
48
|
+
end
|
49
|
+
|
50
|
+
[ fromrev, torev ].each do |rev|
|
51
|
+
revstr = to_revision_string rev
|
52
|
+
cmd << " -L '#{displaypath}\t(#{revstr})'"
|
53
|
+
end
|
54
|
+
cmd << " #{frompath}"
|
55
|
+
cmd << " #{topath}"
|
56
|
+
|
57
|
+
info "cmd: #{cmd}"
|
58
|
+
|
59
|
+
$io.puts "Index: #{displaypath}"
|
60
|
+
$io.puts "==================================================================="
|
61
|
+
IO.popen(cmd) do |io|
|
62
|
+
$io.puts io.readlines
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def run_diff displaypath, fromlines, fromrev, tolines, torev, whitespace
|
67
|
+
Tempfile.open('pvn') do |from|
|
68
|
+
if fromlines
|
69
|
+
from.puts fromlines
|
70
|
+
end
|
71
|
+
from.close
|
72
|
+
|
73
|
+
Tempfile.open('pvn') do |to|
|
74
|
+
if tolines
|
75
|
+
to.puts tolines
|
76
|
+
end
|
77
|
+
to.close
|
78
|
+
|
79
|
+
run_diff_command displaypath, fromrev, torev, from.path, to.path, whitespace
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
51
83
|
end
|
52
84
|
end
|