svn_wc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog ADDED
@@ -0,0 +1,2 @@
1
+ version 0.0.1
2
+ * initial checkin
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/Manifest ADDED
@@ -0,0 +1,8 @@
1
+ ChangeLog
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ svn_wc_conf.yaml
6
+ svn_wc.gemspec
7
+ lib/svn_wc.rb
8
+ test/svn_wc_test.rb
data/README.rdoc ADDED
@@ -0,0 +1,312 @@
1
+ = SvnWc::RepoAccess
2
+
3
+ Operate on the working copy of a (remote) Subversion (svn) repository.
4
+
5
+
6
+ == VERSION:
7
+
8
+ Version 0.0.1
9
+
10
+
11
+ == SYNOPSIS:
12
+ ruby code
13
+
14
+ require 'svn_wc'
15
+
16
+ # assumes a previous initial checkout
17
+ svn_wc = SvnWc::RepoAccess.new
18
+
19
+ svn_wc.set_conf 'svn_wc_conf.yaml'
20
+
21
+ # checkout, needed first time only,
22
+ # 'true', force overwrite of working copy directory path
23
+ #svn_wc.do_checkout true
24
+
25
+ file = Tempfile.new('test_', svn_wc.svn_repo_working_copy).path
26
+ begin
27
+ svn_wc.add file
28
+ puts "svn Added file: #{file}"
29
+ rev = svn_wc.commit file
30
+ raise 'commit failed' unless rev >= 1
31
+ puts "svn committed file: #{file}, revision #{rev}"
32
+ svn_wc.delete file
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
37
+ rescue SvnWc::RepoAccessError, Exception => e
38
+ raise e.message
39
+ end
40
+
41
+
42
+ == DESCRIPTION:
43
+
44
+ This library is designed to operate on a working copy (on the local file system) of a remote Subversion repository.
45
+
46
+ Currently, it provides very basic svn functions (see FEATURES) driven programmatically.
47
+ It uses the Subversion Ruby Bindings to utilize/expose their functionality in a simplified way.
48
+
49
+ It does not do any sort of repository administration type operations, just working directory repository management.
50
+
51
+
52
+ == FEATURES:
53
+
54
+ * Programatic access to the following:
55
+
56
+ * Current supported operations
57
+ - open
58
+ - checkout/co
59
+ - list/ls
60
+ - update/up
61
+ - commit/ci
62
+ - status/stat
63
+ - diff
64
+ - info
65
+ - add
66
+ - revert
67
+ - delete
68
+ - svn+ssh is our primary connection use case, however can connect to, and operate on a (local) file:/// URI as well
69
+
70
+
71
+ == REQUIREMENTS:
72
+
73
+ * Requires that the Subversion (SWIG) Ruby Bindings are installed.
74
+ (which could be as easy as)
75
+ Linux
76
+ Redhat and Fedora: yum install subversion-ruby
77
+ Ubuntu and Debian: apt-get install libsvn-ruby
78
+ OS X
79
+ sudo port install subversion-rubybindings
80
+ Windows
81
+ unknown,...
82
+
83
+ * Ruby 1.8.6 (not tested with previous, or later versions, should work anywhere the ruby bindings are installed)
84
+
85
+ == INSTALL:
86
+
87
+ This library is intended to be installed as a Gem. (hosted on gemcutter.org)
88
+ ($ gem source -a http://gemcutter.org - no longer needed)
89
+
90
+ $ gem install svn_wc
91
+
92
+
93
+ == OVERVIEW:
94
+
95
+ This library was written to be the back end for a web app GUI front end. (Currently in progress)
96
+
97
+ This serverfault post describes what I was looking for and what I am trying to satisfy with the (Front End) Application:
98
+
99
+ "I want a web interface to manage a WORKING COPY of a repository (NOT the repository itself).
100
+ There are lots of already made tools to manage the repository, but I also have not found a
101
+ single one to manage a remote working copy. I need a user-friendly interface to perform stuff like:
102
+ "svn status", "svn info", "svn commit", "svn update", "svn revert",
103
+ "svn add", "svn delete" and "svn diff"... upon a WORKING COPY which resides
104
+ in a remote host. (I'm not interested in the repository, I'm interested in the WORKING COPY
105
+ management.)
106
+ I don't want to do SSH login and perform these commands. I want to enable
107
+ not-advanced users to do some stuff in the hosted working copy, using a
108
+ web interface,...
109
+
110
+ * {serverfault link}[http://serverfault.com/questions/52532/svn-web-interface/67788#67788]
111
+
112
+ == USAGE:
113
+
114
+ Provide the svn connection info upon initializaion.
115
+ (One can also provide the path to a conf file. See 'svn_wc_conf.yaml')
116
+
117
+ ruby code
118
+ require 'svn_wc'
119
+
120
+ yconf = Hash.new
121
+ yconf['svn_user'] = 'test_user'
122
+ yconf['svn_pass'] = 'test_pass'
123
+ yconf['svn_repo_master'] = 'svn+ssh://www.example.com/svn_repository'
124
+ yconf['svn_repo_working_copy'] = '/opt/svn_repo'
125
+
126
+ # 'do_checkout' is only needed until the local repository exists. (i.e. usually first time run only)
127
+ # 'force' will plow over anything that may exist at the path.
128
+ # i.e. if you ask for a do_checkout without force and the local repo exists, the call will fail
129
+
130
+ svn = SvnWc::RepoAccess.new(YAML::dump(yconf), do_checkout=true, force=true)
131
+
132
+ puts svn.svn_repo_master # 'svn+ssh://www.example.com/svn_repository'
133
+ puts svn.svn_user # 'test_user'
134
+ puts svn.svn_pass # 'test_pass'
135
+ puts svn.svn_repo_working_copy # '/opt/svn_repo'
136
+
137
+ info = svn.info # another way
138
+ puts info[:root_url] # 'svn+ssh://www.example.com/svn_repository'
139
+
140
+ file = Tempfile.new('tmp', svn.svn_repo_working_copy).path
141
+ begin
142
+ svn.info(file)
143
+ # SvnWc::RepoAccess' generic exeception class (the only one, raised for all exceptions)
144
+ rescue SvnWc::RepoAccessError => e
145
+ puts e.message.match(/is not under version control/)
146
+ end
147
+
148
+ svn.add file
149
+
150
+ puts svn.commit file # returns the revision number of the commit
151
+
152
+ puts svn.status file # ' ' empty string, file is current
153
+
154
+ File.open(file, 'a') {|f| f.write('adding this to file.')}
155
+
156
+ puts svn.status(file)[0][:status] # 'M' (modified)
157
+ # or, whole repo, multiple entries
158
+ svn_wc.status.each do |entries|
159
+ puts "#{entries[:status]}\t#{entries[:path]}"
160
+ end
161
+
162
+ puts svn.info(file)[:rev] # current revision of file
163
+ svn_wc.info(file).each_key do |entries|
164
+ puts entries[:rev]
165
+ puts entries[:last_changed_author]
166
+ puts entries[:last_changed_rev]
167
+ end
168
+
169
+ puts svn.diff(file) # =~ 'adding this to file.'
170
+
171
+ svn.revert file
172
+ svn.commit file # -1 i.e commit failed, file is current
173
+
174
+ svn.delete file
175
+ svn.commit file # must commit our delete
176
+
177
+ (In general, the above operations also accept a list (array) in place of a single file)
178
+
179
+
180
+ See test/* for more examples.
181
+
182
+
183
+ == DIAGNOSTICS
184
+
185
+ * An exception such as
186
+ SvnWc::RepoAccessError =>
187
+ 'Add Failed: /tmp/buildd/subversion-1.6.3dfsg/subversion/libsvn_wc/lock.c:572:
188
+ Svn::Error::WcNotDirectory: '/path/to/repository' is not a working copy (RuntimeError)'
189
+
190
+ means there is no working directory where you have specified there is one,
191
+ you need to do a 'do_checkout'
192
+ i.e. svn = SvnWc::RepoAccess.new('conf.yaml', do_checkout=true, force=true)
193
+
194
+ * All the exceptions received using this module should be SvnWc::RepoAccessError
195
+ which produce a (hopefully helpful) message, which is usually just the underlying
196
+ exception returned from the Ruby SWIG library
197
+
198
+
199
+ == CONFIGURATION AND ENVIRONMENT:
200
+
201
+ * In order to make use of this module, one must provide connection information for svn
202
+
203
+ One can provide this as a hash at Runtime, or as a configuration file:
204
+
205
+ # conf file (YAML)
206
+ $ cat svnwc_conf.yaml
207
+ # svn connection info
208
+ #svn_repo_master : file:///tmp/svnrepo
209
+ svn_repo_master : svn+ssh://example.com/opt/svnrepo
210
+ svn_repo_working_copy : /usr/local/svn/repo_root
211
+ svn_user : svn_test_user
212
+ svn_pass : svn_test_pass
213
+ svn_repo_config_path : /opt/config
214
+
215
+ # conf info
216
+ yconf = Hash.new
217
+ yconf['svn_user'] = 'test_user'
218
+ yconf['svn_pass'] = 'test_pass'
219
+ yconf['svn_repo_master'] = 'svn+ssh://www.example.com/svn_repository'
220
+ yconf['svn_repo_working_copy'] = '/opt/svn_repo'
221
+
222
+ svn = SvnWc::RepoAccess.new YAML::dump(yconf)
223
+
224
+ * This library should work anywhere that the 'subversion-rubybindings' are installed
225
+ (.*NIX systems,...)
226
+
227
+
228
+ == DEPENDENCIES:
229
+
230
+ require 'yaml'
231
+ require 'pathname'
232
+ require 'find'
233
+ require 'svn/core'
234
+ require 'svn/client'
235
+ require 'svn/wc'
236
+ require 'svn/repos'
237
+ require 'svn/info'
238
+ require 'svn/error'
239
+
240
+
241
+ == INCOMPATIBILITIES:
242
+
243
+ none known of
244
+
245
+
246
+ == BUGS AND LIMITATIONS:
247
+
248
+ This library currently provides only very basic svn operations, more work is
249
+ needed if more functionality is desired. i.e. propset/propget, specific
250
+ revisions operations, etc
251
+
252
+
253
+ == SUPPORT:
254
+
255
+ ri 'svn_wc'
256
+
257
+ * {svn_wc general page}[http://www.dwright.us/misc/svn_wc]
258
+
259
+
260
+ == CHANGELOG:
261
+
262
+ See the ChangeLog file for details.
263
+
264
+
265
+ == LICENSE AND COPYRIGHT:
266
+
267
+ Copyright 2009 David Wright (david_v_wright@yahoo.com), all rights reserved.
268
+
269
+
270
+ SvnWc::RepoAccess 0.1.0 is released under the LGPL license.
271
+
272
+
273
+ == AUTHOR:
274
+
275
+ Author:: {David Wright}[http://www.dwright.us/] <david_v_wright@yahoo.com>
276
+
277
+
278
+ === KEYWORDS:
279
+
280
+ * Ruby (SWIG) SVN bindings, ruby+svn, ruby, subversion, svn, rubysvn, Subversion extensions in Ruby
281
+
282
+
283
+ == ACKNOWLEDGEMENTS:
284
+
285
+ * Much of this code was guided from reading the {SVN Ruby Bindings unit tests}[https://svn.collab.net/repos/svn/trunk/subversion/bindings/swig/ruby/test/]
286
+
287
+ * {Doxygen Docs}[http://svn.collab.net/svn-doxygen/search.php?query=svn_wc_entry]
288
+ Ruby -> Svn::Wc::Entry
289
+ Doxygen Docs -> svn_wc_entry
290
+
291
+ * The Doxyogen Modules {docs}[http://svn.collab.net/svn-doxygen/modules.html]
292
+
293
+ * Tim Coulter did some work with the {Ruby bindings as well}[http://www.oneofthewolves.com/svn_repos/svn_repos.rb]
294
+
295
+ * "Perl Best Practices" (Conway), module documentation guidelines.
296
+
297
+
298
+ === ERRATA:
299
+
300
+ * There is no Ruby specific documentation on the Ruby Bindings SWIG library, there are the Doxygen docs only.
301
+
302
+ * Explanation/Intention
303
+ My use case scenario is a svn working copy on the local file system
304
+ communicating with a remote SVN repository, as such, I can not make use of any
305
+ of the 'Svn::Fs' module functionality, which is unfortunate. Mainly, I rely
306
+ on the 'Svn::wc' module.
307
+
308
+ My aim was to make this work similarly to what I'm used to in the CLI
309
+ version, as far as commands and the responses to commands.
310
+
311
+ Hopefully, this library, or at least some of the code is useful to someone.
312
+