pvn 0.0.11 → 0.1.1
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.
- 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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8783d050b1dd5c8455f7207f9a1933b00ac080b3
|
|
4
|
+
data.tar.gz: 74df918bdd23b67089dddad91d5736162e72e49f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a84f65d9a725d0f1d45127836d079f2e6bd7d359664f66f828f6c051ca6ed7092757cdfd5654a48eb96a5a0e90c65fdeae3f23bb488c73b83b0044678301457a
|
|
7
|
+
data.tar.gz: c3520d5756c9d08280cf979ec9fbafcda60ca4f366973a9132c10cff1da5a956d4de78a79a1ef37c56558c02a0a5672cc2d7800250ea53a8a1764534a13f2f5f
|
data/bin/pvn
CHANGED
data/lib/pvn/app/runner.rb
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
# -*- ruby -*-
|
|
3
3
|
|
|
4
4
|
require 'rubygems'
|
|
5
|
-
require '
|
|
5
|
+
require 'logue/loggable'
|
|
6
|
+
require 'logue/log'
|
|
6
7
|
|
|
7
8
|
require 'pvn'
|
|
8
9
|
require 'pvn/io/element'
|
|
@@ -13,20 +14,11 @@ require 'pvn/status/command'
|
|
|
13
14
|
require 'pvn/diff/command'
|
|
14
15
|
require 'pvn/seek/command'
|
|
15
16
|
|
|
16
|
-
# the old ones:
|
|
17
|
-
# require 'pvn/diff/diffcmd'
|
|
18
|
-
# require 'pvn/pct/pctcmd'
|
|
19
|
-
|
|
20
|
-
# the new ones:
|
|
21
|
-
# require 'pvn/describe'
|
|
22
|
-
# require 'pvn/upp/uppcmd'
|
|
23
|
-
# require 'pvn/wherecmd'
|
|
24
|
-
|
|
25
17
|
module PVN; module App; end; end
|
|
26
18
|
|
|
27
19
|
module PVN::App
|
|
28
20
|
class Runner
|
|
29
|
-
include Loggable
|
|
21
|
+
include Logue::Loggable
|
|
30
22
|
|
|
31
23
|
SUBCOMMANDS = [ PVN::Log::Command,
|
|
32
24
|
PVN::Pct::Command,
|
|
@@ -39,8 +31,8 @@ module PVN::App
|
|
|
39
31
|
]
|
|
40
32
|
|
|
41
33
|
def initialize io, args
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
Logue::Log.level = Logue::Log::WARN
|
|
35
|
+
Logue::Log.set_widths(-25, 5, -35)
|
|
44
36
|
|
|
45
37
|
if args.empty?
|
|
46
38
|
run_help args
|
|
@@ -51,8 +43,10 @@ module PVN::App
|
|
|
51
43
|
info "arg: #{arg}"
|
|
52
44
|
|
|
53
45
|
case arg
|
|
46
|
+
when "-v", "--version"
|
|
47
|
+
show_version
|
|
54
48
|
when "--verbose"
|
|
55
|
-
|
|
49
|
+
Logue::Log.level = Logue::Log::DEBUG
|
|
56
50
|
when "help", "--help", "-h"
|
|
57
51
|
run_help args
|
|
58
52
|
else
|
|
@@ -70,10 +64,17 @@ module PVN::App
|
|
|
70
64
|
run_help args
|
|
71
65
|
end
|
|
72
66
|
|
|
67
|
+
def show_version
|
|
68
|
+
puts "pvn, version #{PVN::VERSION}"
|
|
69
|
+
puts "Written by Jeff Pace (jeugenepace@gmail.com)."
|
|
70
|
+
puts "Released under the I Haven't Decided Yet License."
|
|
71
|
+
exit 0
|
|
72
|
+
end
|
|
73
|
+
|
|
73
74
|
def run_command cmdcls, args
|
|
74
75
|
begin
|
|
75
76
|
cmdcls.new args
|
|
76
|
-
exit
|
|
77
|
+
exit 0
|
|
77
78
|
rescue => e
|
|
78
79
|
puts e.backtrace
|
|
79
80
|
$stderr.puts e
|
|
@@ -84,8 +85,8 @@ module PVN::App
|
|
|
84
85
|
def run_help args
|
|
85
86
|
forwhat = args[0]
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
SUBCOMMANDS.each do |sc|
|
|
89
|
+
info "sc: #{sc}"
|
|
89
90
|
if sc.matches_subcommand? forwhat
|
|
90
91
|
sc.new(%w{ --help })
|
|
91
92
|
exit 0
|
data/lib/pvn/command/clargs.rb
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
require 'synoption/boolean_option'
|
|
5
5
|
|
|
6
6
|
module PVN::Command
|
|
7
|
-
class ColorOption <
|
|
7
|
+
class ColorOption < Synoption::BooleanOption
|
|
8
8
|
def initialize optargs = Hash.new
|
|
9
|
-
super :color,
|
|
9
|
+
super :color, nil, "show colorized output", true, :negate => [ '-C', %r{^--no-?color} ], :as_cmdline_option => nil
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
data/lib/pvn/command/command.rb
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
# -*- ruby -*-
|
|
3
3
|
|
|
4
4
|
require 'pvn/command/doc'
|
|
5
|
+
require 'logue/loggable'
|
|
5
6
|
|
|
6
7
|
module PVN; module Command; end; end
|
|
7
8
|
|
|
8
9
|
module PVN::Command
|
|
9
10
|
class Command
|
|
10
|
-
include Loggable
|
|
11
|
+
include Logue::Loggable
|
|
11
12
|
|
|
12
13
|
@@doc_for_class = Hash.new { |h, k| h[k] = PVN::Command::Documentation.new }
|
|
13
14
|
|
|
@@ -39,7 +40,7 @@ module PVN::Command
|
|
|
39
40
|
def optset
|
|
40
41
|
optmodule = to_s.sub %r{::\w+$}, ''
|
|
41
42
|
optcls = optmodule + '::OptionSet'
|
|
42
|
-
|
|
43
|
+
instance_eval optcls + '.new'
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def example *ex
|
|
@@ -51,13 +52,13 @@ module PVN::Command
|
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def to_doc
|
|
55
|
+
def to_doc
|
|
55
56
|
doc = self.class.getdoc
|
|
56
|
-
doc.write
|
|
57
|
+
doc.write
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
def show_help
|
|
60
|
-
to_doc
|
|
61
|
+
to_doc
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
def initialize args
|
data/lib/pvn/command/doc.rb
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
# -*- ruby -*-
|
|
3
3
|
|
|
4
4
|
require 'rubygems'
|
|
5
|
-
require '
|
|
5
|
+
require 'rubygems/text'
|
|
6
6
|
|
|
7
7
|
module PVN; module Command; end; end
|
|
8
8
|
|
|
9
|
-
# this is the same as in pvn/cmddoc.rb
|
|
10
|
-
|
|
11
9
|
module PVN::Command
|
|
12
10
|
class Documentation
|
|
11
|
+
include Gem::Text
|
|
12
|
+
|
|
13
|
+
SUMMARY_RE = Regexp.new '^(?:(.*)(?:NOWRAP(.*)/NOWRAP)|(.*))(.*)$', Regexp::MULTILINE
|
|
14
|
+
|
|
13
15
|
attr_accessor :description
|
|
14
16
|
attr_accessor :usage
|
|
15
17
|
attr_accessor :summary
|
|
@@ -40,9 +42,27 @@ module PVN::Command
|
|
|
40
42
|
@subcommands = args
|
|
41
43
|
end
|
|
42
44
|
|
|
43
|
-
def
|
|
44
|
-
|
|
45
|
+
def wrap out, str
|
|
46
|
+
# I could use tput cols; ENV['COLUMNS'] works in irb, not in Ruby scripts.
|
|
47
|
+
out.puts format_text str.gsub("\n", ''), 78, 2
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def write_summary out
|
|
51
|
+
summary.join("\n").scan(SUMMARY_RE) do |md|
|
|
52
|
+
if md[2]
|
|
53
|
+
wrap out, md[2]
|
|
54
|
+
next
|
|
55
|
+
end
|
|
45
56
|
|
|
57
|
+
wrap out, md[0]
|
|
58
|
+
out.puts md[1].collect { |x| " " + x }
|
|
59
|
+
|
|
60
|
+
out.puts
|
|
61
|
+
wrap out, md[3]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def write out = $io
|
|
46
66
|
subcmds = @subcommands
|
|
47
67
|
|
|
48
68
|
subcmdstr = subcmds[0].dup
|
|
@@ -50,45 +70,45 @@ module PVN::Command
|
|
|
50
70
|
subcmdstr << " (" << subcmds[1 .. -1].join(" ") << ")"
|
|
51
71
|
end
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
write_section "options", @options,
|
|
73
|
+
out.puts subcmdstr + ": " + @description
|
|
74
|
+
out.puts "usage: " + subcmds[0] + " " + @usage
|
|
75
|
+
out.puts ""
|
|
76
|
+
write_summary out
|
|
77
|
+
|
|
78
|
+
write_section "options", @options, out do |opt, io|
|
|
59
79
|
option_to_doc opt, io
|
|
60
80
|
end
|
|
61
81
|
|
|
62
|
-
write_section "examples", @examples,
|
|
82
|
+
write_section "examples", @examples, out do |ex, io|
|
|
63
83
|
example_to_doc ex, io
|
|
64
84
|
end
|
|
65
85
|
end
|
|
66
86
|
|
|
67
|
-
def write_section name, section,
|
|
87
|
+
def write_section name, section, out
|
|
68
88
|
if section.length > 0
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
out.puts ""
|
|
90
|
+
out.puts "#{name.capitalize}:"
|
|
91
|
+
out.puts ""
|
|
72
92
|
|
|
73
93
|
section.each do |opt|
|
|
74
|
-
yield opt,
|
|
94
|
+
yield opt, out
|
|
75
95
|
end
|
|
76
96
|
end
|
|
77
97
|
end
|
|
78
98
|
|
|
79
|
-
def example_to_doc ex,
|
|
99
|
+
def example_to_doc ex, out
|
|
80
100
|
ex.each_with_index do |line, idx|
|
|
81
101
|
if idx == 0
|
|
82
|
-
|
|
102
|
+
out.puts " % #{line}"
|
|
83
103
|
else
|
|
84
|
-
|
|
104
|
+
out.puts " #{line}"
|
|
85
105
|
end
|
|
86
106
|
end
|
|
87
|
-
|
|
107
|
+
out.puts
|
|
88
108
|
end
|
|
89
109
|
|
|
90
|
-
def option_to_doc opt,
|
|
91
|
-
opt.to_doc
|
|
110
|
+
def option_to_doc opt, out
|
|
111
|
+
opt.to_doc out
|
|
92
112
|
end
|
|
93
113
|
end
|
|
94
114
|
end
|
data/lib/pvn/command/options.rb
CHANGED
|
@@ -9,23 +9,23 @@ require 'synoption/fixnum_option'
|
|
|
9
9
|
module PVN; module Command; end; end
|
|
10
10
|
|
|
11
11
|
module PVN::Command
|
|
12
|
-
class HelpOption <
|
|
12
|
+
class HelpOption < Synoption::BooleanOption
|
|
13
13
|
def initialize args = Hash.new
|
|
14
14
|
super :help, '-h', "display help", nil
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
class VerboseOption <
|
|
18
|
+
class VerboseOption < Synoption::BooleanOption
|
|
19
19
|
def initialize optargs = Hash.new
|
|
20
20
|
super :verbose, '-v', [ "display verbose output" ], false
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def set_value val
|
|
24
|
-
|
|
24
|
+
Logue::Log.level = Logue::Log::DEBUG
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
class OptionSet <
|
|
28
|
+
class OptionSet < Synoption::OptionSet
|
|
29
29
|
has_option :help, HelpOption
|
|
30
30
|
has_option :verbose, VerboseOption
|
|
31
31
|
|
data/lib/pvn/diff/change.rb
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
# -*- ruby -*-
|
|
3
3
|
|
|
4
4
|
require 'svnx/action'
|
|
5
|
+
require 'logue/loggable'
|
|
5
6
|
|
|
6
7
|
module PVN; module Diff; end; end
|
|
7
8
|
|
|
8
9
|
# A Path Revision is the change to a path within a changelist.
|
|
9
10
|
module PVN::Diff
|
|
10
11
|
class Change
|
|
11
|
-
include Loggable
|
|
12
|
+
include Logue::Loggable
|
|
12
13
|
|
|
13
14
|
attr_reader :revision
|
|
14
15
|
attr_reader :action
|
|
@@ -23,9 +24,5 @@ module PVN::Diff
|
|
|
23
24
|
# Revision::Range?
|
|
24
25
|
rev.kind_of?(Fixnum) ? rev.to_s : rev
|
|
25
26
|
end
|
|
26
|
-
|
|
27
|
-
def to_s
|
|
28
|
-
inspect
|
|
29
|
-
end
|
|
30
27
|
end
|
|
31
28
|
end
|
|
@@ -5,22 +5,23 @@ require 'pvn/diff/log_paths'
|
|
|
5
5
|
require 'pvn/diff/status_paths'
|
|
6
6
|
require 'pvn/diff/local_path'
|
|
7
7
|
require 'pvn/revision/range'
|
|
8
|
+
require 'logue/loggable'
|
|
8
9
|
|
|
9
10
|
module PVN::Diff
|
|
10
11
|
# represents both LogPaths and StatusPaths
|
|
11
12
|
class ChangedPaths
|
|
12
|
-
include Loggable
|
|
13
|
+
include Logue::Loggable
|
|
13
14
|
|
|
14
15
|
def initialize paths
|
|
15
16
|
@paths = paths
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def diff_revision_to_working_copy revision, whitespace
|
|
19
|
-
fromrev = revision.from.value
|
|
20
|
+
# fromrev = revision.from.value
|
|
20
21
|
|
|
21
|
-
info "revision: #{revision}".cyan
|
|
22
|
+
info "revision: #{revision}".color(:cyan)
|
|
22
23
|
rev = PVN::Revision::Range.new revision.to_s, 'HEAD'
|
|
23
|
-
info "rev: #{rev}".cyan
|
|
24
|
+
info "rev: #{rev}".color(:cyan)
|
|
24
25
|
|
|
25
26
|
logpaths = LogPaths.new rev, @paths
|
|
26
27
|
name_to_logpath = logpaths.to_map
|
|
@@ -49,10 +50,10 @@ module PVN::Diff
|
|
|
49
50
|
stpath = name_to_statuspath[name]
|
|
50
51
|
info "stpath: #{stpath}"
|
|
51
52
|
|
|
52
|
-
frrev = nil
|
|
53
|
+
# frrev = nil
|
|
53
54
|
|
|
54
55
|
if logpath
|
|
55
|
-
chgrevs = logpath.revisions_later_than fromrev
|
|
56
|
+
# chgrevs = logpath.revisions_later_than fromrev
|
|
56
57
|
logpath.diff_revision_to_working_copy revision, whitespace
|
|
57
58
|
else
|
|
58
59
|
# it's a local file only
|
data/lib/pvn/diff/command.rb
CHANGED
|
@@ -15,17 +15,21 @@ module PVN::Diff
|
|
|
15
15
|
subcommands [ "diff" ]
|
|
16
16
|
description "Shows the changes to files."
|
|
17
17
|
usage "[OPTIONS] FILE..."
|
|
18
|
-
summary [ "Compare two revisions, filtering through external programs.",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
# summary [ "Compare two revisions, filtering through external programs. ",
|
|
19
|
+
# "For each file compared, the file extension is used to find ",
|
|
20
|
+
# "a diff program. ",
|
|
21
|
+
# "As with other pvn subcommands, 'pvn diff' accepts relative ",
|
|
22
|
+
# "revisions."
|
|
23
|
+
# ]
|
|
24
|
+
summary [ "Compare two revisions. ",
|
|
25
|
+
"As with other pvn subcommands, 'pvn diff' accepts relative ",
|
|
22
26
|
"revisions."
|
|
23
27
|
]
|
|
24
28
|
|
|
25
29
|
optscls
|
|
26
30
|
|
|
27
31
|
example "pvn diff foo.rb", "Compares foo.rb against the last updated version."
|
|
28
|
-
example "pvn diff -3 StringExt.java", "Compares StringExt.java at change (HEAD - 3), using a Java-specific program such as DiffJ."
|
|
32
|
+
# example "pvn diff -3 StringExt.java", "Compares StringExt.java at change (HEAD - 3), using a Java-specific program such as DiffJ."
|
|
29
33
|
example "pvn diff -r +4 -w", "Compares the 4th revision against the working copy, ignoring whitespace."
|
|
30
34
|
example "pvn diff -c 1948", "Compares revision 1948 against 1947."
|
|
31
35
|
example "pvn diff -c -8", "Compares revision (HEAD - 8) against (HEAD - 9)."
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# -*- ruby -*-
|
|
3
|
+
|
|
4
|
+
require 'logue/loggable'
|
|
5
|
+
|
|
6
|
+
# the command-line diff program.
|
|
7
|
+
module PVN::Diff
|
|
8
|
+
class Cmd
|
|
9
|
+
include Logue::Loggable
|
|
10
|
+
|
|
11
|
+
def initialize displaypath, fromrev, torev, fromlines, tolines, whitespace
|
|
12
|
+
open_temp_file(fromlines) do |from|
|
|
13
|
+
open_temp_file(tolines) do |to|
|
|
14
|
+
cmd = "diff -u"
|
|
15
|
+
if whitespace
|
|
16
|
+
cmd << " -w"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
[ fromrev, torev ].each do |rev|
|
|
20
|
+
revstr = to_revision_string rev
|
|
21
|
+
cmd << " -L '#{displaypath}\t(#{revstr})'"
|
|
22
|
+
end
|
|
23
|
+
cmd << " #{from.path}"
|
|
24
|
+
cmd << " #{to.path}"
|
|
25
|
+
|
|
26
|
+
info "cmd: #{cmd}"
|
|
27
|
+
|
|
28
|
+
$io.puts "Index: #{displaypath}"
|
|
29
|
+
$io.puts "==================================================================="
|
|
30
|
+
IO.popen(cmd) do |io|
|
|
31
|
+
$io.puts io.readlines
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def open_temp_file lines, &blk
|
|
38
|
+
Tempfile.open('pvn') do |tmpfile|
|
|
39
|
+
if lines
|
|
40
|
+
tmpfile.puts lines
|
|
41
|
+
end
|
|
42
|
+
tmpfile.close
|
|
43
|
+
|
|
44
|
+
blk.call tmpfile
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def to_revision_string rev
|
|
49
|
+
rev ? "revision #{rev}" : "working copy"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/pvn/diff/differ.rb
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
require 'pvn/io/element'
|
|
5
5
|
require 'pvn/diff/options'
|
|
6
6
|
require 'pvn/command/command'
|
|
7
|
+
require 'logue/loggable'
|
|
7
8
|
require 'tempfile'
|
|
8
9
|
|
|
9
10
|
$io = $stdout
|
|
10
11
|
|
|
11
12
|
module PVN::Diff
|
|
12
13
|
class Differ
|
|
13
|
-
include Loggable
|
|
14
|
+
include Logue::Loggable
|
|
14
15
|
|
|
15
16
|
attr_reader :whitespace
|
|
16
17
|
attr_reader :revision
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# -*- ruby -*-
|
|
3
|
+
|
|
4
|
+
require 'logue/loggable'
|
|
5
|
+
require 'riel/pathname'
|
|
6
|
+
require 'pvn/diff/diffcmd'
|
|
7
|
+
|
|
8
|
+
module PVN::Diff
|
|
9
|
+
class DiffSet
|
|
10
|
+
include Logue::Loggable
|
|
11
|
+
|
|
12
|
+
attr_reader :display_path
|
|
13
|
+
attr_reader :from_lines
|
|
14
|
+
attr_reader :from_revision
|
|
15
|
+
attr_reader :to_lines
|
|
16
|
+
attr_reader :to_revision
|
|
17
|
+
attr_reader :whitespace
|
|
18
|
+
|
|
19
|
+
def initialize display_path, from_lines, from_revision, to_lines, to_revision, whitespace
|
|
20
|
+
@display_path = display_path
|
|
21
|
+
@from_lines = from_lines
|
|
22
|
+
@from_revision = from_revision
|
|
23
|
+
@to_lines = to_lines
|
|
24
|
+
@to_revision = to_revision
|
|
25
|
+
@whitespace = whitespace
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def run_diff
|
|
29
|
+
info "display_path: #{@display_path}".color("fafa33")
|
|
30
|
+
ext = Pathname.new(@display_path).extname
|
|
31
|
+
info "ext: #{ext}".color("fafa11")
|
|
32
|
+
|
|
33
|
+
Cmd.new @display_path, @from_revision, @to_revision, @from_lines, @to_lines, @whitespace
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/pvn/diff/local_path.rb
CHANGED
|
@@ -9,7 +9,7 @@ module PVN::Diff
|
|
|
9
9
|
# that's a Status::Entry
|
|
10
10
|
def initialize entry
|
|
11
11
|
@entry = entry
|
|
12
|
-
@elmt =
|
|
12
|
+
@elmt = PVN::IO::Element.new :local => @entry.path
|
|
13
13
|
name = entry.path
|
|
14
14
|
action = SVNx::Action.new @entry.status
|
|
15
15
|
revision = action.added? ? 0 : @elmt.get_info.revision
|
|
@@ -37,33 +37,32 @@ module PVN::Diff
|
|
|
37
37
|
pn.readlines
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def create_element
|
|
41
|
-
PVN::IO::Element.new :local => @entry.path
|
|
42
|
-
end
|
|
43
|
-
|
|
44
40
|
def get_latest_revision
|
|
45
41
|
svninfo = @elmt.get_info
|
|
46
42
|
svninfo.revision
|
|
47
43
|
end
|
|
48
44
|
|
|
45
|
+
def get_remote_lines
|
|
46
|
+
# revision = nil; use_cache = false
|
|
47
|
+
@elmt.cat nil, false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run_diff from_lines, from_rev, to_lines, to_rev, whitespace
|
|
51
|
+
super @entry.path, from_lines, from_rev, to_lines, to_rev, whitespace
|
|
52
|
+
end
|
|
53
|
+
|
|
49
54
|
def show_as_added
|
|
50
|
-
|
|
51
|
-
tolines = read_working_copy
|
|
52
|
-
run_diff @entry.path, fromlines, 0, tolines, 0, nil
|
|
55
|
+
run_diff nil, 0, read_working_copy, 0, nil
|
|
53
56
|
end
|
|
54
57
|
|
|
55
58
|
def show_as_deleted
|
|
56
59
|
fromrev = changes[0].revision
|
|
57
|
-
|
|
58
|
-
lines = @elmt.cat nil, false
|
|
59
|
-
run_diff @entry.path, lines, fromrev, nil, nil, nil
|
|
60
|
+
run_diff get_remote_lines, fromrev, nil, nil, nil
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
def show_as_modified whitespace
|
|
63
|
-
remotelines = @elmt.cat nil, false
|
|
64
64
|
fromrev = changes[0].revision
|
|
65
|
-
|
|
66
|
-
run_diff @entry.path, remotelines, fromrev, wclines, nil, whitespace
|
|
65
|
+
run_diff get_remote_lines, fromrev, read_working_copy, nil, whitespace
|
|
67
66
|
end
|
|
68
67
|
end
|
|
69
68
|
end
|