pvn 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pvn.rb +1 -1
- data/lib/pvn/app/runner.rb +13 -13
- data/lib/pvn/log/command.rb +6 -48
- data/lib/pvn/log/entries.rb +42 -0
- data/lib/pvn/log/formatter/summary_formatter.rb +1 -1
- data/lib/pvn/log/options.rb +7 -1
- data/lib/pvn/log/user_entries.rb +39 -0
- data/lib/pvn/pct/local_differ.rb +2 -1
- data/lib/pvn/revision/multiple_revisions_option.rb +4 -0
- data/lib/pvn/revision/revision_option.rb +5 -1
- data/lib/pvn/revision/revision_regexp_option.rb +0 -7
- data/lib/pvn/seek/command.rb +11 -77
- data/lib/pvn/seek/options.rb +29 -2
- data/lib/pvn/seek/path.rb +149 -0
- data/lib/svnx/cat/command.rb +17 -2
- data/lib/svnx/command.rb +17 -13
- data/lib/svnx/entries.rb +4 -5
- data/lib/svnx/log/command.rb +10 -16
- metadata +7 -4
data/lib/pvn.rb
CHANGED
data/lib/pvn/app/runner.rb
CHANGED
@@ -84,22 +84,22 @@ module PVN::App
|
|
84
84
|
def run_help args
|
85
85
|
forwhat = args[0]
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
SUBCOMMANDS.each do |sc|
|
88
|
+
puts sc
|
89
|
+
if sc.matches_subcommand? forwhat
|
90
|
+
sc.new(%w{ --help })
|
91
|
+
exit 0
|
92
|
+
end
|
89
93
|
end
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
puts "PVN has the subcommands:"
|
98
|
-
SUBCOMMANDS.each do |sc|
|
99
|
-
printf " %-10s %s\n", sc.getdoc.subcommands[0], sc.getdoc.description
|
100
|
-
end
|
95
|
+
puts "usage: pvn [--verbose] <command> [<options>] [<args>]"
|
96
|
+
puts "PVN, version #{PVN::VERSION}"
|
97
|
+
puts
|
98
|
+
puts "PVN has the subcommands:"
|
99
|
+
SUBCOMMANDS.each do |sc|
|
100
|
+
printf " %-10s %s\n", sc.getdoc.subcommands[0], sc.getdoc.description
|
101
101
|
end
|
102
|
-
exit
|
102
|
+
exit 0
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
data/lib/pvn/log/command.rb
CHANGED
@@ -5,6 +5,8 @@ require 'pvn/io/element'
|
|
5
5
|
require 'pvn/log/formatter/entries_formatter'
|
6
6
|
require 'pvn/log/options'
|
7
7
|
require 'pvn/command/command'
|
8
|
+
require 'pvn/log/entries'
|
9
|
+
require 'pvn/log/user_entries'
|
8
10
|
|
9
11
|
module PVN::Log
|
10
12
|
class Command < PVN::Command::Command
|
@@ -28,7 +30,7 @@ module PVN::Log
|
|
28
30
|
example "pvn log -3 foo.rb", "Prints the log entry for revision (HEAD - 3)."
|
29
31
|
example "pvn log +3 foo.rb", "Prints the 3rd log entry."
|
30
32
|
example "pvn log -l 10 --no-color", "Prints the latest 10 entries, uncolorized."
|
31
|
-
example "pvn log -r 122 -
|
33
|
+
example "pvn log -r 122 -f", "Prints log entry for revision 122, including the files in that change."
|
32
34
|
example "pvn log -u barney", "Prints log entries only for user 'barney', with the default limit."
|
33
35
|
|
34
36
|
def init options
|
@@ -39,9 +41,11 @@ module PVN::Log
|
|
39
41
|
info "paths: #{paths}"
|
40
42
|
|
41
43
|
allentries = Array.new
|
44
|
+
|
45
|
+
entcls = options.user ? UserEntries : Entries
|
42
46
|
|
43
47
|
paths.each do |path|
|
44
|
-
allentries.concat
|
48
|
+
allentries.concat entcls.new(path, options).entries
|
45
49
|
end
|
46
50
|
|
47
51
|
# we can show relative revisions for a single path, without filtering by
|
@@ -56,51 +60,5 @@ module PVN::Log
|
|
56
60
|
ef = PVN::Log::EntriesFormatter.new options.color, allentries, from_head, from_tail
|
57
61
|
puts ef.format
|
58
62
|
end
|
59
|
-
|
60
|
-
def find_entries_for_path path, options
|
61
|
-
cmdargs = Hash.new
|
62
|
-
cmdargs[:path] = path
|
63
|
-
|
64
|
-
[ :limit, :verbose, :revision ].each do |field|
|
65
|
-
cmdargs[field] = options.send field
|
66
|
-
end
|
67
|
-
|
68
|
-
if options.user
|
69
|
-
cmdargs[:limit] = nil
|
70
|
-
end
|
71
|
-
|
72
|
-
# we can't cache this, because we don't know if there has been an svn
|
73
|
-
# update since the previous run:
|
74
|
-
cmdargs[:use_cache] = false
|
75
|
-
|
76
|
-
logargs = SVNx::LogCommandArgs.new cmdargs
|
77
|
-
elmt = PVN::IO::Element.new :local => path || '.'
|
78
|
-
log = elmt.log logargs
|
79
|
-
entries = log.entries
|
80
|
-
|
81
|
-
info { "options: #{options}" }
|
82
|
-
info { "options.user: #{options.user}" }
|
83
|
-
|
84
|
-
if options.user
|
85
|
-
entries = find_entries_for_user entries, options.user, options.limit
|
86
|
-
info { "entries: #{entries}" }
|
87
|
-
|
88
|
-
# don't show relative revisions, since we've got a slice out of the list:
|
89
|
-
from_head = nil
|
90
|
-
from_tail = nil
|
91
|
-
end
|
92
|
-
|
93
|
-
entries
|
94
|
-
end
|
95
|
-
|
96
|
-
def find_entries_for_user entries, user, limit
|
97
|
-
entries = entries.select { |entry| entry.author == user }
|
98
|
-
|
99
|
-
raise "ERROR: no matching log entries for '#{user}'" if entries.empty?
|
100
|
-
|
101
|
-
info { "entries: #{entries}" }
|
102
|
-
|
103
|
-
limit ? entries[0 ... limit] : entries
|
104
|
-
end
|
105
63
|
end
|
106
64
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'svnx/log/command'
|
5
|
+
require 'svnx/log/entries'
|
6
|
+
|
7
|
+
module PVN::Log
|
8
|
+
class Entries < SVNx::Log::Entries
|
9
|
+
include Loggable
|
10
|
+
|
11
|
+
def initialize path, options
|
12
|
+
cmdargs = create_cmd_args options, path
|
13
|
+
cmdargs[:path] = path
|
14
|
+
|
15
|
+
info "cmdargs: #{cmdargs}".magenta
|
16
|
+
|
17
|
+
logargs = SVNx::LogCommandArgs.new cmdargs
|
18
|
+
cmd = SVNx::LogCommand.new logargs
|
19
|
+
|
20
|
+
super :xmllines => cmd.execute
|
21
|
+
|
22
|
+
info { "options: #{options}" }
|
23
|
+
info { "options.user: #{options.user}".yellow }
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_cmd_args options, path
|
27
|
+
cmdargs = Hash.new
|
28
|
+
cmdargs[:path] = path
|
29
|
+
|
30
|
+
[ :limit, :revision ].each do |field|
|
31
|
+
cmdargs[field] = options.send field
|
32
|
+
end
|
33
|
+
|
34
|
+
cmdargs[:verbose] = options.files
|
35
|
+
|
36
|
+
# we can't cache this, because we don't know if there has been an svn
|
37
|
+
# update since the previous run:
|
38
|
+
cmdargs[:use_cache] = false
|
39
|
+
cmdargs
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/pvn/log/options.rb
CHANGED
@@ -24,6 +24,12 @@ module PVN::Log
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
class FilesOption < PVN::BooleanOption
|
28
|
+
def initialize optargs = Hash.new
|
29
|
+
super :files, '-f', [ "list the files in the change" ], false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
27
33
|
class UserOption < PVN::Option
|
28
34
|
def initialize optargs = Hash.new
|
29
35
|
super :user, '-u', "show only changes for the given user", nil, :as_cmdline_option => nil
|
@@ -36,6 +42,6 @@ module PVN::Log
|
|
36
42
|
has_option :help, PVN::Command::HelpOption
|
37
43
|
has_option :limit, LimitOption
|
38
44
|
has_option :user, UserOption
|
39
|
-
has_option :
|
45
|
+
has_option :files, FilesOption
|
40
46
|
end
|
41
47
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pvn/log/entries'
|
5
|
+
|
6
|
+
module PVN::Log
|
7
|
+
class UserEntries < PVN::Log::Entries
|
8
|
+
include Loggable
|
9
|
+
|
10
|
+
def initialize path, options
|
11
|
+
@user = options.user
|
12
|
+
@limit = options.limit
|
13
|
+
|
14
|
+
super
|
15
|
+
|
16
|
+
filter_entries_for_user
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_cmd_args options, path
|
20
|
+
cmdargs = super
|
21
|
+
cmdargs[:limit] = nil
|
22
|
+
cmdargs
|
23
|
+
end
|
24
|
+
|
25
|
+
def filter_entries_for_user
|
26
|
+
userentries = Hash.new
|
27
|
+
each do |entry|
|
28
|
+
break if userentries.size >= @limit
|
29
|
+
if entry.author == @user
|
30
|
+
userentries[userentries.size] = entry
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
raise "ERROR: no matching log entries for '#{@user}'" if userentries.empty?
|
35
|
+
|
36
|
+
@entries = userentries
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/pvn/pct/local_differ.rb
CHANGED
@@ -19,7 +19,8 @@ module PVN::Pct
|
|
19
19
|
|
20
20
|
modified.each do |entry|
|
21
21
|
info "entry.path: #{entry.path}"
|
22
|
-
|
22
|
+
catargs = SVNx::CatCommandArgs.new :path => entry.path, :use_cache => false
|
23
|
+
catcmd = SVNx::CatCommand.new catargs
|
23
24
|
svn_count = catcmd.execute.size
|
24
25
|
local_count = Pathname.new(entry.path).readlines.size
|
25
26
|
|
@@ -11,7 +11,11 @@ module PVN
|
|
11
11
|
def initialize revargs = Hash.new
|
12
12
|
@fromdate = nil
|
13
13
|
@todate = nil
|
14
|
-
super :revision, '-r',
|
14
|
+
super :revision, '-r', description, nil, revargs
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
REVISION_DESCRIPTION
|
15
19
|
end
|
16
20
|
|
17
21
|
def to_svn_revision_date date
|
@@ -8,13 +8,6 @@ module PVN
|
|
8
8
|
class RevisionRegexpOption < PVN::RevisionOption
|
9
9
|
TAG_RE = Regexp.new '^(?:([\-\+]\d+)|(-r(.+)))$'
|
10
10
|
|
11
|
-
REVISION_DESCRIPTION = [ "revision to apply.",
|
12
|
-
"ARG can be relative, of the form:",
|
13
|
-
" +N : N revisions from the BASE",
|
14
|
-
" -N : N revisions from the HEAD,",
|
15
|
-
" when -1 is the previous revision" ,
|
16
|
-
]
|
17
|
-
|
18
11
|
def initialize revargs = Hash.new
|
19
12
|
revargs[:regexp] = TAG_RE
|
20
13
|
super
|
data/lib/pvn/seek/command.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'pvn/seek/options'
|
5
5
|
require 'pvn/command/command'
|
6
|
+
require 'pvn/seek/path'
|
6
7
|
|
7
8
|
module PVN::Seek
|
8
9
|
class Command < PVN::Command::Command
|
@@ -11,18 +12,15 @@ module PVN::Seek
|
|
11
12
|
description "Searches through revisions for a pattern match."
|
12
13
|
usage "[OPTIONS] FILE..."
|
13
14
|
summary [ "Goes through a set of revisions, looking for when a pattern",
|
14
|
-
"first matched
|
15
|
-
|
16
|
-
|
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." ]
|
15
|
+
"first matched (the default), or when a pattern no longer matched.",
|
16
|
+
"This command therefore shows when a file was changed to add",
|
17
|
+
"or remove something such as a method." ]
|
20
18
|
|
21
19
|
optscls
|
22
20
|
|
23
|
-
example "pvn seek 'raise
|
21
|
+
example "pvn seek 'raise \\w+Exception' foo.rb", "Shows when 'raise \\w+Exception was added, through all revisions."
|
24
22
|
# example "pvn seek -r137:211 'raise \w+Exception' foo.rb", "As above, but only between revisions 137 and 211."
|
25
|
-
|
23
|
+
example "pvn seek --removed 'void\\s+reinitialize()' *.java", "Looks through Java files for the latest revision when 'void reinitialize() does not match."
|
26
24
|
|
27
25
|
def init options
|
28
26
|
info "options: #{options.inspect}".red
|
@@ -35,77 +33,13 @@ module PVN::Seek
|
|
35
33
|
paths = %w{ . } if paths.empty?
|
36
34
|
info "paths: #{paths}".cyan
|
37
35
|
|
38
|
-
|
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
|
36
|
+
info "options.revision: #{options.revision}".bold.black.on_cyan
|
70
37
|
|
71
|
-
|
72
|
-
return nil if midpt + 1 >= to
|
38
|
+
seektype = options.removed ? :removed : :added
|
73
39
|
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
40
|
+
# can handle only one path for now
|
41
|
+
seekpath = Path.new paths[0], pattern, options.revision
|
42
|
+
seekpath.seek seektype, options.color
|
109
43
|
end
|
110
44
|
end
|
111
45
|
end
|
data/lib/pvn/seek/options.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'pvn/revision/
|
4
|
+
require 'pvn/revision/multiple_revisions_option'
|
5
5
|
require 'pvn/command/options'
|
6
|
+
require 'pvn/command/color_option'
|
6
7
|
|
7
8
|
module PVN::Seek
|
8
9
|
class MatchOption < PVN::BooleanOption
|
@@ -13,9 +14,35 @@ module PVN::Seek
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
class RemovedOption < PVN::BooleanOption
|
18
|
+
def initialize optargs = Hash.new
|
19
|
+
opts = Hash.new
|
20
|
+
super :removed, '-M', 'find where the pattern did not match', false, opts
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class SeekRevisionOption < PVN::MultipleRevisionsRegexpOption
|
25
|
+
REVISION_DESCRIPTION = PVN::RevisionRegexpOption::REVISION_DESCRIPTION +
|
26
|
+
[
|
27
|
+
'Zero, one, or two revisions may be specified:',
|
28
|
+
' A single revision is the equivalent of -rN:HEAD.',
|
29
|
+
' Multiple revisions are the equivalent of -rM:N.'
|
30
|
+
]
|
31
|
+
|
32
|
+
def resolve_value optset, unprocessed
|
33
|
+
super optset, unprocessed[-1, 1]
|
34
|
+
end
|
35
|
+
|
36
|
+
def description
|
37
|
+
REVISION_DESCRIPTION
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
16
41
|
class OptionSet < PVN::Command::OptionSet
|
17
|
-
|
42
|
+
has_option :revision, SeekRevisionOption
|
43
|
+
has_option :color, PVN::Command::ColorOption
|
18
44
|
# has_option :match, MatchOption
|
45
|
+
has_option :removed, RemovedOption
|
19
46
|
has_option :help, PVN::Command::HelpOption
|
20
47
|
end
|
21
48
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'svnx/cat/command'
|
5
|
+
require 'pvn/log/entries'
|
6
|
+
|
7
|
+
module PVN::Seek
|
8
|
+
class Match
|
9
|
+
attr_reader :index
|
10
|
+
attr_reader :lnum
|
11
|
+
attr_reader :line
|
12
|
+
attr_reader :entry
|
13
|
+
|
14
|
+
def initialize index, lnum, line, entry
|
15
|
+
@index = index
|
16
|
+
@lnum = lnum
|
17
|
+
@line = line
|
18
|
+
@entry = entry
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class PathLogOptions
|
23
|
+
def initialize revision
|
24
|
+
@revision = revision
|
25
|
+
end
|
26
|
+
|
27
|
+
def limit; nil; end
|
28
|
+
def verbose; nil; end
|
29
|
+
def revision; @revision; end
|
30
|
+
def user; nil; end
|
31
|
+
def use_cache; nil; end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Path
|
35
|
+
include Loggable
|
36
|
+
|
37
|
+
def initialize path, pattern, revision
|
38
|
+
@path = path
|
39
|
+
@pattern = pattern
|
40
|
+
@revision = revision
|
41
|
+
get_log_entries
|
42
|
+
end
|
43
|
+
|
44
|
+
def matches? entry
|
45
|
+
contents = cat entry.revision
|
46
|
+
contents.each_with_index do |line, lnum|
|
47
|
+
if line.index @pattern
|
48
|
+
info "line: #{line}".red
|
49
|
+
return [ entry, lnum, line ]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def cat revision
|
56
|
+
info "path: #{@path}"
|
57
|
+
info "revision: #{revision}"
|
58
|
+
catargs = SVNx::CatCommandArgs.new :path => @path, :use_cache => true, :revision => revision
|
59
|
+
cmd = SVNx::CatCommand.new catargs
|
60
|
+
cmd.execute
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_seek_criteria type = :added
|
64
|
+
if type == :added
|
65
|
+
Proc.new { |preventry, currentry| !currentry && preventry }
|
66
|
+
else
|
67
|
+
Proc.new { |preventry, currentry| !preventry && currentry }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def seek type, use_color
|
72
|
+
criteria = get_seek_criteria type
|
73
|
+
ref = seek_for criteria
|
74
|
+
if ref
|
75
|
+
# todo: use previous or current entry, and run through entry formatter in log:
|
76
|
+
log ref.entry.inspect.red
|
77
|
+
entry = @entries[ref.index]
|
78
|
+
info "entry: #{entry}"
|
79
|
+
|
80
|
+
info "use_color: #{use_color}"
|
81
|
+
fromrev = @entries[ref.index + 1].revision
|
82
|
+
torev = @entries[ref.index].revision
|
83
|
+
pathrev = nil
|
84
|
+
line = nil
|
85
|
+
|
86
|
+
if use_color
|
87
|
+
pathrev = "#{@path.yellow} -r#{fromrev.magenta}:#{torev.green}"
|
88
|
+
line = "#{ref.lnum}: #{ref.line.chomp.bold}"
|
89
|
+
else
|
90
|
+
pathrev = "#{@path} -r#{fromrev}:#{torev}"
|
91
|
+
line = "#{ref.lnum}: #{ref.line.chomp}"
|
92
|
+
end
|
93
|
+
|
94
|
+
$io.puts pathrev
|
95
|
+
$io.puts line
|
96
|
+
else
|
97
|
+
msg = type == :added ? "not found" : "not removed"
|
98
|
+
fromrev = @entries[-1].revision
|
99
|
+
torev = @entries[0].revision
|
100
|
+
$io.puts "#{msg} in revisions: #{fromrev} .. #{torev}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def seek_for criteria
|
105
|
+
prevref = nil
|
106
|
+
|
107
|
+
(0 ... @entries.size).each do |idx|
|
108
|
+
entry = @entries[idx]
|
109
|
+
ref = matches? entry
|
110
|
+
|
111
|
+
if idx == 0
|
112
|
+
prevref = ref
|
113
|
+
next
|
114
|
+
end
|
115
|
+
|
116
|
+
info "idx: #{idx}; entry: #{entry}"
|
117
|
+
info "ref: #{ref}"
|
118
|
+
info "prevref: #{prevref}"
|
119
|
+
|
120
|
+
if matchref = criteria.call(prevref, ref)
|
121
|
+
info "matchref: #{matchref}"
|
122
|
+
return Match.new idx - 1, matchref[1], matchref[2], matchref[0]
|
123
|
+
end
|
124
|
+
|
125
|
+
info "ref: #{ref}"
|
126
|
+
|
127
|
+
if ref
|
128
|
+
prevref = ref
|
129
|
+
end
|
130
|
+
end
|
131
|
+
nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_log_entries
|
135
|
+
rev = if @revision
|
136
|
+
if @revision.size == 1
|
137
|
+
[ @revision[0], 'HEAD' ].join(':')
|
138
|
+
else
|
139
|
+
@revision.join(':')
|
140
|
+
end
|
141
|
+
else
|
142
|
+
nil
|
143
|
+
end
|
144
|
+
|
145
|
+
logentries = PVN::Log::Entries.new @path, PathLogOptions.new(rev)
|
146
|
+
@entries = logentries.entries
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/lib/svnx/cat/command.rb
CHANGED
@@ -4,10 +4,11 @@
|
|
4
4
|
require 'svnx/command'
|
5
5
|
|
6
6
|
module SVNx
|
7
|
-
|
7
|
+
module CatCmdLine
|
8
8
|
# this can be either an Array (for which to_a returns itself), or
|
9
9
|
# a CommandArgs, which also has to_a.
|
10
10
|
def initialize args = Array.new
|
11
|
+
info "args: #{args}"
|
11
12
|
super "cat", args.to_a
|
12
13
|
end
|
13
14
|
|
@@ -15,6 +16,14 @@ module SVNx
|
|
15
16
|
false
|
16
17
|
end
|
17
18
|
end
|
19
|
+
|
20
|
+
class CatCommandLine < CommandLine
|
21
|
+
include CatCmdLine
|
22
|
+
end
|
23
|
+
|
24
|
+
class CatCommandLineCaching < CachingCommandLine
|
25
|
+
include CatCmdLine
|
26
|
+
end
|
18
27
|
|
19
28
|
class CatCommandArgs < CommandArgs
|
20
29
|
attr_reader :revision
|
@@ -41,8 +50,14 @@ module SVNx
|
|
41
50
|
end
|
42
51
|
|
43
52
|
class CatCommand < Command
|
53
|
+
def initialize args
|
54
|
+
@use_cache = args.use_cache
|
55
|
+
super
|
56
|
+
end
|
57
|
+
|
44
58
|
def command_line
|
45
|
-
|
59
|
+
cls = @use_cache ? CatCommandLineCaching : CatCommandLine
|
60
|
+
cls.new @args
|
46
61
|
end
|
47
62
|
end
|
48
63
|
end
|
data/lib/svnx/command.rb
CHANGED
@@ -8,11 +8,17 @@ require 'system/command/line'
|
|
8
8
|
# this replaces svnx/lib/command/svncommand.
|
9
9
|
|
10
10
|
module SVNx
|
11
|
-
|
12
|
-
|
11
|
+
DEFAULT_CACHE_DIR = '/tmp/svnx'
|
12
|
+
TMP_DIR_ENV_VARNAME = 'SVNX_TMP_DIR'
|
13
|
+
|
14
|
+
module CmdLine
|
15
|
+
include Loggable
|
16
|
+
|
17
|
+
def initialize subcmd, args
|
13
18
|
info "args: #{args}"
|
14
19
|
cmdargs = [ 'svn', subcmd ]
|
15
20
|
cmdargs << '--xml' if uses_xml?
|
21
|
+
info "cmdargs: #{cmdargs}"
|
16
22
|
cmdargs.concat args
|
17
23
|
info "cmdargs: #{cmdargs}"
|
18
24
|
super cmdargs
|
@@ -21,20 +27,18 @@ module SVNx
|
|
21
27
|
def uses_xml?
|
22
28
|
true
|
23
29
|
end
|
24
|
-
end
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
info "args: #{args}"
|
29
|
-
cmdargs << '--xml' if uses_xml?
|
30
|
-
cmdargs.concat args
|
31
|
-
info "cmdargs: #{cmdargs}"
|
32
|
-
super cmdargs
|
31
|
+
def cache_dir
|
32
|
+
ENV[TMP_DIR_ENV_VARNAME] || DEFAULT_CACHE_DIR
|
33
33
|
end
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
class CommandLine < System::CommandLine
|
37
|
+
include CmdLine
|
38
|
+
end
|
39
|
+
|
40
|
+
class CachingCommandLine < System::CachingCommandLine
|
41
|
+
include CmdLine
|
38
42
|
end
|
39
43
|
|
40
44
|
class CommandArgs
|
data/lib/svnx/entries.rb
CHANGED
@@ -13,12 +13,10 @@ module SVNx
|
|
13
13
|
attr_reader :size
|
14
14
|
|
15
15
|
def initialize args = Hash.new
|
16
|
-
# it's a hash, but indexed with integers
|
16
|
+
# it's a hash, but indexed with integers, for non-sequential access:
|
17
17
|
@entries = Hash.new
|
18
18
|
|
19
19
|
if xmllines = args[:xmllines]
|
20
|
-
# this is preferred
|
21
|
-
|
22
20
|
if xmllines.kind_of? Array
|
23
21
|
xmllines = xmllines.join ''
|
24
22
|
end
|
@@ -33,9 +31,11 @@ module SVNx
|
|
33
31
|
end
|
34
32
|
|
35
33
|
def get_elements doc
|
34
|
+
raise "get_elements must be implemented for: #{self.class}"
|
36
35
|
end
|
37
36
|
|
38
37
|
def create_entry xmlelement
|
38
|
+
raise "create_entry must be implemented for: #{self.class}"
|
39
39
|
end
|
40
40
|
|
41
41
|
# this doesn't handle negative indices
|
@@ -46,12 +46,11 @@ module SVNx
|
|
46
46
|
if idx < 0 && idx >= size
|
47
47
|
raise "error: index #{idx} is not in range(0 .. #{size})"
|
48
48
|
end
|
49
|
-
|
50
49
|
@entries[idx] = create_entry(@elements[idx + 1])
|
51
50
|
end
|
52
51
|
|
53
52
|
def each(&blk)
|
54
|
-
# all elements must be processed before
|
53
|
+
# all elements must be processed before each can run:
|
55
54
|
if @elements
|
56
55
|
# a little confusing here: REXML does each_with_index with idx
|
57
56
|
# zero-based, but elements[0] is invalid.
|
data/lib/svnx/log/command.rb
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'rubygems'
|
5
|
-
require 'riel'
|
6
4
|
require 'system/command/line'
|
7
5
|
require 'system/command/caching'
|
8
6
|
require 'svnx/command'
|
9
7
|
|
10
8
|
module SVNx
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
class LogCommandLine < CommandLine
|
9
|
+
module LogCmdLine
|
10
|
+
# this can be either an Array (for which to_a returns itself), or
|
11
|
+
# a CommandArgs, which also has to_a.
|
16
12
|
def initialize args = Array.new
|
17
13
|
info "args: #{args}"
|
18
14
|
super "log", args.to_a
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
class
|
23
|
-
|
24
|
-
|
25
|
-
super "log", args.to_a
|
26
|
-
end
|
18
|
+
class LogCommandLine < CommandLine
|
19
|
+
include LogCmdLine
|
20
|
+
end
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
22
|
+
class LogCommandLineCaching < CachingCommandLine
|
23
|
+
include LogCmdLine
|
31
24
|
end
|
32
25
|
|
33
26
|
class LogCommandArgs < CommandArgs
|
@@ -81,7 +74,8 @@ module SVNx
|
|
81
74
|
end
|
82
75
|
|
83
76
|
def command_line
|
84
|
-
@use_cache ? LogCommandLineCaching
|
77
|
+
cls = @use_cache ? LogCommandLineCaching : LogCommandLine
|
78
|
+
cls.new @args
|
85
79
|
end
|
86
80
|
end
|
87
81
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
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-11-05 00:00:00 -05:00
|
19
19
|
default_executable: pvn
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/pvn/util/textlines.rb
|
91
91
|
- lib/pvn/util/color_formatter.rb
|
92
92
|
- lib/pvn/util/diffcount.rb
|
93
|
+
- lib/pvn/seek/path.rb
|
93
94
|
- lib/pvn/seek/options.rb
|
94
95
|
- lib/pvn/seek/command.rb
|
95
96
|
- lib/pvn/config.rb
|
@@ -122,8 +123,10 @@ files:
|
|
122
123
|
- lib/pvn/pct/command.rb
|
123
124
|
- lib/pvn/pct/differ.rb
|
124
125
|
- lib/pvn/doc.rb
|
126
|
+
- lib/pvn/log/user_entries.rb
|
125
127
|
- lib/pvn/log/options.rb
|
126
128
|
- lib/pvn/log/command.rb
|
129
|
+
- lib/pvn/log/entries.rb
|
127
130
|
- lib/pvn/log/formatter/entry_formatter.rb
|
128
131
|
- lib/pvn/log/formatter/summary_formatter.rb
|
129
132
|
- lib/pvn/log/formatter/entries_formatter.rb
|