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
@@ -2,13 +2,13 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'pvn/diff/repository_differ'
|
5
|
-
require 'integration/pvn/diff/
|
5
|
+
require 'integration/pvn/diff/tc'
|
6
6
|
|
7
7
|
module PVN::Diff
|
8
|
-
class RepositoryDifferTestCase <
|
8
|
+
class RepositoryDifferTestCase < TestCase
|
9
9
|
|
10
|
-
def
|
11
|
-
RepositoryDiffer
|
10
|
+
def assert_diff_command args, explines
|
11
|
+
super RepositoryDiffer, args, explines
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_adds
|
@@ -114,14 +114,5 @@ module PVN::Diff
|
|
114
114
|
|
115
115
|
assert_diff_command %w{ -r1:4 }, explines
|
116
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
117
|
end
|
127
118
|
end
|
@@ -7,11 +7,11 @@ require 'pp'
|
|
7
7
|
|
8
8
|
module PVN::Diff
|
9
9
|
class StatusPathsTestCase < PVN::IntegrationTestCase
|
10
|
-
def assert_status_path exp_name,
|
10
|
+
def assert_status_path exp_name, exp_nchanges, exp_url, statuspaths, idx
|
11
11
|
statuspath = statuspaths[idx]
|
12
12
|
msg = "element[#{idx}]"
|
13
|
-
assert_equal exp_name,
|
14
|
-
assert_equal
|
13
|
+
assert_equal exp_name, statuspath.name, msg
|
14
|
+
assert_equal exp_nchanges, statuspath.changes.size, msg
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_to_working_copy
|
@@ -22,10 +22,10 @@ module PVN::Diff
|
|
22
22
|
pp statuspaths
|
23
23
|
assert_equal 4, statuspaths.size
|
24
24
|
|
25
|
-
assert_status_path "
|
26
|
-
assert_status_path "
|
27
|
-
assert_status_path "
|
28
|
-
assert_status_path "
|
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
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'riel'
|
6
|
+
require 'integration/pvn/pct/tc'
|
7
|
+
require 'pvn/pct/local_differ'
|
8
|
+
require 'pvn/pct/options'
|
9
|
+
|
10
|
+
module PVN::Pct
|
11
|
+
class LocalDifferTest < TestCase
|
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_diff_command LocalDiffer, %w{ }, explines
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'riel'
|
6
|
+
require 'integration/pvn/pct/tc'
|
7
|
+
require 'pvn/pct/repository_differ'
|
8
|
+
|
9
|
+
module PVN::Pct
|
10
|
+
class RepositoryDifferTest < TestCase
|
11
|
+
def test_revision_to_working_copy
|
12
|
+
explines = Array.new
|
13
|
+
|
14
|
+
explines << " 3 5 2 66.7% SecondFile.txt"
|
15
|
+
explines << " 3 5 2 66.7% total"
|
16
|
+
|
17
|
+
assert_diff_command RepositoryDiffer, %w{ -r20 }, explines
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_revision_to_revision
|
21
|
+
explines = Array.new
|
22
|
+
|
23
|
+
explines << " 3 7 4 133.3% SecondFile.txt"
|
24
|
+
explines << " 7 8 1 14.3% src/ruby/charlie.rb"
|
25
|
+
explines << " 10 15 5 50.0% total"
|
26
|
+
|
27
|
+
assert_diff_command RepositoryDiffer, %w{ -r19:22 }, explines
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_revision_to_relative_revision
|
31
|
+
explines = Array.new
|
32
|
+
|
33
|
+
explines << " 3 7 4 133.3% SecondFile.txt"
|
34
|
+
explines << " 7 8 1 14.3% src/ruby/charlie.rb"
|
35
|
+
explines << " 10 15 5 50.0% total"
|
36
|
+
|
37
|
+
assert_diff_command RepositoryDiffer, %w{ -r19 -1 }, explines
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'tc'
|
5
|
+
require 'pvn/diff/change'
|
6
|
+
|
7
|
+
module PVN::Diff
|
8
|
+
class ChangeTestCase < PVN::TestCase
|
9
|
+
def create_change revision, action
|
10
|
+
Change.new revision, action
|
11
|
+
end
|
12
|
+
|
13
|
+
def assert_change_revision exprevision, revision
|
14
|
+
prev = create_change revision, "added"
|
15
|
+
assert_equal exprevision, prev.revision
|
16
|
+
end
|
17
|
+
|
18
|
+
def assert_change_action expaction, action
|
19
|
+
prev = create_change "0", action
|
20
|
+
assert_equal expaction, prev.action
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_init_revision_string
|
24
|
+
assert_change_revision "0", "0"
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_init_revision_integer
|
28
|
+
assert_change_revision "0", 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_init_action_long_string
|
32
|
+
assert_change_action SVNx::Action.new(:added), "added"
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_init_action_short_string
|
36
|
+
assert_change_action SVNx::Action.new(:deleted), "D"
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_init_action_symbol
|
40
|
+
assert_change_action SVNx::Action.new(:modified), :modified
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -28,11 +28,11 @@ module PVN::Diff
|
|
28
28
|
assert_path_url "file:///var/svn/repo", "file:///var/svn/repo"
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_add_change
|
32
32
|
path = create_path "File.txt", "0", :added, "file:///var/svn/repo"
|
33
|
-
assert_equal 1, path.
|
34
|
-
path.
|
35
|
-
assert_equal 2, path.
|
33
|
+
assert_equal 1, path.changes.size
|
34
|
+
path.add_change "1", :modified
|
35
|
+
assert_equal 2, path.changes.size
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -8,60 +8,31 @@ module SVNx
|
|
8
8
|
class ActionTestCase < PVN::TestCase
|
9
9
|
include Loggable
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def assert_action_modified exp, str
|
22
|
-
action = Action.new str
|
23
|
-
assert_equal exp, action.modified?
|
24
|
-
end
|
25
|
-
|
26
|
-
def assert_action_unversioned exp, str
|
27
|
-
action = Action.new str
|
28
|
-
assert_equal exp, action.unversioned?
|
29
|
-
end
|
11
|
+
def assert_action_equals expadd, expdel, expmod, expunver, *vals
|
12
|
+
vals.each do |val|
|
13
|
+
action = Action.new val
|
14
|
+
msg = "value: #{val}"
|
15
|
+
assert_equal expadd, action.added?, msg
|
16
|
+
assert_equal expdel, action.deleted?, msg
|
17
|
+
assert_equal expmod, action.modified?, msg
|
18
|
+
assert_equal expunver, action.unversioned?, msg
|
19
|
+
end
|
20
|
+
end
|
30
21
|
|
31
22
|
def test_added
|
32
|
-
|
33
|
-
assert_action_added true, str
|
34
|
-
assert_action_deleted false, str
|
35
|
-
assert_action_modified false, str
|
36
|
-
assert_action_unversioned false, str
|
37
|
-
end
|
23
|
+
assert_action_equals true, false, false, false, 'added', 'A'
|
38
24
|
end
|
39
25
|
|
40
26
|
def test_deleted
|
41
|
-
|
42
|
-
assert_action_added false, str
|
43
|
-
assert_action_deleted true, str
|
44
|
-
assert_action_modified false, str
|
45
|
-
assert_action_unversioned false, str
|
46
|
-
end
|
27
|
+
assert_action_equals false, true, false, false, 'deleted', 'D'
|
47
28
|
end
|
48
29
|
|
49
30
|
def test_modified
|
50
|
-
|
51
|
-
assert_action_added false, str
|
52
|
-
assert_action_deleted false, str
|
53
|
-
assert_action_modified true, str
|
54
|
-
assert_action_unversioned false, str
|
55
|
-
end
|
31
|
+
assert_action_equals false, false, true, false, 'modified', 'M'
|
56
32
|
end
|
57
33
|
|
58
34
|
def test_unversioned
|
59
|
-
|
60
|
-
assert_action_added false, str
|
61
|
-
assert_action_deleted false, str
|
62
|
-
assert_action_modified false, str
|
63
|
-
assert_action_unversioned true, str
|
64
|
-
end
|
35
|
+
assert_action_equals false, false, false, true, 'unversioned', '?'
|
65
36
|
end
|
66
37
|
end
|
67
38
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pvn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeff Pace
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-10-19 00:00:00 -04:00
|
19
19
|
default_executable: pvn
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,10 +66,6 @@ files:
|
|
66
66
|
- lib/system/command/cachefile.rb
|
67
67
|
- lib/system/command/line.rb
|
68
68
|
- lib/system/command/caching.rb
|
69
|
-
- lib/system/cmdline.rb
|
70
|
-
- lib/system/command.rb
|
71
|
-
- lib/system/cachecmd.rb
|
72
|
-
- lib/system/cmdexec.rb
|
73
69
|
- lib/svnx/cat/command.rb
|
74
70
|
- lib/svnx/status/command.rb
|
75
71
|
- lib/svnx/status/entries.rb
|
@@ -93,6 +89,9 @@ files:
|
|
93
89
|
- lib/pvn/util/array.rb
|
94
90
|
- lib/pvn/util/textlines.rb
|
95
91
|
- lib/pvn/util/color_formatter.rb
|
92
|
+
- lib/pvn/util/diffcount.rb
|
93
|
+
- lib/pvn/seek/options.rb
|
94
|
+
- lib/pvn/seek/command.rb
|
96
95
|
- lib/pvn/config.rb
|
97
96
|
- lib/pvn/cmddoc.rb
|
98
97
|
- lib/pvn/status/options.rb
|
@@ -105,10 +104,13 @@ files:
|
|
105
104
|
- lib/pvn/diff/paths.rb
|
106
105
|
- lib/pvn/diff/path.rb
|
107
106
|
- lib/pvn/diff/options.rb
|
107
|
+
- lib/pvn/diff/changed_paths.rb
|
108
|
+
- lib/pvn/diff/local_path.rb
|
108
109
|
- lib/pvn/diff/repository_differ.rb
|
109
|
-
- lib/pvn/diff/
|
110
|
+
- lib/pvn/diff/log_path.rb
|
110
111
|
- lib/pvn/diff/command.rb
|
111
|
-
- lib/pvn/diff/
|
112
|
+
- lib/pvn/diff/change.rb
|
113
|
+
- lib/pvn/diff/name.rb
|
112
114
|
- lib/pvn/diff/differ.rb
|
113
115
|
- lib/pvn/diff/status_paths.rb
|
114
116
|
- lib/pvn/io/element.rb
|
@@ -117,7 +119,6 @@ files:
|
|
117
119
|
- lib/pvn/pct/local_differ.rb
|
118
120
|
- lib/pvn/pct/options.rb
|
119
121
|
- lib/pvn/pct/repository_differ.rb
|
120
|
-
- lib/pvn/pct/diffcount.rb
|
121
122
|
- lib/pvn/pct/command.rb
|
122
123
|
- lib/pvn/pct/differ.rb
|
123
124
|
- lib/pvn/doc.rb
|
@@ -152,9 +153,8 @@ files:
|
|
152
153
|
- test/unit/svnx/log/entries_test.rb
|
153
154
|
- test/unit/svnx/log/entry_test.rb
|
154
155
|
- test/unit/svnx/log/cmargs_test.rb
|
155
|
-
- test/unit/pvn/diff/revision_test.rb
|
156
156
|
- test/unit/pvn/diff/path_test.rb
|
157
|
-
- test/unit/pvn/diff/
|
157
|
+
- test/unit/pvn/diff/change_test.rb
|
158
158
|
- test/unit/pvn/io/element/log/log_test.rb
|
159
159
|
- test/unit/pvn/log/options_test.rb
|
160
160
|
- test/unit/pvn/log/formatter/entry_formatter_test.rb
|
@@ -166,11 +166,13 @@ files:
|
|
166
166
|
- test/unit/pvn/revision/revision_option_test.rb
|
167
167
|
- test/integration/pvn/status/command_test.rb
|
168
168
|
- test/integration/pvn/diff/repository_differ_test.rb
|
169
|
+
- test/integration/pvn/diff/changed_paths_test.rb
|
169
170
|
- test/integration/pvn/diff/local_differ_test.rb
|
170
171
|
- test/integration/pvn/diff/log_paths_test.rb
|
171
172
|
- test/integration/pvn/diff/status_paths_test.rb
|
172
173
|
- test/integration/pvn/diff/command_test.rb
|
173
|
-
- test/integration/pvn/pct/
|
174
|
+
- test/integration/pvn/pct/repository_differ_test.rb
|
175
|
+
- test/integration/pvn/pct/local_differ_test.rb
|
174
176
|
- test/integration/pvn/log/command_test.rb
|
175
177
|
- README.markdown
|
176
178
|
has_rdoc: true
|
@@ -223,9 +225,8 @@ test_files:
|
|
223
225
|
- test/unit/svnx/log/entries_test.rb
|
224
226
|
- test/unit/svnx/log/entry_test.rb
|
225
227
|
- test/unit/svnx/log/cmargs_test.rb
|
226
|
-
- test/unit/pvn/diff/revision_test.rb
|
227
228
|
- test/unit/pvn/diff/path_test.rb
|
228
|
-
- test/unit/pvn/diff/
|
229
|
+
- test/unit/pvn/diff/change_test.rb
|
229
230
|
- test/unit/pvn/io/element/log/log_test.rb
|
230
231
|
- test/unit/pvn/log/options_test.rb
|
231
232
|
- test/unit/pvn/log/formatter/entry_formatter_test.rb
|
@@ -237,9 +238,11 @@ test_files:
|
|
237
238
|
- test/unit/pvn/revision/revision_option_test.rb
|
238
239
|
- test/integration/pvn/status/command_test.rb
|
239
240
|
- test/integration/pvn/diff/repository_differ_test.rb
|
241
|
+
- test/integration/pvn/diff/changed_paths_test.rb
|
240
242
|
- test/integration/pvn/diff/local_differ_test.rb
|
241
243
|
- test/integration/pvn/diff/log_paths_test.rb
|
242
244
|
- test/integration/pvn/diff/status_paths_test.rb
|
243
245
|
- test/integration/pvn/diff/command_test.rb
|
244
|
-
- test/integration/pvn/pct/
|
246
|
+
- test/integration/pvn/pct/repository_differ_test.rb
|
247
|
+
- test/integration/pvn/pct/local_differ_test.rb
|
245
248
|
- test/integration/pvn/log/command_test.rb
|
data/lib/pvn/diff/revision.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'pvn/revision/range'
|
5
|
-
|
6
|
-
module PVN::Diff
|
7
|
-
class RevisionRange < PVN::Revision::Range
|
8
|
-
include Loggable, Comparable
|
9
|
-
|
10
|
-
def initialize change, rev
|
11
|
-
if change
|
12
|
-
super change.to_i - 1, change.to_i
|
13
|
-
elsif rev.kind_of? Array
|
14
|
-
if rev.size == 2
|
15
|
-
# this is some contorting, since -rx:y does not mean comparing the files
|
16
|
-
# in changelist x; it means all the entries from x+1 through y, inclusive.
|
17
|
-
|
18
|
-
super rev[0].to_i, rev[1].to_i
|
19
|
-
else
|
20
|
-
from, to = rev[0].split(':')
|
21
|
-
info "from: #{from}"
|
22
|
-
info "to : #{to}".cyan
|
23
|
-
super from, to
|
24
|
-
end
|
25
|
-
else
|
26
|
-
raise "revision argument not handled: #{rev}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def <=> other
|
31
|
-
info "other: #{other}".yellow
|
32
|
-
info "self: #{self}".yellow
|
33
|
-
nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/system/cachecmd.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'system/command'
|
5
|
-
|
6
|
-
module PVN
|
7
|
-
class CachableCommand < Command
|
8
|
-
TMP_DIR = ENV['PVN_TMP_DIR'] || '/tmp/pvncache'
|
9
|
-
CACHE_DIR = Pathname.new TMP_DIR
|
10
|
-
|
11
|
-
attr_accessor :lines
|
12
|
-
|
13
|
-
def initialize args = Hash.new
|
14
|
-
debug "args: #{args.inspect}"
|
15
|
-
|
16
|
-
@use_cache = args[:use_cache].nil? ? true : args[:use_cache]
|
17
|
-
info "@use_cache: #{@use_cache}".blue
|
18
|
-
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
|
-
def sysexec cmd
|
23
|
-
info "cmd: #{cmd}".on_red
|
24
|
-
if use_cache?
|
25
|
-
info "cmd: #{cmd}".on_green
|
26
|
-
run_cached_command cmd
|
27
|
-
else
|
28
|
-
@output = ::IO::popen(cmd).readlines
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def run args
|
33
|
-
if use_cache?
|
34
|
-
run_cached_command args
|
35
|
-
else
|
36
|
-
super
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def use_cache?
|
41
|
-
@use_cache
|
42
|
-
end
|
43
|
-
|
44
|
-
def get_cache_file cmd
|
45
|
-
pwd = Pathname.pwd.to_s.sub(%r{^/}, '')
|
46
|
-
CACHE_DIR + pwd + cmd.gsub(' ', '')
|
47
|
-
end
|
48
|
-
|
49
|
-
def run_cached_command cmd
|
50
|
-
stack "cmd: #{cmd}".cyan
|
51
|
-
cfile = get_cache_file cmd
|
52
|
-
if cfile.exist?
|
53
|
-
debug "reading from cache file: #{cfile}".cyan
|
54
|
-
@output = cfile.readlines
|
55
|
-
else
|
56
|
-
@output = ::IO::popen(cmd).readlines
|
57
|
-
cfile.parent.mkpath
|
58
|
-
stack "saving output to cache file: #{cfile}".cyan
|
59
|
-
File.put_via_temp_file cfile do
|
60
|
-
output
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/lib/system/cmdexec.rb
DELETED
data/lib/system/cmdline.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
module PVN
|
5
|
-
class CommandLine
|
6
|
-
include Loggable
|
7
|
-
|
8
|
-
attr_reader :output
|
9
|
-
attr_accessor :use_cache
|
10
|
-
|
11
|
-
def initialize use_cache, args = Array.new
|
12
|
-
@args = args.dup
|
13
|
-
@use_cache = use_cache
|
14
|
-
end
|
15
|
-
|
16
|
-
def use_cache?
|
17
|
-
@use_cache
|
18
|
-
end
|
19
|
-
|
20
|
-
def cache_dir
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
|
24
|
-
def << arg
|
25
|
-
@args << arg
|
26
|
-
end
|
27
|
-
|
28
|
-
def execute
|
29
|
-
if use_cache?
|
30
|
-
run_cached_command
|
31
|
-
else
|
32
|
-
@output = ::IO.popen(to_command).readlines
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_command
|
37
|
-
@args.join ' '
|
38
|
-
end
|
39
|
-
|
40
|
-
def run args
|
41
|
-
if use_cache?
|
42
|
-
run_cached_command
|
43
|
-
else
|
44
|
-
super
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def get_cache_file
|
49
|
-
pwd = Pathname.pwd.split_path.join('')
|
50
|
-
info "pwd: #{pwd}"
|
51
|
-
Pathname.new(cache_dir) + pwd + @args.join('-')
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_cached_command
|
55
|
-
stack "@args: #{@args}".cyan
|
56
|
-
cachefile = get_cache_file
|
57
|
-
if cachefile.exist?
|
58
|
-
debug "reading from cache file: #{cachefile}".cyan
|
59
|
-
@output = cachefile.readlines
|
60
|
-
else
|
61
|
-
@output = IO.popen(to_command).readlines
|
62
|
-
cachefile.parent.mkpath
|
63
|
-
debug "saving output to cache file: #{cachefile}".on_cyan
|
64
|
-
File.put_via_temp_file cachefile do
|
65
|
-
@output
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/system/command.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'system/cmdexec'
|
5
|
-
require 'synoption/optionable'
|
6
|
-
require 'pvn/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
|
@@ -1,30 +0,0 @@
|
|
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
|