svnx 2.0.6 → 2.1.0

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.zshrc +2 -0
  4. data/Rakefile +2 -3
  5. data/lib/cmdline/arg.rb +12 -0
  6. data/lib/cmdline/cachefile.rb +37 -0
  7. data/lib/cmdline/caching.rb +25 -0
  8. data/lib/cmdline/filename.rb +16 -0
  9. data/lib/cmdline/gzpathname.rb +26 -0
  10. data/lib/cmdline/line.rb +57 -0
  11. data/lib/svnx/base/action.rb +31 -61
  12. data/lib/svnx/base/action_status.rb +37 -0
  13. data/lib/svnx/base/cmd.rb +20 -0
  14. data/lib/svnx/base/cmdline.rb +43 -37
  15. data/lib/svnx/base/command.rb +57 -50
  16. data/lib/svnx/base/command_factory.rb +24 -0
  17. data/lib/svnx/base/entries.rb +42 -40
  18. data/lib/svnx/base/entry.rb +46 -44
  19. data/lib/svnx/base/env.rb +14 -15
  20. data/lib/svnx/base/options.rb +22 -10
  21. data/lib/svnx/cat/command.rb +4 -2
  22. data/lib/svnx/cat/options.rb +11 -14
  23. data/lib/svnx/commit/command.rb +4 -2
  24. data/lib/svnx/commit/options.rb +11 -16
  25. data/lib/svnx/diff/command.rb +9 -7
  26. data/lib/svnx/diff/elements.rb +56 -54
  27. data/lib/svnx/diff/options.rb +14 -21
  28. data/lib/svnx/diff/parser.rb +73 -71
  29. data/lib/svnx/info/command.rb +4 -2
  30. data/lib/svnx/info/entries.rb +8 -6
  31. data/lib/svnx/info/entry.rb +23 -17
  32. data/lib/svnx/info/options.rb +11 -14
  33. data/lib/svnx/io/directory.rb +3 -1
  34. data/lib/svnx/io/element.rb +88 -86
  35. data/lib/svnx/log/command.rb +4 -2
  36. data/lib/svnx/log/entries.rb +14 -12
  37. data/lib/svnx/log/entry.rb +36 -58
  38. data/lib/svnx/log/entrypath.rb +35 -0
  39. data/lib/svnx/log/options.rb +14 -18
  40. data/lib/svnx/merge/command.rb +4 -2
  41. data/lib/svnx/merge/options.rb +17 -22
  42. data/lib/svnx/project.rb +27 -15
  43. data/lib/svnx/propget/command.rb +4 -2
  44. data/lib/svnx/propget/entries.rb +8 -6
  45. data/lib/svnx/propget/entry.rb +12 -10
  46. data/lib/svnx/propget/options.rb +13 -17
  47. data/lib/svnx/propset/command.rb +4 -2
  48. data/lib/svnx/propset/options.rb +14 -19
  49. data/lib/svnx/revision/argfactory.rb +6 -2
  50. data/lib/svnx/revision/argument.rb +22 -19
  51. data/lib/svnx/revision/date.rb +16 -16
  52. data/lib/svnx/revision/error.rb +4 -1
  53. data/lib/svnx/revision/range.rb +2 -1
  54. data/lib/svnx/status/command.rb +4 -2
  55. data/lib/svnx/status/entries.rb +13 -11
  56. data/lib/svnx/status/entry.rb +37 -39
  57. data/lib/svnx/status/options.rb +12 -15
  58. data/lib/svnx/update/command.rb +4 -2
  59. data/lib/svnx/update/options.rb +11 -12
  60. data/lib/svnx/util/classutil.rb +19 -0
  61. data/lib/svnx/util/dateutil.rb +1 -0
  62. data/lib/svnx/util/objutil.rb +36 -6
  63. data/lib/svnx/version.rb +1 -1
  64. data/repackage +1 -0
  65. data/svnx.gemspec +6 -5
  66. metadata +29 -6
  67. data/lib/system/command/arg.rb +0 -13
  68. data/lib/system/command/cachefile.rb +0 -58
  69. data/lib/system/command/caching.rb +0 -23
  70. data/lib/system/command/line.rb +0 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a992a704932883d96a27188971922a847807eb1
