pvn 0.0.7 → 0.0.8

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.
Files changed (111) hide show
  1. data/bin/change.rb +50 -0
  2. data/bin/pvn +8 -4
  3. data/bin/quote.rb +18 -6
  4. data/bin/quotes.orig.txt +145 -0
  5. data/bin/quotes.txt +64 -0
  6. data/lib/pvn/app/runner.rb +103 -0
  7. data/lib/pvn/app.rb +1 -142
  8. data/lib/pvn/{subcommands/base → command}/color_option.rb +1 -1
  9. data/lib/pvn/{subcommands/base → command}/command.rb +10 -6
  10. data/lib/pvn/{subcommands/base → command}/doc.rb +2 -2
  11. data/lib/pvn/{subcommands/base → command}/options.rb +2 -2
  12. data/lib/pvn/config.rb +14 -1
  13. data/lib/pvn/{subcommands/diff → diff}/command.rb +6 -6
  14. data/lib/pvn/diff/differ.rb +60 -44
  15. data/lib/pvn/diff/local_differ.rb +99 -0
  16. data/lib/pvn/diff/log_paths.rb +46 -0
  17. data/lib/pvn/{subcommands/diff → diff}/options.rb +8 -6
  18. data/lib/pvn/diff/path.rb +52 -0
  19. data/lib/pvn/diff/path_revision.rb +31 -0
  20. data/lib/pvn/diff/paths.rb +42 -0
  21. data/lib/pvn/diff/repository_differ.rb +154 -0
  22. data/lib/pvn/diff/revision.rb +36 -0
  23. data/lib/pvn/diff/status_paths.rb +87 -0
  24. data/lib/pvn/io/element.rb +29 -8
  25. data/lib/pvn/{subcommands/log → log}/command.rb +4 -4
  26. data/lib/pvn/log/formatter/log_formatter.rb +1 -1
  27. data/lib/pvn/{subcommands/log → log}/options.rb +7 -7
  28. data/lib/pvn/{subcommands/pct → pct}/command.rb +6 -6
  29. data/lib/pvn/{subcommands/pct → pct}/diffcount.rb +1 -1
  30. data/lib/pvn/{subcommands/pct → pct}/differ.rb +2 -2
  31. data/lib/pvn/{subcommands/pct → pct}/local_differ.rb +3 -3
  32. data/lib/pvn/pct/options.rb +12 -0
  33. data/lib/pvn/{subcommands/pct → pct}/repository_differ.rb +5 -13
  34. data/lib/pvn/revision/{entry.rb → argument.rb} +45 -30
  35. data/lib/pvn/{subcommands/revision → revision}/base_option.rb +2 -2
  36. data/lib/pvn/revision/error.rb +11 -0
  37. data/lib/pvn/{subcommands/revision → revision}/multiple_revisions_option.rb +1 -1
  38. data/lib/pvn/revision/range.rb +49 -0
  39. data/lib/pvn/{subcommands/revision → revision}/revision_option.rb +1 -8
  40. data/lib/pvn/{subcommands/revision → revision}/revision_regexp_option.rb +2 -2
  41. data/lib/pvn/{subcommands/status → status}/command.rb +6 -6
  42. data/lib/pvn/status/formatter/status_formatter.rb +1 -1
  43. data/lib/pvn/status/options.rb +12 -0
  44. data/lib/pvn/{base/util.rb → util/array.rb} +2 -1
  45. data/lib/pvn.rb +1 -6
  46. data/lib/svnx/action.rb +52 -0
  47. data/lib/svnx/entries.rb +9 -1
  48. data/lib/svnx/log/command.rb +4 -3
  49. data/lib/svnx/status/entry.rb +30 -13
  50. data/lib/synoption/base_option.rb +10 -27
  51. data/lib/synoption/matchers.rb +22 -0
  52. data/lib/system/command/cachefile.rb +28 -14
  53. data/lib/system/command.rb +1 -1
  54. data/test/integration/pvn/diff/command_test.rb +20 -0
  55. data/test/integration/pvn/diff/local_differ_test.rb +72 -0
  56. data/test/integration/pvn/diff/log_paths_test.rb +28 -0
  57. data/test/integration/pvn/diff/repository_differ_test.rb +127 -0
  58. data/test/integration/pvn/diff/status_paths_test.rb +31 -0
  59. data/test/integration/pvn/log/command_test.rb +29 -0
  60. data/test/integration/pvn/pct/command_test.rb +30 -0
  61. data/test/integration/pvn/status/command_test.rb +26 -0
  62. data/test/unit/pvn/app_test.rb +7 -5
  63. data/test/unit/pvn/diff/path_revision_test.rb +45 -0
  64. data/test/unit/pvn/diff/path_test.rb +38 -0
  65. data/test/unit/pvn/diff/revision_test.rb +35 -0
  66. data/test/unit/pvn/io/element/log/log_test.rb +2 -2
  67. data/test/unit/pvn/log/formatter/entry_formatter_test.rb +40 -29
  68. data/test/unit/pvn/{subcommands/log → log}/options_test.rb +4 -4
  69. data/test/unit/pvn/revision/argument_test.rb +157 -0
  70. data/test/unit/pvn/{subcommands/revision → revision}/multiple_revisions_option_test.rb +10 -11
  71. data/test/unit/pvn/revision/range_test.rb +26 -0
  72. data/test/unit/pvn/{subcommands/revision → revision}/revision_option_test.rb +13 -18
  73. data/test/unit/pvn/{subcommands/revision → revision}/revision_regexp_option_test.rb +8 -10
  74. data/test/unit/svnx/action_test.rb +67 -0
  75. data/test/unit/svnx/info/entries_test.rb +10 -10
  76. data/test/unit/svnx/info/entry_test.rb +7 -10
  77. data/test/unit/svnx/log/entries_test.rb +31 -29
  78. data/test/unit/svnx/log/entry_test.rb +3 -7
  79. data/test/unit/svnx/status/entries_test.rb +7 -6
  80. data/test/unit/svnx/status/entry_test.rb +2 -23
  81. data/test/unit/system/command/cachefile_test.rb +53 -0
  82. data/test/unit/system/command/caching_test.rb +14 -23
  83. metadata +83 -64
  84. data/lib/pvn/describe.rb +0 -40
  85. data/lib/pvn/diff/diffcmd.rb +0 -49
  86. data/lib/pvn/diff/diffopts.rb +0 -58
  87. data/lib/pvn/log/logcmd.rb +0 -135
  88. data/lib/pvn/log/logentry.rb +0 -116
  89. data/lib/pvn/log/logfactory.rb +0 -101
  90. data/lib/pvn/log/logoptions.rb +0 -43
  91. data/lib/pvn/revision.rb +0 -119
  92. data/lib/pvn/subcommands/diff/differ.rb +0 -65
  93. data/lib/pvn/subcommands/diff/local_differ.rb +0 -103
  94. data/lib/pvn/subcommands/diff/repository_differ.rb +0 -145
  95. data/lib/pvn/subcommands/pct/clargs.rb +0 -33
  96. data/lib/pvn/subcommands/pct/options.rb +0 -12
  97. data/lib/pvn/subcommands/status/options.rb +0 -12
  98. data/lib/pvn/svn/command/svncmd.rb +0 -39
  99. data/lib/pvn/svn/environment.rb +0 -23
  100. data/lib/pvn/svn/svnelement.rb +0 -89
  101. data/lib/pvn/svn/svninfo.rb +0 -42
  102. data/lib/pvn/svn/svnroot.rb +0 -29
  103. data/lib/pvn/upp/uppcmd.rb +0 -112
  104. data/lib/pvn/wherecmd.rb +0 -55
  105. data/test/integration/pvn/subcommands/diff/command_test.rb +0 -153
  106. data/test/integration/pvn/subcommands/log/command_test.rb +0 -22
  107. data/test/integration/svnx/log/test.rb +0 -43
  108. data/test/unit/pvn/revision/entry_test.rb +0 -110
  109. /data/lib/pvn/{subcommands/base → command}/clargs.rb +0 -0
  110. /data/lib/pvn/{base → util}/color_formatter.rb +0 -0
  111. /data/lib/pvn/{base → util}/textlines.rb +0 -0
