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
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'svnx/base/action'
5
+
6
+ module Svnx
7
+ module Log
8
+ end
9
+ end
10
+
11
+ module Svnx::Log
12
+ class EntryPath
13
+ include Comparable
14
+
15
+ attr_reader :kind, :action, :name
16
+
17
+ def initialize args = Hash.new
18
+ @kind = args[:kind]
19
+ @action = args[:action]
20
+ @name = args[:name]
21
+ end
22
+
23
+ def to_s
24
+ @name
25
+ end
26
+
27
+ def <=> other
28
+ name <=> other.name
29
+ end
30
+
31
+ def match? action, filter
32
+ @action.to_s == action.to_s && @name.start_with?(filter)
33
+ end
34
+ end
35
+ end
@@ -8,24 +8,20 @@ module Svnx
8
8
  end
9
9
  end
10
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 ]
11
+ module Svnx::Log
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :limit, :verbose, :revision, :url, :path ]
14
+
15
+ has_fields FIELDS
16
+
17
+ def options_to_args
18
+ Array.new.tap do |a|
19
+ a << [ :limit, [ "--limit", limit ] ]
20
+ a << [ :verbose, "-v" ]
21
+ a << [ :revision, "-r" + revision.to_s ]
22
+ a << [ :url, url ]
23
+ a << [ :path, path ]
24
+ end
29
25
  end
30
26
  end
31
27
  end
@@ -4,6 +4,8 @@
4
4
  require 'svnx/merge/options'
5
5
  require 'svnx/base/command'
6
6
 
7
- class Svnx::Merge::Command < Svnx::Base::Command
8
- noncaching
7
+ module Svnx::Merge
8
+ class Command < Svnx::Base::Command
9
+ noncaching
10
+ end
9
11
  end
@@ -8,27 +8,22 @@ module Svnx
8
8
  end
9
9
  end
10
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
11
+ module Svnx::Merge
12
+ class Options < Svnx::Base::Options
13
+ # FIELDS = [ :commit, :range, :accept, :from, :path, :url ]
14
+ FIELDS = [ :commit, :range, :accept, :from, :to ]
15
+
16
+ has_fields FIELDS
22
17
 
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
18
+ def options_to_args
19
+ # an array, not a hash, because "from" should be in the exec args before "url"/"path"
20
+ Array.new.tap do |a|
21
+ a << [ :commit, [ "-c", commit ] ]
22
+ a << [ :range, [ "-r", range ] ]
23
+ a << [ :accept, [ "--accept", accept ] ]
24
+ a << [ :from, from ]
25
+ a << [ :to, to ]
26
+ end
27
+ end
28
+ end
34
29
  end
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
+ require 'logue/loggable'
5
+
4
6
  module Svnx
5
7
  end
6
8
 
@@ -8,12 +10,17 @@ end
8
10
  # entries (svnx/<command>/entry) or output. Enhances the low level functionality.
9
11
 
10
12
  class Svnx::Project
13
+ include Logue::Loggable
14
+
11
15
  attr_reader :dir
12
16
 
13
- def initialize dir: nil, url: nil, exec: nil
17
+ def initialize dir: nil, url: nil, cls: nil
14
18
  @dir = dir
15
19
  @url = url
16
- @exec = exec
20
+ @cls = cls
21
+ debug "dir: #{dir}"
22
+ debug "url: #{url}"
23
+ debug "cls: #{cls}"
17
24
  end
18
25
 
19
26
  def where
@@ -31,40 +38,45 @@ class Svnx::Project
31
38
  info.path
32
39
  end
33
40
 
34
- def run_command cmdcls, cmdargs, args, exec: nil
35
- cmdargs = cmdargs.merge args
36
- cmd = cmdcls.new cmdargs, exec: exec
41
+ def run_command cmdcls, cmdargs, args
42
+ cmd = cmdcls.new cmdargs, cls: @cls
37
43
  cmd.respond_to?(:entries) ? cmd.entries : cmd.output
38
44
  end
39
45
 