4
- data.tar.gz: 9a6f8f859120f59241006a8957a74d2977253d0d
3
+ metadata.gz: fd37aad9c296bc3739eced16136fc73f1e8831ba
4
+ data.tar.gz: 2b829bf99dad72f3ec1bdc3a4913ff5a7e30879f
5
5
  SHA512:
6
- metadata.gz: 3052dbdc201d00d88abb2ed4e239b5479a1f713642362eab1ae0294c79657f5a843bca6640c3a57e0c9b2646b635899b76e509832e14c82e15713b967d40d4f0
7
- data.tar.gz: 208eb47bd7e0e1379a773b53aaf577ceeae16376eec4093f3fe4898ef1781d2154abef54fed00672b9190360f1402eeaa0b2609edc9c05ba7410237ee69fd388
6
+ metadata.gz: 840ed6cfcd13332ffbcf8413adcc06fc9d18d7bf3d382f88e788297d776ca16f77b5650de4da706f9d8d63ee0bc5f3cb5ba7f64e44af0c2018febe41c964d64a
7
+ data.tar.gz: 637d08aa4258d2e044b01a8c9957a2d93f76eaed0755d5f605546b6dccc8436a167eef16a73f39b38ddf33828a66938ecc9ce22186773e272fe6b81f8e510756
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  pkg
2
2
  Gemfile.lock
3
+ .raketasks
data/.zshrc ADDED
@@ -0,0 +1,2 @@
1
+ alias tt='rake test'
2
+ alias t='ruby -Itest -Itest/unit -Ilib `ecf`'
data/Rakefile CHANGED
@@ -1,10 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'rubygems/package_task'
4
3
 
5
4
  task :default => :test
6
5
 
7
- Rake::TestTask.new("test") do |t|
6
+ Rake::TestTask.new(:test) do |t|
8
7
  t.libs << 'test'
9
8
  t.pattern = 'test/**/*_test.rb'
10
9
  t.warning = true
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ module CmdLine
5
+ class Argument < String
6
+ # just a string, but quotes itself
7
+
8
+ def to_s
9
+ '"' + super + '"'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'cmdline/line'
5
+ require 'cmdline/filename'
6
+ require 'cmdline/gzpathname'
7
+
8
+ # A file that has a pathname and output
9
+ module CmdLine
10
+ class CacheFile
11
+ attr_reader :output
12
+ attr_reader :pathname
13
+
14
+ def initialize cache_dir, args
15
+ @args = args
16
+ basename = FileName.new(args).name
17
+ fullname = Pathname(cache_dir) + basename
18
+ @pathname = GzipPathname.new fullname
19
+ @output = nil
20
+ end
21
+
22
+ def readlines
23
+ if @pathname.exist?
24
+ @output = @pathname.read_file
25
+ else
26
+ cl = CommandLine.new @args
27
+ @output = cl.execute
28
+ @pathname.save_file @output
29
+ @output
30
+ end
31
+ end
32
+
33
+ def to_s
34
+ @pathname.to_s
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'cmdline/line'
5
+ require 'cmdline/cachefile'
6
+
7
+ module CmdLine
8
+ class CachingCommandLine < CommandLine
9
+ # caches its input and values.
10
+
11
+ def cache_dir
12
+ @cache_dir ||= '/tmp' + Pathname.new($0).expand_path.to_s
13
+ @cache_dir
14
+ end
15
+
16
+ def cache_file
17
+ CacheFile.new cache_dir, @args
18
+ end
19
+
20
+ def execute
21
+ cachefile = cache_file
22
+ @output = cachefile.readlines
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ module CmdLine
5
+ class FileName
6
+ attr_reader :name
7
+
8
+ def initialize args
9
+ @name = args.join('-').gsub('/', '_slash_') + '.gz'
10
+ end
11
+
12
+ def to_s
13
+ @name
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'zlib'
5
+ require 'pathname'
6
+
7
+ module CmdLine
8
+ # A pathname that reads and writes itself as gzipped
9
+ class GzipPathname < Pathname
10
+ def save_file content
11
+ parent.mkpath unless parent.exist?
12
+ unlink if exist?
13
+ Zlib::GzipWriter.open(to_s) do |gz|
14
+ gz.puts content
15
+ end
16
+ end
17
+
18
+ def read_file
19
+ Array.new.tap do |content|
20
+ Zlib::GzipReader.open(to_s) do |gz|
21
+ content.concat gz.readlines
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'logue/loggable'
5
+ require 'open3'
6
+
7
+ module CmdLine
8
+ class CommandLine
9
+ include Logue::Loggable
10
+
11
+ attr_reader :args
12
+ attr_reader :output
13
+ attr_reader :error
14
+ attr_reader :status
15
+
16
+ def initialize *args, debug: false
17
+ @args = args.dup
18
+ end
19
+
20
+ def << arg
21
+ @args << arg
22
+ end
23
+
24
+ def execute
25
+ cmd = to_command
26
+ debug "cmd: #{cmd}"
27
+
28
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wthr|
29
+ @output = stdout.readlines
30
+ @error = stderr.readlines
31
+ @status = wthr.value
32
+ end
33
+
34
+ if false && @output
35
+ puts "output"
36
+ @output.each_with_index do |line, idx|
37
+ debug "output[#{idx}]: #{line}"
38
+ end
39
+ end
40
+
41
+ if false && @error
42
+ puts "error"
43
+ @error.each_with_index do |line, idx|
44
+ debug "error[#{idx}]: #{line}"
45
+ end
46
+ end
47
+
48
+ debug "@status: #{@status}"
49
+
50
+ @output
51
+ end
52
+
53
+ def to_command
54
+ @args.join ' '
55
+ end
56
+ end
57
+ end
@@ -3,72 +3,42 @@
3
3
 
