svnx 1.0.1 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.glarkrc +1 -0
- data/Features.txt +7 -0
- data/Gemfile +4 -0
- data/History.txt +4 -0
- data/LICENSE +20 -0
- data/Manifest.txt +0 -0
- data/README.md +12 -0
- data/Rakefile +12 -0
- data/lib/svnx/base/action.rb +57 -52
- data/lib/svnx/base/cmdline.rb +58 -0
- data/lib/svnx/base/command.rb +49 -41
- data/lib/svnx/base/entries.rb +46 -45
- data/lib/svnx/base/entry.rb +51 -38
- data/lib/svnx/base/env.rb +26 -0
- data/lib/svnx/base/options.rb +25 -0
- data/lib/svnx/cat/command.rb +3 -64
- data/lib/svnx/cat/options.rb +28 -0
- data/lib/svnx/commit/command.rb +9 -0
- data/lib/svnx/commit/options.rb +29 -0
- data/lib/svnx/diff/command.rb +17 -0
- data/lib/svnx/diff/elements.rb +84 -0
- data/lib/svnx/diff/options.rb +35 -0
- data/lib/svnx/diff/parser.rb +105 -0
- data/lib/svnx/info/command.rb +4 -47
- data/lib/svnx/info/entries.rb +6 -8
- data/lib/svnx/info/entry.rb +21 -23
- data/lib/svnx/info/options.rb +28 -0
- data/lib/svnx/io/directory.rb +9 -5
- data/lib/svnx/io/element.rb +93 -95
- data/lib/svnx/log/command.rb +7 -3
- data/lib/svnx/log/entries.rb +17 -14
- data/lib/svnx/log/entry.rb +61 -49
- data/lib/svnx/log/options.rb +31 -0
- data/lib/svnx/merge/command.rb +9 -0
- data/lib/svnx/merge/options.rb +34 -0
- data/lib/svnx/project.rb +74 -0
- data/lib/svnx/propget/command.rb +9 -0
- data/lib/svnx/propget/entries.rb +15 -0
- data/lib/svnx/propget/entry.rb +23 -0
- data/lib/svnx/propget/options.rb +31 -0
- data/lib/svnx/propset/command.rb +9 -0
- data/lib/svnx/propset/options.rb +33 -0
- data/lib/svnx/revision/argfactory.rb +2 -2
- data/lib/svnx/revision/argument.rb +7 -3
- data/lib/svnx/revision/date.rb +27 -0
- data/lib/svnx/revision/error.rb +2 -2
- data/lib/svnx/revision/range.rb +5 -2
- data/lib/svnx/status/command.rb +4 -42
- data/lib/svnx/status/entries.rb +11 -12
- data/lib/svnx/status/entry.rb +43 -41
- data/lib/svnx/status/options.rb +28 -0
- data/lib/svnx/update/command.rb +9 -0
- data/lib/svnx/update/options.rb +25 -0
- data/lib/svnx/util/dateutil.rb +35 -0
- data/lib/svnx/util/objutil.rb +14 -0
- data/lib/{svnx.rb → svnx/version.rb} +2 -2
- data/lib/system/command/arg.rb +6 -5
- data/lib/system/command/cachefile.rb +29 -21
- data/lib/system/command/caching.rb +12 -25
- data/lib/system/command/line.rb +41 -30
- data/svnx.gemspec +34 -0
- metadata +85 -61
- data/lib/svnx/base/args.rb +0 -24
- data/lib/svnx/log/args.rb +0 -57
- data/lib/svnx/log/exec.rb +0 -27
- data/lib/svnx/log/line.rb +0 -42
- data/test/integration/info/info_test.rb +0 -21
- data/test/integration/log/log_test.rb +0 -74
- data/test/integration/status/status_test.rb +0 -35
- data/test/integration/svnx/io/element_test.rb +0 -235
- data/test/unit/svnx/base/action_test.rb +0 -49
- data/test/unit/svnx/cat/command_test.rb +0 -55
- data/test/unit/svnx/info/entries_test.rb +0 -22
- data/test/unit/svnx/log/args_test.rb +0 -15
- data/test/unit/svnx/log/entries_test.rb +0 -87
- data/test/unit/svnx/log/entry_test.rb +0 -15
- data/test/unit/svnx/log/exec_test.rb +0 -15
- data/test/unit/svnx/log/line_test.rb +0 -14
- data/test/unit/svnx/revision/argfactory_test.rb +0 -50
- data/test/unit/svnx/revision/argument_test.rb +0 -167
- data/test/unit/svnx/revision/range_test.rb +0 -48
- data/test/unit/svnx/status/entries_test.rb +0 -20
- data/test/unit/system/command/cachefile_test.rb +0 -52
- data/test/unit/system/command/caching_test.rb +0 -92
- data/test/unit/system/command/line_test.rb +0 -63
data/lib/svnx/log/command.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'svnx/log/
|
5
|
-
require 'svnx/log/
|
6
|
-
require 'svnx/
|
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
|
data/lib/svnx/log/entries.rb
CHANGED
@@ -4,22 +4,25 @@
|
|
4
4
|
require 'svnx/base/entries'
|
5
5
|
require 'svnx/log/entry'
|
6
6
|
|
7
|
-
module
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
module Svnx
|
8
|
+
module Log
|
9
|
+
end
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
data/lib/svnx/log/entry.rb
CHANGED
@@ -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
|
8
|
+
module Svnx
|
9
|
+
module Log
|
10
|
+
end
|
11
|
+
end
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
14
|
-
|
24
|
+
def to_s
|
25
|
+
@name
|
26
|
+
end
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@paths = Array.new
|
28
|
+
def <=> other
|
29
|
+
name <=> other.name
|
30
|
+
end
|
21
31
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
def match? action, filter
|
33
|
+
@action.to_s == action.to_s && @name.start_with?(filter)
|
34
|
+
end
|
35
|
+
end
|
26
36
|
|
27
|
-
|
28
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@name = args[:name]
|
58
|
-
end
|
54
|
+
# Svn isn't consistent with the order of paths
|
55
|
+
@paths.sort!
|
56
|
+
end
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
def message
|
59
|
+
@msg
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
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
|
-
|
69
|
-
|
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,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
|
data/lib/svnx/project.rb
ADDED
@@ -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,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,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
|