svnx 1.0.1 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.glarkrc +1 -0
  4. data/Features.txt +7 -0
  5. data/Gemfile +4 -0
  6. data/History.txt +4 -0
  7. data/LICENSE +20 -0
  8. data/Manifest.txt +0 -0
  9. data/README.md +12 -0
  10. data/Rakefile +12 -0
  11. data/lib/svnx/base/action.rb +57 -52
  12. data/lib/svnx/base/cmdline.rb +58 -0
  13. data/lib/svnx/base/command.rb +49 -41
  14. data/lib/svnx/base/entries.rb +46 -45
  15. data/lib/svnx/base/entry.rb +51 -38
  16. data/lib/svnx/base/env.rb +26 -0
  17. data/lib/svnx/base/options.rb +25 -0
  18. data/lib/svnx/cat/command.rb +3 -64
  19. data/lib/svnx/cat/options.rb +28 -0
  20. data/lib/svnx/commit/command.rb +9 -0
  21. data/lib/svnx/commit/options.rb +29 -0
  22. data/lib/svnx/diff/command.rb +17 -0
  23. data/lib/svnx/diff/elements.rb +84 -0
  24. data/lib/svnx/diff/options.rb +35 -0
  25. data/lib/svnx/diff/parser.rb +105 -0
  26. data/lib/svnx/info/command.rb +4 -47
  27. data/lib/svnx/info/entries.rb +6 -8
  28. data/lib/svnx/info/entry.rb +21 -23
  29. data/lib/svnx/info/options.rb +28 -0
  30. data/lib/svnx/io/directory.rb +9 -5
  31. data/lib/svnx/io/element.rb +93 -95
  32. data/lib/svnx/log/command.rb +7 -3
  33. data/lib/svnx/log/entries.rb +17 -14
  34. data/lib/svnx/log/entry.rb +61 -49
  35. data/lib/svnx/log/options.rb +31 -0
  36. data/lib/svnx/merge/command.rb +9 -0
  37. data/lib/svnx/merge/options.rb +34 -0
  38. data/lib/svnx/project.rb +74 -0
  39. data/lib/svnx/propget/command.rb +9 -0
  40. data/lib/svnx/propget/entries.rb +15 -0
  41. data/lib/svnx/propget/entry.rb +23 -0
  42. data/lib/svnx/propget/options.rb +31 -0
  43. data/lib/svnx/propset/command.rb +9 -0
  44. data/lib/svnx/propset/options.rb +33 -0
  45. data/lib/svnx/revision/argfactory.rb +2 -2
  46. data/lib/svnx/revision/argument.rb +7 -3
  47. data/lib/svnx/revision/date.rb +27 -0
  48. data/lib/svnx/revision/error.rb +2 -2
  49. data/lib/svnx/revision/range.rb +5 -2
  50. data/lib/svnx/status/command.rb +4 -42
  51. data/lib/svnx/status/entries.rb +11 -12
  52. data/lib/svnx/status/entry.rb +43 -41
  53. data/lib/svnx/status/options.rb +28 -0
  54. data/lib/svnx/update/command.rb +9 -0
  55. data/lib/svnx/update/options.rb +25 -0
  56. data/lib/svnx/util/dateutil.rb +35 -0
  57. data/lib/svnx/util/objutil.rb +14 -0
  58. data/lib/{svnx.rb → svnx/version.rb} +2 -2
  59. data/lib/system/command/arg.rb +6 -5
  60. data/lib/system/command/cachefile.rb +29 -21
  61. data/lib/system/command/caching.rb +12 -25
  62. data/lib/system/command/line.rb +41 -30
  63. data/svnx.gemspec +34 -0
  64. metadata +85 -61
  65. data/lib/svnx/base/args.rb +0 -24
  66. data/lib/svnx/log/args.rb +0 -57
  67. data/lib/svnx/log/exec.rb +0 -27
  68. data/lib/svnx/log/line.rb +0 -42
  69. data/test/integration/info/info_test.rb +0 -21
  70. data/test/integration/log/log_test.rb +0 -74
  71. data/test/integration/status/status_test.rb +0 -35
  72. data/test/integration/svnx/io/element_test.rb +0 -235
  73. data/test/unit/svnx/base/action_test.rb +0 -49
  74. data/test/unit/svnx/cat/command_test.rb +0 -55
  75. data/test/unit/svnx/info/entries_test.rb +0 -22
  76. data/test/unit/svnx/log/args_test.rb +0 -15
  77. data/test/unit/svnx/log/entries_test.rb +0 -87
  78. data/test/unit/svnx/log/entry_test.rb +0 -15
  79. data/test/unit/svnx/log/exec_test.rb +0 -15
  80. data/test/unit/svnx/log/line_test.rb +0 -14
  81. data/test/unit/svnx/revision/argfactory_test.rb +0 -50
  82. data/test/unit/svnx/revision/argument_test.rb +0 -167
  83. data/test/unit/svnx/revision/range_test.rb +0 -48
  84. data/test/unit/svnx/status/entries_test.rb +0 -20
  85. data/test/unit/system/command/cachefile_test.rb +0 -52
  86. data/test/unit/system/command/caching_test.rb +0 -92
  87. data/test/unit/system/command/line_test.rb +0 -63
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6eeffb9336d56a2ec27ae467c19b772407b05efe
4
- data.tar.gz: 4665ae1fc141ee1a4bad2808d31fb28ec15e3b99
3
+ metadata.gz: 2a992a704932883d96a27188971922a847807eb1
4
+ data.tar.gz: 9a6f8f859120f59241006a8957a74d2977253d0d
5
5
  SHA512:
