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
@@ -4,54 +4,67 @@
4
4
  require 'rexml/document'
5
5
  require 'logue/loggable'
6
6
 
7
- module SVNx
8
- class Entry
9
- include Logue::Loggable
10
-
11
- def initialize args
12
- if xmllines = args[:xmllines]
13
- if xmllines.kind_of? Array
14
- xmllines = xmllines.join ''
15
- end
16
-
17
- doc = REXML::Document.new xmllines
18
-
19
- set_from_xml doc
20
- elsif elmt = args[:xmlelement]
21
- set_from_element elmt
22
- else
23
- raise "must be initialized with xmllines or xmlelement"
7
+ module Svnx
8
+ module Base
9
+ end
10
+ end
11
+
12
+ class Svnx::Base::Entry
13
+ include Logue::Loggable
14
+
15
+ def initialize xmllines: nil, xmlelement: nil
16
+ if xmllines
17
+ if xmllines.kind_of? Array
18
+ xmllines = xmllines.join ''
24
19
  end
20
+ doc = REXML::Document.new xmllines
21
+ set_from_xml doc
22
+ elsif xmlelement
23
+ set_from_element xmlelement
24
+ else
25
+ raise "must be initialized with xmllines (received: #{xmllines.inspect}) or xmlelement (received: #{xmlelement.inspect})"
25
26
  end
27
+ end
26
28
 
27
- def set_from_xml xmldoc
28
- raise "must be implemented"
29
- end
29
+ def set_from_xml xmldoc
30
+ raise "must be implemented"
31
+ end
30
32
 
31
- def set_from_element elmt
32
- raise "must be implemented"
33
- end
33
+ def set_from_element elmt
34
+ raise "must be implemented"
35
+ end
34
36
 
35
- def get_attribute xmlelement, attrname
36
- xmlelement.attributes[attrname]
37
- end
37
+ def set_attr_var xmlelement, varname
38
+ set_var varname, attribute_value(xmlelement, varname)
39
+ end
38
40
 
39
- def get_element_text xmlelement, elmtname
40
- elmt = xmlelement.elements[elmtname]
41
- # in my test svn repository, revision 1 doesn't have an author element:
42
- (elmt && elmt.text) || ""
41
+ def set_attr_vars xmlelement, *varnames
42
+ varnames.each do |varname|
43
+ set_attr_var xmlelement, varname
43
44
  end
45
+ end
44
46
 
45
- def set_attr_var xmlelement, varname
46
- set_var varname, get_attribute(xmlelement, varname)
47
- end
47
+ def set_elmt_var xmlelement, varname
48
+ set_var varname, element_text(xmlelement, varname)
49
+ end
48
50
 
49
- def set_elmt_var xmlelement, varname
50
- set_var varname, get_element_text(xmlelement, varname)
51
+ def set_elmt_vars xmlelement, *varnames
52
+ varnames.each do |varname|
53
+ set_elmt_var xmlelement, varname
51
54
  end
55
+ end
52
56
 
53
- def set_var varname, value
54
- instance_variable_set '@' + varname, value
55
- end
57
+ def set_var varname, value
58
+ instance_variable_set '@' + varname.to_s, value
59
+ end
60
+
61
+ def attribute_value xmlelement, attrname
62
+ xmlelement.attributes[attrname.to_s]
56
63
  end
64
+
65
+ def element_text xmlelement, elmtname
66
+ elmt = xmlelement.elements[elmtname.to_s]
67
+ # some elements don't have text:
68
+ (elmt && elmt.text) || ""
69
+ end
57
70
  end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'singleton'
