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
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/io/element'
5
+ require 'pvn/diff/path'
6
+ require 'pvn/diff/paths'
7
+
8
+ module PVN::Diff
9
+ # represents the log entries from one revision through another.
10
+ class StatusPaths < 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
+ add elmt, pathinfo.url
18
+ end
19
+
20
+ def add elmt, url
21
+ status = elmt.find_files_by_status
22
+ info "status: #{status}"
23
+ status.entries.each do |entry|
24
+ # we don't care about unversioned entries for diffing.
25
+ next if entry.status == 'unversioned'
26
+
27
+ info "@revision: #{@revision}"
28
+ info "entry: #{entry}"
29
+ # svn log prepends /; svn status does not
30
+ name = '/' + entry.path
31
+ info "name: #{name}"
32
+ rev = :working_copy
33
+ info "rev: #{rev}"
34
+
35
+ # what Status::Entry calls a status, we call an action, unifying it with
36
+ # svn log representation.
37
+ action = entry.status
38
+ info "action: #{action}"
39
+ revisions = get_status_revisions entry
40
+ info "revisions: #{revisions}"
41
+
42
+ info "status.revision: #{entry.status_revision}"
43
+
44
+ @elements << Path.new(name, entry.status_revision, action, url)
45
+ end
46
+ end
47
+
48
+ # this may belong in Status::Entry
49
+ def get_status_revisions status_entry
50
+ # the printing revision in svn (svn diff -r20) are confusing, but this
51
+ # is what it looks like:
52
+
53
+ # when a file is added locally
54
+ # the revisions are (0, 0)
55
+ # when a file is modified:
56
+ # if the file is modified in other revisions since givenfromrev
57
+ # the revision is (most recent rev, working copy)
58
+ # otherwise
59
+ # the revision is (previous revision, working copy)
60
+ # when a file is deleted:
61
+ # the revision is (given from rev, working copy)
62
+
63
+ # okay, summary #2:
64
+
65
+ # if a file is modified,
66
+ # if the file existed at fromrev
67
+ # it is compared with fromrev
68
+ # else
69
+ # it is compared to BASE
70
+
71
+ info "status_entry.status: #{status_entry.status}"
72
+
73
+ action = SVNx::Action.new status_entry.status
74
+ case
75
+ when action.added?
76
+ info "added"
77
+ [ 0, 0 ]
78
+ when action.deleted?
79
+ info "deleted"
80
+ [ @revision.from, :working_copy ]
81
+ when action.modified?
82
+ info "modified"
83
+ [ status_entry.status_revision, :working_copy ]
84
+ end
85
+ end
86
+ end
87
+ end
@@ -3,7 +3,6 @@
3
3
 
4
4
  require 'rubygems'
5
5
  require 'riel'
6
- require 'pvn/base/util'
7
6
 
8
7
  require 'svnx/log/command'
9
8
  require 'svnx/log/entries'
@@ -124,9 +123,22 @@ module PVN::IO
124
123
  modified
125
124
  end
126
125
 
127
- def cat_remote rev = nil
128
- raise "revision not yet supported: #{rev}" if rev
129
- catargs = SVNx::CatCommandArgs.new :path => @local, :use_cache => false
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
+ def cat revision, use_cache = false
136
+ path = (@local || @path || @svn).dup
137
+ if revision && revision != :working_copy
138
+ path << '@' << revision.to_s
139
+ end
140
+ info "path: #{path}"
141
+ catargs = SVNx::CatCommandArgs.new :path => path, :use_cache => use_cache
130
142
  cmd = SVNx::CatCommand.new catargs
131
143
  cmd.execute
132
144
  end
@@ -139,8 +151,8 @@ module PVN::IO
139
151
  def find_files_by_status status = nil
140
152
  cmdargs = SVNx::StatusCommandArgs.new :path => @local, :use_cache => false
141
153
  cmd = SVNx::StatusCommand.new cmdargs
142
- xml = cmd.execute
143
- entries = SVNx::Status::Entries.new :xmllines => xml
154
+ xmllines = cmd.execute
155
+ entries = SVNx::Status::Entries.new :xmllines => xmllines
144
156
 
145
157
  if status
146
158
  entries.select do |entry|
@@ -164,12 +176,21 @@ module PVN::IO
164
176
  SVNx::Log::Entries.new :xmllines => cmd.execute
165
177
  end
166
178
 
