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
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'svnx/log/args'
5
- require 'svnx/log/exec'
6
- require 'svnx/log/line'
4
+ require 'svnx/log/options'
5
+ require 'svnx/log/entries'
6
+ require 'svnx/base/command'
7
+
8
+ class Svnx::Log::Command < Svnx::Base::EntriesCommand
9
+ noncaching
10
+ end
@@ -4,22 +4,25 @@
4
4
  require 'svnx/base/entries'
5
5
  require 'svnx/log/entry'
6
6
 
7
- module SVNx::Log
8
- class Entries < SVNx::Entries
9
- def get_elements doc
10
- doc.elements['log'].elements
11
- end
7
+ module Svnx
8
+ module Log
9
+ end
10
+ end
12
11
 
13
- def create_entry xmlelement
14
- Entry.new :xmlelement => xmlelement
15
- end
12
+ class Svnx::Log::Entries < Svnx::Base::Entries
13
+ def get_elements doc
14
+ doc.elements['log'].elements
15
+ end
16
+
17
+ def create_entry xmlelement
18
+ Svnx::Log::Entry.new xmlelement: xmlelement
19
+ end
16
20
 
17
- def match action, filter
18
- matching = Array.new
19
- each do |entry|
20
- matching.concat entry.match(action, filter)
21
- end
22
- matching.sort
21
+ def match action, filter
22
+ matching = Array.new
23
+ each do |entry|
24
+ matching.concat entry.match(action, filter)
23
25
  end
26
+ matching.sort
24
27
  end
25
28
  end
@@ -3,70 +3,82 @@
3
3
 
4
4
  require 'svnx/base/entry'
5
5
  require 'svnx/base/action'
6
+ require 'time'
6
7
 
7
- module SVNx; module Log; end; end
8
+ module Svnx
9
+ module Log
10
+ end
11
+ end
8
12
 
9
- module SVNx::Log
10
- class Entry < SVNx::Entry
11
- attr_reader :revision, :author, :date, :paths, :msg
13
+ class Svnx::Log::EntryPath
14
+ include Comparable
15
+
16
+ attr_reader :kind, :action, :name
17
+
18
+ def initialize args = Hash.new
19
+ @kind = args[:kind]
20
+ @action = args[:action]
21
+ @name = args[:name]
22
+ end
12
23
 
13
- def set_from_element elmt
14
- set_attr_var elmt, 'revision'
24
+ def to_s
25
+ @name
26
+ end
15
27
 
16
- %w{ author date msg }.each do |field|
17
- set_elmt_var elmt, field
18
- end
19
-
20
- @paths = Array.new
28
+ def <=> other
29
+ name <=> other.name
30
+ end
21
31
 
22
- elmt.elements.each('paths/path') do |pe|
23
- kind = get_attribute pe, 'kind'
24
- action = get_attribute pe, 'action'
25
- name = pe.text
32
+ def match? action, filter
33
+ @action.to_s == action.to_s && @name.start_with?(filter)
34
+ end
35
+ end
26
36
 
27
- @paths << LogEntryPath.new(kind: kind, action: SVNx::Action.new(action), name: name)
28
- end
29
-
30
- # Svn isn't consistent with the order of paths
31
- @paths.sort!
32
- end
37
+ class Svnx::Log::Entry < Svnx::Base::Entry
38
+ attr_reader :revision, :author, :date, :paths, :msg
33
39
 
34
- def message
35
- @msg
36
- end
40
+ def set_from_element elmt
41
+ set_attr_var elmt, 'revision'
42
+ set_elmt_vars elmt, 'author', 'date', 'msg'
43
+
44
+ @paths = Array.new
37
45
 