@@ -2,15 +2,15 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'pvn/io/element'
5
- require 'pvn/subcommands/diff/options'
6
- require 'pvn/subcommands/base/command'
7
- require 'pvn/subcommands/diff/local_differ'
8
- require 'pvn/subcommands/diff/repository_differ'
5
+ require 'pvn/diff/options'
6
+ require 'pvn/command/command'
7
+ require 'pvn/diff/local_differ'
8
+ require 'pvn/diff/repository_differ'
9
9
  require 'tempfile'
10
10
  require 'synoption/exception'
11
11
 
12
- module PVN::Subcommands::Diff
13
- class Command < PVN::Subcommands::Base::Command
12
+ module PVN::Diff
13
+ class Command < PVN::Command::Command
14
14
 
15
15
  subcommands [ "diff" ]
16
16
  description "Shows the changes to files."
@@ -1,67 +1,83 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pathname'
5
- require 'pvn/config'
4
+ require 'pvn/io/element'
5
+ require 'pvn/diff/options'
6
+ require 'pvn/command/command'
7
+ require 'tempfile'
6
8
 
7
- module PVN
8
- # the app for svn --diff-cmd
9
+ $io = $stdout
10
+
11
+ module PVN::Diff
9
12
  class Differ
10
13
  include Loggable