179
+ # returns log entries
180
+ def logentries revision
181
+ # use_cache should be conditional on revision:
182
+ # cmdargs[:use_cache] = false
183
+ cmdargs = SVNx::LogCommandArgs.new :path => @local, :revision => revision.to_s, :use_cache => false, :verbose => true
184
+ cmd = SVNx::LogCommand.new cmdargs
185
+ SVNx::Log::Entries.new :xmllines => cmd.execute
186
+ end
187
+
167
188
  # returns :added, :deleted, "modified"
168
189
  def status
169
190
  cmdargs = SVNx::StatusCommandArgs.new :path => @local
170
191
  cmd = SVNx::StatusCommand.new :cmdargs => cmdargs
171
- xml = cmd.execute.join ''
172
- entries = SVNx::Status::Entries.new :xml => SVNx::Status::XMLEntries.new(xml)
192
+ xmllines = cmd.execute
193
+ entries = SVNx::Status::Entries.new :xmllines => xmllines
173
194
  entry = entries[0]
174
195
  entry.status
175
196
  end
@@ -3,11 +3,11 @@
3
3
 
4
4
  require 'pvn/io/element'
5
5
  require 'pvn/log/formatter/entries_formatter'
6
- require 'pvn/subcommands/log/options'
7
- require 'pvn/subcommands/base/command'
6
+ require 'pvn/log/options'
7
+ require 'pvn/command/command'
8
8
 
9
- module PVN::Subcommands::Log
10
- class Command < PVN::Subcommands::Base::Command
9
+ module PVN::Log
10
+ class Command < PVN::Command::Command
11
11
 
12
12
  DEFAULT_LIMIT = 15
13
13
 
@@ -2,7 +2,7 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'svnx/log/entry'
5
- require 'pvn/base/color_formatter'
5
+ require 'pvn/util/color_formatter'
6
6
 
7
7
  module PVN; module Log; end; end
8
8
 
@@ -5,11 +5,11 @@ require 'synoption/set'
5
5
  require 'synoption/option'
6
6
  require 'synoption/fixnum_option'
7
7
  require 'synoption/boolean_option'
8
- require 'pvn/subcommands/revision/multiple_revisions_option'
9
- require 'pvn/subcommands/base/options'
10
- require 'pvn/subcommands/base/color_option'
8
+ require 'pvn/revision/multiple_revisions_option'
9
+ require 'pvn/command/options'
10
+ require 'pvn/command/color_option'
11
11
 
12
- module PVN::Subcommands::Log
12
+ module PVN::Log
13
13
  DEFAULT_LIMIT = 5
14
14
 
15
15
  class LimitOption < PVN::FixnumOption
@@ -30,10 +30,10 @@ module PVN::Subcommands::Log
30
30
  end
31
31
  end
32
32
 
33
- class OptionSet < PVN::Subcommands::Base::OptionSet
33
+ class OptionSet < PVN::Command::OptionSet
34
34
  has_option :revision, PVN::MultipleRevisionsRegexpOption, [ :unsets => :limit ]
35
- has_option :color, PVN::Subcommands::Base::ColorOption
36
- has_option :help, PVN::Subcommands::Base::HelpOption
35
+ has_option :color, PVN::Command::ColorOption
36
+ has_option :help, PVN::Command::HelpOption
37
37
  has_option :limit, LimitOption
38
38
  has_option :user, UserOption
39
39
  has_option :verbose, PVN::BooleanOption, [ :verbose, '-v', [ "include the files in the change" ], false ]
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pvn/subcommands/pct/options'
5
- require 'pvn/subcommands/base/command'
6
- require 'pvn/subcommands/pct/local_differ'
7
- require 'pvn/subcommands/pct/repository_differ'
4
+ require 'pvn/pct/options'
5
+ require 'pvn/command/command'
6
+ require 'pvn/pct/local_differ'
7
+ require 'pvn/pct/repository_differ'
8
8
 
9
- module PVN::Subcommands::Pct
10
- class Command < PVN::Subcommands::Base::Command
9
+ module PVN::Pct
10
+ class Command < PVN::Command::Command
11
11
 
12
12
  subcommands [ "pct" ]
13
13
  description "Compares revisions as a percentage of lines modified."
@@ -17,7 +17,7 @@ module PVN
17
17
  diff = to - from
18
18
  diffpct = diff == 0 ? 0 : 100.0 * diff / from
19
19
 
20
- printf "%8d %8d %8d %8.1f%% %s\n", from, to, diff, diffpct, name
20
+ $io.printf "%8d %8d %8d %8.1f%% %s\n", from, to, diff, diffpct, name
21
21
  end