40
46
  def self.add_command_delegator name, takes_multiple_paths
41
47
  require "svnx/#{name}/command"
42
48
 
43
- pathargs = (takes_multiple_paths ? "{ paths: [ @dir ], url: @url }" : "{ path: @dir, url: @url }")
49
+ pathargs = takes_multiple_paths ? "paths: [ @dir ]" : "path: @dir"
50
+
51
+ unless NOURL.include? name
52
+ pathargs << ", url: @url"
53
+ end
44
54
 
45
55
  args = [
46
56
  "Svnx::#{name.to_s.capitalize}::Command",
47
- pathargs,
48
- "args",
49
- "exec: exec"
57
+ "{ " + pathargs + " }",
58
+ "**args"
50
59
  ]
51
-
60
+
52
61
  src = [
53
- "def #{name} exec: @exec, **args",
54
- " run_command " + args.join(", "),
62
+ "def #{name} cls: nil, **args",
63
+ " run_command " + args.join(", ") + ", cls: @cls",
55
64
  "end"
56
65
  ].join("\n")
66
+
57
67
  module_eval src
58
68
  end
59
69
 
70
+ NOURL = [ :diff, :update, :merge ]
71
+
60
72
  add_command_delegator :info, false
61
73
 
62
74
  add_command_delegator :update, true
63
- add_command_delegator :merge, true
64
- add_command_delegator :commit, true
65
75
 
76
+ add_command_delegator :commit, true
66
77
  add_command_delegator :log, false
67
- add_command_delegator :diff, false
78
+
79
+ add_command_delegator :diff, true
68
80
  add_command_delegator :propset, false
69
81
  add_command_delegator :propget, false
70
82
 
@@ -4,6 +4,8 @@
4
4
  require 'svnx/propget/options'
5
5
  require 'svnx/base/command'
6
6
 
7
- class Svnx::Propget::Command < Svnx::Base::EntriesCommand
8
- noncaching
7
+ module Svnx::Propget
8
+ class Command < Svnx::Base::EntriesCommand
9
+ noncaching
10
+ end
9
11
  end
@@ -4,12 +4,14 @@
4
4
  require 'svnx/propget/entry'
5
5
  require 'svnx/base/entries'
6
6
 
7
- class Svnx::Propget::Entries < Svnx::Base::Entries
8
- def get_elements doc
9
- doc.elements['properties'].elements
10
- end
7
+ module Svnx::Propget
8
+ class Entries < Svnx::Base::Entries
9
+ def get_elements doc
10
+ doc.elements['properties'].elements
11
+ end
11
12
 
12
- def create_entry xmlelement
13
- Svnx::Propget::Entry.new :xmlelement => xmlelement
13
+ def create_entry xmlelement
14
+ Entry.new :xmlelement => xmlelement
15
+ end
14
16
  end
15
17
  end
@@ -8,16 +8,18 @@ module Svnx
8
8
  end
9
9
  end
10
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
11
+ module Svnx::Propget
12
+ class Entry < Svnx::Base::Entry
13
+ attr_reader :path
14
+ attr_reader :name
15
+ attr_reader :value
16
+
17
+ def set_from_element elmt
18
+ set_attr_vars elmt, :path
18
19
 
19
- prop = elmt.elements["property"]
20
- set_attr_vars prop, :name
21
- @value = prop.text
20
+ prop = elmt.elements["property"]
21
+ set_attr_vars prop, :name
22
+ @value = prop.text
23
+ end
22
24
  end
23
25
  end
@@ -8,24 +8,20 @@ module Svnx
8
8
  end
9
9
  end
10
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
11
+ module Svnx::Propget
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :revision, :revprop, :name, :url, :path ]
14
+
15
+ has_fields FIELDS
21
16
 
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 ]
17
+ def options_to_args
18
+ Array.new.tap do |a|
19
+ a << [ :revision, [ "-r", revision ] ]
20
+ a << [ :revprop, "--revprop" ]
21
+ a << [ :name, name ]
22
+ a << [ :url, url ]
23
+ a << [ :path, path ]
24
+ end
29
25
  end