11
-
12
- def initialize args
13
- fromlabel = args[2]
14
- tolabel = args[4]
15
-
16
- fromname, fromrev = fromlabel.split("\t")
17
- toname, torev = tolabel.split("\t")
18
14
 
19
- fromfile = args[-2]
20
- tofile = args[-1]
21
-
22
- diffcmd = diff_command_by_ext fromname
23
- info "diffcmd: #{diffcmd}"
15
+ attr_reader :whitespace
16
+ attr_reader :revision
17
+
18
+ def initialize options
19
+ end
24
20
 
25
- if diffcmd
26
- workingcmd = diffcmd.dup
21
+ def to_revision_string rev
22
+ rev ? "revision #{rev}" : "working copy"
23
+ end
27
24
 
28
- [ fromlabel, tolabel, fromfile, tofile ].each_with_index do |str, idx|
29
- workingcmd.gsub! Regexp.new('\{' + idx.to_s + '\}'), str
25
+ def write_to_temp entry, lines
26
+ Tempfile.open('pvn') do |to|
27
+ topath = to.path
28
+ to.puts lines
29
+ to.close
30
+ cmd = "diff -u"
31
+ label = " -L '#{entry.path} (revision 0)'"
32
+ 2.times do
33
+ cmd << label
34
+ end
35
+ cmd << " #{frpath}"
36
+ cmd << " #{entry.path}"
37
+ IO.popen(cmd) do |io|
38
+ puts io.readlines
30
39
  end
31
-
32
- run_command workingcmd
33
- else
34
- run_diff_default fromlabel, tolabel, fromfile, tofile
35
40
  end
36
41
  end
37
42
 
38
- def diff_command_by_ext fname
39
- extname = Pathname.new(fname).extname
40
- return nil if extname.empty?
41
-
42
- ext = extname[1 .. -1]
43
+ def run_diff_command displaypath, fromrev, torev, frompath, topath
44
+ cmd = "diff -u"
45
+ if whitespace
46
+ cmd << " -w"
47
+ end
43
48
 
44
- cfg = PVN::Configuration.read
49
+ [ fromrev, torev ].each do |rev|
50
+ revstr = to_revision_string rev
51
+ cmd << " -L '#{displaypath}\t(#{revstr})'"
52
+ end
53
+ cmd << " #{frompath}"
54
+ cmd << " #{topath}"
45
55
 