22
22
 
23
23
  def << diff
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pvn/subcommands/pct/diffcount'
4
+ require 'pvn/pct/diffcount'
5
5
 
6
- module PVN::Subcommands::Pct
6
+ module PVN::Pct
7
7
  class Differ
8
8
  include Loggable
9
9
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  require 'pvn/io/element'
5
5
  require 'svnx/cat/command'
6
- require 'pvn/subcommands/pct/diffcount'
7
- require 'pvn/subcommands/pct/differ'
6
+ require 'pvn/pct/diffcount'
7
+ require 'pvn/pct/differ'
8
8
 
9
- module PVN::Subcommands::Pct
9
+ module PVN::Pct
10
10
  class LocalDiffer < Differ
11
11
  def get_diff_counts path, options
12
12
  elmt = PVN::IO::Element.new :local => path
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/revision/multiple_revisions_option'
5
+ require 'pvn/command/options'
6
+
7
+ module PVN::Pct
8
+ class OptionSet < PVN::Command::OptionSet
9
+ has_option :revision, PVN::MultipleRevisionsRegexpOption
10
+ has_option :help, PVN::Command::HelpOption
11
+ end
12
+ end
@@ -2,11 +2,10 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'pvn/io/element'
5
- require 'svnx/cat/command'
6
- require 'pvn/subcommands/pct/diffcount'
7
- require 'pvn/subcommands/pct/differ'
5
+ require 'pvn/pct/diffcount'
6
+ require 'pvn/pct/differ'
8
7
 
9
- module PVN::Subcommands::Pct
8
+ module PVN::Pct
10
9
  class RepositoryDiffer < Differ
11
10
  ### $$$ this belongs in Revision
12
11
  def get_from_to_revisions rev
@@ -24,13 +23,6 @@ module PVN::Subcommands::Pct
24
23
  info "rev: #{rev}".bold.white.on_red
25
24
  end
26
25
  end
27
-
28
- def get_line_count path, revision
29
- info "path: #{path}".yellow
30
- cmdargs = SVNx::CatCommandArgs.new :path => path, :revision => revision
31
- catcmd = SVNx::CatCommand.new cmdargs
32
- catcmd.execute.size
33
- end
34
26
 
35
27
  def get_diff_counts path, options
36
28
  diff_counts = Array.new
@@ -62,8 +54,8 @@ module PVN::Subcommands::Pct
62
54
  next unless elmt.has_revision? torev
63
55
  next if elmt.get_info.kind == 'dir'
64
56
 
65
- from_count = get_line_count fullpath, fromrev
66
- to_count = get_line_count fullpath, torev
57
+ from_count = elmt.cat(fromrev).size
58
+ to_count = elmt.cat(torev).size
67
59
 
68
60
  name = mod.dup
69
61
  name.slice! filterre
@@ -2,25 +2,29 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'svnx/log/entries'
5
+ require 'pvn/revision/error'
5
6
 
6
- # This is an abuse of all the element/entry nonsense in this code. This will
7
- # replace lib/pvn/revision.rb as PVN::Revision.
7
+ module PVN; module Revision; end; end
8
8
 
9
+ # We represent what svn calls a revision (-r134:{2010-1-1}) as a Range,
10
+ # consisting of a from and to (optional) Argument.
9
11
  module PVN::Revision
10
- class RevisionError < RuntimeError
11
- end
12
-
13
- DATE_REGEXP = Regexp.new '^\{(.*?)\}'
14
- SVN_REVISION_WORDS = %w{ HEAD BASE COMMITTED PREV }
15
12
  RELATIVE_REVISION_RE = Regexp.new '^([\+\-])(\d+)$'
16
-
13
+
17
14
  # Returns the Nth revision from the given logging output.
18
-
15
+
19
16
  # -n means to count from the end of the list.
20
17
  # +n means to count from the beginning of the list.
21
18
  # n means the literal revision number.
22
- class Entry
23
- include Loggable
19
+ class Argument
20
+ include Loggable, Comparable
21
+
22
+ DATE_REGEXP = Regexp.new '^\{(.*?)\}'
23
+ SVN_ARGUMENT_WORDS = %w{ HEAD BASE COMMITTED PREV }
24
+
25
+ # these are also valid revisions
26
+ # :working_copy
27
+ # :head
24
28
 
25
29
  attr_reader :value
26
30
  attr_reader :log_entry
