svnx 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'svnx/util/objutil'
5
4
  require 'svnx/base/options'
6
5
 
7
6
  module Svnx
@@ -9,20 +8,18 @@ module Svnx
9
8
  end
10
9
  end
11
10
 
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
11
+ module Svnx::Cat
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :revision, :path, :url ]
14
+
15
+ has_fields FIELDS
20
16
 
21
- def options_to_args
22
- Array.new.tap do |optargs|
23
- optargs << [ :revision, [ "-r", revision ] ]
24
- optargs << [ :url, url ]
25
- optargs << [ :path, path ]
17
+ def options_to_args
18
+ Array.new.tap do |a|
19
+ a << [ :revision, [ "-r", revision ] ]
20
+ a << [ :url, url ]
21
+ a << [ :path, path ]
22
+ end
26
23
  end
27
24
  end
28
25
  end
@@ -4,6 +4,8 @@
4
4
  require 'svnx/commit/options'
5
5
  require 'svnx/base/command'
6
6
 
7
- class Svnx::Commit::Command < Svnx::Base::Command
8
- noncaching
7
+ module Svnx::Commit
8
+ class Command < Svnx::Base::Command
9
+ noncaching
10
+ end
9
11
  end
@@ -8,22 +8,17 @@ module Svnx
8
8
  end
9
9
  end
10
10
 
11
- class Svnx::Commit::Options < Svnx::Base::Options
12
- include Svnx::ObjectUtil
11
+ module Svnx::Commit
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :file, :paths ]
13
14
 
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
15
+ has_fields FIELDS
21
16
 
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
17
+ def options_to_args
18
+ Array.new.tap do |a|
19
+ a << [ :file, [ "-F", file ] ]
20
+ a << [ :paths, paths ]
21
+ end
22
+ end
23
+ end
29
24
  end
@@ -5,13 +5,15 @@ require 'svnx/diff/options'
5
5
  require 'svnx/base/command'
6
6
  require 'svnx/diff/parser'
7
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
8
+ module Svnx::Diff
9
+ class Command < Svnx::Base::Command
10
+ attr_reader :entries
11
+
12
+ def initialize cmdopts, cls: Svnx::Base::CommandLine
13
+ super cmdopts, cls: cls, xml: false, caching: true
14
+ if @output
15
+ @entries = Svnx::Diff::Parser.new.parse_all_output @output.dup
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -8,77 +8,79 @@ module Svnx
8
8
  end
9
9
  end
10
10
 
11
- class Svnx::Diff::File
12
- attr_reader :filename
13
- attr_reader :revision
11
+ module Svnx::Diff
12
+ class File
13
+ attr_reader :filename
14
+ attr_reader :revision
14
15
 
15
- def initialize args
16
- @filename = args[:filename]
17
- @revision = args[:revision]
16
+ def initialize args
17
+ @filename = args[:filename]
18
+ @revision = args[:revision]
19
+ end
18
20
  end
19
- end
20
21
 
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]
22
+ class Header
23
+ attr_reader :filename
24
+ attr_reader :from
25
+ attr_reader :to
26
+
27
+ def initialize args
28
+ @filename = args[:filename]
29
+ @from = args[:from]
30
+ @to = args[:to]
31
+ end
30
32
  end
31
- end
32
33
 
33
- class Svnx::Diff::HunkRange
34
- attr_reader :line
35
- attr_reader :length
34
+ class HunkRange
35
+ attr_reader :line
36
+ attr_reader :length
36
37
 
37
- def initialize line, length
38
- @line = line
39
- @length = length
38
+ def initialize line, length
39
+ @line = line
40
+ @length = length
41
+ end
40
42
  end
41
- end
42
43
 
43
- class Svnx::Diff::HunkRanges
44
- attr_reader :from
45
- attr_reader :to
44
+ class HunkRanges
45
+ attr_reader :from
46
+ attr_reader :to
46
47
 
47
- def initialize from, to
48
- @from = from
49
- @to = to
48
+ def initialize from, to
49
+ @from = from
50
+ @to = to
51
+ end
50
52
  end
