svnx 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/svnx.rb +2 -2
- data/lib/svnx/base/action.rb +39 -18
- data/lib/svnx/info/entry.rb +8 -0
- data/lib/svnx/io/directory.rb +10 -0
- data/lib/svnx/io/element.rb +123 -0
- data/lib/svnx/log/entries.rb +8 -0
- data/lib/svnx/log/entry.rb +22 -3
- data/lib/svnx/status/command.rb +16 -1
- data/lib/svnx/status/entries.rb +6 -1
- data/lib/svnx/status/entry.rb +13 -1
- data/test/integration/status/status_test.rb +1 -1
- data/test/integration/svnx/io/element_test.rb +225 -0
- data/test/unit/svnx/base/action_test.rb +13 -0
- data/test/unit/svnx/revision/range_test.rb +0 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf3407b885d82f3046303ab8ceb10ec94bc06d30
|
4
|
+
data.tar.gz: 2ae00cd95c6a21110d762a2fb1dd51b35febd2d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e60a7fd8ac963f7b992bc65cddf9fc8863e58c0c118a44406ee24854b933598d3ae90a6d629bb4649703d3ea7dbfc35120913166712ff33dafc31ea172aca1
|
7
|
+
data.tar.gz: 5ad12585bda46174f3313f065e44e9e5b904e8690668b623ee5d4cd0eca7e653c6fd0a24199d7248df424bfd16851d5b86fbff1f5b3dfcefcf2a3a3c2a897e99
|
data/lib/svnx.rb
CHANGED
data/lib/svnx/base/action.rb
CHANGED
@@ -10,37 +10,58 @@ module SVNx
|
|
10
10
|
attr_reader :type
|
11
11
|
|
12
12
|
STATUS_TO_TYPE = Hash.new
|
13
|
+
STATUS_TO_ACTION = Hash.new
|
13
14
|
|
14
|
-
def
|
15
|
-
|
16
|
-
STATUS_TO_TYPE[key] = sym
|
17
|
-
end
|
15
|
+
def initialize type
|
16
|
+
@type = type
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
class << self
|
20
|
+
alias_method :orig_new, :new
|
21
|
+
|
22
|
+
def new arg
|
23
|
+
if arg.kind_of? Action
|
24
|
+
arg
|
25
|
+
elsif act = STATUS_TO_ACTION[arg]
|
26
|
+
act
|
27
|
+
else
|
28
|
+
type = STATUS_TO_TYPE[arg]
|
29
|
+
raise "no such action: #{arg.inspect}" unless type
|
30
|
+
STATUS_TO_ACTION[arg] = orig_new type
|
31
|
+
end
|
32
|
+
end
|
24
33
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
def add_type str, char
|
35
|
+
sym = str.to_sym
|
36
|
+
STATUS_TO_TYPE[sym] = sym
|
37
|
+
action = SVNx::Action.new(sym)
|
38
|
+
SVNx::Action.const_set str.upcase, action
|
39
|
+
[ sym, str, char ].each do |key|
|
40
|
+
STATUS_TO_ACTION[key] = action
|
30
41
|
end
|
31
42
|
end
|
32
43
|
end
|
33
|
-
|
34
|
-
def initialize str
|
35
|
-
@type = STATUS_TO_TYPE[str]
|
36
|
-
end
|
37
44
|
|
38
45
|
def <=> other
|
39
|
-
@type
|
46
|
+
@type <=> other.type
|
40
47
|
end
|
41
48
|
|
42
49
|
def to_s
|
43
50
|
@type.to_s
|
44
51
|
end
|
52
|
+
|
53
|
+
add_type 'added', 'A'
|
54
|
+
add_type 'deleted', 'D'
|
55
|
+
add_type 'modified', 'M'
|
56
|
+
add_type 'unversioned', '?'
|
57
|
+
|
58
|
+
STATUS_TO_TYPE.values.uniq.each do |val|
|
59
|
+
methname = val.to_s + '?'
|
60
|
+
define_method methname do
|
61
|
+
instance_eval do
|
62
|
+
@type == STATUS_TO_TYPE[val]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
45
66
|
end
|
46
67
|
end
|
data/lib/svnx/info/entry.rb
CHANGED
@@ -12,6 +12,7 @@ module SVNx::Info
|
|
12
12
|
attr_reader :kind
|
13
13
|
attr_reader :path
|
14
14
|
attr_reader :revision
|
15
|
+
attr_reader :wc_root
|
15
16
|
|
16
17
|
def set_from_element elmt
|
17
18
|
set_attr_var elmt, 'kind'
|
@@ -22,6 +23,13 @@ module SVNx::Info
|
|
22
23
|
|
23
24
|
repo = elmt.elements['repository']
|
24
25
|
set_elmt_var repo, 'root'
|
26
|
+
|
27
|
+
@wc_root = nil
|
28
|
+
if wcinfo = elmt.elements['wc-info']
|
29
|
+
if wcroot = wcinfo.elements['wcroot-abspath']
|
30
|
+
@wc_root = wcroot.text
|
31
|
+
end
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'logue/loggable'
|
6
|
+
require 'svnx/log/entries'
|
7
|
+
require 'svnx/status/entries'
|
8
|
+
require 'svnx/status/command'
|
9
|
+
require 'svnx/info/entries'
|
10
|
+
require 'svnx/info/command'
|
11
|
+
require 'svnx/cat/command'
|
12
|
+
require 'pathname'
|
13
|
+
|
14
|
+
module SVNx; module IO; end; end
|
15
|
+
|
16
|
+
module SVNx::IO
|
17
|
+
# An element unites an svn element and a file/directory (at least one of
|
18
|
+
# which should exist).
|
19
|
+
|
20
|
+
class Element
|
21
|
+
include Logue::Loggable, Comparable
|
22
|
+
|
23
|
+
attr_reader :svn
|
24
|
+
attr_reader :path
|
25
|
+
attr_reader :local
|
26
|
+
|
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
|
40
|
+
|
41
|
+
def exist?
|
42
|
+
@local && @local.exist?
|
43
|
+
end
|
44
|
+
|
45
|
+
def directory?
|
46
|
+
@local && @local.directory?
|
47
|
+
end
|
48
|
+
|
49
|
+
def file?
|
50
|
+
@local && @local.file?
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_info revision = nil
|
54
|
+
return nil unless in_svn?
|
55
|
+
|
56
|
+
usepath = @local ? @local.to_path : @path
|
57
|
+
inf = SVNx::InfoExec.new path: usepath, revision: revision
|
58
|
+
inf.entry
|
59
|
+
end
|
60
|
+
|
61
|
+
def in_svn?
|
62
|
+
usepath = @local ? @local.to_path : @path
|
63
|
+
st = SVNx::StatusExec.new path: usepath
|
64
|
+
st.entries.size == 0 || st.entries[0].status.to_s != 'unversioned'
|
65
|
+
end
|
66
|
+
|
67
|
+
def find_entries args = Hash.new
|
68
|
+
revision = args[:revision]
|
69
|
+
status = args[:status]
|
70
|
+
|
71
|
+
if revision.nil?
|
72
|
+
find_by_status status
|
73
|
+
else
|
74
|
+
find_in_log revision, status
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def find_in_log revision, action
|
79
|
+
svninfo = get_info
|
80
|
+
|
81
|
+
filter = svninfo.url.dup
|
82
|
+
filter.slice! svninfo.root
|
83
|
+
|
84
|
+
# we can't cache this, because we don't know if there has been an svn
|
85
|
+
# update since the previous run:
|
86
|
+
logexec = SVNx::LogExec.new path: @local, revision: revision, verbose: true, use_cache: false
|
87
|
+
entries = logexec.entries
|
88
|
+
|
89
|
+
act = action.kind_of?(SVNx::Action) ? action : SVNx::Action.new(action)
|
90
|
+
entries.match act, filter
|
91
|
+
end
|
92
|
+
|
93
|
+
def find_by_status status
|
94
|
+
statexec = SVNx::StatusExec.new path: @local, use_cache: false
|
95
|
+
entries = statexec.entries
|
96
|
+
|
97
|
+
entries.select do |entry|
|
98
|
+
status.nil? || entry.status.to_s == status.to_s
|
99
|
+
end.sort
|
100
|
+
end
|
101
|
+
|
102
|
+
def log_entries args = Hash.new
|
103
|
+
rev = args[:revision]
|
104
|
+
# use_cache should be conditional on revision:
|
105
|
+
logexec = SVNx::LogExec.new :path => @local, :revision => rev && rev.to_s, :verbose => true, :use_cache => false
|
106
|
+
logexec.entries
|
107
|
+
end
|
108
|
+
|
109
|
+
def cat args = Hash.new
|
110
|
+
rev = args[:revision]
|
111
|
+
catexec = SVNx::CatExec.new :path => @local, :revision => rev && rev.to_s, :use_cache => false
|
112
|
+
catexec.output
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_s
|
116
|
+
"svn => " + @svn.to_s + "; local => " + @local.to_s
|
117
|
+
end
|
118
|
+
|
119
|
+
def <=> other
|
120
|
+
@local <=> other.local
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/svnx/log/entries.rb
CHANGED
@@ -13,5 +13,13 @@ module SVNx::Log
|
|
13
13
|
def create_entry xmlelement
|
14
14
|
Entry.new :xmlelement => xmlelement
|
15
15
|
end
|
16
|
+
|
17
|
+
def match action, filter
|
18
|
+
matching = Array.new
|
19
|
+
each do |entry|
|
20
|
+
matching.concat entry.match(action, filter)
|
21
|
+
end
|
22
|
+
matching.sort
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/svnx/log/entry.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'svnx/base/entry'
|
5
|
+
require 'svnx/base/action'
|
5
6
|
|
6
7
|
module SVNx; module Log; end; end
|
7
8
|
|
8
9
|
module SVNx::Log
|
9
10
|
class Entry < SVNx::Entry
|
10
|
-
|
11
11
|
attr_reader :revision, :author, :date, :paths, :msg
|
12
12
|
|
13
13
|
def set_from_element elmt
|
@@ -24,8 +24,11 @@ module SVNx::Log
|
|
24
24
|
action = get_attribute pe, 'action'
|
25
25
|
name = pe.text
|
26
26
|
|
27
|
-
@paths << LogEntryPath.new(:
|
27
|
+
@paths << LogEntryPath.new(kind: kind, action: SVNx::Action.new(action), name: name)
|
28
28
|
end
|
29
|
+
|
30
|
+
# Svn isn't consistent with the order of paths
|
31
|
+
@paths.sort!
|
29
32
|
end
|
30
33
|
|
31
34
|
def message
|
@@ -35,9 +38,17 @@ module SVNx::Log
|
|
35
38
|
def to_s
|
36
39
|
[ @revision, @author, @date, @msg, @paths ].collect { |x| x.to_s }.join " "
|
37
40
|
end
|
38
|
-
end
|
39
41
|
|
42
|
+
def match action, filter
|
43
|
+
paths.select do |path|
|
44
|
+
path.match? action, filter
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
40
49
|
class LogEntryPath
|
50
|
+
include Comparable
|
51
|
+
|
41
52
|
attr_reader :kind, :action, :name
|
42
53
|
|
43
54
|
def initialize args = Hash.new
|
@@ -49,5 +60,13 @@ module SVNx::Log
|
|
49
60
|
def to_s
|
50
61
|
@name
|
51
62
|
end
|
63
|
+
|
64
|
+
def <=> other
|
65
|
+
name <=> other.name
|
66
|
+
end
|
67
|
+
|
68
|
+
def match? action, filter
|
69
|
+
@action.to_s == action.to_s && @name.start_with?(filter)
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|
data/lib/svnx/status/command.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'svnx/base/command'
|
5
|
+
require 'svnx/info/command'
|
5
6
|
|
6
7
|
module SVNx
|
7
8
|
class StatusCommandLine < CommandLine
|
@@ -26,8 +27,22 @@ module SVNx
|
|
26
27
|
attr_reader :entries
|
27
28
|
|
28
29
|
def initialize args
|
30
|
+
path = args[:path]
|
31
|
+
rootpath = nil
|
32
|
+
|
33
|
+
while true
|
34
|
+
begin
|
35
|
+
inf = InfoExec.new(path: path).entry
|
36
|
+
rootpath = inf.wc_root
|
37
|
+
break
|
38
|
+
rescue
|
39
|
+
path = Pathname.new(path).dirname.to_s
|
40
|
+
break if path == '/'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
29
44
|
cmd = StatusCommand.new StatusCommandArgs.new(args)
|
30
|
-
@entries = SVNx::Status::Entries.new(:
|
45
|
+
@entries = SVNx::Status::Entries.new(xmllines: cmd.execute, rootpath: rootpath)
|
31
46
|
end
|
32
47
|
end
|
33
48
|
end
|
data/lib/svnx/status/entries.rb
CHANGED
@@ -6,12 +6,17 @@ require 'svnx/base/entries'
|
|
6
6
|
|
7
7
|
module SVNx::Status
|
8
8
|
class Entries < SVNx::Entries
|
9
|
+
def initialize args = Hash.new
|
10
|
+
@rootpath = args[:rootpath]
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
9
14
|
def get_elements doc
|
10
15
|
doc.elements['status'].elements['target'].elements
|
11
16
|
end
|
12
17
|
|
13
18
|
def create_entry xmlelement
|
14
|
-
Entry.new :xmlelement
|
19
|
+
Entry.new xmlelement: xmlelement, rootpath: @rootpath
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
data/lib/svnx/status/entry.rb
CHANGED
@@ -8,13 +8,17 @@ module SVNx; module Status; end; end
|
|
8
8
|
|
9
9
|
module SVNx::Status
|
10
10
|
class Entry < SVNx::Entry
|
11
|
+
include Comparable
|
12
|
+
|
11
13
|
attr_reader :status
|
12
14
|
attr_reader :path
|
13
15
|
attr_reader :status_revision
|
14
16
|
attr_reader :action
|
15
17
|
attr_reader :commit_revision
|
18
|
+
attr_reader :name
|
16
19
|
|
17
20
|
def initialize args
|
21
|
+
@rootpath = args[:rootpath]
|
18
22
|
super
|
19
23
|
@action = SVNx::Action.new @status
|
20
24
|
end
|
@@ -23,15 +27,23 @@ module SVNx::Status
|
|
23
27
|
set_attr_var elmt, 'path'
|
24
28
|
|
25
29
|
wcstatus = elmt.elements['wc-status']
|
26
|
-
@status = wcstatus.attributes['item']
|
30
|
+
@status = SVNx::Action.new(wcstatus.attributes['item'])
|
27
31
|
@status_revision = wcstatus.attributes['revision']
|
28
32
|
|
29
33
|
commit = wcstatus.elements['commit']
|
30
34
|
@commit_revision = commit && commit.attributes['revision']
|
35
|
+
@name = @path.dup
|
36
|
+
if @rootpath
|
37
|
+
@name[Regexp.new('^' + @rootpath)] = ""
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
41
|
def to_s
|
34
42
|
"path: #{@path}; status: #{@status}"
|
35
43
|
end
|
44
|
+
|
45
|
+
def <=> other
|
46
|
+
path <=> other.path
|
47
|
+
end
|
36
48
|
end
|
37
49
|
end
|
@@ -13,7 +13,7 @@ module SVNx::Status
|
|
13
13
|
|
14
14
|
assert_equal exp_path, entry.path, msg
|
15
15
|
assert_equal exp_cmt_rev, entry.commit_revision, msg
|
16
|
-
assert_equal exp_status, entry.status, msg
|
16
|
+
assert_equal exp_status.to_s, entry.status.to_s, msg
|
17
17
|
assert_equal exp_st_rev, entry.status_revision, msg
|
18
18
|
end
|
19
19
|
|
@@ -0,0 +1,225 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'integration/tc'
|
5
|
+
require 'svnx/io/element'
|
6
|
+
|
7
|
+
module SVNx::IO
|
8
|
+
class ElementTestCase < SVNx::IntegrationTestCase
|
9
|
+
PENDING_PATH = '/Programs/pvn/pvntestbed.pending'
|
10
|
+
|
11
|
+
def test_init
|
12
|
+
el = Element.new local: PENDING_PATH
|
13
|
+
assert_equal PENDING_PATH, el.local.to_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_exists
|
17
|
+
el = Element.new local: PENDING_PATH
|
18
|
+
assert el.exist?
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_does_not_exist
|
22
|
+
el = Element.new local: '/Programs/pvn/nosuchdirectory'
|
23
|
+
assert !el.exist?
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_is_directory
|
27
|
+
el = Element.new local: PENDING_PATH + '/text'
|
28
|
+
assert el.directory?
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_is_not_directory
|
32
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
33
|
+
assert !el.directory?
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_info_has_info
|
37
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
38
|
+
inf = el.get_info
|
39
|
+
assert_equal 'file', inf.kind
|
40
|
+
assert_equal 'FirstFile.txt', inf.path
|
41
|
+
assert_equal '22', inf.revision
|
42
|
+
assert_equal 'file:///Programs/Subversion/Repositories/pvntestbed.from', inf.root
|
43
|
+
assert_equal 'file:///Programs/Subversion/Repositories/pvntestbed.from/FirstFile.txt', inf.url
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_get_info_no_info
|
47
|
+
el = Element.new local: PENDING_PATH + '/src/java/Charlie.java'
|
48
|
+
assert_nil el.get_info
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_is_in_svn_up_to_date
|
52
|
+
el = Element.new local: PENDING_PATH + '/src/java/Alpha.java'
|
53
|
+
assert el.in_svn?
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_is_in_svn_modified
|
57
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.java'
|
58
|
+
assert el.in_svn?
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_not_in_svn
|
62
|
+
el = Element.new local: PENDING_PATH + '/src/java/Charlie.java'
|
63
|
+
assert !el.in_svn?
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_status_entry idx, exp, entries
|
67
|
+
entry = entries[idx]
|
68
|
+
msg = "entry \##{idx}"
|
69
|
+
assert_equal exp[:path], entry.path, msg
|
70
|
+
assert_equal exp[:name], entry.name, msg
|
71
|
+
assert_equal exp[:status], entry.status.to_s, msg
|
72
|
+
end
|
73
|
+
|
74
|
+
def run_local_test expected, status
|
75
|
+
el = Element.new local: PENDING_PATH
|
76
|
+
entries = el.find_entries status: status
|
77
|
+
assert_equal expected.size, entries.size
|
78
|
+
expected.each_with_index do |exp, idx|
|
79
|
+
assert_status_entry idx, exp, entries
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_status_expected name, status
|
84
|
+
{ path: PENDING_PATH + name, name: name, status: status }
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_find_modified_local_entries
|
88
|
+
expected = Array.new
|
89
|
+
expected << create_status_expected('/FirstFile.txt', 'modified')
|
90
|
+
run_local_test expected, :modified
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_find_added_local_entries
|
94
|
+
expected = Array.new
|
95
|
+
expected << create_status_expected('/SeventhFile.txt', 'added')
|
96
|
+
expected << create_status_expected('/src/ruby/dog.rb', 'added')
|
97
|
+
run_local_test expected, :added
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_find_deleted_local_entries
|
101
|
+
expected = Array.new
|
102
|
+
expected << create_status_expected('/dirzero/SixthFile.txt', 'deleted')
|
103
|
+
run_local_test expected, :deleted
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_find_unversioned_local_entries
|
107
|
+
expected = Array.new
|
108
|
+
expected << create_status_expected('/src/java/Charlie.java', 'unversioned')
|
109
|
+
run_local_test expected, :unversioned
|
110
|
+
end
|
111
|
+
|
112
|
+
def assert_log_entry expname, expaction, entry
|
113
|
+
assert_equal expname, entry.name
|
114
|
+
assert_equal expaction, entry.action.to_s
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_find_modified_remote_entries
|
118
|
+
el = Element.new local: PENDING_PATH
|
119
|
+
entries = el.find_entries revision: '20:22', status: :modified
|
120
|
+
assert_equal 3, entries.size
|
121
|
+
assert_log_entry '/SecondFile.txt', 'modified', entries[0]
|
122
|
+
assert_log_entry '/SecondFile.txt', 'modified', entries[1]
|
123
|
+
assert_log_entry '/src/ruby/charlie.rb', 'modified', entries[2]
|
124
|
+
end
|
125
|
+
|
126
|
+
def assert_paths_equal exppath, path
|
127
|
+
assert_equal exppath[:name], path.name
|
128
|
+
assert_equal exppath[:action], path.action.to_s
|
129
|
+
assert_equal exppath[:kind], path.kind
|
130
|
+
end
|
131
|
+
|
132
|
+
def assert_log_entries expected, entries, idx
|
133
|
+
msg = "entry \##{idx}"
|
134
|
+
assert_equal expected[idx][:author], entries[idx].author, msg
|
135
|
+
assert_equal expected[idx][:date], entries[idx].date, msg
|
136
|
+
assert_equal expected[idx][:author], entries[idx].author, msg
|
137
|
+
assert_equal expected[idx][:revision], entries[idx].revision, msg
|
138
|
+
expected[idx][:paths].each_with_index do |exppath, ix|
|
139
|
+
assert_paths_equal exppath, entries[idx].paths[ix]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_log_entries_no_revision
|
144
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
145
|
+
# these are entries of entries
|
146
|
+
entries = el.log_entries
|
147
|
+
assert_equal 5, entries.size
|
148
|
+
|
149
|
+
expected = Array.new
|
150
|
+
expected << { author: 'Jim',
|
151
|
+
date: '2012-09-16T13:51:55.741762Z',
|
152
|
+
msg: "We're not sure. Are we...black?",
|
153
|
+
revision: '13',
|
154
|
+
paths: [
|
155
|
+
{ action: 'modified', kind: 'file', name: '/FirstFile.txt' },
|
156
|
+
{ action: 'added', kind: 'file', name: '/SecondFile.txt' }
|
157
|
+
]
|
158
|
+
}
|
159
|
+
|
160
|
+
assert_log_entries expected, entries, 0
|
161
|
+
|
162
|
+
expected << { author: 'Lyle',
|
163
|
+
date: '2012-09-15T17:30:36.869900Z',
|
164
|
+
msg: 'Send wire, main office, tell them I said "ow". Gotcha!',
|
165
|
+
revision: '5',
|
166
|
+
paths: [
|
167
|
+
{ action: 'modified', kind: 'file', name: '/FirstFile.txt' },
|
168
|
+
{ action: 'modified', kind: 'file', name: '/SecondFile.txt' }
|
169
|
+
]
|
170
|
+
}
|
171
|
+
|
172
|
+
assert_log_entries expected, entries, 1
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_cat_no_revision
|
176
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
177
|
+
|
178
|
+
expected = Array.new
|
179
|
+
expected << "this is the second line of the first file.\n"
|
180
|
+
expected << "third line here.\n"
|
181
|
+
expected << "fourth line this is.\n"
|
182
|
+
|
183
|
+
lines = el.cat
|
184
|
+
assert_equal expected, lines
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_cat_valid_revision
|
188
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
189
|
+
|
190
|
+
expected = Array.new
|
191
|
+
expected << "This is the first line of the first file in the testbed.\n"
|
192
|
+
expected << "This is the second line of the first file.\n"
|
193
|
+
|
194
|
+
lines = el.cat revision: 2
|
195
|
+
|
196
|
+
assert_equal expected, lines
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_cat_invalid_revision
|
200
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
201
|
+
assert_raises(RuntimeError) do
|
202
|
+
el.cat revision: 41
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_to_s
|
207
|
+
el = Element.new local: PENDING_PATH + '/FirstFile.txt'
|
208
|
+
assert_equal "svn => ; local => #{PENDING_PATH}/FirstFile.txt", el.to_s
|
209
|
+
end
|
210
|
+
|
211
|
+
def assert_comparable expected, x, y
|
212
|
+
assert_equal expected, x <=> y
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_comparable
|
216
|
+
a = Element.new local: PENDING_PATH + '/A.txt'
|
217
|
+
b0 = Element.new local: PENDING_PATH + '/B.txt'
|
218
|
+
b1 = Element.new local: PENDING_PATH + '/B.txt'
|
219
|
+
|
220
|
+
assert_comparable -1, a, b0
|
221
|
+
assert_comparable 1, b0, a
|
222
|
+
assert_comparable 0, b0, b1
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
@@ -32,5 +32,18 @@ module SVNx
|
|
32
32
|
def test_unversioned
|
33
33
|
assert_action_equals false, false, false, true, 'unversioned', '?'
|
34
34
|
end
|
35
|
+
|
36
|
+
def test_constants
|
37
|
+
assert_equal SVNx::Action.new('added'), SVNx::Action::ADDED
|
38
|
+
assert_equal SVNx::Action.new('deleted'), SVNx::Action::DELETED
|
39
|
+
assert_equal SVNx::Action.new('modified'), SVNx::Action::MODIFIED
|
40
|
+
assert_equal SVNx::Action.new('unversioned'), SVNx::Action::UNVERSIONED
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_invalid_type
|
44
|
+
assert_raise(RuntimeError) do
|
45
|
+
SVNx::Action.new('dummy')
|
46
|
+
end
|
47
|
+
end
|
35
48
|
end
|
36
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svnx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Pace
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logue
|
@@ -54,6 +54,8 @@ files:
|
|
54
54
|
- lib/svnx/info/command.rb
|
55
55
|
- lib/svnx/info/entries.rb
|
56
56
|
- lib/svnx/info/entry.rb
|
57
|
+
- lib/svnx/io/directory.rb
|
58
|
+
- lib/svnx/io/element.rb
|
57
59
|
- lib/svnx/log/command.rb
|
58
60
|
- lib/svnx/log/entries.rb
|
59
61
|
- lib/svnx/log/entry.rb
|
@@ -71,6 +73,7 @@ files:
|
|
71
73
|
- test/integration/info/info_test.rb
|
72
74
|
- test/integration/log/log_test.rb
|
73
75
|
- test/integration/status/status_test.rb
|
76
|
+
- test/integration/svnx/io/element_test.rb
|
74
77
|
- test/unit/svnx/base/action_test.rb
|
75
78
|
- test/unit/svnx/cat/command_test.rb
|
76
79
|
- test/unit/svnx/info/entries_test.rb
|
@@ -111,6 +114,7 @@ test_files:
|
|
111
114
|
- test/integration/info/info_test.rb
|
112
115
|
- test/integration/log/log_test.rb
|
113
116
|
- test/integration/status/status_test.rb
|
117
|
+
- test/integration/svnx/io/element_test.rb
|
114
118
|
- test/unit/svnx/base/action_test.rb
|
115
119
|
- test/unit/svnx/cat/command_test.rb
|
116
120
|
- test/unit/svnx/info/entries_test.rb
|