5
+
6
+ module Svnx
7
+ end
8
+
9
+ class Svnx::Env
10
+ include Singleton
11
+
12
+ # the directory into which to put cached files
13
+ attr_accessor :cache_dir_name
14
+
15
+ # the environment variable, naming the cache directory
16
+ attr_accessor :cache_dir_env_varname
17
+
18
+ def initialize
19
+ @cache_dir_name = "/tmp/svnx"
20
+ @cache_dir_env_varname = "SVNX_TMP_DIR"
21
+ end
22
+
23
+ def cache_dir
24
+ ENV[@cache_dir_env_varname] || @cache_dir_name
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/util/objutil'
5
+
6
+ module Svnx
7
+ module Base
8
+ end
9
+ end
10
+
11
+ class Svnx::Base::Options
12
+ include Svnx::ObjectUtil
13
+
14
+ def to_args
15
+ Array.new.tap do |args|
16
+ options_to_args.each do |opt|
17
+ optname = opt[0]
18
+ values = opt[1]
19
+ if send optname
20
+ args.concat [ values ].flatten
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,70 +1,9 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
+ require 'svnx/cat/options'
4
5
  require 'svnx/base/command'
5
- require 'system/command/caching'
6
6
 
7
- module SVNx
8
- module CatCmdLine
9
- # this can be either an Array (for which to_a returns itself), or a
10
- # CommandArgs, which also has to_a.
11
- def initialize args = Array.new
12
- super "cat", args.to_a
13
- end
14
-
15
- def uses_xml?
16
- false
17
- end
18
- end
19
-
20
- class CatCommandLine < CommandLine
21
- include CatCmdLine
22
- end
23
-
24
- class CatCommandLineCaching < CachingCommandLine
25
- include CatCmdLine
26
- end
27
-
28
- class CatCommandArgs < CommandArgs
29
- attr_reader :revision
30
- attr_reader :use_cache
31
-
32
- def initialize args = Hash.new
33
- @use_cache = args[:use_cache].nil? || args[:use_cache]
34
- @revision = args[:revision]
35
- super
36
- end
37
-
38
- def to_a
39
- ary = Array.new
40
- if @revision
41
- ary << "-r#{@revision}"
42
- end
43
-
44
- if @path
45
- ary << @path
46
- end
47
- end
48
- end
49
-
50
- class CatCommand < Command
51
- def initialize args
52
- @use_cache = args.use_cache
53
- super
54
- end
55
-
56
- def command_line
57
- cls = @use_cache ? CatCommandLineCaching : CatCommandLine
58
- cls.new @args
59
- end
60
- end
61
-
62
- class CatExec
63
- attr_reader :output
64
-
65
- def initialize args
66
- cmd = CatCommand.new CatCommandArgs.new(args)
67
- @output = cmd.execute
68
- end
69
- end
7
+ class Svnx::Cat::Command < Svnx::Base::Command
8
+ caching
70
9
  end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/util/objutil'
