svn_wc 0.0.1 → 0.0.2
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/README.rdoc +10 -12
- data/lib/svn_wc.rb +65 -34
- data/test/svn_wc_test.rb +53 -8
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -5,37 +5,35 @@ 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.2
|
9
9
|
|
10
10
|
|
11
11
|
== SYNOPSIS:
|
12
|
-
ruby code
|
13
12
|
|
14
13
|
require 'svn_wc'
|
15
14
|
|
16
|
-
# assumes a previous initial checkout
|
17
15
|
svn_wc = SvnWc::RepoAccess.new
|
18
16
|
|
19
17
|
svn_wc.set_conf 'svn_wc_conf.yaml'
|
20
18
|
|
21
19
|
# checkout, needed first time only,
|
22
20
|
# 'true', force overwrite of working copy directory path
|
23
|
-
|
21
|
+
svn_wc.do_checkout true
|
24
22
|
|
25
23
|
file = Tempfile.new('test_', svn_wc.svn_repo_working_copy).path
|
24
|
+
|
26
25
|
begin
|
26
|
+
|
27
27
|
svn_wc.add file
|
28
|
-
|
28
|
+
|
29
29
|
rev = svn_wc.commit file
|
30
|
-
|
30
|
+
|
31
31
|
puts "svn committed file: #{file}, revision #{rev}"
|
32
|
-
|
33
|
-
# commit our delete
|
34
|
-
rev = svn_wc.commit file
|
35
|
-
puts "svn deleted file: #{file}, revision #{rev}"
|
36
|
-
raise 'commit failed' unless rev >= 1
|
32
|
+
|
37
33
|
rescue SvnWc::RepoAccessError, Exception => e
|
34
|
+
|
38
35
|
raise e.message
|
36
|
+
|
39
37
|
end
|
40
38
|
|
41
39
|
|
@@ -267,7 +265,7 @@ See the ChangeLog file for details.
|
|
267
265
|
Copyright 2009 David Wright (david_v_wright@yahoo.com), all rights reserved.
|
268
266
|
|
269
267
|
|
270
|
-
SvnWc::RepoAccess 0.
|
268
|
+
SvnWc::RepoAccess 0.0.2 is released under the LGPL license.
|
271
269
|
|
272
270
|
|
273
271
|
== AUTHOR:
|
data/lib/svn_wc.rb
CHANGED
@@ -110,6 +110,18 @@ require 'svn/error'
|
|
110
110
|
# #assert(wc_status.entry.normal?)
|
111
111
|
# #ctx.prop_set(Svn::Core::PROP_IGNORE, file2, dir_path)
|
112
112
|
#++
|
113
|
+
#module Svn
|
114
|
+
# class Error
|
115
|
+
# #WC_NOT_DIRECTORY # 1.4.2
|
116
|
+
# class WcNotDirectory # 1.6.6
|
117
|
+
# raise StandardError.new(
|
118
|
+
# #WC_NOT_DIRECTORY # 1.4.2
|
119
|
+
# end
|
120
|
+
# class AuthnNoProvider
|
121
|
+
# raise StandardError
|
122
|
+
# end
|
123
|
+
# end
|
124
|
+
#end
|
113
125
|
|
114
126
|
module SvnWc
|
115
127
|
|
@@ -118,7 +130,7 @@ module SvnWc
|
|
118
130
|
|
119
131
|
class RepoAccess
|
120
132
|
|
121
|
-
VERSION = '0.0.
|
133
|
+
VERSION = '0.0.2'
|
122
134
|
|
123
135
|
DEFAULT_CONF_FILE = File.join(File.dirname(File.dirname(\
|
124
136
|
File.expand_path(__FILE__))), 'svn_wc_conf.yaml')
|
@@ -146,6 +158,9 @@ module SvnWc
|
|
146
158
|
attr_reader :ctx, :repos
|
147
159
|
|
148
160
|
def do_checkout(force=false)
|
161
|
+
if @svn_repo_working_copy.nil?
|
162
|
+
raise RepoAccessError, 'conf file not loaded! - Fatal Error'
|
163
|
+
end
|
149
164
|
## do checkout if not exists at specified local path
|
150
165
|
if File.directory? @svn_repo_working_copy and not force
|
151
166
|
raise RepoAccessError, 'target local directory ' << \
|
@@ -189,9 +204,10 @@ module SvnWc
|
|
189
204
|
svn_session() { |ctx|
|
190
205
|
ctx.checkout(@svn_repo_master, @svn_repo_working_copy)
|
191
206
|
}
|
192
|
-
rescue Svn::Error::RaLocalReposOpenFailed,
|
193
|
-
|
194
|
-
|
207
|
+
#rescue Svn::Error::RaLocalReposOpenFailed,
|
208
|
+
# Svn::Error::FsAlreadyExists,
|
209
|
+
# Exception => e
|
210
|
+
rescue Exception => e
|
195
211
|
raise RepoAccessError, e.message
|
196
212
|
end
|
197
213
|
end
|
@@ -242,10 +258,11 @@ module SvnWc
|
|
242
258
|
files.each { |ef|
|
243
259
|
svn.add(ef, true)
|
244
260
|
}
|
245
|
-
rescue Svn::Error::ENTRY_EXISTS,
|
246
|
-
|
247
|
-
|
248
|
-
|
261
|
+
#rescue Svn::Error::ENTRY_EXISTS,
|
262
|
+
# Svn::Error::AuthnNoProvider,
|
263
|
+
# #Svn::Error::WcNotDirectory,
|
264
|
+
# Svn::Error::SvnError => e
|
265
|
+
rescue Exception => e
|
249
266
|
raise RepoAccessError, "Add Failed: #{e.message}"
|
250
267
|
end
|
251
268
|
end
|
@@ -264,10 +281,11 @@ module SvnWc
|
|
264
281
|
svn_session() do |svn|
|
265
282
|
begin
|
266
283
|
svn.delete(files)
|
267
|
-
rescue Svn::Error::AuthnNoProvider,
|
268
|
-
|
269
|
-
|
270
|
-
|
284
|
+
#rescue Svn::Error::AuthnNoProvider,
|
285
|
+
# #Svn::Error::WcNotDirectory,
|
286
|
+
# Svn::Error::ClientModified,
|
287
|
+
# Svn::Error::SvnError => e
|
288
|
+
rescue Exception => e
|
271
289
|
raise RepoAccessError, "Delete Failed: #{e.message}"
|
272
290
|
end
|
273
291
|
end
|
@@ -293,10 +311,12 @@ module SvnWc
|
|
293
311
|
svn_session(msg) do |svn|
|
294
312
|
begin
|
295
313
|
rev = svn.commit(files).revision
|
296
|
-
rescue Svn::Error::
|
297
|
-
|
298
|
-
|
299
|
-
|
314
|
+
#rescue Svn::Error::AuthnNoProvider,
|
315
|
+
# #Svn::Error::WcNotDirectory,
|
316
|
+
# Svn::Error::IllegalTarget,
|
317
|
+
# #Svn::Error::EntryNotFound => e
|
318
|
+
# Exception => e
|
319
|
+
rescue Exception => e
|
300
320
|
raise RepoAccessError, "Commit Failed: #{e.message}"
|
301
321
|
end
|
302
322
|
end
|
@@ -349,9 +369,12 @@ module SvnWc
|
|
349
369
|
begin
|
350
370
|
#p svn.status paths
|
351
371
|
rev = svn.update(paths, nil, 'infinity')
|
352
|
-
rescue Svn::Error::
|
353
|
-
|
354
|
-
|
372
|
+
#rescue Svn::Error::AuthnNoProvider,
|
373
|
+
# #Svn::Error::FS_NO_SUCH_REVISION,
|
374
|
+
# #Svn::Error::WcNotDirectory,
|
375
|
+
# #Svn::Error::EntryNotFound => e
|
376
|
+
# Exception => e
|
377
|
+
rescue Exception => e
|
355
378
|
raise RepoAccessError, "Update Failed: #{e.message}"
|
356
379
|
end
|
357
380
|
end
|
@@ -439,8 +462,9 @@ module SvnWc
|
|
439
462
|
) do |path, status|
|
440
463
|
infos << [path, status]
|
441
464
|
end
|
442
|
-
rescue
|
443
|
-
|
465
|
+
rescue RuntimeError,
|
466
|
+
#Svn::Error::WcNotDirectory,
|
467
|
+
Exception => svn_err
|
444
468
|
raise RepoAccessError, "status check Failed: #{svn_err}"
|
445
469
|
end
|
446
470
|
end
|
@@ -498,10 +522,12 @@ module SvnWc
|
|
498
522
|
f_rec[:last_changed_rev] = dirent.created_rev
|
499
523
|
paths.push f_rec
|
500
524
|
end
|
501
|
-
rescue Svn::Error::
|
502
|
-
|
503
|
-
|
504
|
-
|
525
|
+
#rescue Svn::Error::AuthnNoProvider,
|
526
|
+
# #Svn::Error::WcNotDirectory,
|
527
|
+
# Svn::Error::FS_NO_SUCH_REVISION,
|
528
|
+
# #Svn::Error::EntryNotFound => e
|
529
|
+
# Exception => e
|
530
|
+
rescue Exception => e
|
505
531
|
raise RepoAccessError, "List Failed: #{e.message}"
|
506
532
|
end
|
507
533
|
end
|
@@ -682,34 +708,38 @@ module SvnWc
|
|
682
708
|
r_info[:last_changed_rev] = type.last_changed_rev
|
683
709
|
r_info[:last_changed_date] = type.last_changed_date
|
684
710
|
r_info[:conflict_old] = type.conflict_old
|
685
|
-
r_info[:tree_conflict] = type.tree_conflict
|
711
|
+
#r_info[:tree_conflict] = type.tree_conflict
|
686
712
|
r_info[:repos_root_url] = type.repos_root_url
|
687
713
|
r_info[:repos_root_URL] = type.repos_root_URL
|
688
714
|
r_info[:copyfrom_rev] = type.copyfrom_rev
|
689
715
|
r_info[:copyfrom_url] = type.copyfrom_url
|
690
|
-
r_info[:working_size] = type.working_size
|
716
|
+
#r_info[:working_size] = type.working_size
|
691
717
|
r_info[:conflict_wrk] = type.conflict_wrk
|
692
718
|
r_info[:conflict_new] = type.conflict_new
|
693
719
|
r_info[:has_wc_info] = type.has_wc_info
|
694
720
|
r_info[:repos_UUID] = type.repos_UUID
|
695
|
-
r_info[:changelist] = type.changelist
|
721
|
+
#r_info[:changelist] = type.changelist
|
696
722
|
r_info[:prop_time] = type.prop_time
|
697
723
|
r_info[:text_time] = type.text_time
|
698
724
|
r_info[:checksum] = type.checksum
|
699
725
|
r_info[:prejfile] = type.prejfile
|
700
726
|
r_info[:schedule] = type.schedule
|
701
727
|
r_info[:taguri] = type.taguri
|
702
|
-
r_info[:depth] = type.depth
|
728
|
+
#r_info[:depth] = type.depth
|
703
729
|
r_info[:lock] = type.lock
|
704
|
-
r_info[:size] = type.size
|
730
|
+
#r_info[:size] = type.size
|
705
731
|
r_info[:url] = type.url
|
706
732
|
r_info[:dup] = type.dup
|
707
733
|
r_info[:URL] = type.URL
|
708
734
|
r_info[:rev] = type.rev
|
709
735
|
end
|
710
|
-
rescue Svn::Error::
|
711
|
-
|
712
|
-
|
736
|
+
#rescue Svn::Error::WcNotDirectory => e
|
737
|
+
# #Svn::Error::RaIllegalUrl,
|
738
|
+
# #Svn::Error::EntryNotFound,
|
739
|
+
# #Svn::Error::RaIllegalUrl,
|
740
|
+
# #Svn::Error::WC_NOT_DIRECTORY
|
741
|
+
# #Svn::Error::WcNotDirectory => e
|
742
|
+
rescue Exception => e
|
713
743
|
raise RepoAccessError, "cant get info: #{e.message}"
|
714
744
|
end
|
715
745
|
r_info
|
@@ -776,7 +806,8 @@ module SvnWc
|
|
776
806
|
svn_session() do |svn|
|
777
807
|
begin
|
778
808
|
svn.diff([], file, rev, file, "WORKING", out_file.path, err_file.path)
|
779
|
-
rescue
|
809
|
+
rescue Exception => e
|
810
|
+
#Svn::Error::EntryNotFound => e
|
780
811
|
raise RepoAccessError, "Diff Failed: #{e.message}"
|
781
812
|
end
|
782
813
|
end
|
data/test/svn_wc_test.rb
CHANGED
@@ -164,7 +164,8 @@ class TestSvnWc < Test::Unit::TestCase
|
|
164
164
|
end
|
165
165
|
|
166
166
|
# the 'dot' dirs
|
167
|
-
assert_equal 2, Dir.entries(@conf['svn_repo_working_copy']).count
|
167
|
+
#assert_equal 2, Dir.entries(@conf['svn_repo_working_copy']).count # 1.8.7 >
|
168
|
+
assert_equal 2, Dir.entries(@conf['svn_repo_working_copy']).size # 1.8.6 <
|
168
169
|
|
169
170
|
assert_raise SvnWc::RepoAccessError do
|
170
171
|
# already exists, wont overwrite dir
|
@@ -172,12 +173,14 @@ class TestSvnWc < Test::Unit::TestCase
|
|
172
173
|
end
|
173
174
|
|
174
175
|
# the 'dot' dirs
|
175
|
-
assert_equal 2, Dir.entries(@conf['svn_repo_working_copy']).count
|
176
|
+
#assert_equal 2, Dir.entries(@conf['svn_repo_working_copy']).count # 1.8.7 >
|
177
|
+
assert_equal 2, Dir.entries(@conf['svn_repo_working_copy']).size # 1.8.6 <
|
176
178
|
|
177
179
|
SvnWc::RepoAccess.new(YAML::dump(@conf), true, true)
|
178
180
|
|
179
181
|
# did a checkout, now more than 2 files
|
180
|
-
assert Dir.entries(@conf['svn_repo_working_copy']).count > 2
|
182
|
+
#assert Dir.entries(@conf['svn_repo_working_copy']).count > 2 # 1.8.7 >
|
183
|
+
assert Dir.entries(@conf['svn_repo_working_copy']).size > 2 # 1.8.6 <
|
181
184
|
end
|
182
185
|
|
183
186
|
## NOTE too much 'system' setup work
|
@@ -233,7 +236,7 @@ class TestSvnWc < Test::Unit::TestCase
|
|
233
236
|
assert_equal @conf['svn_repo_master'], svn.info[:repos_root_url]
|
234
237
|
|
235
238
|
# now have a working copy
|
236
|
-
assert File.directory?
|
239
|
+
assert File.directory?(@conf['svn_repo_working_copy'])
|
237
240
|
|
238
241
|
end
|
239
242
|
|
@@ -376,7 +379,7 @@ class TestSvnWc < Test::Unit::TestCase
|
|
376
379
|
assert_equal rev+1, n_rev
|
377
380
|
|
378
381
|
assert ! File.file?(f[4])
|
379
|
-
assert File.file?
|
382
|
+
assert File.file?(f[3])
|
380
383
|
assert FileUtils.rm_rf(File.dirname(f[3]))
|
381
384
|
end
|
382
385
|
|
@@ -445,7 +448,7 @@ class TestSvnWc < Test::Unit::TestCase
|
|
445
448
|
assert_equal rev+1, rev1
|
446
449
|
|
447
450
|
fe = Array.new
|
448
|
-
files.each { |e| fe.push File.basename
|
451
|
+
files.each { |e| fe.push File.basename(e)}
|
449
452
|
assert_equal \
|
450
453
|
[(rev + 1), ["A\t#{fe[0]}", "A\t#{fe[1]}", "A\t#{fe[2]}"]],
|
451
454
|
svn.update, 'added 3 files into another working copy of the repo, update
|
@@ -462,7 +465,7 @@ class TestSvnWc < Test::Unit::TestCase
|
|
462
465
|
)
|
463
466
|
# add 1 file, in another repo
|
464
467
|
(rev3, file) = check_out_new_working_copy_add_and_commit_new_entries
|
465
|
-
fe.push File.basename
|
468
|
+
fe.push File.basename(file[0])
|
466
469
|
|
467
470
|
assert_equal \
|
468
471
|
[(rev + 3), ["M\t#{fe[0]}", "A\t#{fe[3]}", "D\t#{fe[1]}", "D\t#{fe[2]}"]],
|
@@ -516,7 +519,7 @@ class TestSvnWc < Test::Unit::TestCase
|
|
516
519
|
|
517
520
|
the_diff = r_list - d_list
|
518
521
|
# not cross platform
|
519
|
-
assert_equal the_diff, [File.join
|
522
|
+
assert_equal the_diff, [File.join(@conf['svn_repo_working_copy'], '/')]
|
520
523
|
#puts the_diff
|
521
524
|
#p d_list.length
|
522
525
|
#p r_list.length
|
@@ -671,3 +674,45 @@ class TestSvnWc < Test::Unit::TestCase
|
|
671
674
|
|
672
675
|
end
|
673
676
|
|
677
|
+
if VERSION < '1.8.7'
|
678
|
+
# File lib/tmpdir.rb, line 99
|
679
|
+
def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
680
|
+
case prefix_suffix
|
681
|
+
when nil
|
682
|
+
prefix = "d"
|
683
|
+
suffix = ""
|
684
|
+
when String
|
685
|
+
prefix = prefix_suffix
|
686
|
+
suffix = ""
|
687
|
+
when Array
|
688
|
+
prefix = prefix_suffix[0]
|
689
|
+
suffix = prefix_suffix[1]
|
690
|
+
else
|
691
|
+
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
692
|
+
end
|
693
|
+
tmpdir ||= Dir.tmpdir
|
694
|
+
t = Time.now.strftime("%Y%m%d")
|
695
|
+
n = nil
|
696
|
+
begin
|
697
|
+
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
698
|
+
path << "-#{n}" if n
|
699
|
+
path << suffix
|
700
|
+
Dir.mkdir(path, 0700)
|
701
|
+
rescue Errno::EEXIST
|
702
|
+
n ||= 0
|
703
|
+
n += 1
|
704
|
+
retry
|
705
|
+
end
|
706
|
+
|
707
|
+
if block_given?
|
708
|
+
begin
|
709
|
+
yield path
|
710
|
+
ensure
|
711
|
+
FileUtils.remove_entry_secure path
|
712
|
+
end
|
713
|
+
else
|
714
|
+
path
|
715
|
+
end
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svn_wc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Wright
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-17 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|