6
- metadata.gz: e148e4792f0fb77881cdd968715410378fc50d4542588e5ade9b462873eda6f5694ab1ae581a542354e7f724fc49c7b591f1d40e00d68102de4e34ae0df7f682
7
- data.tar.gz: e5d6d3a2e25971b555e7ad7935f01c3dd0dec318c4e5cd6f74d50c9e32468dd835059f3fa22a39f8f399a08a5aef8c0e015fa7b30c6857349263047ca1ce705f
6
+ metadata.gz: 3052dbdc201d00d88abb2ed4e239b5479a1f713642362eab1ae0294c79657f5a843bca6640c3a57e0c9b2646b635899b76e509832e14c82e15713b967d40d4f0
7
+ data.tar.gz: 208eb47bd7e0e1379a773b53aaf577ceeae16376eec4093f3fe4898ef1781d2154abef54fed00672b9190360f1402eeaa0b2609edc9c05ba7410237ee69fd388
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ Gemfile.lock
data/.glarkrc ADDED
@@ -0,0 +1 @@
1
+ skip-path: pkg
data/Features.txt ADDED
@@ -0,0 +1,7 @@
1
+ Wed Aug 28 08:41:00 2013
2
+
3
+ Added Argument.create.
4
+
5
+ Thu Nov 7 10:11:50 2013
6
+
7
+ Added char method to Action, to match Svn's status character.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in svnx.gemspec
4
+ gemspec
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ 0.0.1 @ 2013-01-05
2
+
3
+ Initial version. Spun off from PVN.
4
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jeffrey E. Pace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ svnx(1) - Subversion extensions
2
+ ===============================
3
+
4
+ ## DESCRIPTION
5
+
6
+ Svnx is a module that wraps the `svn` command line.
7
+
8
+ ## AUTHOR
9
+
10
+ Jeff Pace
11
+
12
+ http://www.github.com/jpace/svnx
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+ require 'rubygems/package_task'
4
+
5
+ task :default => :test
6
+
7
+ Rake::TestTask.new("test") do |t|
8
+ t.libs << 'test'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.warning = true
11
+ t.verbose = true
12
+ end
@@ -2,68 +2,73 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'logue/loggable'
5
+ require 'singleton'
5
6
 
6
- module SVNx
7
- class Action
8
- include Logue::Loggable, Comparable
9
-
10
- attr_reader :type
11
- attr_reader :char
7
+ module Svnx
8
+ end
12
9
 
13
- STATUS_TO_TYPE = Hash.new
14
- STATUS_TO_ACTION = Hash.new
10
+ class Svnx::ActionStatus
11
+ include Singleton
15
12
 
16
- def initialize type, char
17
- @type = type
18
- @char = char
19
- end
13
+ attr_reader :stati
20
14
 
21
- class << self
22
- alias_method :orig_new, :new
23
-
24
- def new arg, char = nil
25
- if arg.kind_of? Action
26
- arg
27
- elsif act = STATUS_TO_ACTION[arg]
28
- act
29
- else
30
- type = STATUS_TO_TYPE[arg]
31
- raise "no such action: #{arg.inspect}" unless type
32
- STATUS_TO_ACTION[arg] = orig_new type, char
33
- end
34
- end
15
+ def initialize
16
+ @status_to_symbol = Hash.new
17
+ @stati = Array.new
35
18
 
36
- def add_type str, char
37
- sym = str.to_sym
38
- STATUS_TO_TYPE[sym] = sym
39
- action = SVNx::Action.new sym, char
40
- SVNx::Action.const_set str.upcase, action
41
- [ sym, str, char ].each do |key|
42
- STATUS_TO_ACTION[key] = action
43
- end
44
- end
45
- end
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
46
27
 