5
+ require 'svnx/base/options'
6
+
7
+ module Svnx
8
+ module Cat
9
+ end
10
+ end
11
+
12
+ class Svnx::Cat::Options < Svnx::Base::Options
13
+ attr_reader :revision
14
+ attr_reader :url
15
+ attr_reader :path
16
+
17
+ def initialize args
18
+ assign args, :revision, :url, :path
19
+ end
20
+
21
+ def options_to_args
22
+ Array.new.tap do |optargs|
23
+ optargs << [ :revision, [ "-r", revision ] ]
24
+ optargs << [ :url, url ]
25
+ optargs << [ :path, path ]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/commit/options'
5
+ require 'svnx/base/command'
6
+
7
+ class Svnx::Commit::Command < Svnx::Base::Command
8
+ noncaching
9
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/options'
5
+
6
+ module Svnx
7
+ module Commit
8
+ end
9
+ end
10
+
11
+ class Svnx::Commit::Options < Svnx::Base::Options
12
+ include Svnx::ObjectUtil
13
+
14
+ attr_reader :file
15
+ attr_reader :paths
16
+ attr_reader :url
17
+
18
+ def initialize args = Hash.new
19
+ assign args, :file, :paths, :url
20
+ end
21
+
22
+ def options_to_args
23
+ Array.new.tap do |optargs|
24
+ optargs << [ :file, [ "-F", file ] ]
25
+ optargs << [ :url, url ]
26
+ optargs << [ :paths, paths ]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/diff/options'
5
+ require 'svnx/base/command'
6
+ require 'svnx/diff/parser'
7
+
8
+ class Svnx::Diff::Command < Svnx::Base::Command
9
+ attr_reader :entries
10
+
11
+ def initialize cmdopts, cls: Svnx::Base::CommandLine, exec: nil
12
+ super cmdopts, cls: cls, exec: exec, xml: false, caching: true
13
+ if @output
14
+ @entries = Svnx::Diff::Parser.new.parse_all_output @output.dup
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'logue/loggable'
5
+
6
+ module Svnx
7
+ module Diff
8
+ end
9
+ end
10
+
11
+ class Svnx::Diff::File
12
+ attr_reader :filename
13
+ attr_reader :revision
14
+
15
+ def initialize args
16
+ @filename = args[:filename]
17
+ @revision = args[:revision]
18
+ end
19
+ end
20
+
21
+ class Svnx::Diff::Header
22
+ attr_reader :filename
23
+ attr_reader :from
24
+ attr_reader :to
25
+
26
+ def initialize args
27
+ @filename = args[:filename]
28
+ @from = args[:from]
29
+ @to = args[:to]
30
+ end
31
+ end
32
+
33
+ class Svnx::Diff::HunkRange
34
+ attr_reader :line
35
+ attr_reader :length
36
+
37
+ def initialize line, length
38
+ @line = line
39
+ @length = length
40
+ end
41
+ end
42
+
43
+ class Svnx::Diff::HunkRanges
44
+ attr_reader :from
45
+ attr_reader :to
46
+
47
+ def initialize from, to
48
+ @from = from
49
+ @to = to
50
+ end
51
+ end
52
+
53
+ # unused; I prefer a two-element array: [ :added, "sometext" ]
54
+
55
+ class Svnx::Diff::Line
56
+ attr_reader :type
57
+ attr_reader :text
58
+
59
+ def initialize type, text
60
+ @type = type
61
+ @text = text
62
+ end
63
+ end
64
+
65
+ class Svnx::Diff::Hunk
66
+ attr_reader :ranges
67
+ attr_reader :lines
68
+
69
+ def initialize ranges, lines
70
+ @ranges = ranges
71
+ @lines = lines
72
+ end
73
+ end
74
+
75
+ # all diffs for one file
76
+ class SvnFileDiff
77
+ attr_reader :header
78
+ attr_reader :hunks
79
+
80
+ def initialize header, hunks = Array.new
81
+ @header = header
82
+ @hunks = hunks
83
+ end
84
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/options'
5
+
6
+ module Svnx
7
+ module Diff
8
+ end
9
+ end
10
+
11
+ class Svnx::Diff::Options < Svnx::Base::Options
12
+ attr_reader :commit
13
+ attr_reader :ignoreproperties
14
+ attr_reader :ignorewhitespace
15
+ attr_reader :paths
16
+ attr_reader :url
17
+
18
+ def initialize args = Hash.new
19
+ @commit = args[:commit]
20
+ @ignoreproperties = args[:ignoreproperties]
21
+ @ignorewhitespace = args[:ignorewhitespace]
22
+ @paths = args[:paths]
23
+ @url = args[:url]
24
+ end
25
+
26
+ def options_to_args
27
+ Array.new.tap do |optargs|
28
+ optargs << [ :commit, [ "-c", commit ] ]
29
+ optargs << [ :ignoreproperties, "--ignore-properties" ]
30
+ optargs << [ :ignorewhitespace, [ "-x", "-bw" ] ]
31
+ optargs << [ :url, url ]
32
+ optargs << [ :paths, paths ]
33
+ end
34
+ end
35
+ end