svnx 2.0.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.zshrc +2 -0
- data/Rakefile +2 -3
- data/lib/cmdline/arg.rb +12 -0
- data/lib/cmdline/cachefile.rb +37 -0
- data/lib/cmdline/caching.rb +25 -0
- data/lib/cmdline/filename.rb +16 -0
- data/lib/cmdline/gzpathname.rb +26 -0
- data/lib/cmdline/line.rb +57 -0
- data/lib/svnx/base/action.rb +31 -61
- data/lib/svnx/base/action_status.rb +37 -0
- data/lib/svnx/base/cmd.rb +20 -0
- data/lib/svnx/base/cmdline.rb +43 -37
- data/lib/svnx/base/command.rb +57 -50
- data/lib/svnx/base/command_factory.rb +24 -0
- data/lib/svnx/base/entries.rb +42 -40
- data/lib/svnx/base/entry.rb +46 -44
- data/lib/svnx/base/env.rb +14 -15
- data/lib/svnx/base/options.rb +22 -10
- data/lib/svnx/cat/command.rb +4 -2
- data/lib/svnx/cat/options.rb +11 -14
- data/lib/svnx/commit/command.rb +4 -2
- data/lib/svnx/commit/options.rb +11 -16
- data/lib/svnx/diff/command.rb +9 -7
- data/lib/svnx/diff/elements.rb +56 -54
- data/lib/svnx/diff/options.rb +14 -21
- data/lib/svnx/diff/parser.rb +73 -71
- data/lib/svnx/info/command.rb +4 -2
- data/lib/svnx/info/entries.rb +8 -6
- data/lib/svnx/info/entry.rb +23 -17
- data/lib/svnx/info/options.rb +11 -14
- data/lib/svnx/io/directory.rb +3 -1
- data/lib/svnx/io/element.rb +88 -86
- data/lib/svnx/log/command.rb +4 -2
- data/lib/svnx/log/entries.rb +14 -12
- data/lib/svnx/log/entry.rb +36 -58
- data/lib/svnx/log/entrypath.rb +35 -0
- data/lib/svnx/log/options.rb +14 -18
- data/lib/svnx/merge/command.rb +4 -2
- data/lib/svnx/merge/options.rb +17 -22
- data/lib/svnx/project.rb +27 -15
- data/lib/svnx/propget/command.rb +4 -2
- data/lib/svnx/propget/entries.rb +8 -6
- data/lib/svnx/propget/entry.rb +12 -10
- data/lib/svnx/propget/options.rb +13 -17
- data/lib/svnx/propset/command.rb +4 -2
- data/lib/svnx/propset/options.rb +14 -19
- data/lib/svnx/revision/argfactory.rb +6 -2
- data/lib/svnx/revision/argument.rb +22 -19
- data/lib/svnx/revision/date.rb +16 -16
- data/lib/svnx/revision/error.rb +4 -1
- data/lib/svnx/revision/range.rb +2 -1
- data/lib/svnx/status/command.rb +4 -2
- data/lib/svnx/status/entries.rb +13 -11
- data/lib/svnx/status/entry.rb +37 -39
- data/lib/svnx/status/options.rb +12 -15
- data/lib/svnx/update/command.rb +4 -2
- data/lib/svnx/update/options.rb +11 -12
- data/lib/svnx/util/classutil.rb +19 -0
- data/lib/svnx/util/dateutil.rb +1 -0
- data/lib/svnx/util/objutil.rb +36 -6
- data/lib/svnx/version.rb +1 -1
- data/repackage +1 -0
- data/svnx.gemspec +6 -5
- metadata +29 -6
- data/lib/system/command/arg.rb +0 -13
- data/lib/system/command/cachefile.rb +0 -58
- data/lib/system/command/caching.rb +0 -23
- data/lib/system/command/line.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd37aad9c296bc3739eced16136fc73f1e8831ba
|
4
|
+
data.tar.gz: 2b829bf99dad72f3ec1bdc3a4913ff5a7e30879f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840ed6cfcd13332ffbcf8413adcc06fc9d18d7bf3d382f88e788297d776ca16f77b5650de4da706f9d8d63ee0bc5f3cb5ba7f64e44af0c2018febe41c964d64a
|
7
|
+
data.tar.gz: 637d08aa4258d2e044b01a8c9957a2d93f76eaed0755d5f605546b6dccc8436a167eef16a73f39b38ddf33828a66938ecc9ce22186773e272fe6b81f8e510756
|
data/.gitignore
CHANGED
data/.zshrc
ADDED
data/Rakefile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require 'rubygems/package_task'
|
4
3
|
|
5
4
|
task :default => :test
|
6
5
|
|
7
|
-
Rake::TestTask.new(
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
8
7
|
t.libs << 'test'
|
9
8
|
t.pattern = 'test/**/*_test.rb'
|
10
9
|
t.warning = true
|
data/lib/cmdline/arg.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'cmdline/line'
|
5
|
+
require 'cmdline/filename'
|
6
|
+
require 'cmdline/gzpathname'
|
7
|
+
|
8
|
+
# A file that has a pathname and output
|
9
|
+
module CmdLine
|
10
|
+
class CacheFile
|
11
|
+
attr_reader :output
|
12
|
+
attr_reader :pathname
|
13
|
+
|
14
|
+
def initialize cache_dir, args
|
15
|
+
@args = args
|
16
|
+
basename = FileName.new(args).name
|
17
|
+
fullname = Pathname(cache_dir) + basename
|
18
|
+
@pathname = GzipPathname.new fullname
|
19
|
+
@output = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def readlines
|
23
|
+
if @pathname.exist?
|
24
|
+
@output = @pathname.read_file
|
25
|
+
else
|
26
|
+
cl = CommandLine.new @args
|
27
|
+
@output = cl.execute
|
28
|
+
@pathname.save_file @output
|
29
|
+
@output
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
@pathname.to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'cmdline/line'
|
5
|
+
require 'cmdline/cachefile'
|
6
|
+
|
7
|
+
module CmdLine
|
8
|
+
class CachingCommandLine < CommandLine
|
9
|
+
# caches its input and values.
|
10
|
+
|
11
|
+
def cache_dir
|
12
|
+
@cache_dir ||= '/tmp' + Pathname.new($0).expand_path.to_s
|
13
|
+
@cache_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def cache_file
|
17
|
+
CacheFile.new cache_dir, @args
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
cachefile = cache_file
|
22
|
+
@output = cachefile.readlines
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'zlib'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
module CmdLine
|
8
|
+
# A pathname that reads and writes itself as gzipped
|
9
|
+
class GzipPathname < Pathname
|
10
|
+
def save_file content
|
11
|
+
parent.mkpath unless parent.exist?
|
12
|
+
unlink if exist?
|
13
|
+
Zlib::GzipWriter.open(to_s) do |gz|
|
14
|
+
gz.puts content
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def read_file
|
19
|
+
Array.new.tap do |content|
|
20
|
+
Zlib::GzipReader.open(to_s) do |gz|
|
21
|
+
content.concat gz.readlines
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/cmdline/line.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'logue/loggable'
|
5
|
+
require 'open3'
|
6
|
+
|
7
|
+
module CmdLine
|
8
|
+
class CommandLine
|
9
|
+
include Logue::Loggable
|
10
|
+
|
11
|
+
attr_reader :args
|
12
|
+
attr_reader :output
|
13
|
+
attr_reader :error
|
14
|
+
attr_reader :status
|
15
|
+
|
16
|
+
def initialize *args, debug: false
|
17
|
+
@args = args.dup
|
18
|
+
end
|
19
|
+
|
20
|
+
def << arg
|
21
|
+
@args << arg
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
cmd = to_command
|
26
|
+
debug "cmd: #{cmd}"
|
27
|
+
|
28
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wthr|
|
29
|
+
@output = stdout.readlines
|
30
|
+
@error = stderr.readlines
|
31
|
+
@status = wthr.value
|
32
|
+
end
|
33
|
+
|
34
|
+
if false && @output
|
35
|
+
puts "output"
|
36
|
+
@output.each_with_index do |line, idx|
|
37
|
+
debug "output[#{idx}]: #{line}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if false && @error
|
42
|
+
puts "error"
|
43
|
+
@error.each_with_index do |line, idx|
|
44
|
+
debug "error[#{idx}]: #{line}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
debug "@status: #{@status}"
|
49
|
+
|
50
|
+
@output
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_command
|
54
|
+
@args.join ' '
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/svnx/base/action.rb
CHANGED
@@ -3,72 +3,42 @@
|
|
3
3
|
|
4
4
|
require 'logue/loggable'
|
5
5
|
require 'singleton'
|
6
|
+
require 'svnx/base/action_status'
|
6
7
|
|
7
8
|
module Svnx
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
27
|
-
|
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
|
9
|
+
class Action
|
10
|
+
include Logue::Loggable
|
11
|
+
include Comparable
|
12
|
+
|
13
|
+
attr_reader :type
|
14
|
+
|
15
|
+
def initialize type
|
16
|
+
sas = ActionStatus.instance
|
17
|
+
unless @type = sas.symbol_for(type)
|
18
|
+
raise "not a valid action type: #{type}"
|
19
|
+
end
|
37
20
|
end
|
38
|
-
end
|
39
|
-
end
|
40
21
|
|
41
|
-
|
42
|
-
|
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}"
|
22
|
+
def <=> other
|
23
|
+
@type <=> other.type
|
50
24
|
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def <=> other
|
54
|
-
@type <=> other.type
|
55
|
-
end
|
56
25
|
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
26
|
+
def to_s
|
27
|
+
@type.to_s
|
28
|
+
end
|
65
29
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
30
|
+
sas = ActionStatus.instance
|
31
|
+
sas.stati.each do |str|
|
32
|
+
action = Action.new str
|
33
|
+
Action.const_set str.upcase, action
|
34
|
+
|
35
|
+
methname = str + '?'
|
36
|
+
define_method methname do
|
37
|
+
instance_eval do
|
38
|
+
sym = ActionStatus.instance.symbol_for str
|
39
|
+
@type.to_sym == sym
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
74
44
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module Svnx
|
7
|
+
class ActionStatus
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
attr_reader :stati
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@status_to_symbol = Hash.new
|
14
|
+
@stati = Array.new
|
15
|
+
|
16
|
+
add_type 'added', 'A'
|
17
|
+
add_type 'deleted', 'D'
|
18
|
+
add_type 'modified', 'M'
|
19
|
+
add_type 'replaced', 'R'
|
20
|
+
add_type 'unversioned', '?'
|
21
|
+
add_type 'external', 'X'
|
22
|
+
add_type 'normal', 'q' # actually, X, but in a different column than X for external
|
23
|
+
end
|
24
|
+
|
25
|
+
def symbol_for arg
|
26
|
+
@status_to_symbol[arg]
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_type str, char
|
30
|
+
sym = str.to_sym
|
31
|
+
@stati << str
|
32
|
+
[ sym, str, char ].each do |key|
|
33
|
+
@status_to_symbol[key] = sym
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rexml/document'
|
5
|
+
require 'logue/loggable'
|
6
|
+
|
7
|
+
module Svnx
|
8
|
+
class Cmd
|
9
|
+
include Logue::Loggable
|
10
|
+
|
11
|
+
def initialize xml
|
12
|
+
info "xml: #{xml}"
|
13
|
+
|
14
|
+
@doc = REXML::Document.new xml
|
15
|
+
info "@doc: #{@doc}"
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/lib/svnx/base/cmdline.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'logue/loggable'
|
5
|
-
require '
|
6
|
-
require '
|
5
|
+
require 'cmdline/line'
|
6
|
+
require 'cmdline/caching'
|
7
7
|
require 'svnx/base/env'
|
8
8
|
|
9
9
|
module Svnx
|
@@ -11,48 +11,54 @@ module Svnx
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
module Svnx::Base
|
15
|
+
class CachingCommandLine < CmdLine::CachingCommandLine
|
16
|
+
def caching?
|
17
|
+
true
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
def cache_dir
|
21
|
+
Svnx::Env.instance.cache_dir
|
22
|
+
end
|
21
23
|
end
|
22
|
-
end
|
23
24
|
|
24
|
-
class
|
25
|
-
|
25
|
+
class CommandLine
|
26
|
+
include Logue::Loggable
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
attr_reader :output
|
29
|
+
attr_reader :error
|
30
|
+
attr_reader :status
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
def initialize subcommand: nil, xml: true, caching: false, args: Array.new
|
33
|
+
debug "subcommand: #{subcommand}"
|
34
|
+
debug "args: #{args}"
|
35
|
+
@subcommand = subcommand
|
36
|
+
@xml = xml
|
37
|
+
@caching = caching
|
38
|
+
@args = args
|
39
|
+
debug "@args: #{@args}"
|
40
|
+
end
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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}"
|
42
|
+
def execute
|
43
|
+
cmdargs = [ 'svn', @subcommand ]
|
44
|
+
cmdargs << '--xml' if @xml
|
45
|
+
cmdargs.concat @args
|
46
|
+
debug "cmdargs: #{cmdargs}"
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
cmdline = command_line cmdargs
|
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
|
55
58
|
|
56
|
-
|
59
|
+
def command_line cmdargs
|
60
|
+
cls = @caching ? CachingCommandLine : CmdLine::CommandLine
|
61
|
+
cls.new cmdargs
|
62
|
+
end
|
57
63
|
end
|
58
64
|
end
|