svnx 2.0.6 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -5,6 +5,8 @@ require 'svnx/info/options'
5
5
  require 'svnx/info/entries'
6
6
  require 'svnx/base/command'
7
7
 
8
- class Svnx::Info::Command < Svnx::Base::EntriesCommand
9
- noncaching
8
+ module Svnx::Info
9
+ class Command < Svnx::Base::EntriesCommand
10
+ noncaching
11
+ end
10
12
  end
@@ -4,12 +4,14 @@
4
4
  require 'svnx/info/entry'
5
5
  require 'svnx/base/entries'
6
6
 
7
- class Svnx::Info::Entries < Svnx::Base::Entries
8
- def get_elements doc
9
- doc.elements['info'].elements
10
- end
7
+ module Svnx::Info
8
+ class Entries < Svnx::Base::Entries
9
+ def get_elements doc
10
+ doc.elements['info'].elements
11
+ end
11
12
 
12
- def create_entry xmlelement
13
- Svnx::Info::Entry.new :xmlelement => xmlelement
13
+ def create_entry xmlelement
14
+ Entry.new :xmlelement => xmlelement
15
+ end
14
16
  end
15
17
  end
@@ -8,25 +8,31 @@ module Svnx
8
8
  end
9
9
  end
10
10
 
11
- class Svnx::Info::Entry < Svnx::Base::Entry
12
- attr_reader :url
13
- attr_reader :root
14
- attr_reader :kind
15
- attr_reader :path
16
- attr_reader :revision
17
- attr_reader :wc_root
11
+ module Svnx::Info
12
+ class Entry < Svnx::Base::Entry
13
+ attr_reader :url
14
+ attr_reader :root
15
+ attr_reader :kind
16
+ attr_reader :path
17
+ attr_reader :revision
18
+ attr_reader :wc_root
19
+ attr_reader :relative_url
18
20
 
19
- def set_from_element elmt
20
- set_attr_vars elmt, 'kind', 'path', 'revision'
21
- set_elmt_var elmt, 'url'
22
-
23
- repo = elmt.elements['repository']
24
- set_elmt_var repo, 'root'
21
+ def set_from_element elmt
22
+ set_attr_vars elmt, 'kind', 'path', 'revision'
23
+ set_elmt_var elmt, 'url'
24
+ if relurl = elmt.elements['relative-url']
25
+ @relative_url = relurl.text
26
+ end
27
+
28
+ repo = elmt.elements['repository']
29
+ set_elmt_var repo, 'root'
25
30
 
26
- @wc_root = nil
27
- if wcinfo = elmt.elements['wc-info']
28
- if wcroot = wcinfo.elements['wcroot-abspath']
29
- @wc_root = wcroot.text
31
+ @wc_root = nil
32
+ if wcinfo = elmt.elements['wc-info']
33
+ if wcroot = wcinfo.elements['wcroot-abspath']
34
+ @wc_root = wcroot.text
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -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::Info::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::Info
12
+ class Options < Svnx::Base::Options
13
+ FIELDS = [ :revision, :url, :path ]
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
@@ -10,5 +10,7 @@ end
10
10
  # An element unites an svn element and a file/directory (at least one of
11
11
  # which should exist).
12
12
 
13
- class Svnx::IO::Directory < Element
13
+ module Svnx::IO
14
+ class Directory < Element
15
+ end
14
16
  end
@@ -16,110 +16,112 @@ end
16
16
  # An element unites an svn element and a file/directory (at least one of
17
17
  # which should exist).
18
18
 
19
- class Svnx::IO::Element
20
- include Logue::Loggable, Comparable
21
-
22
- attr_reader :svn
23
- attr_reader :path
24
- attr_reader :local
25
-
26
- def initialize args = Hash.new
27
- info "args: #{args.inspect}".color("438802")
28
-
29
- # svnurl = args[:svnurl]
30
- # fname = args[:filename] || args[:file] # legacy
31
- # $$$ todo: map svnurl to SVNElement, and fname to FSElement
19
+ module Svnx::IO
20
+ class Element
21
+ include Logue::Loggable, Comparable
32
22
 
33
- @svn = args[:svn] # || (args[:file] && SVNElement.new(:filename => args[:file]))
34
- @local = args[:local] && Pathname.new(args[:local]) # && PVN::FSElement.new(args[:local] || args[:file])
35
- @path = args[:path]
23
+ attr_reader :svn
24
+ attr_reader :path
25
+ attr_reader :local
36
26
 
37
- info "local: #{@local.inspect}"
38
- end
27
+ def initialize args = Hash.new
28
+ info "args: #{args.inspect}".color("438802")
29
+
30
+ # svnurl = args[:svnurl]
31
+ # fname = args[:filename] || args[:file] # legacy
32
+ # $$$ todo: map svnurl to SVNElement, and fname to FSElement
33
+
34
+ @svn = args[:svn] # || (args[:file] && SVNElement.new(:filename => args[:file]))
35
+ @local = args[:local] && Pathname.new(args[:local]) # && PVN::FSElement.new(args[:local] || args[:file])
36
+ @path = args[:path]
37
+
38
+ info "local: #{@local.inspect}"
39
+ end
39
40
 