4
4
  require 'logue/loggable'
5
5
  require 'singleton'
6
+ require 'svnx/base/action_status'
6
7
 
7
8
  module Svnx
8
- end
9
-
10
- class Svnx::ActionStatus
11
- include Singleton
12
-
13
- attr_reader :stati
14
-
15
- def initialize
16
- @status_to_symbol = Hash.new
17
- @stati = Array.new
18
-
19
- add_type 'added', 'A'
20
- add_type 'deleted', 'D'
21
- add_type 'modified', 'M'
22
- add_type 'replaced', 'R'
23
- add_type 'unversioned', '?'
24
- add_type 'external', 'X'
25
- add_type 'normal', 'q' # actually, X, but in a different column than X for external
26
- end
27
-
28
- def symbol_for arg
29
- @status_to_symbol[arg]
30
- end
31
-
32
- def add_type str, char
33
- sym = str.to_sym
34
- @stati << str
35
- [ sym, str, char ].each do |key|
36
- @status_to_symbol[key] = sym
9
+ class Action
10
+ include Logue::Loggable
11
+ include Comparable
12
+
13
+ attr_reader :type
14
+
15
+ def initialize type
16
+ sas = ActionStatus.instance
17
+ unless @type = sas.symbol_for(type)
18
+ raise "not a valid action type: #{type}"
19
+ end
37
20
  end
38
- end
39
- end
40
21
 
41
- class Svnx::Action
42
- include Logue::Loggable, Comparable
43
-
44
- attr_reader :type
45
-
46
- def initialize type, char = nil
47
- sas = Svnx::ActionStatus.instance
48
- unless @type = sas.symbol_for(type)
49
- raise "not a valid action type: #{type}"
22
+ def <=> other
23
+ @type <=> other.type
50
24
  end
51
- end
52
-
53
- def <=> other
54
- @type <=> other.type
55
- end
56
25
 
57
- def to_s
58
- @type.to_s
59
- end
60
-
61
- sas = Svnx::ActionStatus.instance
62
- sas.stati.each do |str|
63
- action = Svnx::Action.new str
64
- Svnx::Action.const_set str.upcase, action
26
+ def to_s
27
+ @type.to_s
28
+ end
65
29
 
66
- methname = str + '?'
67
- define_method methname do
68
- instance_eval do
69
- sym = Svnx::ActionStatus.instance.symbol_for str
70
- @type.to_sym == sym
71
- end
72
- end
73
- end
30
+ sas = ActionStatus.instance
31
+ sas.stati.each do |str|
32
+ action = Action.new str
33
+ Action.const_set str.upcase, action
34
+
35
+ methname = str + '?'
36
+ define_method methname do
37
+ instance_eval do
38
+ sym = ActionStatus.instance.symbol_for str
39
+ @type.to_sym == sym
40
+ end
41
+ end
42
+ end
43
+ end
74
44
  end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'singleton'
