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
data/lib/svnx/info/command.rb
CHANGED
data/lib/svnx/info/entries.rb
CHANGED
@@ -4,12 +4,14 @@
|
|
4
4
|
require 'svnx/info/entry'
|
5
5
|
require 'svnx/base/entries'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
doc
|
10
|
-
|
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
|
-
|
13
|
-
|
13
|
+
def create_entry xmlelement
|
14
|
+
Entry.new :xmlelement => xmlelement
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/svnx/info/entry.rb
CHANGED
@@ -8,25 +8,31 @@ module Svnx
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
data/lib/svnx/info/options.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
data/lib/svnx/io/directory.rb
CHANGED
data/lib/svnx/io/element.rb
CHANGED
@@ -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
|
-
|
20
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
23
|
+
attr_reader :svn
|
24
|
+
attr_reader :path
|
25
|
+
attr_reader :local
|
36
26
|
|
37
|
-
|
38
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def exist?
|
42
|
+
@local && @local.exist?
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
def directory?
|
46
|
+
@local && @local.directory?
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def file?
|
50
|
+
@local && @local.file?
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
82
|
-
|
82
|
+
def find_in_log revision, action
|
83
|
+
svninfo = get_info
|
83
84
|
|
84
|
-
|
85
|
-
|
85
|
+
filter = svninfo.url.dup
|
86
|
+
filter.slice! svninfo.root
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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
|
-
|
97
|
-
|
98
|
-
|
97
|
+
def find_by_status status
|
98
|
+
statexec = Svnx::StatusExec.new path: @local, use_cache: false
|
99
|
+
entries = statexec.entries
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
entries.select do |entry|
|
102
|
+
status.nil? || entry.status.to_s == status.to_s
|
103
|
+
end.sort
|
104
|
+
end
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
119
|
+
def to_s
|
120
|
+
"svn => " + @svn.to_s + "; local => " + @local.to_s
|
121
|
+
end
|
121
122
|
|
122
|
-
|
123
|
-
|
123
|
+
def <=> other
|
124
|
+
@local <=> other.local
|
125
|
+
end
|
124
126
|
end
|
125
127
|
end
|
data/lib/svnx/log/command.rb
CHANGED
data/lib/svnx/log/entries.rb
CHANGED
@@ -9,20 +9,22 @@ module Svnx
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
doc
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def create_entry xmlelement
|
19
|
+
Entry.new xmlelement: xmlelement
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
data/lib/svnx/log/entry.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
36
|
+
def message
|
37
|
+
@msg
|
38
|
+
end
|
61
39
|
|
62
|
-
|
63
|
-
|
64
|
-
|
40
|
+
def to_s
|
41
|
+
[ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
|
42
|
+
end
|
65
43
|
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
50
|
+
def datetime
|
51
|
+
@dt ||= DateTime.parse date
|
52
|
+
end
|
75
53
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|