47
- def <=> other
48
- @type <=> other.type
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
49
37
  end
38
+ end
39
+ end
50
40
 
51
- def to_s
52
- @type.to_s
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}"
53
50
  end
51
+ end
54
52
 
55
- add_type 'added', 'A'
56
- add_type 'deleted', 'D'
57
- add_type 'modified', 'M'
58
- add_type 'unversioned', '?'
53
+ def <=> other
54
+ @type <=> other.type
55
+ end
59
56
 
60
- STATUS_TO_TYPE.values.uniq.each do |val|
61
- methname = val.to_s + '?'
62
- define_method methname do
63
- instance_eval do
64
- @type == STATUS_TO_TYPE[val]
65
- end
66
- end
67
- end
57
+ def to_s
58
+ @type.to_s
68
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
65
+
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
69
74
  end
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'logue/loggable'
5
+ require 'system/command/line'
6
+ require 'system/command/caching'
7
+ require 'svnx/base/env'
8
+
9
+ module Svnx
10
+ module Base
11
+ end
12
+ end
13
+
14
+ class Svnx::Base::CachingCommandLine < System::CachingCommandLine
15
+ def caching?
16
+ true
17
+ end
18
+
19
+ def cache_dir
20
+ Svnx::Env.instance.cache_dir
21
+ end
22
+ end
23
+
24
+ class Svnx::Base::CommandLine
25
+ include Logue::Loggable
26
+
27
+ attr_reader :output
28
+ attr_reader :error
29
+ attr_reader :status
30
+
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
37
+
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}"
51
+
52
+ @output = cmdline.output
53
+ @error = cmdline.error
54
+ @status = cmdline.status
55
+
56
+ @output
57
+ end
58
+ end
@@ -1,61 +1,69 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'system/command/line'
5
4
  require 'logue/loggable'
6
5
  require 'system/command/caching'
7
- require 'svnx/base/args'
6
+ require 'svnx/base/cmdline'
8
7
 
9
- # this replaces svnx/lib/command/svncommand.
10
-
11
- module SVNx
12
- DEFAULT_CACHE_DIR = '/tmp/svnx'
13
- TMP_DIR_ENV_VARNAME = 'SVNX_TMP_DIR'
14
-
15
- module CmdLine
16
- include Logue::Loggable
17
-
18
- def initialize subcmd, args
19
- cmdargs = [ 'svn', subcmd ]
20
- cmdargs << '--xml' if uses_xml?
21
- cmdargs.concat args
22
- super cmdargs
8
+ class Svnx::Base::Command
9
+ include Logue::Loggable
10
+
11
+ class << self
12
+ def caching
13
+ define_method :caching? do
14
+ true
15
+ end
23
16
  end
24
17
 
25
- def uses_xml?
26
- true
27
- end
28
-
29
- def cache_dir
30
- ENV[TMP_DIR_ENV_VARNAME] || DEFAULT_CACHE_DIR
18
+ def noncaching
19
+ define_method :caching? do
20
+ false
21
+ end
31
22
  end
32
23
  end
33
24
 
34
- class CommandLine < System::CommandLine
35
- include CmdLine
25
+ attr_reader :output
26
+ attr_reader :error
27
+ attr_reader :status
28
+
29
+ def initialize options, cls: Svnx::Base::CommandLine, exec: nil, xml: false, caching: caching?
30
+ melements = module_elements
31
+ modl = find_module melements
32
+ opts = modl::Options.new options
33
+ cmdargs = opts.to_args
34
+ subcommand = melements[-1].downcase
35
+
36
+ @cmdline = exec || cls.new(subcommand: subcommand, xml: xml, caching: caching, args: cmdargs)
37
+
38
+ @output = @cmdline.execute
39
+ @error = @cmdline.error
40
+ @status = @cmdline.status
36
41
  end
37
42
 
38
- class CachingCommandLine < System::CachingCommandLine
39
- include CmdLine
43
+ def module_elements
44
+ mods = self.class.name.split "::"
45
+ mods[0 .. -2]
40
46
  end
41
47
 
42
- class Command
43
- include Logue::Loggable
44
-
45
- attr_reader :output
46
-
47
- def initialize args
48
- @args = args
49
- end
48
+ def find_module elements = module_elements
49
+ mod = elements * "::"
50
+ Kernel.const_get mod
51
+ end
52
+ end
50
53
 