51
- end
52
53
 
53
- # unused; I prefer a two-element array: [ :added, "sometext" ]
54
+ # unused; I prefer a two-element array: [ :added, "sometext" ]
54
55
 
55
- class Svnx::Diff::Line
56
- attr_reader :type
57
- attr_reader :text
56
+ class Line
57
+ attr_reader :type
58
+ attr_reader :text
58
59
 
59
- def initialize type, text
60
- @type = type
61
- @text = text
60
+ def initialize type, text
61
+ @type = type
62
+ @text = text
63
+ end
62
64
  end
63
- end
64
65
 
65
- class Svnx::Diff::Hunk
66
- attr_reader :ranges
67
- attr_reader :lines
66
+ class Hunk
67
+ attr_reader :ranges
68
+ attr_reader :lines
68
69
 
69
- def initialize ranges, lines
70
- @ranges = ranges
71
- @lines = lines
70
+ def initialize ranges, lines
71
+ @ranges = ranges
72
+ @lines = lines
73
+ end
72
74
  end
73
- end
74
75
 
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
76
+ # all diffs for one file
77
+ class SvnFileDiff
78
+ attr_reader :header
79
+ attr_reader :hunks
80
+
81
+ def initialize header, hunks = Array.new
82
+ @header = header
83
+ @hunks = hunks
84
+ end
83
85
  end
84
86
  end
@@ -8,28 +8,21 @@ module Svnx
8
8
  end
9
9
  end
10
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
11
+ module Svnx::Diff
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :commit, :ignoreproperties, :ignorewhitespace, :paths, :url, :depth ]
14
+
15
+ has_fields FIELDS
25
16
 
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 ]
17
+ def options_to_args
18
+ Array.new.tap do |a|
19
+ a << [ :commit, [ "-c", commit ] ]
20
+ a << [ :ignoreproperties, "--ignore-properties" ]
21
+ a << [ :depth, [ "--depth", depth ] ]
22
+ a << [ :ignorewhitespace, [ "-x", "-bw" ] ]
23
+ a << [ :url, url ]
24
+ a << [ :paths, paths ]
25
+ end
33
26
  end
34
27
  end
35
28
  end
@@ -4,100 +4,102 @@
4
4
  require 'logue/loggable'
5
5
  require 'svnx/diff/elements'
6
6
 
7
- class Svnx::Diff::Parser
8
- include Logue::Loggable
7
+ module Svnx::Diff
8
+ class Parser
9
+ include Logue::Loggable
9
10
 
10
- def parse_header_file lines
11
- re = Regexp.new '^[\-\+]{3} (.*)\t\((?:nonexistent|revision (\d+))\)'
12
- if md = re.match(lines.first)
13
- lines.shift
14
- Svnx::Diff::File.new filename: md[1], revision: md[2] && md[2].to_i
11
+ def parse_header_file lines
12
+ re = Regexp.new '^[\-\+]{3} (.*)\t\((?:nonexistent|working copy|revision (\d+))\)'
13
+ if md = re.match(lines.first)
14
+ lines.shift
15
+ File.new filename: md[1], revision: md[2] && md[2].to_i
16
+ end
15
17
  end
16
- end
17
-
18
- def parse_header_section lines
19
- re = Regexp.new '^Index: (.*)'
20
- if md = re.match(lines.first)
21
- filename = md[1]
22
- lines.shift
23
-
24
- # discard the ==== line:
25
- lines.shift
18
+
19
+ def parse_header_section lines
20
+ re = Regexp.new '^Index: (.*)'
21
+ if md = re.match(lines.first)
22
+ filename = md[1]
23
+ lines.shift
24
+
25
+ # discard the ==== line:
26
+ lines.shift
26
27
 
27
- from = parse_header_file lines
28
- to = parse_header_file lines
29
-
30
- Svnx::Diff::Header.new filename: filename, from: from, to: to
28
+ from = parse_header_file lines
29
+ to = parse_header_file lines
30
+
31
+ Header.new filename: filename, from: from, to: to
32
+ end
31
33
  end