46
- diffcfg = cfg.section "diff"
47
- return nil unless diffcfg
56
+ info "cmd: #{cmd}"
48
57
 
49
- diff_for_ext = diffcfg.assoc(ext)
50
- diff_for_ext && diff_for_ext[1]
58
+ $io.puts "Index: #{displaypath}"
59
+ $io.puts "==================================================================="
60
+ IO.popen(cmd) do |io|
61
+ $io.puts io.readlines
62
+ end
51
63
  end
52
64
 
53
- def run_diff_default fromfname, tofname, fromfile, tofile
54
- cmd = "diff -u --label \"#{fromfname}\" --label \"#{tofname}\" #{fromfile} #{tofile}"
55
- run_command cmd
56
- end
65
+ def run_diff displaypath, fromlines, fromrev, tolines, torev
66
+ Tempfile.open('pvn') do |from|
67
+ if fromlines
68
+ from.puts fromlines
69
+ end
70
+ from.close
57
71
 
58
- def run_command cmd
59
- info "cmd: #{cmd}".red
60
- IO.popen(cmd) do |io|
61
- io.each do |line|
62
- puts line
72
+ Tempfile.open('pvn') do |to|
73
+ if tolines
74
+ to.puts tolines
75
+ end
76
+ to.close
77
+
78
+ run_diff_command displaypath, fromrev, torev, from.path, to.path
63
79
  end
64
- end
80
+ end
65
81
  end
66
82
  end
67
83
  end
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/io/element'
5
+ require 'pvn/diff/options'
6
+ require 'pvn/diff/differ'
7
+
8
+ module PVN::Diff
9
+ class LocalDiffer < Differ
10
+ def initialize options
11
+ super
12
+
13
+ paths = options.paths
14
+ paths = %w{ . } if paths.empty?
15
+
16
+ allentries = Array.new
17
+
18
+ # we sort only the sub-entries, so the order in which paths were specified
19
+ # is preserved
20
+
21
+ @whitespace = options.whitespace
22
+
23
+ paths.each do |path|
24
+ elmt = PVN::IO::Element.new :local => path
25
+ entries = elmt.find_files_by_status
26
+
27
+ allentries.concat entries.sort_by { |n| n.path }
28
+ end
29
+
30
+ allentries.each do |entry|
31
+ show_entry entry
32
+ end
33
+ end
34
+
35
+ def show_entry entry
36
+ info "entry: #{entry.inspect}"
37
+ case entry.status
38
+ when 'modified'
39
+ show_as_modified entry
40
+ when 'deleted'
41
+ show_as_deleted entry
42
+ when 'added'
43
+ show_as_added entry
44
+ end
45
+ end
46
+
47
+ ### $$$ todo: integrate these, from old diff/diffcmd
48
+ def use_cache?
49
+ super && !against_head?
50
+ end
51
+
52
+ def against_head?
53
+ @options.change.value.nil? && @options.revision.head?
54
+ end
55
+
56
+ def read_working_copy entry
57
+ pn = Pathname.new entry.path
58
+ pn.readlines
59
+ end
60
+
61
+ def create_element entry
62
+ PVN::IO::Element.new :local => entry.path
63
+ end
64
+
65
+ def cat elmt
66
+ elmt = PVN::IO::Element.new :local => elmt.local
67
+ elmt.cat nil, :use_cache => false
68
+ end
69
+
70
+ def show_as_added entry
71
+ fromlines = nil
72
+ tolines = read_working_copy entry
73
+
74
+ run_diff entry.path, fromlines, 0, tolines, 0
75
+ end
76
+
77
+ def get_latest_revision elmt
78
+ svninfo = elmt.get_info
79
+ svninfo.revision
80
+ end
81
+
82
+ def show_as_deleted entry
83
+ elmt = create_element entry
84
+
85
+ fromrev = get_latest_revision elmt
86
+ lines = cat elmt
87
+
88
+ run_diff entry.path, lines, fromrev, nil, nil
89
+ end
90
+
91
+ def show_as_modified entry
92
+ elmt = create_element entry
93
+ remotelines = cat elmt
94
+ fromrev = get_latest_revision elmt
95
+ wclines = read_working_copy entry
96
+ run_diff entry.path, remotelines, fromrev, wclines, nil
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/io/element'
5
+ require 'pvn/diff/paths'
6
+ require 'pvn/diff/path'
7
+
8
+ module PVN::Diff
9
+ # represents the log entries from one revision through another.
10
+ class LogPaths < Paths
11
+ include Loggable
12
+
13
+ def add_for_path path
14
+ pathelmt = PVN::IO::Element.new :local => path
15
+ pathinfo = pathelmt.get_info
16
+ elmt = PVN::IO::Element.new :local => path
17
+ logentries = elmt.logentries @revision
18
+
19
+ logentries.each do |logentry|
20
+ logentry.paths.each do |logentrypath|
21
+ next if logentrypath.kind != 'file'
22
+ add_path logentry, logentrypath, pathinfo
23
+ end
24
+ end
25
+ end
26
+
27
+ def add_path logentry, logentrypath, pathinfo
28
+ name = logentrypath.name
29
+ revision = logentry.revision
30
+ action = logentrypath.action
31
+ url = pathinfo.url
32
+
33
+ info "action: #{action}".blue
34
+
35
+ path = @elements.detect { |element| element.name == name }
36
+ if path
37
+ info "path: #{path}".on_blue
38
+ path.add_revision logentry.revision, action
39
+ else
40
+ path = Path.new(name, logentry.revision, action, url)
41
+ info "path: #{path}".on_cyan
42
+ @elements << path
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,27 +2,29 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'synoption/boolean_option'
5
- require 'pvn/subcommands/revision/multiple_revisions_option'
6
- require 'pvn/subcommands/revision/base_option'
7
- require 'pvn/subcommands/base/options'
5
+ require 'pvn/revision/multiple_revisions_option'
6
+ require 'pvn/revision/base_option'
7
+ require 'pvn/command/options'
8
8
 
