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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a992a704932883d96a27188971922a847807eb1
|
4
|
+
data.tar.gz: 9a6f8f859120f59241006a8957a74d2977253d0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3052dbdc201d00d88abb2ed4e239b5479a1f713642362eab1ae0294c79657f5a843bca6640c3a57e0c9b2646b635899b76e509832e14c82e15713b967d40d4f0
|
7
|
+
data.tar.gz: 208eb47bd7e0e1379a773b53aaf577ceeae16376eec4093f3fe4898ef1781d2154abef54fed00672b9190360f1402eeaa0b2609edc9c05ba7410237ee69fd388
|
data/.gitignore
ADDED
data/.glarkrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
skip-path: pkg
|
data/Features.txt
ADDED
data/Gemfile
ADDED
data/History.txt
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Jeffrey E. Pace
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
File without changes
|
data/README.md
ADDED
data/Rakefile
ADDED
data/lib/svnx/base/action.rb
CHANGED
@@ -2,68 +2,73 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'logue/loggable'
|
5
|
+
require 'singleton'
|
5
6
|
|
6
|
-
module
|
7
|
-
|
8
|
-
include Logue::Loggable, Comparable
|
9
|
-
|
10
|
-
attr_reader :type
|
11
|
-
attr_reader :char
|
7
|
+
module Svnx
|
8
|
+
end
|
12
9
|
|
13
|
-
|
14
|
-
|
10
|
+
class Svnx::ActionStatus
|
11
|
+
include Singleton
|
15
12
|
|
16
|
-
|
17
|
-
@type = type
|
18
|
-
@char = char
|
19
|
-
end
|
13
|
+
attr_reader :stati
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def new arg, char = nil
|
25
|
-
if arg.kind_of? Action
|
26
|
-
arg
|
27
|
-
elsif act = STATUS_TO_ACTION[arg]
|
28
|
-
act
|
29
|
-
else
|
30
|
-
type = STATUS_TO_TYPE[arg]
|
31
|
-
raise "no such action: #{arg.inspect}" unless type
|
32
|
-
STATUS_TO_ACTION[arg] = orig_new type, char
|
33
|
-
end
|
34
|
-
end
|
15
|
+
def initialize
|
16
|
+
@status_to_symbol = Hash.new
|
17
|
+
@stati = Array.new
|
35
18
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
19
|
+
add_type 'added', 'A'
|
20
|
+
add_type 'deleted', 'D'
|
21
|
+
add_type 'modified', 'M'
|
22
|
+
add_type 'replaced', 'R'
|
23
|
+
add_type 'unversioned', '?'
|
24
|
+
add_type 'external', 'X'
|
25
|
+
add_type 'normal', 'q' # actually, X, but in a different column than X for external
|
26
|
+
end
|
46
27
|
|
47
|
-
|
48
|
-
|
28
|
+
def symbol_for arg
|
29
|
+
@status_to_symbol[arg]
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_type str, char
|
33
|
+
sym = str.to_sym
|
34
|
+
@stati << str
|
35
|
+
[ sym, str, char ].each do |key|
|
36
|
+
@status_to_symbol[key] = sym
|
49
37
|
end
|
38
|
+
end
|
39
|
+
end
|
50
40
|
|
51
|
-
|
52
|
-
|
41
|
+
class Svnx::Action
|
42
|
+
include Logue::Loggable, Comparable
|
43
|
+
|
44
|
+
attr_reader :type
|
45
|
+
|
46
|
+
def initialize type, char = nil
|
47
|
+
sas = Svnx::ActionStatus.instance
|
48
|
+
unless @type = sas.symbol_for(type)
|
49
|
+
raise "not a valid action type: #{type}"
|
53
50
|
end
|
51
|
+
end
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
add_type 'unversioned', '?'
|
53
|
+
def <=> other
|
54
|
+
@type <=> other.type
|
55
|
+
end
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
define_method methname do
|
63
|
-
instance_eval do
|
64
|
-
@type == STATUS_TO_TYPE[val]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
57
|
+
def to_s
|
58
|
+
@type.to_s
|
68
59
|
end
|
60
|
+
|
61
|
+
sas = Svnx::ActionStatus.instance
|
62
|
+
sas.stati.each do |str|
|
63
|
+
action = Svnx::Action.new str
|
64
|
+
Svnx::Action.const_set str.upcase, action
|
65
|
+
|
66
|
+
methname = str + '?'
|
67
|
+
define_method methname do
|
68
|
+
instance_eval do
|
69
|
+
sym = Svnx::ActionStatus.instance.symbol_for str
|
70
|
+
@type.to_sym == sym
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
69
74
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'logue/loggable'
|
5
|
+
require 'system/command/line'
|
6
|
+
require 'system/command/caching'
|
7
|
+
require 'svnx/base/env'
|
8
|
+
|
9
|
+
module Svnx
|
10
|
+
module Base
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Svnx::Base::CachingCommandLine < System::CachingCommandLine
|
15
|
+
def caching?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def cache_dir
|
20
|
+
Svnx::Env.instance.cache_dir
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Svnx::Base::CommandLine
|
25
|
+
include Logue::Loggable
|
26
|
+
|
27
|
+
attr_reader :output
|
28
|
+
attr_reader :error
|
29
|
+
attr_reader :status
|
30
|
+
|
31
|
+
def initialize subcommand: nil, xml: true, caching: false, args: Array.new
|
32
|
+
@subcommand = subcommand
|
33
|
+
@xml = xml
|
34
|
+
@caching = caching
|
35
|
+
@args = args
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute
|
39
|
+
cmdargs = [ 'svn', @subcommand ]
|
40
|
+
cmdargs << '--xml' if @xml
|
41
|
+
cmdargs.concat @args
|
42
|
+
debug "cmdargs: #{cmdargs}"
|
43
|
+
|
44
|
+
cmdline = if @caching
|
45
|
+
Svnx::Base::CachingCommandLine.new cmdargs
|
46
|
+
else
|
47
|
+
System::CommandLine.new cmdargs
|
48
|
+
end
|
49
|
+
cmdline.execute
|
50
|
+
debug "cmdline: #{cmdline}"
|
51
|
+
|
52
|
+
@output = cmdline.output
|
53
|
+
@error = cmdline.error
|
54
|
+
@status = cmdline.status
|
55
|
+
|
56
|
+
@output
|
57
|
+
end
|
58
|
+
end
|
data/lib/svnx/base/command.rb
CHANGED
@@ -1,61 +1,69 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'system/command/line'
|
5
4
|
require 'logue/loggable'
|
6
5
|
require 'system/command/caching'
|
7
|
-
require 'svnx/base/
|
6
|
+
require 'svnx/base/cmdline'
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def initialize subcmd, args
|
19
|
-
cmdargs = [ 'svn', subcmd ]
|
20
|
-
cmdargs << '--xml' if uses_xml?
|
21
|
-
cmdargs.concat args
|
22
|
-
super cmdargs
|
8
|
+
class Svnx::Base::Command
|
9
|
+
include Logue::Loggable
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def caching
|
13
|
+
define_method :caching? do
|
14
|
+
true
|
15
|
+
end
|
23
16
|
end
|
24
17
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def cache_dir
|
30
|
-
ENV[TMP_DIR_ENV_VARNAME] || DEFAULT_CACHE_DIR
|
18
|
+
def noncaching
|
19
|
+
define_method :caching? do
|
20
|
+
false
|
21
|
+
end
|
31
22
|
end
|
32
23
|
end
|
33
24
|
|
34
|
-
|
35
|
-
|
25
|
+
attr_reader :output
|
26
|
+
attr_reader :error
|
27
|
+
attr_reader :status
|
28
|
+
|
29
|
+
def initialize options, cls: Svnx::Base::CommandLine, exec: nil, xml: false, caching: caching?
|
30
|
+
melements = module_elements
|
31
|
+
modl = find_module melements
|
32
|
+
opts = modl::Options.new options
|
33
|
+
cmdargs = opts.to_args
|
34
|
+
subcommand = melements[-1].downcase
|
35
|
+
|
36
|
+
@cmdline = exec || cls.new(subcommand: subcommand, xml: xml, caching: caching, args: cmdargs)
|
37
|
+
|
38
|
+
@output = @cmdline.execute
|
39
|
+
@error = @cmdline.error
|
40
|
+
@status = @cmdline.status
|
36
41
|
end
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
def module_elements
|
44
|
+
mods = self.class.name.split "::"
|
45
|
+
mods[0 .. -2]
|
40
46
|
end
|
41
47
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
def initialize args
|
48
|
-
@args = args
|
49
|
-
end
|
48
|
+
def find_module elements = module_elements
|
49
|
+
mod = elements * "::"
|
50
|
+
Kernel.const_get mod
|
51
|
+
end
|
52
|
+
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
class Svnx::Base::EntriesCommand < Svnx::Base::Command
|
55
|
+
attr_reader :entries
|
56
|
+
|
57
|
+
def initialize options, cls: Svnx::Base::CommandLine, exec: nil, caching: caching?, xml: true, entries_class: nil
|
58
|
+
super options, cls: cls, exec: exec, xml: xml, caching: caching
|
54
59
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
if not @output.empty?
|
61
|
+
entries_class ||= begin
|
62
|
+
modl = find_module
|
63
|
+
modl::Entries
|
64
|
+
end
|
65
|
+
|
66
|
+
@entries = entries_class.new lines: @output
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
data/lib/svnx/base/entries.rb
CHANGED
@@ -4,65 +4,66 @@
|
|
4
4
|
require 'rexml/document'
|
5
5
|
require 'logue/loggable'
|
6
6
|
|
7
|
-
module
|
8
|
-
|
9
|
-
|
7
|
+
module Svnx
|
8
|
+
module Base
|
9
|
+
end
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
# this is a parse/process on-demand list of entries, acting like an
|
13
|
+
# Enumerable.
|
13
14
|
|
14
|
-
|
15
|
+
class Svnx::Base::Entries
|
16
|
+
include Logue::Loggable, Enumerable
|
15
17
|
|
16
|
-
|
17
|
-
# it's a hash, but indexed with integers, for non-sequential access:
|
18
|
-
@entries = Hash.new
|
18
|
+
attr_reader :size
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
20
|
+
def initialize xmllines: nil, lines: nil
|
21
|
+
# it's a hash, but indexed with integers, for non-sequential access:
|
22
|
+
@entries = Hash.new
|
24
23
|
|
25
|
-
|
24
|
+
lines ||= xmllines
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
elsif args[:xmlentries]
|
30
|
-
raise "argument xmlentries is no longer supported"
|
31
|
-
end
|
26
|
+
if lines.kind_of? Array
|
27
|
+
lines = lines.join ''
|
32
28
|
end
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
doc = REXML::Document.new lines
|
31
|
+
|
32
|
+
@elements = get_elements doc
|
33
|
+
@size = @elements.size
|
34
|
+
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
def get_elements doc
|
37
|
+
raise "get_elements must be implemented for: #{self.class}"
|
38
|
+
end
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
return entry
|
46
|
-
end
|
47
|
-
if idx < 0 && idx >= size
|
48
|
-
raise "error: index #{idx} is not in range(0 .. #{size})"
|
49
|
-
end
|
50
|
-
@entries[idx] = create_entry(@elements[idx + 1])
|
51
|
-
end
|
40
|
+
def create_entry xmlelement
|
41
|
+
raise "create_entry must be implemented for: #{self.class}"
|
42
|
+
end
|
52
43
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
44
|
+
# this doesn't handle negative indices
|
45
|
+
def [] idx
|
46
|
+
if entry = @entries[idx]
|
47
|
+
return entry
|
48
|
+
end
|
49
|
+
if idx < 0 || idx >= size
|
50
|
+
raise "error: index #{idx} is not in range(0 .. #{size})"
|
51
|
+
end
|
52
|
+
@entries[idx] = create_entry @elements[idx + 1]
|
53
|
+
end
|
61
54
|
|
62
|
-
|
55
|
+
def each(&blk)
|
56
|
+
# all elements must be processed before each can run:
|
57
|
+
if @elements
|
58
|
+
# a little confusing here: REXML does each_with_index with idx
|
59
|
+
# zero-based, but elements[0] is invalid.
|
60
|
+
@elements.each_with_index do |element, idx|
|
61
|
+
@entries[idx] ||= create_entry(element)
|
63
62
|
end
|
64
63
|
|
65
|
-
@
|
64
|
+
@elements = nil
|
66
65
|
end
|
66
|
+
|
67
|
+
@entries.keys.sort.collect { |idx| @entries[idx] }.each(&blk)
|
67
68
|
end
|
68
69
|
end
|