40
- def exist?
41
- @local && @local.exist?
42
- end
41
+ def exist?
42
+ @local && @local.exist?
43
+ end
43
44
 
44
- def directory?
45
- @local && @local.directory?
46
- end
45
+ def directory?
46
+ @local && @local.directory?
47
+ end
47
48
 
48
- def file?
49
- @local && @local.file?
50
- end
49
+ def file?
50
+ @local && @local.file?
51
+ end
51
52
 
52
- def get_info revision = nil
53
- return nil unless in_svn?
54
-
55
- usepath = @local ? @local.to_path : @path
56
- inf = Svnx::Info::Command.new url: usepath, revision: revision
57
- inf.entry
58
- end
53
+ def get_info revision = nil
54
+ return nil unless in_svn?
55
+
56
+ usepath = @local ? @local.to_path : @path
57
+ inf = Svnx::Info::Command.new url: usepath, revision: revision
58
+ inf.entry
59
+ end
59
60
 
60
- def in_svn?
61
- # svn status can only be a local path:
62
- if @local
63
- st = Svnx::StatusExec.new path: @local.to_path
64
- st.entries.size == 0 || st.entries[0].status.to_s != 'unversioned'
65
- else
66
- raise "cannot determine svn status without a local path; only target '#{@path}' defined"
61
+ def in_svn?
62
+ # svn status can only be a local path:
63
+ if @local
64
+ st = Svnx::StatusExec.new path: @local.to_path
65
+ st.entries.size == 0 || st.entries[0].status.to_s != 'unversioned'
66
+ else
67
+ raise "cannot determine svn status without a local path; only target '#{@path}' defined"
68
+ end
67
69
  end
68
- end
69
70
 
70
- def find_entries args = Hash.new
71
- revision = args[:revision]
72
- status = args[:status]
73
-
74
- if revision.nil?
75
- find_by_status status
76
- else
77
- find_in_log revision, status
71
+ def find_entries args = Hash.new
72
+ revision = args[:revision]
73
+ status = args[:status]
74
+
75
+ if revision.nil?
76
+ find_by_status status
77
+ else
78
+ find_in_log revision, status
79
+ end
78
80
  end
79
- end
80
81
 
81
- def find_in_log revision, action
82
- svninfo = get_info
82
+ def find_in_log revision, action
83
+ svninfo = get_info
83
84
 
84
- filter = svninfo.url.dup
85
- filter.slice! svninfo.root
85
+ filter = svninfo.url.dup
86
+ filter.slice! svninfo.root
86
87
 
87
- # we can't cache this, because we don't know if there has been an svn
88
- # update since the previous run:
89
- logexec = Svnx::LogExec.new path: @local, revision: revision, verbose: true, use_cache: false
90
- entries = logexec.entries
91
-
92
- act = action.kind_of?(Svnx::Action) ? action : Svnx::Action.new(action)
93
- entries.match act, filter
94
- end
88
+ # we can't cache this, because we don't know if there has been an svn
89
+ # update since the previous run:
90
+ logexec = Svnx::LogExec.new path: @local, revision: revision, verbose: true, use_cache: false
91
+ entries = logexec.entries
92
+
93
+ act = action.kind_of?(Svnx::Action) ? action : Svnx::Action.new(action)
94
+ entries.match act, filter
95
+ end
95
96
 
96
- def find_by_status status
97
- statexec = Svnx::StatusExec.new path: @local, use_cache: false
98
- entries = statexec.entries
97
+ def find_by_status status
98
+ statexec = Svnx::StatusExec.new path: @local, use_cache: false
99
+ entries = statexec.entries
99
100
 
100
- entries.select do |entry|
101
- status.nil? || entry.status.to_s == status.to_s
102
- end.sort
103
- end
101
+ entries.select do |entry|
102
+ status.nil? || entry.status.to_s == status.to_s
103
+ end.sort
104
+ end
104
105
 
105
- def log_entries args = Hash.new
106
- rev = args[:revision]
107
- # use_cache should be conditional on revision:
108
- logexec = Svnx::LogExec.new :path => @local, :revision => rev && rev.to_s, :verbose => true, :use_cache => false
109
- logexec.entries
110
- end
106
+ def log_entries args = Hash.new
107
+ rev = args[:revision]
108
+ # use_cache should be conditional on revision:
109
+ logexec = Svnx::LogExec.new :path => @local, :revision => rev && rev.to_s, :verbose => true, :use_cache => false
110
+ logexec.entries
111
+ end
111
112
 
112
- def cat args = Hash.new
113
- rev = args[:revision]
114
- catexec = Svnx::CatExec.new :path => @local, :revision => rev && rev.to_s, :use_cache => false
115
- catexec.output
116
- end
113
+ def cat args = Hash.new
114
+ rev = args[:revision]
115
+ catexec = Svnx::CatExec.new :path => @local, :revision => rev && rev.to_s, :use_cache => false
116
+ catexec.output
117
+ end
117
118
 