5
+
6
+ module Svnx
7
+ class ActionStatus
8
+ include Singleton
9
+
10
+ attr_reader :stati
11
+
12
+ def initialize
13
+ @status_to_symbol = Hash.new
14
+ @stati = Array.new
15
+
16
+ add_type 'added', 'A'
17
+ add_type 'deleted', 'D'
18
+ add_type 'modified', 'M'
19
+ add_type 'replaced', 'R'
20
+ add_type 'unversioned', '?'
21
+ add_type 'external', 'X'
22
+ add_type 'normal', 'q' # actually, X, but in a different column than X for external
23
+ end
24
+
25
+ def symbol_for arg
26
+ @status_to_symbol[arg]
27
+ end
28
+
29
+ def add_type str, char
30
+ sym = str.to_sym
31
+ @stati << str
32
+ [ sym, str, char ].each do |key|
33
+ @status_to_symbol[key] = sym
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rexml/document'
5
+ require 'logue/loggable'
6
+
7
+ module Svnx
8
+ class Cmd
9
+ include Logue::Loggable
10
+
11
+ def initialize xml
12
+ info "xml: #{xml}"
13
+
14
+ @doc = REXML::Document.new xml
15
+ info "@doc: #{@doc}"
16
+
17
+ end
18
+ end
19
+ end
20
+
@@ -2,8 +2,8 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'logue/loggable'
5
- require 'system/command/line'
6
- require 'system/command/caching'
5
+ require 'cmdline/line'
6
+ require 'cmdline/caching'
7
7
  require 'svnx/base/env'
8
8
 
9
9
  module Svnx
@@ -11,48 +11,54 @@ module Svnx
11
11
  end
12
12
  end
13
13
 
14
- class Svnx::Base::CachingCommandLine < System::CachingCommandLine
15
- def caching?
16
- true
17
- end
14
+ module Svnx::Base
15
+ class CachingCommandLine < CmdLine::CachingCommandLine
16
+ def caching?
17
+ true
18
+ end
18
19
 
19
- def cache_dir
20
- Svnx::Env.instance.cache_dir
20
+ def cache_dir
21
+ Svnx::Env.instance.cache_dir
22
+ end
21
23
  end
22
- end
23
24
 
24
- class Svnx::Base::CommandLine
25
- include Logue::Loggable
25
+ class CommandLine
26
+ include Logue::Loggable
26
27
 
27
- attr_reader :output
28
- attr_reader :error
29
- attr_reader :status
28
+ attr_reader :output
29
+ attr_reader :error
30
+ attr_reader :status
30
31
 
31
- def initialize subcommand: nil, xml: true, caching: false, args: Array.new
32
- @subcommand = subcommand
33
- @xml = xml
34
- @caching = caching
35
- @args = args
36
- end
32
+ def initialize subcommand: nil, xml: true, caching: false, args: Array.new
33
+ debug "subcommand: #{subcommand}"
34
+ debug "args: #{args}"
35
+ @subcommand = subcommand
36
+ @xml = xml
37
+ @caching = caching
38
+ @args = args
39
+ debug "@args: #{@args}"
40
+ end
37
41
 
38
- def execute
39
- cmdargs = [ 'svn', @subcommand ]
40
- cmdargs << '--xml' if @xml
41
- cmdargs.concat @args
42
- debug "cmdargs: #{cmdargs}"
43
-
44
- cmdline = if @caching
45
- Svnx::Base::CachingCommandLine.new cmdargs
46
- else
47
- System::CommandLine.new cmdargs
48
- end
49
- cmdline.execute
50
- debug "cmdline: #{cmdline}"
42
+ def execute
43
+ cmdargs = [ 'svn', @subcommand ]
44
+ cmdargs << '--xml' if @xml
45
+ cmdargs.concat @args
46
+ debug "cmdargs: #{cmdargs}"
51
47
 
52
- @output = cmdline.output
53
- @error = cmdline.error
54
- @status = cmdline.status
48
+ cmdline = command_line cmdargs
49
+ cmdline.execute
50
+ debug "cmdline: #{cmdline}"
51
+
52
+ @output = cmdline.output
53
+ @error = cmdline.error
54
+ @status = cmdline.status
55
+
56
+ @output
57
+ end
55
58
 
56
- @output
59
+ def command_line cmdargs
60
+ cls = @caching ? CachingCommandLine : CmdLine::CommandLine
61
+ cls.new cmdargs
62
+ end
57
63
  end
58
64
  end