32
- end
33
34
 
34
- def parse_ranges lines
35
- range_re = Regexp.new '@@ \-(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@'
36
- if md = range_re.match(lines.first)
37
- lines.shift
38
-
39
- from, to = [ 1, 3 ].collect do |idx|
40
- Svnx::Diff::HunkRange.new md[idx].to_i, (md[idx + 1] || 1).to_i
35
+ def parse_ranges lines
36
+ range_re = Regexp.new '@@ \-(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@'
37
+ if md = range_re.match(lines.first)
38
+ lines.shift
39
+
40
+ from, to = [ 1, 3 ].collect do |idx|
41
+ HunkRange.new md[idx].to_i, (md[idx + 1] || 1).to_i
42
+ end
43
+
44
+ HunkRanges.new from, to
41
45
  end
42
-
43
- Svnx::Diff::HunkRanges.new from, to
44
46
  end
45
- end
46
47
 
47
- def parse_hunk lines
48
- if ranges = parse_ranges(lines)
49
- Svnx::Diff::Hunk.new(ranges, Array.new).tap do |hunk|
50
- char_to_type = { ' ' => :context, '+' => :added, '-' => :deleted }
51
-
52
- while !lines.empty?
53
- if lines.first == "\"
54
- hunk.lines << [ :context, :no_newline ]
55
- lines.shift
56
- elsif type = char_to_type[lines.first[0]]
57
- hunk.lines << [ type, lines.shift[1 .. -1] ]
58
- else
59
- break
48
+ def parse_hunk lines
49
+ if ranges = parse_ranges(lines)
50
+ Hunk.new(ranges, Array.new).tap do |hunk|
51
+ char_to_type = { ' ' => :context, '+' => :added, '-' => :deleted }
52
+
53
+ while !lines.empty?
54
+ if lines.first == "\"
55
+ hunk.lines << [ :context, :no_newline ]
56
+ lines.shift
57
+ elsif type = char_to_type[lines.first[0]]
58
+ hunk.lines << [ type, lines.shift[1 .. -1] ]
59
+ else
60
+ break
61
+ end
60
62
  end
61
63
  end
62
64
  end
63
65
  end
64
- end
65
66
 
66
- def parse_hunks lines
67
- Array.new.tap do |hunks|
68
- while !lines.empty?
69
- if hunk = parse_hunk(lines)
70
- hunks << hunk
71
- else
72
- break
67
+ def parse_hunks lines
68
+ Array.new.tap do |hunks|
69
+ while !lines.empty?
70
+ if hunk = parse_hunk(lines)
71
+ hunks << hunk
72
+ else
73
+ break
74
+ end
73
75
  end
74
76
  end
75
77
  end
76
- end
77
78
 
78
- def parse_file_diff lines
79
- if header = parse_header_section(lines)
80
- SvnFileDiff.new(header).tap do |diff|
81
- if header.from && header.to
82
- while !lines.empty?
83
- if hunk = parse_hunk(lines)
84
- diff.hunks << hunk
85
- else
86
- break
79
+ def parse_file_diff lines
80
+ if header = parse_header_section(lines)
81
+ SvnFileDiff.new(header).tap do |diff|
82
+ if header.from && header.to
83
+ while !lines.empty?
84
+ if hunk = parse_hunk(lines)
85
+ diff.hunks << hunk
86
+ else
87
+ break
88
+ end
87
89
  end
88
90
  end
89
91
  end
90
92
  end
91
93
  end
92
- end
93
94
 
94
- def parse_all_output lines
95
- Array.new.tap do |diffs|
96
- until lines.empty?
97
- if filediff = parse_file_diff(lines)
98
- diffs << filediff
99
- else
100
- break
95
+ def parse_all_output lines
96
+ Array.new.tap do |diffs|
97
+ until lines.empty?
98
+ if filediff = parse_file_diff(lines)
99
+ diffs << filediff
100
+ else
101
+ break
102
+ end
101
103
  end
102
104
  end
103
105
  end