9
- module PVN::Subcommands::Diff
9
+ module PVN::Diff
10
10
  class WhitespaceOption < PVN::BooleanOption
11
11
  def initialize optargs = Hash.new
12
12
  super :whitespace, '-w', 'ignore all whitespace', false
13
13
  end
14
14
  end
15
15
 
16
+ # a change option is like a revision option, just against the previous
17
+ # revision
16
18
  class ChangeOption < PVN::BaseRevisionOption
17
19
  def initialize optargs = Hash.new
18
20
  super :change, '-c', 'use the given revision against the previous one', nil
19
21
  end
20
22
  end
21
23
 
22
- class OptionSet < PVN::Subcommands::Base::OptionSet
24
+ class OptionSet < PVN::Command::OptionSet
23
25
  has_option :revision, PVN::MultipleRevisionsRegexpOption
24
26
  has_option :change, ChangeOption
25
27
  has_option :whitespace, WhitespaceOption
26
- has_option :help, PVN::Subcommands::Base::HelpOption
28
+ has_option :help, PVN::Command::HelpOption
27
29
  end
28
30
  end
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/action'
5
+ require 'pvn/diff/path_revision'
6
+
7
+ module PVN; module Diff; end; end
8
+
9
+ module PVN::Diff
10
+ class Path
11
+ include Loggable
12
+
13
+ attr_reader :name
14
+ # attr_reader :revisions
15
+ attr_reader :action
16
+ attr_reader :url
17
+ ### $$$ this will be renamed revisions, when the old one is gone.
18
+ attr_reader :path_revisions
19
+
20
+ # that's the root url
21
+ def initialize name, revision, action, url
22
+ @name = name
23
+ @revisions = Array.new
24
+ @path_revisions = Array.new
25
+ add_revision revision, action
26
+ @action = action.kind_of?(SVNx::Action) || SVNx::Action.new(action)
27
+ @url = url
28
+ end
29
+
30
+ def add_revision rev, action
31
+ info "rev: #{rev}".on_green
32
+ if rev.kind_of?(Array)
33
+ rev.each do |rv|
34
+ @revisions << to_revision(rv)
35
+ end
36
+ else
37
+ @revisions << to_revision(rev)
38
+ end
39
+ @path_revisions << PathRevision.new(to_revision(rev), action)
40
+ end
41
+
42
+ def to_revision rev
43
+ # or should we convert this to Revision::Argument, and @revisions is
44
+ # Revision::Range?
45
+ rev.kind_of?(Fixnum) ? rev.to_s : rev
46
+ end
47
+
48
+ def to_s
49
+ inspect
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/action'
5
+
6
+ module PVN; module Diff; end; end
7
+
8
+ # A Path Revision is the change to a path within a changelist.
9
+ module PVN::Diff
10
+ class PathRevision
11
+ include Loggable
12
+
13
+ attr_reader :revision
14
+ attr_reader :action
15
+
16
+ def initialize revision, action
17
+ @revision = to_revision(revision)
18
+ @action = action.kind_of?(SVNx::Action) || SVNx::Action.new(action)
19
+ end
20
+
21
+ def to_revision rev
22
+ # or should we convert this to Revision::Argument, and @revisions is
23
+ # Revision::Range?
24
+ rev.kind_of?(Fixnum) ? rev.to_s : rev
25
+ end
26
+
27
+ def to_s
28
+ inspect
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ module PVN::Diff
5
+ # represents the paths from one revision through another.
6
+ class Paths
7
+ include Loggable, Enumerable
8
+
9
+ # takes paths of the form ".", "foo.rb", etc.
10
+ def initialize revision, paths
11
+ @revision = revision
12
+ @elements = Array.new
13
+
14
+ paths.each do |path|
15
+ add_for_path path
16
+ end
17
+ end
18
+
19
+ def add_for_path path
20
+ raise "implement this"
21
+ end
22
+
23
+ def [] idx
24
+ @elements[idx]
25
+ end
26
+
27
+ def size
28
+ @elements.size
29
+ end
30
+
31
+ # returns a map from names to logpaths
32
+ def to_map
33
+ names_to_paths = Hash.new
34
+ @elements.each { |path| names_to_paths[path.name] = path }
35
+ names_to_paths
36
+ end
37
+
38
+ def each(&blk)
39
+ @elements.each(&blk)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/io/element'
5
+ require 'pvn/diff/options'
6
+ require 'pvn/diff/differ'
7
+ require 'pvn/diff/log_paths'
8
+ require 'pvn/diff/status_paths'
9
+ require 'pvn/diff/revision'
10
+
11
+ module PVN::Diff
12
+ class RepositoryDiffer < Differ
13
+ include Loggable
14
+
15
+ attr_reader :whitespace
16
+ attr_reader :revision
17
+
18
+ def initialize options
19
+ paths = options.paths
20
+ paths = %w{ . } if paths.empty?
21
+
22
+ # we sort only the sub-entries, so the order in which paths were specified is preserved
23
+
24
+ @whitespace = options.whitespace
25
+ rev = options.revision
26
+ change = options.change
27
+
28
+ if rev[1].nil? || rev[1].to == :working_copy
29
+ # rev[1] = "BASE"
30
+ end
31
+
32
+ fromrev = if change
33
+ change.to_i - 1
34
+ else
35
+ rev[0].to_i
36
+ end
37
+
38
+ @revision = RevisionRange.new change, rev
39
+
40
+ logpaths = LogPaths.new @revision, paths
41
+ name_to_logpath = logpaths.to_map
42
+
43
+ name_to_logpath.sort.each do |name, logpath|
44
+ if is_revision_later_than? logpath, fromrev
45
+ diff_logpath logpath
46
+ end
47
+ end
48
+
49
+ return if true
50
+
51
+ if @revision.working_copy?
52
+ ### $$$ not handled yet
53
+ statuspaths = StatusPaths.new @revision, paths
54
+ info "statuspaths: #{statuspaths}".on_blue
55
+ statuspaths.each do |stpath|
56
+ info "stpath: #{stpath}".on_green
57
+ # diff_status_path stpath
58
+ end
59
+ # name_to_logpath = logpaths.to_map
60
+ end
61
+ end
62
+
63
+ def is_revision_later_than? logpath, revision
64
+ logpath.path_revisions.detect do |rev|
65
+ info "rev.revision: #{rev.revision.inspect}".cyan
66
+ x = PVN::Revision::Argument.new rev.revision
67
+ y = PVN::Revision::Argument.new revision
68
+ x > y
69
+ end
70
+ end
71
+
72
+ def show_as_modified elmt, path, fromrev, torev
73
+ info "elmt: #{elmt}"
74
+ fromlines = elmt.cat fromrev
75
+ tolines = elmt.cat torev
76
+ fromrev = @revision.from.value.to_i
77
+ run_diff path, fromlines, fromrev, tolines, @revision.to
78
+ end
79
+
80
+ def show_as_added elmt, path
81
+ info "elmt: #{elmt}"
82
+ tolines = elmt.cat @revision.to
83
+ run_diff path, nil, 0, tolines, @revision.to
84
+ end
85
+
86
+ def show_as_deleted elmt, path
87
+ info "elmt: #{elmt}"
88
+ fromrev = @revision.from.value.to_i
89
+ fromlines = elmt.cat fromrev
90
+ run_diff path, fromlines, fromrev, nil, @revision.to
91
+ end
92
+
93
+ def diff_logpath logpath
94
+ info "logpath.name: #{logpath.name}"
95
+ name = logpath.name
96
+
97
+ revisions = logpath.path_revisions
98
+
99
+ # all the paths will be the same, so any can be selected (actually, a
100
+ # logpath should have multiple revisions)
101
+ svnurl = logpath.url
102
+ info "svnurl: #{svnurl}"
103
+
104
+ svnpath = svnurl + name
105
+ info "svnpath: #{svnpath}"
106
+ elmt = PVN::IO::Element.new :svn => svnpath
107
+
108
+ displaypath = name[1 .. -1]
109
+ info "displaypath: #{displaypath}"
110
+
111
+ firstrev = revisions[0].revision
112
+ info "firstrev: #{firstrev}".yellow
113
+ lastrev = revisions[-1].revision
114
+
115
+ action = logpath.action
116
+ info "action: #{action}".on_blue
117
+
118
+ pathrevs = logpath.path_revisions
119
+ info "pathrevs: #{pathrevs}".green
120
+
121
+ info "@revision.from: #{@revision.from}".cyan
122
+
123
+ pathrevs = logpath.path_revisions.select do |rev|
124
+ info "rev.revision: #{rev.revision.inspect}".cyan
125
+ revarg = PVN::Revision::Argument.new rev.revision
126
+ revarg > @revision.from
127
+ end
128
+
129
+ info "pathrevs: #{pathrevs}".green
130
+
131
+ # we ignore unversioned logpaths
132
+
133
+ # I'm sure there is a bunch of permutations here, so this is probably
134
+ # overly simplistic.
135
+ firstaction = pathrevs[0].action
136
+
137
+ case
138
+ when firstaction.added?
139
+ show_as_added elmt, displaypath
140
+ when firstaction.deleted?
141
+ show_as_deleted elmt, displaypath
142
+ when firstaction.modified?
143
+ fromrev, torev = if firstrev == lastrev
144
+ [ @revision.from.value.to_i - 1, @revision.to ]
145
+ else
146
+ [ firstrev.to_i - 1, lastrev ]
147
+ end
148
+ info "firstrev: #{firstrev.inspect}"
149
+ info "torev: #{torev.inspect}"
150
+ show_as_modified elmt, displaypath, firstrev, torev
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,36 @@
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