pvn 0.0.11 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/pvn +1 -1
- data/lib/pvn/app/runner.rb +18 -17
- data/lib/pvn/command/clargs.rb +3 -1
- data/lib/pvn/command/color_option.rb +2 -2
- data/lib/pvn/command/command.rb +6 -5
- data/lib/pvn/command/doc.rb +43 -23
- data/lib/pvn/command/options.rb +4 -4
- data/lib/pvn/diff/change.rb +2 -5
- data/lib/pvn/diff/changed_paths.rb +7 -6
- data/lib/pvn/diff/command.rb +9 -5
- data/lib/pvn/diff/diffcmd.rb +52 -0
- data/lib/pvn/diff/differ.rb +2 -1
- data/lib/pvn/diff/diffset.rb +36 -0
- data/lib/pvn/diff/local_path.rb +13 -14
- data/lib/pvn/diff/log_path.rb +24 -34
- data/lib/pvn/diff/log_paths.rb +5 -3
- data/lib/pvn/diff/options.rb +1 -1
- data/lib/pvn/diff/path.rb +12 -48
- data/lib/pvn/diff/paths.rb +6 -3
- data/lib/pvn/diff/repository_differ.rb +4 -1
- data/lib/pvn/diff/status_paths.rb +7 -4
- data/lib/pvn/doc.rb +2 -4
- data/lib/pvn/io/element.rb +27 -85
- data/lib/pvn/io/fselement.rb +8 -2
- data/lib/pvn/log/command.rb +2 -2
- data/lib/pvn/log/entries.rb +13 -27
- data/lib/pvn/log/formatter/date_formatter.rb +16 -0
- data/lib/pvn/log/formatter/entry_formatter.rb +0 -12
- data/lib/pvn/log/formatter/message_formatter.rb +1 -1
- data/lib/pvn/log/formatter/summary_formatter.rb +8 -1
- data/lib/pvn/log/options.rb +4 -4
- data/lib/pvn/log/user_entries.rb +4 -5
- data/lib/pvn/pct/command.rb +9 -9
- data/lib/pvn/pct/differ.rb +2 -3
- data/lib/pvn/pct/local_differ.rb +4 -5
- data/lib/pvn/pct/repository_differ.rb +35 -24
- data/lib/pvn/revision/argument.rb +2 -1
- data/lib/pvn/revision/base_option.rb +5 -10
- data/lib/pvn/revision/range.rb +2 -1
- data/lib/pvn/seek/command.rb +9 -14
- data/lib/pvn/seek/match.rb +65 -0
- data/lib/pvn/seek/options.rb +3 -3
- data/lib/pvn/seek/path.rb +31 -115
- data/lib/pvn/seek/seeker.rb +88 -0
- data/lib/pvn/status/command.rb +2 -1
- data/lib/pvn/status/formatter/entries_formatter.rb +0 -1
- data/lib/pvn/util/color_formatter.rb +9 -3
- data/lib/pvn/util/textlines.rb +2 -2
- data/lib/pvn.rb +1 -1
- data/test/integration/pvn/diff/changed_paths_test.rb +3 -3
- data/test/integration/pvn/diff/local_differ_test.rb +0 -2
- data/test/integration/pvn/diff/log_paths_test.rb +13 -4
- data/test/integration/pvn/diff/repository_differ_test.rb +6 -0
- data/test/integration/pvn/diff/status_paths_test.rb +12 -7
- data/test/integration/pvn/log/command_test.rb +62 -5
- data/test/integration/pvn/pct/local_differ_test.rb +2 -5
- data/test/integration/pvn/pct/repository_differ_test.rb +4 -6
- data/test/integration/pvn/seek/command_test.rb +106 -0
- data/test/integration/pvn/status/command_test.rb +2 -6
- data/test/unit/pvn/app_test.rb +1 -1
- data/test/unit/pvn/diff/change_test.rb +0 -0
- data/test/unit/pvn/diff/path_test.rb +0 -0
- data/test/unit/pvn/io/element/log/log_test.rb +0 -0
- data/test/unit/pvn/log/formatter/entry_formatter_test.rb +9 -12
- data/test/unit/pvn/log/options_test.rb +0 -0
- data/test/unit/pvn/revision/argument_test.rb +0 -0
- data/test/unit/pvn/revision/multiple_revisions_option_test.rb +1 -1
- data/test/unit/pvn/revision/range_test.rb +0 -0
- data/test/unit/pvn/revision/revision_option_test.rb +0 -0
- data/test/unit/pvn/revision/revision_regexp_option_test.rb +0 -0
- metadata +156 -195
- data/README.markdown +0 -43
- data/bin/quote.rb +0 -218
- data/bin/quotes.orig.txt +0 -145
- data/bin/quotes.txt +0 -64
- data/lib/pvn/app.rb +0 -7
- data/lib/pvn/cmddoc.rb +0 -77
- data/lib/pvn/diff/name.rb +0 -23
- data/lib/svnx/action.rb +0 -47
- data/lib/svnx/cat/command.rb +0 -63
- data/lib/svnx/command.rb +0 -77
- data/lib/svnx/entries.rb +0 -67
- data/lib/svnx/entry.rb +0 -58
- data/lib/svnx/info/command.rb +0 -42
- data/lib/svnx/info/entries.rb +0 -19
- data/lib/svnx/info/entry.rb +0 -38
- data/lib/svnx/log/command.rb +0 -81
- data/lib/svnx/log/entries.rb +0 -18
- data/lib/svnx/log/entry.rb +0 -53
- data/lib/svnx/status/command.rb +0 -28
- data/lib/svnx/status/entries.rb +0 -17
- data/lib/svnx/status/entry.rb +0 -53
- data/lib/synoption/base_option.rb +0 -132
- data/lib/synoption/boolean_option.rb +0 -21
- data/lib/synoption/doc.rb +0 -81
- data/lib/synoption/exception.rb +0 -12
- data/lib/synoption/fixnum_option.rb +0 -13
- data/lib/synoption/match.rb +0 -47
- data/lib/synoption/matchers.rb +0 -22
- data/lib/synoption/option.rb +0 -10
- data/lib/synoption/optionable.rb +0 -66
- data/lib/synoption/set.rb +0 -145
- data/lib/system/command/arg.rb +0 -12
- data/lib/system/command/cachefile.rb +0 -53
- data/lib/system/command/caching.rb +0 -36
- data/lib/system/command/line.rb +0 -47
- data/test/integration/pvn/diff/command_test.rb +0 -20
- data/test/unit/svnx/action_test.rb +0 -38
- data/test/unit/svnx/info/entries_test.rb +0 -22
- data/test/unit/svnx/info/entry_test.rb +0 -22
- data/test/unit/svnx/log/cmargs_test.rb +0 -22
- data/test/unit/svnx/log/entries_test.rb +0 -90
- data/test/unit/svnx/log/entry_test.rb +0 -17
- data/test/unit/svnx/status/entries_test.rb +0 -21
- data/test/unit/svnx/status/entry_test.rb +0 -16
- data/test/unit/synoption/base_option_test.rb +0 -182
- data/test/unit/synoption/match_test.rb +0 -61
- data/test/unit/synoption/option_test.rb +0 -15
- data/test/unit/synoption/set_test.rb +0 -53
- data/test/unit/system/command/cachefile_test.rb +0 -53
- data/test/unit/system/command/caching_test.rb +0 -88
- data/test/unit/system/command/line_test.rb +0 -33
data/lib/pvn/diff/log_path.rb
CHANGED
@@ -8,20 +8,25 @@ module PVN::Diff
|
|
8
8
|
# this is a path wrapping a log entry; it could also be a RemotePath or a
|
9
9
|
# RepoPath.
|
10
10
|
class LogPath < Path
|
11
|
-
|
12
11
|
# the "path" parameter is the displayed name; "logpath" is the LogPath.
|
13
|
-
# These are in the process of
|
14
|
-
def show_as_modified elmt, path,
|
15
|
-
|
12
|
+
# These are in the process of being refactored.
|
13
|
+
def show_as_modified elmt, path, changes, revision, whitespace
|
14
|
+
firstrev = changes[0].revision
|
15
|
+
lastrev = changes[-1].revision
|
16
|
+
fromrev, torev = if firstrev == lastrev
|
17
|
+
[ revision.from.value.to_i - 1, revision.to ]
|
18
|
+
else
|
19
|
+
[ firstrev.to_i - 1, lastrev ]
|
20
|
+
end
|
21
|
+
|
22
|
+
fromlines = elmt.cat firstrev
|
16
23
|
tolines = elmt.cat torev
|
17
24
|
fromrev = revision.from.value.to_i
|
18
25
|
run_diff path, fromlines, fromrev, tolines, revision.to, whitespace
|
19
26
|
end
|
20
27
|
|
21
28
|
def show_as_added elmt, path, revision, whitespace
|
22
|
-
info "path: #{path}".on_blue
|
23
29
|
tolines = elmt.cat revision.to
|
24
|
-
info "tolines: #{tolines}".blue
|
25
30
|
run_diff path, nil, 0, tolines, revision.to, whitespace
|
26
31
|
end
|
27
32
|
|
@@ -37,26 +42,18 @@ module PVN::Diff
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def diff_revision_to_revision revision, whitespace
|
40
|
-
logpath = self
|
41
|
-
info "name: #{name}"
|
42
|
-
|
43
45
|
# all the paths will be the same, so any can be selected (actually, a
|
44
46
|
# logpath should have multiple changes)
|
45
47
|
svnpath = url + name
|
46
|
-
info "svnpath: #{svnpath}"
|
47
48
|
elmt = PVN::IO::Element.new :svn => svnpath
|
48
49
|
|
49
50
|
displaypath = get_display_path
|
50
51
|
|
51
|
-
info "revision.from: #{revision.from}".cyan
|
52
|
-
|
53
52
|
rev_change = changes.detect do |chg|
|
54
53
|
revarg = PVN::Revision::Argument.new chg.revision
|
55
54
|
revarg > revision.from
|
56
55
|
end
|
57
56
|
|
58
|
-
info "rev_change: #{rev_change}".green
|
59
|
-
|
60
57
|
# we ignore unversioned logpaths
|
61
58
|
|
62
59
|
# I'm sure there is a bunch of permutations here, so this is probably
|
@@ -69,26 +66,17 @@ module PVN::Diff
|
|
69
66
|
when action.deleted?
|
70
67
|
show_as_deleted elmt, displaypath, revision, whitespace
|
71
68
|
when action.modified?
|
72
|
-
|
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
|
69
|
+
show_as_modified elmt, displaypath, changes, revision, whitespace
|
80
70
|
end
|
81
71
|
end
|
82
72
|
|
83
73
|
def get_diff_revision change, revision
|
84
|
-
info "change: #{change}"
|
85
|
-
info "revision: #{revision}"
|
86
74
|
# find the first revision where logpath was in svn, no earlier than the
|
87
75
|
# revision.from value
|
88
76
|
if change.action.added?
|
89
|
-
|
77
|
+
change.revision.to_i
|
90
78
|
elsif change.revision.to_i >= revision.from.value
|
91
|
-
|
79
|
+
revision.from.value
|
92
80
|
else
|
93
81
|
nil
|
94
82
|
end
|
@@ -101,31 +89,34 @@ module PVN::Diff
|
|
101
89
|
### modified.
|
102
90
|
|
103
91
|
change = revisions_later_than(fromrev).first
|
104
|
-
info "change: #{change}".red
|
92
|
+
info "change: #{change}".color(:red)
|
105
93
|
|
106
94
|
# revision should be a class here, not a primitive
|
107
95
|
diffrev = get_diff_revision change, revision
|
108
96
|
|
109
|
-
|
97
|
+
displaypath = get_display_path
|
110
98
|
|
111
|
-
pn = Pathname.new
|
99
|
+
pn = Pathname.new displaypath
|
112
100
|
|
101
|
+
info "url: #{url}"
|
102
|
+
info "name: #{name}"
|
113
103
|
svnpath = url + name
|
114
104
|
info "svnpath: #{svnpath}"
|
105
|
+
|
115
106
|
elmt = PVN::IO::Element.new :svn => svnpath
|
116
107
|
|
117
108
|
if change.action.added?
|
118
|
-
show_as_added elmt,
|
109
|
+
show_as_added elmt, displaypath, revision, whitespace
|
119
110
|
else
|
120
111
|
fromlines = elmt.cat diffrev
|
121
112
|
info "fromlines.size: #{fromlines.size}"
|
122
|
-
pp fromlines
|
113
|
+
# pp fromlines
|
123
114
|
|
124
115
|
tolines = pn.readlines
|
125
116
|
info "tolines.size: #{tolines.size}"
|
126
|
-
pp tolines
|
117
|
+
# pp tolines
|
127
118
|
|
128
|
-
run_diff
|
119
|
+
run_diff displaypath, fromlines, diffrev, tolines, nil, whitespace
|
129
120
|
end
|
130
121
|
end
|
131
122
|
|
@@ -135,7 +126,6 @@ module PVN::Diff
|
|
135
126
|
|
136
127
|
def revisions_later_than revision
|
137
128
|
changes.select do |chg|
|
138
|
-
info "chg: #{chg.revision.inspect}"
|
139
129
|
x = PVN::Revision::Argument.new chg.revision
|
140
130
|
y = PVN::Revision::Argument.new revision
|
141
131
|
x > y
|
data/lib/pvn/diff/log_paths.rb
CHANGED
@@ -4,11 +4,12 @@
|
|
4
4
|
require 'pvn/io/element'
|
5
5
|
require 'pvn/diff/paths'
|
6
6
|
require 'pvn/diff/log_path'
|
7
|
+
require 'logue/loggable'
|
7
8
|
|
8
9
|
module PVN::Diff
|
9
10
|
# represents the log entries from one revision through another.
|
10
11
|
class LogPaths < Paths
|
11
|
-
include Loggable
|
12
|
+
include Logue::Loggable
|
12
13
|
|
13
14
|
def add_for_path path
|
14
15
|
pathelmt = PVN::IO::Element.new :local => path
|
@@ -31,13 +32,14 @@ module PVN::Diff
|
|
31
32
|
url = pathinfo.url
|
32
33
|
|
33
34
|
info "action: #{action}"
|
35
|
+
info "url: #{url}"
|
34
36
|
|
35
37
|
path = @elements.detect { |element| element.name == name }
|
36
38
|
if path
|
37
39
|
info "path: #{path}"
|
38
|
-
path.add_change
|
40
|
+
path.add_change revision, action
|
39
41
|
else
|
40
|
-
path = LogPath.new(name,
|
42
|
+
path = LogPath.new(name, revision, action, url)
|
41
43
|
info "path: #{path}"
|
42
44
|
@elements << path
|
43
45
|
end
|
data/lib/pvn/diff/options.rb
CHANGED
@@ -7,7 +7,7 @@ require 'pvn/revision/base_option'
|
|
7
7
|
require 'pvn/command/options'
|
8
8
|
|
9
9
|
module PVN::Diff
|
10
|
-
class WhitespaceOption <
|
10
|
+
class WhitespaceOption < Synoption::BooleanOption
|
11
11
|
def initialize optargs = Hash.new
|
12
12
|
super :whitespace, '-w', 'ignore all whitespace', false
|
13
13
|
end
|
data/lib/pvn/diff/path.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'logue/loggable'
|
5
|
+
require 'riel/pathname'
|
5
6
|
require 'pvn/diff/change'
|
6
|
-
|
7
|
-
module PVN; module Diff; end; end
|
7
|
+
require 'pvn/diff/diffset'
|
8
8
|
|
9
9
|
module PVN::Diff
|
10
10
|
class Path
|
11
|
-
include Loggable
|
11
|
+
include Logue::Loggable
|
12
12
|
|
13
13
|
attr_reader :name
|
14
14
|
attr_reader :url
|
@@ -21,9 +21,8 @@ module PVN::Diff
|
|
21
21
|
add_change revision, action
|
22
22
|
@url = url
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def add_change rev, action
|
26
|
-
info "rev: #{rev}"
|
27
26
|
@changes << Change.new(to_revision(rev), action)
|
28
27
|
end
|
29
28
|
|
@@ -33,52 +32,17 @@ module PVN::Diff
|
|
33
32
|
rev.kind_of?(Fixnum) ? rev.to_s : rev
|
34
33
|
end
|
35
34
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
def to_revision_string rev
|
41
|
-
rev ? "revision #{rev}" : "working copy"
|
35
|
+
def run_diff displaypath, fromlines, fromrev, tolines, torev, whitespace
|
36
|
+
ds = DiffSet.new displaypath, fromlines, fromrev, tolines, torev, whitespace
|
37
|
+
ds.run_diff
|
42
38
|
end
|
43
39
|
|
44
|
-
def
|
45
|
-
|
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
|
40
|
+
def to_s
|
41
|
+
"#{name}; #{url}"
|
64
42
|
end
|
65
43
|
|
66
|
-
def
|
67
|
-
|
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
|
44
|
+
def <=> other
|
45
|
+
name <=> other.name
|
82
46
|
end
|
83
47
|
end
|
84
48
|
end
|
data/lib/pvn/diff/paths.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
+
require 'logue/loggable'
|
5
|
+
require 'set'
|
6
|
+
|
4
7
|
module PVN::Diff
|
5
8
|
# represents the paths from one revision through another.
|
6
9
|
class Paths
|
7
|
-
include Loggable, Enumerable
|
10
|
+
include Logue::Loggable, Enumerable
|
8
11
|
|
9
12
|
# takes paths of the form ".", "foo.rb", etc.
|
10
13
|
def initialize revision, paths
|
11
14
|
@revision = revision
|
12
|
-
@elements =
|
15
|
+
@elements = SortedSet.new
|
13
16
|
|
14
17
|
paths.each do |path|
|
15
18
|
add_for_path path
|
@@ -21,7 +24,7 @@ module PVN::Diff
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def [] idx
|
24
|
-
@elements[idx]
|
27
|
+
@elements.to_a[idx]
|
25
28
|
end
|
26
29
|
|
27
30
|
def size
|
@@ -6,10 +6,11 @@ require 'pvn/diff/differ'
|
|
6
6
|
require 'pvn/diff/log_paths'
|
7
7
|
require 'pvn/diff/status_paths'
|
8
8
|
require 'pvn/diff/changed_paths'
|
9
|
+
require 'logue/loggable'
|
9
10
|
|
10
11
|
module PVN::Diff
|
11
12
|
class RepositoryDiffer < Differ
|
12
|
-
include Loggable
|
13
|
+
include Logue::Loggable
|
13
14
|
|
14
15
|
attr_reader :whitespace
|
15
16
|
attr_reader :revision
|
@@ -20,6 +21,8 @@ module PVN::Diff
|
|
20
21
|
paths = options.paths
|
21
22
|
paths = %w{ . } if paths.empty?
|
22
23
|
|
24
|
+
info "paths: #{paths}"
|
25
|
+
|
23
26
|
# we sort only the sub-entries, so the order in which paths were specified is preserved
|
24
27
|
|
25
28
|
rev = options.revision
|
@@ -4,10 +4,12 @@
|
|
4
4
|
require 'pvn/io/element'
|
5
5
|
require 'pvn/diff/path'
|
6
6
|
require 'pvn/diff/paths'
|
7
|
+
require 'logue/loggable'
|
8
|
+
require 'pvn/diff/local_path'
|
7
9
|
|
8
10
|
module PVN::Diff
|
9
11
|
class StatusPaths < Paths
|
10
|
-
include Loggable
|
12
|
+
include Logue::Loggable
|
11
13
|
|
12
14
|
def add_for_path path
|
13
15
|
pathelmt = PVN::IO::Element.new :local => path
|
@@ -23,12 +25,13 @@ module PVN::Diff
|
|
23
25
|
next if entry.status == 'unversioned'
|
24
26
|
|
25
27
|
# svn log prepends /; svn status does not
|
26
|
-
name = '/' + entry.path
|
27
|
-
rev = :working_copy
|
28
|
+
# name = '/' + entry.path
|
29
|
+
# rev = :working_copy
|
28
30
|
|
29
31
|
# what Status::Entry calls a status, we call an action, unifying it with
|
30
32
|
# svn log representation.
|
31
|
-
action = entry.status
|
33
|
+
# action = entry.status
|
34
|
+
|
32
35
|
info "entry.status_revision: #{entry.status_revision}"
|
33
36
|
path = LocalPath.new entry
|
34
37
|
@elements << path
|
data/lib/pvn/doc.rb
CHANGED
@@ -2,14 +2,12 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require '
|
5
|
+
require 'logue/loggable'
|
6
6
|
require 'pvn/documenter'
|
7
7
|
|
8
|
-
# Log.level = Log::DEBUG
|
9
|
-
|
10
8
|
module PVN
|
11
9
|
module Doc
|
12
|
-
include Loggable
|
10
|
+
include Logue::Loggable
|
13
11
|
|
14
12
|
def self.included base
|
15
13
|
base.extend ClassMethods
|
data/lib/pvn/io/element.rb
CHANGED
@@ -2,20 +2,12 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require '
|
6
|
-
|
7
|
-
require 'svnx/log/command'
|
5
|
+
require 'logue/loggable'
|
8
6
|
require 'svnx/log/entries'
|
9
|
-
|
10
|
-
require 'svnx/status/command'
|
11
7
|
require 'svnx/status/entries'
|
12
|
-
|
13
|
-
require 'svnx/info/command'
|
14
8
|
require 'svnx/info/entries'
|
15
|
-
|
16
|
-
require 'svnx/cat/command'
|
17
|
-
|
18
9
|
require 'pvn/io/fselement'
|
10
|
+
require 'svnx/exec'
|
19
11
|
|
20
12
|
module PVN; module IO; end; end
|
21
13
|
|
@@ -24,23 +16,23 @@ module PVN::IO
|
|
24
16
|
# which should exist).
|
25
17
|
|
26
18
|
class Element
|
27
|
-
include Loggable
|
19
|
+
include Logue::Loggable
|
28
20
|
|
29
21
|
attr_reader :svn
|
30
22
|
attr_reader :local
|
31
23
|
|
32
24
|
def initialize args = Hash.new
|
33
|
-
info "args: #{args}"
|
25
|
+
info "args: #{args.inspect}".color("438802")
|
34
26
|
|
35
|
-
svnurl = args[:svnurl]
|
36
|
-
fname = args[:filename] || args[:file] # legacy
|
27
|
+
# svnurl = args[:svnurl]
|
28
|
+
# fname = args[:filename] || args[:file] # legacy
|
37
29
|
# $$$ todo: map svnurl to SVNElement, and fname to FSElement
|
38
30
|
|
39
31
|
@svn = args[:svn] || (args[:file] && SVNElement.new(:filename => args[:file]))
|
40
32
|
@local = args[:local] && PVN::FSElement.new(args[:local] || args[:file])
|
41
33
|
@path = args[:path]
|
42
34
|
|
43
|
-
info "local: #{@local}"
|
35
|
+
info "local: #{@local.inspect}"
|
44
36
|
end
|
45
37
|
|
46
38
|
def exist?
|
@@ -66,9 +58,7 @@ module PVN::IO
|
|
66
58
|
|
67
59
|
def get_info revision = nil
|
68
60
|
usepath = @local || @path
|
69
|
-
|
70
|
-
infcmd = SVNx::InfoCommand.new cmdargs
|
71
|
-
output = infcmd.execute
|
61
|
+
output = SVNx::Exec.new.info usepath, revision
|
72
62
|
|
73
63
|
infentries = SVNx::Info::Entries.new :xmllines => output
|
74
64
|
infentries[0]
|
@@ -81,35 +71,27 @@ module PVN::IO
|
|
81
71
|
def has_revision? rev
|
82
72
|
# was there a revision then?
|
83
73
|
begin
|
84
|
-
|
74
|
+
get_info rev
|
85
75
|
true
|
86
76
|
rescue => e
|
87
|
-
|
88
|
-
|
77
|
+
puts "e: #{e}"
|
78
|
+
raise e
|
79
|
+
# false
|
89
80
|
end
|
90
81
|
end
|
91
82
|
|
92
83
|
# returns a set of entries modified over the given revision
|
93
84
|
def find_modified_entries revision
|
94
|
-
cmdargs = Hash.new
|
95
|
-
|
96
85
|
svninfo = get_info
|
97
86
|
|
98
87
|
filter = svninfo.url.dup
|
99
88
|
filter.slice! svninfo.root
|
100
89
|
|
101
|
-
cmdargs[:path] = @local
|
102
|
-
|
103
90
|
# we can't cache this, because we don't know if there has been an svn
|
104
91
|
# update since the previous run:
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
cmdargs[:revision] = revision
|
109
|
-
|
110
|
-
logargs = SVNx::LogCommandArgs.new cmdargs
|
111
|
-
entries = log(logargs).entries
|
112
|
-
|
92
|
+
xmllines = SVNx::Exec.new.log @local, revision, nil, true, false
|
93
|
+
entries = SVNx::Log::Entries.new :xmllines => xmllines
|
94
|
+
|
113
95
|
modified = Set.new
|
114
96
|
|
115
97
|
entries.each do |entry|
|
@@ -123,43 +105,27 @@ module PVN::IO
|
|
123
105
|
modified
|
124
106
|
end
|
125
107
|
|
126
|
-
def xxxcat_remote rev = nil
|
127
|
-
path = @local || @svn
|
128
|
-
info "path: #{path}".blue
|
129
|
-
info "rev: #{rev}; #{rev.class}".blue
|
130
|
-
catargs = SVNx::CatCommandArgs.new :path => path, :use_cache => false, :revision => rev
|
131
|
-
cmd = SVNx::CatCommand.new catargs
|
132
|
-
cmd.execute
|
133
|
-
end
|
134
|
-
|
135
108
|
def cat revision, use_cache = false
|
109
|
+
info "@local: #{@local}"
|
110
|
+
info "@path: #{@path}"
|
111
|
+
info "@svn: #{@svn}"
|
112
|
+
|
136
113
|
path = (@local || @path || @svn).dup
|
114
|
+
info "path: #{path.to_s}"
|
137
115
|
if revision && revision != :working_copy
|
138
116
|
path << '@' << revision.to_s
|
139
117
|
end
|
140
118
|
info "path: #{path}"
|
141
|
-
|
142
|
-
cmd = SVNx::CatCommand.new catargs
|
143
|
-
cmd.execute
|
144
|
-
end
|
145
|
-
|
146
|
-
# returns a set of local files that are in the given status
|
147
|
-
def find_files
|
119
|
+
SVNx::Exec.new.cat path, nil, use_cache
|
148
120
|
end
|
149
121
|
|
150
122
|
# returns a set of local files that are in the given status
|
151
123
|
def find_files_by_status status = nil
|
152
|
-
|
153
|
-
cmd = SVNx::StatusCommand.new cmdargs
|
154
|
-
xmllines = cmd.execute
|
124
|
+
xmllines = SVNx::Exec.new.status @local, false
|
155
125
|
entries = SVNx::Status::Entries.new :xmllines => xmllines
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
entry.status == status
|
160
|
-
end
|
161
|
-
else
|
162
|
-
entries
|
126
|
+
|
127
|
+
entries.select do |entry|
|
128
|
+
status.nil? || entry.status == status
|
163
129
|
end
|
164
130
|
end
|
165
131
|
|
@@ -168,37 +134,13 @@ module PVN::IO
|
|
168
134
|
find_files_by_status 'modified'
|
169
135
|
end
|
170
136
|
|
171
|
-
# returns log entries
|
172
|
-
def log cmdargs = SVNx::LogCommandArgs.new
|
173
|
-
# $$$ todo: this should be either @local if set, otherwise @svn (url)
|
174
|
-
# cmdargs.path = @local
|
175
|
-
cmd = SVNx::LogCommand.new cmdargs
|
176
|
-
SVNx::Log::Entries.new :xmllines => cmd.execute
|
177
|
-
end
|
178
|
-
|
179
137
|
# returns log entries
|
180
138
|
def logentries revision
|
181
139
|
# use_cache should be conditional on revision:
|
182
|
-
|
183
|
-
|
184
|
-
cmd = SVNx::LogCommand.new cmdargs
|
185
|
-
SVNx::Log::Entries.new :xmllines => cmd.execute
|
140
|
+
xmllines = SVNx::Exec.new.log @local, revision.to_s, nil, true, false
|
141
|
+
SVNx::Log::Entries.new :xmllines => xmllines
|
186
142
|
end
|
187
143
|
|
188
|
-
# returns :added, :deleted, "modified"
|
189
|
-
def status
|
190
|
-
cmdargs = SVNx::StatusCommandArgs.new :path => @local
|
191
|
-
cmd = SVNx::StatusCommand.new :cmdargs => cmdargs
|
192
|
-
xmllines = cmd.execute
|
193
|
-
entries = SVNx::Status::Entries.new :xmllines => xmllines
|
194
|
-
entry = entries[0]
|
195
|
-
entry.status
|
196
|
-
end
|
197
|
-
|
198
|
-
# def line_counts
|
199
|
-
# [ @svnelement && @svnelement.line_count, @fselement && @fselement.line_count ]
|
200
|
-
# end
|
201
|
-
|
202
144
|
def <=> other
|
203
145
|
@svn <=> other.svn
|
204
146
|
end
|
data/lib/pvn/io/fselement.rb
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require 'riel'
|
5
|
+
require 'riel/pathname'
|
6
|
+
require 'logue/loggable'
|
6
7
|
|
7
8
|
module PVN
|
8
9
|
# A filesystem element (directory or file).
|
9
10
|
class FSElement < Pathname
|
10
|
-
include Loggable
|
11
|
+
include Logue::Loggable
|
12
|
+
|
11
13
|
attr_reader :name
|
12
14
|
|
13
15
|
def initialize name
|
@@ -18,5 +20,9 @@ module PVN
|
|
18
20
|
def line_count
|
19
21
|
readlines.size
|
20
22
|
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
super
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
data/lib/pvn/log/command.rb
CHANGED
@@ -16,9 +16,9 @@ module PVN::Log
|
|
16
16
|
subcommands [ "log" ]
|
17
17
|
description "Print log messages for the given files."
|
18
18
|
usage "[OPTIONS] FILE..."
|
19
|
-
summary [ "Prints the log entries for the given files, with colorized",
|
19
|
+
summary [ "Prints the log entries for the given files, with colorized ",
|
20
20
|
"output. Unlike 'svn log', which prints all log entries, ",
|
21
|
-
"'pvn log' prints #{DEFAULT_LIMIT} entries by default.",
|
21
|
+
"'pvn log' prints #{DEFAULT_LIMIT} entries by default. ",
|
22
22
|
"As with other pvn subcommands, 'pvn log' accepts relative ",
|
23
23
|
"revisions."
|
24
24
|
]
|
data/lib/pvn/log/entries.rb
CHANGED
@@ -1,42 +1,28 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'logue/loggable'
|
5
|
+
require 'svnx/exec'
|
5
6
|
require 'svnx/log/entries'
|
6
7
|
|
7
8
|
module PVN::Log
|
8
9
|
class Entries < SVNx::Log::Entries
|
9
|
-
include Loggable
|
10
|
+
include Logue::Loggable
|
10
11
|
|
11
12
|
def initialize path, options
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
info "cmdargs: #{cmdargs}".magenta
|
13
|
+
revision = options.revision
|
14
|
+
limit = limit options
|
15
|
+
verbose = options.files
|
16
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
17
|
# we can't cache this, because we don't know if there has been an svn
|
37
18
|
# update since the previous run:
|
38
|
-
|
39
|
-
|
19
|
+
use_cache = false
|
20
|
+
xmllines = SVNx::Exec.new.log path, revision, limit, verbose, use_cache
|
21
|
+
super :xmllines => xmllines
|
22
|
+
end
|
23
|
+
|
24
|
+
def limit options
|
25
|
+
options.limit
|
40
26
|
end
|
41
27
|
end
|
42
28
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module PVN::Log
|
7
|
+
# a format for the date.
|
8
|
+
class DateFormatter
|
9
|
+
DEFAULT_FORMAT = "%y-%m-%d %H:%M:%S"
|
10
|
+
|
11
|
+
def format date
|
12
|
+
dt = date.kind_of?(DateTime) ? date : DateTime.parse(date.to_s)
|
13
|
+
dt.strftime DEFAULT_FORMAT
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|