pvn 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +5 -1
- data/lib/pvn/app.rb +3 -0
- data/lib/pvn/{log/formatter → base}/color_formatter.rb +0 -0
- data/lib/pvn/io/element.rb +36 -29
- data/lib/pvn/log/formatter/log_formatter.rb +1 -10
- data/lib/pvn/log/formatter/summary_formatter.rb +0 -2
- data/lib/pvn/log/logcmd.rb +0 -1
- data/lib/pvn/revision/entry.rb +7 -2
- data/lib/pvn/status/formatter/entries_formatter.rb +27 -0
- data/lib/pvn/status/formatter/entry_formatter.rb +27 -0
- data/lib/pvn/status/formatter/status_formatter.rb +31 -0
- data/lib/pvn/subcommands/base/color_option.rb +12 -0
- data/lib/pvn/subcommands/base/command.rb +21 -2
- data/lib/pvn/subcommands/base/options.rb +1 -0
- data/lib/pvn/subcommands/log/command.rb +26 -30
- data/lib/pvn/subcommands/log/options.rb +2 -7
- data/lib/pvn/subcommands/pct/command.rb +71 -91
- data/lib/pvn/subcommands/pct/diffcount.rb +26 -0
- data/lib/pvn/subcommands/revision/revision_option.rb +7 -5
- data/lib/pvn/subcommands/status/command.rb +42 -0
- data/lib/pvn/subcommands/status/options.rb +16 -0
- data/lib/svnx/info/command.rb +14 -0
- data/lib/svnx/log/entry.rb +4 -0
- data/lib/synoption/fixnum_option.rb +1 -1
- data/test/{unit → integration}/pvn/subcommands/log/command_test.rb +0 -0
- data/test/unit/pvn/io/element/log/log_test.rb +3 -2
- data/test/unit/pvn/log/formatter/entry_formatter_test.rb +1 -1
- data/test/unit/pvn/revision/entry_test.rb +10 -10
- data/test/unit/pvn/subcommands/log/options_test.rb +12 -31
- data/test/unit/pvn/subcommands/revision/multiple_revisions_option_test.rb +14 -21
- data/test/unit/pvn/subcommands/revision/revision_option_test.rb +20 -13
- data/test/unit/pvn/subcommands/revision/revision_regexp_option_test.rb +17 -15
- metadata +15 -11
- data/lib/pvn/pct/linecount.rb +0 -33
- data/lib/pvn/pct/pctcmd.rb +0 -204
- data/lib/pvn/pct/statcmd.rb +0 -13
@@ -3,9 +3,23 @@
|
|
3
3
|
|
4
4
|
require 'tc'
|
5
5
|
require 'pvn/subcommands/revision/revision_regexp_option'
|
6
|
+
require 'pvn/subcommands/revision/tc'
|
7
|
+
require 'resources'
|
6
8
|
|
7
9
|
module PVN
|
8
|
-
class
|
10
|
+
class MockRevisionRegexpOption < RevisionRegexpOption
|
11
|
+
include MockBaseRevisionOption
|
12
|
+
end
|
13
|
+
|
14
|
+
class RevisionRegexpOptionTest < BaseRevisionOptionTestCase
|
15
|
+
def create_option
|
16
|
+
PVN::MockRevisionRegexpOption.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_value opt, val
|
20
|
+
opt.set_value val
|
21
|
+
end
|
22
|
+
|
9
23
|
def assert_tag_match str
|
10
24
|
assert_match RevisionRegexpOption::TAG_RE, str
|
11
25
|
end
|
@@ -25,21 +39,9 @@ module PVN
|
|
25
39
|
assert_tag_no_match '123'
|
26
40
|
assert_tag_no_match '-x'
|
27
41
|
end
|
28
|
-
|
42
|
+
|
29
43
|
def test_out_of_range
|
30
|
-
|
31
|
-
ropt = PVN::RevisionRegexpOption.new
|
32
|
-
ropt.process [ '-164' ]
|
33
|
-
ropt.post_process nil, [ '/Programs/wiquery/trunk' ]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def assert_post_process exp, val, path = '/Programs/wiquery/trunk'
|
38
|
-
ropt = PVN::RevisionRegexpOption.new
|
39
|
-
ropt.set_value val
|
40
|
-
ropt.post_process nil, [ path ]
|
41
|
-
act = ropt.value
|
42
|
-
assert_equal exp, act, "val: #{val}; path: #{path}"
|
44
|
+
assert_revision_option_raises '-164'
|
43
45
|
end
|
44
46
|
|
45
47
|
def test_post_process_middling
|
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
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-09-
|
18
|
+
date: 2012-09-09 00:00:00 -04:00
|
19
19
|
default_executable: pvn
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 1.1.6
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
|
-
description: A set of extensions to the Subversion command line.
|
37
|
+
description: A set of extensions to the Subversion command line, inspired by Git and Perforce.
|
38
38
|
email: jeugenepace@gmail.com
|
39
39
|
executables:
|
40
40
|
- pvn
|
@@ -74,12 +74,16 @@ files:
|
|
74
74
|
- lib/svnx/log/command.rb
|
75
75
|
- lib/svnx/log/entries.rb
|
76
76
|
- lib/svnx/log/entry.rb
|
77
|
+
- lib/pvn/subcommands/status/options.rb
|
78
|
+
- lib/pvn/subcommands/status/command.rb
|
77
79
|
- lib/pvn/subcommands/base/options.rb
|
80
|
+
- lib/pvn/subcommands/base/color_option.rb
|
78
81
|
- lib/pvn/subcommands/base/clargs.rb
|
79
82
|
- lib/pvn/subcommands/base/command.rb
|
80
83
|
- lib/pvn/subcommands/base/doc.rb
|
81
84
|
- lib/pvn/subcommands/pct/options.rb
|
82
85
|
- lib/pvn/subcommands/pct/clargs.rb
|
86
|
+
- lib/pvn/subcommands/pct/diffcount.rb
|
83
87
|
- lib/pvn/subcommands/pct/command.rb
|
84
88
|
- lib/pvn/subcommands/log/options.rb
|
85
89
|
- lib/pvn/subcommands/log/command.rb
|
@@ -90,7 +94,11 @@ files:
|
|
90
94
|
- lib/pvn/config.rb
|
91
95
|
- lib/pvn/cmddoc.rb
|
92
96
|
- lib/pvn/revision.rb
|
97
|
+
- lib/pvn/status/formatter/entry_formatter.rb
|
98
|
+
- lib/pvn/status/formatter/status_formatter.rb
|
99
|
+
- lib/pvn/status/formatter/entries_formatter.rb
|
93
100
|
- lib/pvn/base/textlines.rb
|
101
|
+
- lib/pvn/base/color_formatter.rb
|
94
102
|
- lib/pvn/base/util.rb
|
95
103
|
- lib/pvn/diff/diffcmd.rb
|
96
104
|
- lib/pvn/diff/diffopts.rb
|
@@ -99,9 +107,6 @@ files:
|
|
99
107
|
- lib/pvn/io/fselement.rb
|
100
108
|
- lib/pvn/wherecmd.rb
|
101
109
|
- lib/pvn/app.rb
|
102
|
-
- lib/pvn/pct/statcmd.rb
|
103
|
-
- lib/pvn/pct/linecount.rb
|
104
|
-
- lib/pvn/pct/pctcmd.rb
|
105
110
|
- lib/pvn/doc.rb
|
106
111
|
- lib/pvn/log/logentry.rb
|
107
112
|
- lib/pvn/log/logcmd.rb
|
@@ -109,7 +114,6 @@ files:
|
|
109
114
|
- lib/pvn/log/logoptions.rb
|
110
115
|
- lib/pvn/log/formatter/entry_formatter.rb
|
111
116
|
- lib/pvn/log/formatter/summary_formatter.rb
|
112
|
-
- lib/pvn/log/formatter/color_formatter.rb
|
113
117
|
- lib/pvn/log/formatter/entries_formatter.rb
|
114
118
|
- lib/pvn/log/formatter/message_formatter.rb
|
115
119
|
- lib/pvn/log/formatter/log_formatter.rb
|
@@ -136,7 +140,6 @@ files:
|
|
136
140
|
- test/unit/svnx/log/entry_test.rb
|
137
141
|
- test/unit/svnx/log/cmargs_test.rb
|
138
142
|
- test/unit/pvn/subcommands/log/options_test.rb
|
139
|
-
- test/unit/pvn/subcommands/log/command_test.rb
|
140
143
|
- test/unit/pvn/subcommands/revision/multiple_revisions_option_test.rb
|
141
144
|
- test/unit/pvn/subcommands/revision/revision_regexp_option_test.rb
|
142
145
|
- test/unit/pvn/subcommands/revision/revision_option_test.rb
|
@@ -145,6 +148,7 @@ files:
|
|
145
148
|
- test/unit/pvn/app_test.rb
|
146
149
|
- test/unit/pvn/revision/entry_test.rb
|
147
150
|
- test/integration/svnx/log/test.rb
|
151
|
+
- test/integration/pvn/subcommands/log/command_test.rb
|
148
152
|
- README.markdown
|
149
153
|
has_rdoc: true
|
150
154
|
homepage: http://www.incava.org/projects/pvn
|
@@ -195,7 +199,6 @@ test_files:
|
|
195
199
|
- test/unit/svnx/log/entry_test.rb
|
196
200
|
- test/unit/svnx/log/cmargs_test.rb
|
197
201
|
- test/unit/pvn/subcommands/log/options_test.rb
|
198
|
-
- test/unit/pvn/subcommands/log/command_test.rb
|
199
202
|
- test/unit/pvn/subcommands/revision/multiple_revisions_option_test.rb
|
200
203
|
- test/unit/pvn/subcommands/revision/revision_regexp_option_test.rb
|
201
204
|
- test/unit/pvn/subcommands/revision/revision_option_test.rb
|
@@ -204,3 +207,4 @@ test_files:
|
|
204
207
|
- test/unit/pvn/app_test.rb
|
205
208
|
- test/unit/pvn/revision/entry_test.rb
|
206
209
|
- test/integration/svnx/log/test.rb
|
210
|
+
- test/integration/pvn/subcommands/log/command_test.rb
|
data/lib/pvn/pct/linecount.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
module PVN
|
5
|
-
class LineCount
|
6
|
-
attr_accessor :to
|
7
|
-
attr_accessor :from
|
8
|
-
attr_accessor :name
|
9
|
-
|
10
|
-
def initialize args = Hash.new
|
11
|
-
@name = args[:name] || ""
|
12
|
-
@to = args[:to] || 0
|
13
|
-
@from = args[:from] || 0
|
14
|
-
end
|
15
|
-
|
16
|
-
def +(other)
|
17
|
-
# the new wc has the name of the lhs of the add:
|
18
|
-
self.class.new :to => @to + other.to, :from => @from + other.from, :name => @name
|
19
|
-
end
|
20
|
-
|
21
|
-
def diff
|
22
|
-
@to - @from
|
23
|
-
end
|
24
|
-
|
25
|
-
def diffpct
|
26
|
-
@from.zero? ? "0" : 100.0 * diff / @from
|
27
|
-
end
|
28
|
-
|
29
|
-
def write
|
30
|
-
printf "%8d %8d %8d %8.1f%% %s\n", @from, @to, diff, diffpct, @name
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/pvn/pct/pctcmd.rb
DELETED
@@ -1,204 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'system/command'
|
5
|
-
require 'pvn/pct/linecount'
|
6
|
-
require 'pvn/io/fselement'
|
7
|
-
require 'pvn/svn/svnelement'
|
8
|
-
require 'pvn/svn/svnroot'
|
9
|
-
require 'pvn/io/element'
|
10
|
-
|
11
|
-
module PVN
|
12
|
-
class PctOptionSet < OptionSet
|
13
|
-
attr_accessor :revision
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
super
|
17
|
-
@revision = add RevisionRegexpOption.new
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class PctCommand < Command
|
22
|
-
DEFAULT_LIMIT = 5
|
23
|
-
COMMAND = "pct"
|
24
|
-
|
25
|
-
self.doc do |doc|
|
26
|
-
doc.subcommands = [ COMMAND ]
|
27
|
-
doc.description = "Print the comparison of size of locally-changed files."
|
28
|
-
doc.usage = "[OPTIONS] FILE..."
|
29
|
-
doc.summary = [ "Prints the changes in the size (length) of files that have ",
|
30
|
-
"been changed locally, to show the extent to which they have",
|
31
|
-
"increased or decreased. The columns are:",
|
32
|
-
" - length in svn repository",
|
33
|
-
" - length in local version",
|
34
|
-
" - difference",
|
35
|
-
" - percentage change",
|
36
|
-
" - file name",
|
37
|
-
"When more than one file is specified, the total is displayed",
|
38
|
-
"as the last line." ]
|
39
|
-
doc.examples << [ "pvn pct main.c", "Prints the number of lines and percentage by which main.c has changed." ]
|
40
|
-
end
|
41
|
-
|
42
|
-
def initialize args
|
43
|
-
# not calling super, since all of our stuff goes on in this ctor.
|
44
|
-
|
45
|
-
info "args: #{args}"
|
46
|
-
|
47
|
-
@options = PctOptionSet.new
|
48
|
-
|
49
|
-
@options.process self, args, args[:command_args]
|
50
|
-
info "args: #{args}"
|
51
|
-
|
52
|
-
files = get_files @options.arguments
|
53
|
-
info "files: #{files.inspect}"
|
54
|
-
|
55
|
-
rev = @options.revision.value
|
56
|
-
info "rev: #{rev}"
|
57
|
-
|
58
|
-
@output = Array.new
|
59
|
-
|
60
|
-
totallc = LineCount.new :name => "total"
|
61
|
-
|
62
|
-
files.sort.each do |file|
|
63
|
-
info "file: #{file}"
|
64
|
-
|
65
|
-
fromlc, tolc = if rev
|
66
|
-
[ file.svn.line_count(rev - 1), file.svn.line_count(rev) ]
|
67
|
-
else
|
68
|
-
[ file.svn.line_count(rev), file.local.line_count ]
|
69
|
-
end
|
70
|
-
|
71
|
-
info "fromlc: #{fromlc}"
|
72
|
-
info "tolc: #{tolc}"
|
73
|
-
|
74
|
-
filelc = LineCount.new :from => fromlc, :to => tolc, :name => file.local.name
|
75
|
-
filelc.write
|
76
|
-
|
77
|
-
totallc += filelc
|
78
|
-
info "totallc: #{totallc.inspect}"
|
79
|
-
end
|
80
|
-
|
81
|
-
if files.size > 1
|
82
|
-
totallc.write
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def to_command subcmd, *args
|
87
|
-
cmd = "svn #{subcmd}"
|
88
|
-
info "cmd: #{cmd}"
|
89
|
-
info "args: #{args}"
|
90
|
-
args = args.flatten
|
91
|
-
|
92
|
-
revcl = @options.revision.to_command_line
|
93
|
-
if revcl
|
94
|
-
cmd << " " << revcl.join(" ")
|
95
|
-
end
|
96
|
-
cmd << " " << Util::quote_list(args)
|
97
|
-
info "cmd: #{cmd}".on_blue
|
98
|
-
cmd
|
99
|
-
end
|
100
|
-
|
101
|
-
def get_changed_files filespec
|
102
|
-
rev = @options.revision.value
|
103
|
-
info "rev: #{rev}"
|
104
|
-
|
105
|
-
if rev
|
106
|
-
get_changed_files_revision filespec
|
107
|
-
else
|
108
|
-
get_changed_files_wc filespec
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def svn_fullname_to_local_file svnname
|
113
|
-
svnelement = SVNElement.new :name => '.'
|
114
|
-
info "svnelement.info: #{svnelement.info}"
|
115
|
-
|
116
|
-
fullurl = svnelement.info[:repository_root] + svnname
|
117
|
-
info "fullurl : #{fullurl}".yellow
|
118
|
-
|
119
|
-
svnroot = SVNRootElement.new
|
120
|
-
info "svnroot : #{svnroot}".yellow
|
121
|
-
|
122
|
-
info "svnroot.info : #{svnroot.info}".yellow
|
123
|
-
|
124
|
-
here = SVNElement.new :name => '.'
|
125
|
-
|
126
|
-
hereinfo = here.info
|
127
|
-
info "hereinfo[:url] : #{hereinfo[:url]}".yellow
|
128
|
-
reporoot = hereinfo[:repository_root]
|
129
|
-
|
130
|
-
info "reporoot : #{reporoot}".yellow
|
131
|
-
|
132
|
-
info "svnroot[:url] : #{svnroot.info[:url]}".yellow
|
133
|
-
|
134
|
-
rootpath = svnroot.name
|
135
|
-
rooturl = svnroot.info[:url]
|
136
|
-
|
137
|
-
info "rootpath : #{rootpath}".yellow
|
138
|
-
info "rooturl : #{rooturl}".yellow
|
139
|
-
|
140
|
-
if fullurl.index(rooturl) == 0
|
141
|
-
localname = fullurl[rooturl.length .. -1]
|
142
|
-
info "localname : #{localname}".yellow
|
143
|
-
localname
|
144
|
-
else
|
145
|
-
info "fullurl : #{fullurl}".on_red
|
146
|
-
nil
|
147
|
-
end
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
|
-
def get_changed_files_revision filespec
|
152
|
-
lc = LogCommand.new :revision => @options.revision.value, :verbose => true
|
153
|
-
info "lc: #{lc}"
|
154
|
-
entry = lc.entries[0]
|
155
|
-
return Array.new if entry.nil?
|
156
|
-
|
157
|
-
# entry.write true
|
158
|
-
|
159
|
-
files = entry.files.collect do |svnfile|
|
160
|
-
localfile = svn_fullname_to_local_file svnfile
|
161
|
-
Element.new :file => localfile
|
162
|
-
end
|
163
|
-
info "files: #{files}".yellow
|
164
|
-
files
|
165
|
-
end
|
166
|
-
|
167
|
-
def get_changed_files_wc filespec
|
168
|
-
files = Array.new
|
169
|
-
cmd = to_command "st", filespec
|
170
|
-
IO.popen cmd do |io|
|
171
|
-
io.each do |line|
|
172
|
-
info "line: #{line}".yellow
|
173
|
-
next if line.index %r{^\?}
|
174
|
-
pn = Element.new :file => line.chomp[8 .. -1]
|
175
|
-
files << pn if pn.local.file?
|
176
|
-
end
|
177
|
-
end
|
178
|
-
info "files: #{files}".red
|
179
|
-
files
|
180
|
-
end
|
181
|
-
|
182
|
-
def get_files fileargs
|
183
|
-
info "fileargs: #{fileargs}".yellow
|
184
|
-
|
185
|
-
files = Array.new
|
186
|
-
if fileargs.empty?
|
187
|
-
files = get_changed_files fileargs
|
188
|
-
else
|
189
|
-
fileargs.collect do |fn|
|
190
|
-
elmt = Element.new :file => fn
|
191
|
-
if elmt.local.directory?
|
192
|
-
files.concat get_changed_files(fn)
|
193
|
-
else
|
194
|
-
files << elmt
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
info "files: #{files}".yellow
|
200
|
-
|
201
|
-
files
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|