118
- def to_s
119
- "svn => " + @svn.to_s + "; local => " + @local.to_s
120
- end
119
+ def to_s
120
+ "svn => " + @svn.to_s + "; local => " + @local.to_s
121
+ end
121
122
 
122
- def <=> other
123
- @local <=> other.local
123
+ def <=> other
124
+ @local <=> other.local
125
+ end
124
126
  end
125
127
  end
@@ -5,6 +5,8 @@ require 'svnx/log/options'
5
5
  require 'svnx/log/entries'
6
6
  require 'svnx/base/command'
7
7
 
8
- class Svnx::Log::Command < Svnx::Base::EntriesCommand
9
- noncaching
8
+ module Svnx::Log
9
+ class Command < Svnx::Base::EntriesCommand
10
+ noncaching
11
+ end
10
12
  end
@@ -9,20 +9,22 @@ module Svnx
9
9
  end
10
10
  end
11
11
 
12
- class Svnx::Log::Entries < Svnx::Base::Entries
13
- def get_elements doc
14
- doc.elements['log'].elements
15
- end
12
+ module Svnx::Log
13
+ class Entries < Svnx::Base::Entries
14
+ def get_elements doc
15
+ doc.elements['log'].elements
16
+ end
16
17
 
17
- def create_entry xmlelement
18
- Svnx::Log::Entry.new xmlelement: xmlelement
19
- end
18
+ def create_entry xmlelement
19
+ Entry.new xmlelement: xmlelement
20
+ end
20
21
 
21
- def match action, filter
22
- matching = Array.new
23
- each do |entry|
24
- matching.concat entry.match(action, filter)
22
+ def match action, filter
23
+ matching = Array.new
24
+ each do |entry|
25
+ matching.concat entry.match(action, filter)
26
+ end
27
+ matching.sort
25
28
  end
26
- matching.sort
27
29
  end
28
30
  end
@@ -4,81 +4,59 @@
4
4
  require 'svnx/base/entry'
5
5
  require 'svnx/base/action'
6
6
  require 'time'
7
+ require 'svnx/log/entrypath'
7
8
 
8
9
  module Svnx
9
10
  module Log
10
11
  end
11
12
  end
12
13
 
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
23
-
24
- def to_s
25
- @name
26
- end
27
-
28
- def <=> other
29
- name <=> other.name
30
- end
14
+ module Svnx::Log
15
+ class Entry < Svnx::Base::Entry
16
+ attr_reader :revision, :author, :date, :paths, :msg
31
17
 
32
- def match? action, filter
33
- @action.to_s == action.to_s && @name.start_with?(filter)
34
- end
35
- end
36
-
37
- class Svnx::Log::Entry < Svnx::Base::Entry
38
- attr_reader :revision, :author, :date, :paths, :msg
18
+ def set_from_element elmt
19
+ set_attr_var elmt, 'revision'
20
+ set_elmt_vars elmt, 'author', 'date', 'msg'
21
+
22
+ @paths = Array.new
39
23
 
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
24
+ elmt.elements.each('paths/path') do |pe|
25
+ kind = attribute_value pe, 'kind'
26
+ action = attribute_value pe, 'action'
27
+ name = pe.text
45
28
 
46
- elmt.elements.each('paths/path') do |pe|
47
- kind = attribute_value pe, 'kind'
48
- action = attribute_value pe, 'action'
49
- name = pe.text
50
-
51
- @paths << Svnx::Log::EntryPath.new(kind: kind, action: Svnx::Action.new(action), name: name)
29
+ @paths << EntryPath.new(kind: kind, action: Svnx::Action.new(action), name: name)
30
+ end
31
+
32
+ # Svn isn't consistent with the order of paths
33
+ @paths.sort!
52
34
  end
53
-
54
- # Svn isn't consistent with the order of paths
55
- @paths.sort!
56
- end
57
35
 
58
- def message
59
- @msg
60
- end
36
+ def message
37
+ @msg
38
+ end
61
39
 
62
- def to_s
63
- [ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
64
- end
40
+ def to_s
41
+ [ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
42
+ end
65
43
 
66
- def match action, filter
67
- paths.select do |path|
68
- path.match? action, filter
44
+ def match action, filter
45
+ paths.select do |path|
46
+ path.match? action, filter
47
+ end
69
48
  end
70
- end
71
49
 
72
- def datetime
73
- @dt ||= DateTime.parse date
74
- end
50
+ def datetime
51
+ @dt ||= DateTime.parse date
52
+ end
75
53
 
76
- def find_paths args
77
- paths.select do |path|
78
- if args[:kind]
79
- path.kind == args[:kind]
54
+ def find_paths args
55
+ paths.select do |path|
56
+ if args[:kind]
57
+ path.kind == args[:kind]
58
+ end
80
59
  end
81
60
  end
82
61
  end
83
62
  end
84
-