51
- def command_line
52
- raise "must be implemented"
53
- end
54
+ class Svnx::Base::EntriesCommand < Svnx::Base::Command
55
+ attr_reader :entries
56
+
57
+ def initialize options, cls: Svnx::Base::CommandLine, exec: nil, caching: caching?, xml: true, entries_class: nil
58
+ super options, cls: cls, exec: exec, xml: xml, caching: caching
54
59
 
55
- def execute
56
- cmdline = command_line
57
- cmdline.execute
58
- @output = cmdline.output
60
+ if not @output.empty?
61
+ entries_class ||= begin
62
+ modl = find_module
63
+ modl::Entries
64
+ end
65
+
66
+ @entries = entries_class.new lines: @output
59
67
  end
60
68
  end
61
69
  end
@@ -4,65 +4,66 @@
4
4
  require 'rexml/document'
5
5
  require 'logue/loggable'
6
6
 
7
- module SVNx
8
- # this is a parse/process on-demand list of entries, acting like an
9
- # Enumerable.
7
+ module Svnx
8
+ module Base
9
+ end
10
+ end
10
11
 
11
- class Entries
12
- include Logue::Loggable, Enumerable
12
+ # this is a parse/process on-demand list of entries, acting like an
13
+ # Enumerable.
13
14
 
14
- attr_reader :size
15
+ class Svnx::Base::Entries
16
+ include Logue::Loggable, Enumerable
15
17
 
16
- def initialize args = Hash.new
17
- # it's a hash, but indexed with integers, for non-sequential access:
18
- @entries = Hash.new
18
+ attr_reader :size
19
19
 
20
- if xmllines = args[:xmllines]
21
- if xmllines.kind_of? Array
22
- xmllines = xmllines.join ''
23
- end
20
+ def initialize xmllines: nil, lines: nil
21
+ # it's a hash, but indexed with integers, for non-sequential access:
22
+ @entries = Hash.new
24
23
 
25
- doc = REXML::Document.new xmllines
24
+ lines ||= xmllines
26
25
 
27
- @elements = get_elements doc
28
- @size = @elements.size
29
- elsif args[:xmlentries]
30
- raise "argument xmlentries is no longer supported"
31
- end
26
+ if lines.kind_of? Array
27
+ lines = lines.join ''
32
28
  end
33
29
 
34
- def get_elements doc
35
- raise "get_elements must be implemented for: #{self.class}"
36
- end
30
+ doc = REXML::Document.new lines
31
+
32
+ @elements = get_elements doc
33
+ @size = @elements.size
34
+ end
37
35
 
38
- def create_entry xmlelement
39
- raise "create_entry must be implemented for: #{self.class}"
40
- end
36
+ def get_elements doc
37
+ raise "get_elements must be implemented for: #{self.class}"
38
+ end
41
39
 
42
- # this doesn't handle negative indices
43
- def [] idx
44
- if entry = @entries[idx]
45
- return entry
46
- end
47
- if idx < 0 && idx >= size
48
- raise "error: index #{idx} is not in range(0 .. #{size})"
49
- end
50
- @entries[idx] = create_entry(@elements[idx + 1])
51
- end
40
+ def create_entry xmlelement
41
+ raise "create_entry must be implemented for: #{self.class}"
42
+ end
52
43
 
53
- def each(&blk)
54
- # all elements must be processed before each can run:
55
- if @elements
56
- # a little confusing here: REXML does each_with_index with idx
57
- # zero-based, but elements[0] is invalid.
58
- @elements.each_with_index do |element, idx|
59
- @entries[idx] ||= create_entry(element)
60
- end
44
+ # this doesn't handle negative indices
45
+ def [] idx
46
+ if entry = @entries[idx]
47
+ return entry
48
+ end
49
+ if idx < 0 || idx >= size
50
+ raise "error: index #{idx} is not in range(0 .. #{size})"
51
+ end
52
+ @entries[idx] = create_entry @elements[idx + 1]
53
+ end
61
54
 
62
- @elements = nil
55
+ def each(&blk)
56
+ # all elements must be processed before each can run:
57
+ if @elements
58
+ # a little confusing here: REXML does each_with_index with idx
59
+ # zero-based, but elements[0] is invalid.
60
+ @elements.each_with_index do |element, idx|
61
+ @entries[idx] ||= create_entry(element)
63
62
  end
64
63
 
65
- @entries.keys.sort.collect { |idx| @entries[idx] }.each(&blk)
64
+ @elements = nil
66
65
  end
66
+
67
+ @entries.keys.sort.collect { |idx| @entries[idx] }.each(&blk)
67
68
  end
68
69
  end