38
- def to_s
39
- [ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
40
- end
46
+ elmt.elements.each('paths/path') do |pe|
47
+ kind = attribute_value pe, 'kind'
48
+ action = attribute_value pe, 'action'
49
+ name = pe.text
41
50
 
42
- def match action, filter
43
- paths.select do |path|
44
- path.match? action, filter
45
- end
51
+ @paths << Svnx::Log::EntryPath.new(kind: kind, action: Svnx::Action.new(action), name: name)
46
52
  end
47
- end
48
-
49
- class LogEntryPath
50
- include Comparable
51
-
52
- attr_reader :kind, :action, :name
53
53
 
54
- def initialize args = Hash.new
55
- @kind = args[:kind]
56
- @action = args[:action]
57
- @name = args[:name]
58
- end
54
+ # Svn isn't consistent with the order of paths
55
+ @paths.sort!
56
+ end
59
57
 
60
- def to_s
61
- @name
62
- end
58
+ def message
59
+ @msg
60
+ end
63
61
 
64
- def <=> other
65
- name <=> other.name
62
+ def to_s
63
+ [ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
64
+ end
65
+
66
+ def match action, filter
67
+ paths.select do |path|
68
+ path.match? action, filter
66
69
  end
70
+ end
67
71
 
68
- def match? action, filter
69
- @action.to_s == action.to_s && @name.start_with?(filter)
72
+ def datetime
73
+ @dt ||= DateTime.parse date
74
+ end
75
+
76
+ def find_paths args
77
+ paths.select do |path|
78
+ if args[:kind]
79
+ path.kind == args[:kind]
80
+ end
70
81
  end
71
82
  end
72
83
  end
84
+
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/options'
5
+
6
+ module Svnx
7
+ module Log
8
+ end
9
+ end
10
+
11
+ class Svnx::Log::Options < Svnx::Base::Options
12
+ attr_reader :limit
13
+ attr_reader :verbose
14
+ attr_reader :revision
15
+ attr_reader :url
16
+ attr_reader :path
17
+
18
+ def initialize args
19
+ assign args, :limit, :verbose, :revision, :url, :path
20
+ end
21
+
22
+ def options_to_args
23
+ Array.new.tap do |optargs|
24
+ optargs << [ :limit, [ "--limit", limit ] ]
25
+ optargs << [ :verbose, "-v" ]
26
+ optargs << [ :revision, "-r" + revision.to_s ]
27
+ optargs << [ :url, url ]
28
+ optargs << [ :path, path ]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/merge/options'
5
+ require 'svnx/base/command'
6
+
7
+ class Svnx::Merge::Command < Svnx::Base::Command
8
+ noncaching
9
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/options'
5
+
6
+ module Svnx
7
+ module Merge
8
+ end
9
+ end
10
+
11
+ class Svnx::Merge::Options < Svnx::Base::Options
12
+ attr_reader :commit
13
+ attr_reader :range
14
+ attr_reader :accept
15
+ attr_reader :from
16
+ attr_reader :path
17
+ attr_reader :url
18
+
19
+ def initialize args = Hash.new
20
+ assign args, :url, :path, :accept, :range, :commit, :from
21
+ end
22
+
23
+ def options_to_args
24
+ # an array, not a hash, because "from" should be in the exec args before "url"/"path"
25
+ Array.new.tap do |optargs|
26
+ optargs << [ :commit, [ "-c", commit ] ]
27
+ optargs << [ :range, [ "-r", range ] ]
28
+ optargs << [ :accept, [ "--accept", accept ] ]
29
+ optargs << [ :from, from ]
30
+ optargs << [ :url, url ]
31
+ optargs << [ :path, path ]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ module Svnx
5
+ end
6
+
7
+ # A low-level wrapper around the Svnx commands, converting arguments (svnx/<command>/options) into
8
+ # entries (svnx/<command>/entry) or output. Enhances the low level functionality.
9
+
10
+ class Svnx::Project
11
+ attr_reader :dir
12
+
13
+ def initialize dir: nil, url: nil, exec: nil
14
+ @dir = dir
15
+ @url = url
16
+ @exec = exec
17
+ end
18
+
19
+ def where
20
+ @url || @dir
21
+ end
22
+
23
+ def url
24
+ @url ||= begin
25
+ entries = info
26
+ entries && entries[0].url
27
+ end
28
+ end
29
+
30
+ def path
31
+ info.path
32
+ end
33
+
34
+ def run_command cmdcls, cmdargs, args, exec: nil
35
+ cmdargs = cmdargs.merge args
36
+ cmd = cmdcls.new cmdargs, exec: exec
37
+ cmd.respond_to?(:entries) ? cmd.entries : cmd.output
38
+ end
39
+
40
+ def self.add_command_delegator name, takes_multiple_paths
41
+ require "svnx/#{name}/command"
42
+
43
+ pathargs = (takes_multiple_paths ? "{ paths: [ @dir ], url: @url }" : "{ path: @dir, url: @url }")
44
+
45
+ args = [
46
+ "Svnx::#{name.to_s.capitalize}::Command",
47
+ pathargs,
48
+ "args",
49
+ "exec: exec"
50
+ ]
51
+
52
+ src = [
53
+ "def #{name} exec: @exec, **args",
54
+ " run_command " + args.join(", "),
55
+ "end"
56
+ ].join("\n")
57
+ module_eval src
58
+ end
59
+
60
+ add_command_delegator :info, false
61
+
62
+ add_command_delegator :update, true
63
+ add_command_delegator :merge, true
64
+ add_command_delegator :commit, true
65
+
66
+ add_command_delegator :log, false
67
+ add_command_delegator :diff, false
68
+ add_command_delegator :propset, false
69
+ add_command_delegator :propget, false
70
+
71
+ def to_s
72
+ where.to_s
73
+ end
74
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/propget/options'
5
+ require 'svnx/base/command'
6
+
7
+ class Svnx::Propget::Command < Svnx::Base::EntriesCommand
8
+ noncaching
9
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/propget/entry'
5
+ require 'svnx/base/entries'
6
+
7
+ class Svnx::Propget::Entries < Svnx::Base::Entries
8
+ def get_elements doc
9
+ doc.elements['properties'].elements
10
+ end
11
+
12
+ def create_entry xmlelement
13
+ Svnx::Propget::Entry.new :xmlelement => xmlelement
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/entry'
5
+
6
+ module Svnx
7
+ module Propget
8
+ end
9
+ end
10
+
11
+ class Svnx::Propget::Entry < Svnx::Base::Entry
12
+ attr_reader :path
13
+ attr_reader :name
14
+ attr_reader :value
15
+
16
+ def set_from_element elmt
17
+ set_attr_vars elmt, :path
18
+
19
+ prop = elmt.elements["property"]
20
+ set_attr_vars prop, :name
21
+ @value = prop.text
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/options'
5
+
6
+ module Svnx
7
+ module Propget
8
+ end
9
+ end
10
+
11
+ class Svnx::Propget::Options < Svnx::Base::Options
12
+ attr_reader :revision
13
+ attr_reader :revprop
14
+ attr_reader :name
15
+ attr_reader :url
16
+ attr_reader :path
17
+
18
+ def initialize args
19
+ assign args, :revision, :revprop, :name, :url, :path
20
+ end
21
+
22
+ def options_to_args
23
+ Array.new.tap do |optargs|
24
+ optargs << [ :revision, [ "-r", revision ] ]
25
+ optargs << [ :revprop, "--revprop" ]
26
+ optargs << [ :name, name ]
27
+ optargs << [ :url, url ]
28
+ optargs << [ :path, path ]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/propset/options'
5
+ require 'svnx/base/command'
6
+
7
+ class Svnx::Propset::Command < Svnx::Base::Command
8
+ noncaching
9
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/options'
5
+
6
+ module Svnx
7
+ module Propset
8
+ end
9
+ end
10
+
11
+ class Svnx::Propset::Options < Svnx::Base::Options
12
+ attr_reader :file
13
+ attr_reader :revision
14
+ attr_reader :name
15
+ attr_reader :value
16
+ attr_reader :url
17
+ attr_reader :path
18
+
19
+ def initialize args
20
+ assign args, :file, :revision, :name, :value, :url, :path
21
+ end
22
+
23
+ def options_to_args
24
+ Array.new.tap do |optargs|
25
+ optargs << [ :name, name ]
26
+ optargs << [ :revision, [ "--revprop", "-r", revision ] ]
27
+ optargs << [ :file, [ "--file", file ] ]
28
+ optargs << [ :value, value ]
29
+ optargs << [ :url, url ]
30
+ optargs << [ :path, path ]
31
+ end
32
+ end
33
+ end