30
26
  end
31
27
  end
@@ -4,6 +4,8 @@
4
4
  require 'svnx/propset/options'
5
5
  require 'svnx/base/command'
6
6
 
7
- class Svnx::Propset::Command < Svnx::Base::Command
8
- noncaching
7
+ module Svnx::Propset
8
+ class Command < Svnx::Base::Command
9
+ noncaching
10
+ end
9
11
  end
@@ -8,26 +8,21 @@ module Svnx
8
8
  end
9
9
  end
10
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
11
+ module Svnx::Propset
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :file, :revision, :name, :value, :url, :path ]
14
+
15
+ has_fields FIELDS
22
16
 
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 ]
17
+ def options_to_args
18
+ Array.new.tap do |a|
19
+ a << [ :name, name ]
20
+ a << [ :revision, [ "--revprop", "-r", revision ] ]
21
+ a << [ :file, [ "--file", file ] ]
22
+ a << [ :value, value ]
23
+ a << [ :url, url ]
24
+ a << [ :path, path ]
25
+ end
31
26
  end
32
27
  end
33
28
  end
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- module Svnx; module Revision; end; end
4
+ module Svnx
5
+ module Revision
6
+ RELATIVE_REVISION_RE = Regexp.new '^([\+\-])(\d+)$'
7
+ end
8
+ end
5
9
 
6
- module Svnx::Revision
10
+ module Svnx::Revision
7
11
  class ArgumentFactory
8
12
  include Logue::Loggable
9
13
 
@@ -6,21 +6,24 @@ require 'svnx/revision/error'
6
6
  require 'logue/loggable'
7
7
  require 'svnx/revision/argfactory'
8
8
 
9
- module Svnx; module Revision; end; end
10
-
11
9
  # We represent what svn calls a revision (-r134:{2010-1-1}) as a Range,
12
10
  # consisting of a from and to (optional) Argument.
11
+
12
+ module Svnx
13
+ module Revision
14
+ end
15
+ end
16
+
13
17
  module Svnx::Revision
14
- RELATIVE_REVISION_RE = Regexp.new '^([\+\-])(\d+)$'
15
-
16
- # Returns the Nth revision from the given logging output.
17
-
18
- # -n means to count from the end of the list.
19
- # +n means to count from the beginning of the list.
20
- # n means the literal revision number.
21
18
  class Argument
22
19
  include Logue::Loggable, Comparable
23
20
 
21
+ # Returns the Nth revision from the given logging output.
22
+
23
+ # -n means to count from the end of the list.
24
+ # +n means to count from the beginning of the list.
25
+ # n means the literal revision number.
26
+
24
27
  # these are also valid revisions
25
28
  # :working_copy
26
29
  # :head
@@ -42,27 +45,27 @@ module Svnx::Revision
42
45
  end
43
46
 
44
47
  def <=> other
45
- if other.kind_of? Argument
46
- @value <=> other.value
47
- else
48
- @value <=> other
49
- end
48
+ @value <=> (other.kind_of?(Argument) ? other.value : other)
50
49
  end
51
50
  end
51
+ end
52
52
 
53
+ module Svnx::Revision
53
54
  class IndexArgument < Argument
54
55
  end
56
+ end
55
57
 
58
+ module Svnx::Revision
56
59
  class StringArgument < Argument
57
60
  end
61
+ end
58
62
 
59
- # this is of the form -3, which is revision[-3] (second one from the most
60
- # recent; -1 is the most recent).
63
+ # this is of the form -3, which is revision[-3] (second one from the most
64
+ # recent; -1 is the most recent).
65
+ module Svnx::Revision
61
66
  class RelativeArgument < IndexArgument
62
67
  def initialize value, args
63
- entries = args[:entries]
64
-
65
- unless entries
68
+ unless entries = args[:entries]
66
69
  raise RevisionError.new "cannot determine relative revision without entries"
67
70
  end
68
71