@@ -28,37 +32,36 @@ module PVN::Revision
28
32
  class << self
29
33
  alias_method :orig_new, :new
30
34
 
31
- def new args = Hash.new
32
- value = args[:value]
33
-
35
+ def new value, xmllines = nil
34
36
  # these are lines from "svn log -v <file>"
35
- xmllines = args[:xmllines]
36
37
  if xmllines.kind_of? Array
37
38
  xmllines = xmllines.join ''
38
39
  end
39
-
40
+
40
41
  case value
41
42
  when Fixnum
42
43
  if value < 0
43
- RelativeEntry.orig_new value, xmllines
44
+ RelativeArgument.orig_new value, xmllines
44
45
  else
45
- FixnumEntry.orig_new value
46
+ FixnumArgument.orig_new value
46
47
  end
47
48
  when String
48
- if SVN_REVISION_WORDS.include? value
49
- StringEntry.orig_new value
49
+ if SVN_ARGUMENT_WORDS.include? value
50
+ StringArgument.orig_new value
50
51
  elsif md = RELATIVE_REVISION_RE.match(value)
51
- RelativeEntry.orig_new md[0].to_i, xmllines
52
+ RelativeArgument.orig_new md[0].to_i, xmllines
52
53
  elsif DATE_REGEXP.match value
53
- StringEntry.orig_new value
54
+ StringArgument.orig_new value
54
55
  else
55
- FixnumEntry.orig_new value.to_i
56
+ FixnumArgument.orig_new value.to_i
56
57
  end
58
+ when Symbol
59
+ raise RevisionError.new "symbol not yet handled"
57
60
  when Date
58
61
  # $$$ this (and Time) will probably have to be converted to svn's format
59
- raise "date not yet handled"
62
+ raise RevisionError.new "date not yet handled"
60
63
  when Time
61
- raise "time not yet handled"
64
+ raise RevisionError.new "time not yet handled"
62
65
  end
63
66
  end
64
67
 
@@ -70,22 +73,34 @@ module PVN::Revision
70
73
  def initialize value
71
74
  @value = value
72
75
  end
76
+
77
+ def to_s
78
+ @value.to_s
79
+ end
80
+
81
+ def <=> other
82
+ @value <=> other.value
83
+ end
73
84
  end
74
85
 
75
- class FixnumEntry < Entry
86
+ class FixnumArgument < Argument
76
87
  end
77
88
 
78
- class StringEntry < Entry
89
+ class StringArgument < Argument
79
90
  end
80
91
 
81
- class RelativeEntry < FixnumEntry
92
+ class WorkingCopyArgument < Argument
93
+ end
94
+
95
+ # this is of the form -3, which is revision[-3] (second one from the most
96
+ # recent; -1 is the most recent).
97
+ class RelativeArgument < FixnumArgument
82
98
  def initialize value, xmllines
83
99
  unless xmllines
84
100
  raise RevisionError.new "cannot determine relative revision without xmllines"
85
101
  end
86
-
102
+
87
103
  logentries = SVNx::Log::Entries.new :xmllines => xmllines
88
-
89
104
  nentries = logentries.size
90
105
 
91
106
  # logentries are in descending order, so the most recent one is index 0
@@ -5,7 +5,6 @@ require 'riel'
5
5
  require 'rubygems'
6
6
  require 'synoption/option'
7
7
  require 'svnx/log/command'
8
- require 'pvn/revision/entry'
9
8
 
10
9
  module PVN
11
10
  class BaseRevisionOption < Option
@@ -31,7 +30,8 @@ module PVN
31
30
  limit = rel[0, 1] == '-' ? rel.to_i.abs : nil
32
31
  xmllines = run_log_command limit, path
33
32
 
34
- reventry = PVN::Revision::Entry.new :value => rel, :xmllines => xmllines
33
+ # This is Argument, not Range, because we're getting the value
34
+ reventry = PVN::Revision::Argument.new rel, xmllines
35
35
  revval = reventry.value.to_s
36
36
  revval
37
37
  end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ module PVN; module Revision; end; end
5
+
6
+ module PVN
7
+ module Revision
8
+ class RevisionError < RuntimeError
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pvn/subcommands/revision/revision_regexp_option'
4
+ require 'pvn/revision/revision_regexp_option'
5
5
 
6
6
  module PVN
