svn_wc 0.0.4 → 0.0.5
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.
- data/ChangeLog +3 -0
- data/README.rdoc +3 -3
- data/lib/svn_wc.rb +68 -106
- data/test/svn_wc_test.rb +19 -5
- metadata +9 -4
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
|
@@ -5,7 +5,7 @@ Operate on the working copy of a (remote) Subversion (svn) repository.
|
|
|
5
5
|
|
|
6
6
|
== VERSION:
|
|
7
7
|
|
|
8
|
-
Version 0.0.
|
|
8
|
+
Version 0.0.5
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
== SYNOPSIS:
|
|
@@ -262,10 +262,10 @@ See the ChangeLog file for details.
|
|
|
262
262
|
|
|
263
263
|
== LICENSE AND COPYRIGHT:
|
|
264
264
|
|
|
265
|
-
Copyright
|
|
265
|
+
Copyright 2010 David Wright (david_v_wright@yahoo.com), all rights reserved.
|
|
266
266
|
|
|
267
267
|
|
|
268
|
-
SvnWc::RepoAccess 0.0.
|
|
268
|
+
SvnWc::RepoAccess 0.0.5 is released under the LGPL license.
|
|
269
269
|
|
|
270
270
|
|
|
271
271
|
== AUTHOR:
|
data/lib/svn_wc.rb
CHANGED
|
@@ -154,7 +154,9 @@ module SvnWc
|
|
|
154
154
|
# introduce Delegation, if we don't define the method pass it on to the
|
|
155
155
|
# ruby bindings.
|
|
156
156
|
#
|
|
157
|
+
#--
|
|
157
158
|
# (yup, this is probably asking for trouble)
|
|
159
|
+
#++
|
|
158
160
|
#
|
|
159
161
|
def method_missing(sym, *args, &block)
|
|
160
162
|
@ctx.send sym, *args, &block
|
|
@@ -163,9 +165,10 @@ module SvnWc
|
|
|
163
165
|
#--
|
|
164
166
|
# TODO revist these
|
|
165
167
|
#++
|
|
166
|
-
attr_accessor :svn_user, :svn_pass, :svn_repo_master,
|
|
168
|
+
attr_accessor :svn_user, :svn_pass, :svn_repo_master,
|
|
167
169
|
:svn_repo_working_copy, :cur_file,
|
|
168
|
-
:svn_repo_config_path, :svn_repo_config_file
|
|
170
|
+
:svn_repo_config_path, :svn_repo_config_file,
|
|
171
|
+
:force_checkout
|
|
169
172
|
attr_reader :ctx, :repos
|
|
170
173
|
|
|
171
174
|
#
|
|
@@ -176,6 +179,7 @@ module SvnWc
|
|
|
176
179
|
conf = load_conf(conf)
|
|
177
180
|
@svn_user = conf['svn_user']
|
|
178
181
|
@svn_pass = conf['svn_pass']
|
|
182
|
+
@force_checkout = conf['force_checkout']
|
|
179
183
|
@svn_repo_master = conf['svn_repo_master']
|
|
180
184
|
@svn_repo_working_copy = conf['svn_repo_working_copy']
|
|
181
185
|
@svn_repo_config_path = conf['svn_repo_config_path']
|
|
@@ -192,11 +196,12 @@ module SvnWc
|
|
|
192
196
|
end
|
|
193
197
|
## do checkout if not exists at specified local path
|
|
194
198
|
|
|
195
|
-
if force
|
|
199
|
+
if force or @force_checkout
|
|
196
200
|
begin
|
|
197
|
-
|
|
198
|
-
FileUtils.mkdir_p @svn_repo_working_copy
|
|
199
|
-
rescue
|
|
201
|
+
FileUtils.rm_rf @svn_repo_working_copy
|
|
202
|
+
FileUtils.mkdir_p @svn_repo_working_copy
|
|
203
|
+
rescue Errno::EACCES => err
|
|
204
|
+
raise RepoAccessError, err.message
|
|
200
205
|
end
|
|
201
206
|
else
|
|
202
207
|
if File.directory? @svn_repo_working_copy
|
|
@@ -489,8 +494,10 @@ module SvnWc
|
|
|
489
494
|
|
|
490
495
|
def do_status(dir=self.svn_repo_working_copy, file=nil) # :nodoc:
|
|
491
496
|
|
|
497
|
+
# set default
|
|
492
498
|
wc_path = Svn::Core.path_canonicalize dir if File.directory? dir
|
|
493
499
|
|
|
500
|
+
# override default if set
|
|
494
501
|
wc_path = Svn::Core.path_canonicalize file \
|
|
495
502
|
if (!file.nil? && File.file?(file))
|
|
496
503
|
|
|
@@ -570,7 +577,7 @@ module SvnWc
|
|
|
570
577
|
svn.list(wc_path, rev, verbose, depth) do |path, dirent, lock, abs_path|
|
|
571
578
|
#paths.push(path.empty? ? abs_path : File.join(abs_path, path))
|
|
572
579
|
f_rec = Hash.new
|
|
573
|
-
f_rec[:entry] =
|
|
580
|
+
f_rec[:entry] = path
|
|
574
581
|
f_rec[:last_changed_rev] = dirent.created_rev
|
|
575
582
|
paths.push f_rec
|
|
576
583
|
end
|
|
@@ -614,19 +621,16 @@ module SvnWc
|
|
|
614
621
|
#
|
|
615
622
|
|
|
616
623
|
def list_entries(dir=self.svn_repo_working_copy, file=nil, verbose=false)
|
|
624
|
+
|
|
617
625
|
@entry_list, @show, @verbose = [], true, verbose
|
|
626
|
+
|
|
618
627
|
Svn::Wc::AdmAccess.open(nil, dir, false, 5) do |adm|
|
|
619
628
|
@adm = adm
|
|
620
629
|
if file.nil?
|
|
621
630
|
#also see walk_entries (in svn bindings) has callback
|
|
622
631
|
adm.read_entries.keys.sort.each { |ef|
|
|
623
632
|
next unless ef.length >= 1 # why this check and not file.exists?
|
|
624
|
-
|
|
625
|
-
if File.file? f_path
|
|
626
|
-
_collect_get_entry_info(f_path)
|
|
627
|
-
elsif File.directory? f_path
|
|
628
|
-
_walk_entries(f_path)
|
|
629
|
-
end
|
|
633
|
+
_collect_get_entry_info(File.join(dir, ef))
|
|
630
634
|
}
|
|
631
635
|
else
|
|
632
636
|
_collect_get_entry_info(file)
|
|
@@ -637,22 +641,6 @@ module SvnWc
|
|
|
637
641
|
@entry_list
|
|
638
642
|
end
|
|
639
643
|
|
|
640
|
-
#
|
|
641
|
-
# private
|
|
642
|
-
#
|
|
643
|
-
# given a dir, iterate each entry, getting detailed file entry info
|
|
644
|
-
#
|
|
645
|
-
|
|
646
|
-
def _walk_entries(f_path) #:nodoc:
|
|
647
|
-
Dir.entries(f_path).each do |de|
|
|
648
|
-
next if de == '..' or de == '.' or de == '.svn'
|
|
649
|
-
fp_path = File.join(f_path, de)
|
|
650
|
-
_collect_get_entry_info(fp_path)
|
|
651
|
-
end
|
|
652
|
-
end
|
|
653
|
-
private :_walk_entries
|
|
654
|
-
|
|
655
|
-
|
|
656
644
|
#
|
|
657
645
|
# private
|
|
658
646
|
#
|
|
@@ -663,9 +651,16 @@ module SvnWc
|
|
|
663
651
|
#
|
|
664
652
|
|
|
665
653
|
def _collect_get_entry_info(abs_path_file) #:nodoc:
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
654
|
+
if File.directory?(abs_path_file)
|
|
655
|
+
Dir.entries(abs_path_file).each do |de|
|
|
656
|
+
next if de == '..' or de == '.' or de == '.svn'
|
|
657
|
+
status_info = _get_entry_info(File.join(abs_path_file, de))
|
|
658
|
+
@entry_list.push status_info if status_info and not status_info.empty?
|
|
659
|
+
end
|
|
660
|
+
else
|
|
661
|
+
status_info = _get_entry_info(abs_path_file)
|
|
662
|
+
@entry_list.push status_info if status_info and not status_info.empty?
|
|
663
|
+
end
|
|
669
664
|
end
|
|
670
665
|
private :_collect_get_entry_info
|
|
671
666
|
|
|
@@ -692,55 +687,34 @@ module SvnWc
|
|
|
692
687
|
status = @adm.status(abs_path_file)
|
|
693
688
|
return if status.entry.nil?
|
|
694
689
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
690
|
+
status_info = Hash.new
|
|
691
|
+
status_info[:entry_name] = entry_repo_location
|
|
692
|
+
status_info[:status] = status_codes(status.text_status)
|
|
693
|
+
status_info[:repo_rev] = status.entry.revision
|
|
694
|
+
status_info[:kind] = status.entry.kind
|
|
699
695
|
|
|
700
|
-
if
|
|
696
|
+
if status_info[:kind] == 2
|
|
701
697
|
# remove the repo root abs path, give dirs relative to repo root
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
_walk_entries(abs_path_file)
|
|
698
|
+
status_info[:dir_name] = entry_repo_location
|
|
699
|
+
_collect_get_entry_info(abs_path_file)
|
|
705
700
|
end
|
|
706
|
-
return if @verbose == false
|
|
701
|
+
return status_info if @verbose == false
|
|
707
702
|
# only on demand ; i.e. verbose = true
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
#@status_info[:keep_local] = s.keep_local
|
|
724
|
-
@status_info[:lock_owner] = s.lock_owner
|
|
725
|
-
@status_info[:prop_time] = s.prop_time
|
|
726
|
-
@status_info[:has_props] = s.has_props
|
|
727
|
-
@status_info[:schedule] = s.schedule
|
|
728
|
-
@status_info[:text_time] = s.text_time
|
|
729
|
-
@status_info[:revision] = s.revision
|
|
730
|
-
@status_info[:checksum] = s.checksum
|
|
731
|
-
@status_info[:cmt_date] = s.cmt_date
|
|
732
|
-
@status_info[:prejfile] = s.prejfile
|
|
733
|
-
@status_info[:is_file] = s.file?
|
|
734
|
-
@status_info[:normal?] = s.normal?
|
|
735
|
-
@status_info[:cmt_rev] = s.cmt_rev
|
|
736
|
-
@status_info[:deleted] = s.deleted
|
|
737
|
-
@status_info[:absent] = s.absent
|
|
738
|
-
@status_info[:is_add] = s.add?
|
|
739
|
-
@status_info[:is_dir] = s.dir?
|
|
740
|
-
@status_info[:repos] = s.repos
|
|
741
|
-
#@status_info[:depth] = s.depth
|
|
742
|
-
@status_info[:uuid] = s.uuid
|
|
743
|
-
@status_info[:url] = s.url
|
|
703
|
+
status_info[:entry_conflict] = entry.conflicted?(abs_path_file)
|
|
704
|
+
s_entry_info = %w(
|
|
705
|
+
lock_creation_date present_props has_prop_mods
|
|
706
|
+
copyfrom_url conflict_old conflict_new
|
|
707
|
+
lock_comment copyfrom_rev conflict_wrk
|
|
708
|
+
cmt_author lock_token lock_owner
|
|
709
|
+
prop_time has_props schedule text_time revision
|
|
710
|
+
checksum cmt_date prejfile normal? file? add? dir?
|
|
711
|
+
cmt_rev deleted absent repos uuid url
|
|
712
|
+
) # working_size changelist keep_local depth
|
|
713
|
+
|
|
714
|
+
s_entry_info.each do |each_info|
|
|
715
|
+
status_info[:"#{each_info}"] = status.entry.method(:"#{each_info}").call
|
|
716
|
+
end
|
|
717
|
+
status_info
|
|
744
718
|
end
|
|
745
719
|
private :_get_entry_info
|
|
746
720
|
|
|
@@ -750,38 +724,26 @@ module SvnWc
|
|
|
750
724
|
# TODO - document all the params available from this command
|
|
751
725
|
#++
|
|
752
726
|
#
|
|
753
|
-
def info(file=
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
else
|
|
757
|
-
wc_path = self.svn_repo_working_copy
|
|
758
|
-
end
|
|
727
|
+
def info(file=nil)
|
|
728
|
+
wc_path = self.svn_repo_working_copy
|
|
729
|
+
wc_path = file if file and file.class == String
|
|
759
730
|
|
|
760
731
|
r_info = Hash.new
|
|
732
|
+
type_info = %w(
|
|
733
|
+
last_changed_author last_changed_rev
|
|
734
|
+
last_changed_date conflict_old
|
|
735
|
+
repos_root_url repos_root_URL
|
|
736
|
+
copyfrom_rev copyfrom_url conflict_wrk
|
|
737
|
+
conflict_new has_wc_info repos_UUID
|
|
738
|
+
checksum prop_time text_time prejfile
|
|
739
|
+
schedule taguri lock rev dup url URL
|
|
740
|
+
) # changelist depth size tree_conflict working_size
|
|
741
|
+
|
|
761
742
|
begin
|
|
762
743
|
@ctx.info(wc_path) do |path, type|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
r_info[:conflict_old] = type.conflict_old
|
|
767
|
-
#r_info[:tree_conflict] = type.tree_conflict
|
|
768
|
-
r_info[:repos_root_url] = type.repos_root_url
|
|
769
|
-
r_info[:repos_root_URL] = type.repos_root_URL
|
|
770
|
-
r_info[:copyfrom_rev] = type.copyfrom_rev
|
|
771
|
-
r_info[:copyfrom_url] = type.copyfrom_url
|
|
772
|
-
#r_info[:working_size] = type.working_size
|
|
773
|
-
r_info[:conflict_wrk] = type.conflict_wrk
|
|
774
|
-
r_info[:conflict_new] = type.conflict_new
|
|
775
|
-
r_info[:has_wc_info] = type.has_wc_info
|
|
776
|
-
r_info[:repos_UUID] = type.repos_UUID
|
|
777
|
-
r_info[:checksum] = type.checksum
|
|
778
|
-
r_info[:prop_time], r_info[:text_time] = type.prop_time, type.text_time
|
|
779
|
-
r_info[:prejfile], r_info[:schedule] = type.prejfile, type.schedule
|
|
780
|
-
r_info[:taguri], r_info[:lock] = type.taguri, type.lock
|
|
781
|
-
r_info[:rev], r_info[:dup] = type.rev, type.dup
|
|
782
|
-
r_info[:url], r_info[:URL] = type.url, type.URL
|
|
783
|
-
#r_info[:changelist] = type.changelist
|
|
784
|
-
#r_info[:depth], r_info[:size] = type.depth, type.size
|
|
744
|
+
type_info.each do |t_info|
|
|
745
|
+
r_info[:"#{t_info}"] = type.method(:"#{t_info}").call
|
|
746
|
+
end
|
|
785
747
|
end
|
|
786
748
|
#rescue Svn::Error::WcNotDirectory => e
|
|
787
749
|
# #Svn::Error::RaIllegalUrl,
|
|
@@ -869,7 +831,7 @@ module SvnWc
|
|
|
869
831
|
# TODO support other propset's ; also propget
|
|
870
832
|
#++
|
|
871
833
|
def propset(type, files, dir_path=self.svn_repo_working_copy)
|
|
872
|
-
raise RepoAccessError, '"ignore" is only supported propset' \
|
|
834
|
+
raise RepoAccessError, 'currently, "ignore" is the only supported propset' \
|
|
873
835
|
unless type == 'ignore'
|
|
874
836
|
|
|
875
837
|
svn_session() do |svn|
|
data/test/svn_wc_test.rb
CHANGED
|
@@ -619,9 +619,9 @@ class TestSvnWc < Test::Unit::TestCase
|
|
|
619
619
|
|
|
620
620
|
entries = svn.list_entries
|
|
621
621
|
|
|
622
|
-
assert_equal File.basename(entries[1][:entry_name]),
|
|
623
|
-
File.basename(file)
|
|
624
622
|
assert_equal File.basename(entries[0][:entry_name]),
|
|
623
|
+
File.basename(file)
|
|
624
|
+
assert_equal File.basename(entries[1][:entry_name]),
|
|
625
625
|
File.basename(file2)
|
|
626
626
|
assert_equal entries.size, 2
|
|
627
627
|
assert_nil entries[2]
|
|
@@ -632,14 +632,14 @@ class TestSvnWc < Test::Unit::TestCase
|
|
|
632
632
|
# bools
|
|
633
633
|
assert ! info[:absent]
|
|
634
634
|
assert ! info[:entry_conflict]
|
|
635
|
-
assert ! info[:
|
|
636
|
-
assert ! info[:
|
|
635
|
+
assert ! info[:add?]
|
|
636
|
+
assert ! info[:dir?]
|
|
637
637
|
assert ! info[:has_props]
|
|
638
638
|
assert ! info[:deleted]
|
|
639
639
|
#assert ! info[:keep_local]
|
|
640
640
|
assert ! info[:has_prop_mods]
|
|
641
641
|
assert info[:normal?]
|
|
642
|
-
assert info[:
|
|
642
|
+
assert info[:file?]
|
|
643
643
|
|
|
644
644
|
assert_nil info[:copyfrom_url]
|
|
645
645
|
assert_nil info[:conflict_old]
|
|
@@ -671,6 +671,20 @@ class TestSvnWc < Test::Unit::TestCase
|
|
|
671
671
|
assert_equal info[:repos], @conf['svn_repo_master']
|
|
672
672
|
end
|
|
673
673
|
|
|
674
|
+
# list and list_entries report the same entry path
|
|
675
|
+
list_entries = []
|
|
676
|
+
entries.each do |info|
|
|
677
|
+
list_entries.push info[:entry_name]
|
|
678
|
+
end
|
|
679
|
+
|
|
680
|
+
entries = []
|
|
681
|
+
svn.list.each do |info|
|
|
682
|
+
next unless info[:entry].match(/\.txt$/)
|
|
683
|
+
entries.push info[:entry]
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
assert_equal entries, list_entries
|
|
687
|
+
|
|
674
688
|
end
|
|
675
689
|
|
|
676
690
|
def test_propset_ignore_file
|
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: svn_wc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 21
|
|
4
5
|
prerelease: false
|
|
5
6
|
segments:
|
|
6
7
|
- 0
|
|
7
8
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 0.0.
|
|
9
|
+
- 5
|
|
10
|
+
version: 0.0.5
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- David Wright
|
|
@@ -14,7 +15,7 @@ autorequire:
|
|
|
14
15
|
bindir: bin
|
|
15
16
|
cert_chain: []
|
|
16
17
|
|
|
17
|
-
date: 2010-
|
|
18
|
+
date: 2010-10-11 00:00:00 -07:00
|
|
18
19
|
default_executable:
|
|
19
20
|
dependencies: []
|
|
20
21
|
|
|
@@ -44,23 +45,27 @@ rdoc_options: []
|
|
|
44
45
|
require_paths:
|
|
45
46
|
- lib
|
|
46
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
|
+
none: false
|
|
47
49
|
requirements:
|
|
48
50
|
- - ">="
|
|
49
51
|
- !ruby/object:Gem::Version
|
|
52
|
+
hash: 3
|
|
50
53
|
segments:
|
|
51
54
|
- 0
|
|
52
55
|
version: "0"
|
|
53
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
54
58
|
requirements:
|
|
55
59
|
- - ">="
|
|
56
60
|
- !ruby/object:Gem::Version
|
|
61
|
+
hash: 3
|
|
57
62
|
segments:
|
|
58
63
|
- 0
|
|
59
64
|
version: "0"
|
|
60
65
|
requirements: []
|
|
61
66
|
|
|
62
67
|
rubyforge_project:
|
|
63
|
-
rubygems_version: 1.3.
|
|
68
|
+
rubygems_version: 1.3.7
|
|
64
69
|
signing_key:
|
|
65
70
|
specification_version: 3
|
|
66
71
|
summary: svn_wc operates on a working copy (on the local filesystem) of a remote Subversion repository.
|