7
7
  # A revision option with multiple values.
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/log/entries'
5
+ require 'pvn/revision/argument'
6
+
7
+ module PVN; module Revision; end; end
8
+
9
+ module PVN::Revision
10
+ # this is of the form: -r123:456
11
+ class Range
12
+ include Loggable
13
+
14
+ attr_reader :from
15
+ attr_reader :to
16
+
17
+ def initialize from, to = nil, xmllines = nil
18
+ if to
19
+ @from = to_revision from, xmllines
20
+ @to = to_revision to, xmllines
21
+ elsif from.kind_of? String
22
+ @from, @to = from.split(':').collect { |x| to_revision x, xmllines }
23
+ else
24
+ @from = to_revision from, xmllines
25
+ @to = :working_copy
26
+ end
27
+ end
28
+
29
+ def to_revision val, xmllines
30
+ val.kind_of?(Argument) || Argument.new(val, xmllines)
31
+ end
32
+
33
+ def to_s
34
+ str = @from.to_s
35
+ unless working_copy?
36
+ str << ':' << @to.to_s
37
+ end
38
+ str
39
+ end
40
+
41
+ def head?
42
+ @to == :head
43
+ end
44
+
45
+ def working_copy?
46
+ @to == nil || @to == :wc || @to == :working_copy
47
+ end
48
+ end
49
+ end
@@ -1,20 +1,13 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pvn/subcommands/revision/base_option'
4
+ require 'pvn/revision/base_option'
5
5
 
6
6
  module PVN
7
7
  class RevisionOption < BaseRevisionOption
8
8
  attr_accessor :fromdate
9
9
  attr_accessor :todate
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
  @fromdate = nil
20
13
  @todate = nil
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'pvn/subcommands/revision/revision_option'
4
+ require 'pvn/revision/revision_option'
5
5
 
6
6
  module PVN
7
7
  # A revision that is also set by -N and +N.
@@ -19,7 +19,7 @@ module PVN
19
19
  revargs[:regexp] = TAG_RE
20
20
  super
21
21
  end
22
-
22
+
23
23
  def resolve_value optset, unprocessed
24
24
  val = value
25
25
  md = TAG_RE.match val
@@ -2,16 +2,16 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'pvn/io/element'
5
- require 'pvn/subcommands/base/command'
6
- require 'pvn/subcommands/status/options'
5
+ require 'pvn/command/command'
6
+ require 'pvn/status/options'
7
7
  require 'pvn/status/formatter/entries_formatter'
8
8
 
9
- module PVN::Subcommands::Status
10
- class Command < PVN::Subcommands::Base::Command
9
+ module PVN::Status
10
+ class Command < PVN::Command::Command
11
11
 
12
12
  DEFAULT_LIMIT = 15
13
13
 
14
- subcommands [ "status" ]
14
+ subcommands [ "status", "st" ]
15
15
  description "Prints the status for locally changed files."
16
16
  usage "[OPTIONS] FILE..."
17
17
  summary [ "Prints the status for the given files, with colorized",
@@ -41,7 +41,7 @@ module PVN::Subcommands::Status
41
41
  end
42
42
 
43
43
  fmtr = PVN::Status::EntriesFormatter.new options.color, allentries
44
- puts fmtr.format
44
+ $io.puts fmtr.format
45
45
  end
46
46
  end
47
47
  end
@@ -2,7 +2,7 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'svnx/status/entry'
5
- require 'pvn/base/color_formatter'
5
+ require 'pvn/util/color_formatter'
6
6
 
7
7
  module PVN; module Status; end; end
8
8
 
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'pvn/command/options'
5
+ require 'pvn/command/color_option'
6
+
7
+ module PVN::Status
8
+ class OptionSet < PVN::Command::OptionSet
9
+ has_option :color, PVN::Command::ColorOption
10
+ has_option :help, PVN::Command::HelpOption
11
+ end
12
+ end
@@ -2,7 +2,8 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  module PVN
5
- module Util
5
+ # a bad name, but I'm not sure if I'm going to monkey patch Array
6
+ module ArrayUtil
6
7
  POS_NEG_NUMERIC_RE = Regexp.new('^[\-\+]?\d+$')
7
8
 
8
9
  # Returns the list joined by spaces, with each element in the list in double
data/lib/pvn.rb CHANGED
@@ -1,8 +1,3 @@
1
- fdirname = File.dirname(__FILE__)
2
-
3
- $:.unshift(fdirname) unless
4
- $:.include?(fdirname) || $:.include?(File.expand_path(fdirname))
5
-
6
1
  module PVN
7
- VERSION = '0.0.4'
2
+ VERSION = '0.0.8'
8
3
  end