Module: SvnWc

Defined in:
lib/svn_wc.rb

Overview

This module is designed to operate on a working copy (on the local filesystem) of a remote Subversion repository.

It aims to provide (simple) client CLI type behavior, it does not do any sort of repository administration type operations, just working directory repository management.

Current supported operations:

  • open

  • checkout/co

  • list/ls

  • update/up

  • commit/ci

  • status/stat

  • diff

  • info

  • add

  • revert

  • delete

  • log info

  • propset (ignore only)

  • svn+ssh is our primary connection use case, however can connect to, and operate on a (local) file:/// URI as well

Is built on top of the SVN (SWIG) (Subversion) Ruby Bindings and requires that they be installed.

Examples

require 'svn_wc'

yconf = Hash.new
yconf['svn_user']              = 'test_user'
yconf['svn_pass']              = 'test_pass'
yconf['svn_repo_master']       = 'svn+ssh://www.example.com/svn_repository'
yconf['svn_repo_working_copy'] = '/opt/svn_repo'

svn = SvnWc::RepoAccess.new(YAML::dump(yconf), do_checkout=true, force=true)
# or, can pass path to conf file
#svn = SvnWc::RepoAccess.new(File.join(path_to_conf,'conf.yml'), do_checkout=true, force=true)

info = svn.info
puts info[:root_url]           # 'svn+ssh://www.example.com/svn_repository'

file = Tempfile.new('tmp', svn.svn_repo_working_copy).path
begin
  svn.info(file)
rescue SvnWc::RepoAccessError => e
  puts e.message.match(/is not under version control/)
end

svn.add file
puts svn.commit file               # returns the revision number of the commit
puts svn.status file               # ' ' empty string, file is current

File.open(file, 'a') {|f| f.write('adding this to file.')}
puts svn.status(file)[0][:status]  # 'M' (modified)
puts svn.info(file)[:rev]          # current revision of file

puts svn.diff(file)                # =~ 'adding this to file.'

svn.revert file                    # discard working copy changes, get current repo version
svn.commit file                    # -1 i.e commit failed, file is current

svn.delete file
svn.commit file  # must commit our delete
puts "#{file} deleted' unless File.exists? file

(In general also works with an Array of files)
See test/* for more examples.

See the README.rdoc for more

Category

Version Control System/SVN/Subversion Ruby Lib

Package

SvnWc::RepoAccess

Author

David V. Wright <[email protected]>

License

LGPL License

– TODO make sure args are what is expected for all methods TODO propset/propget,

look into:
#wc_status = infos.assoc(@wc_path).last
#assert(wc_status.text_normal?)
#assert(wc_status.entry.dir?)
#assert(wc_status.entry.normal?)
#ctx.prop_set(Svn::Core::PROP_IGNORE, file2, dir_path)

currently, propset IGNORE is enabled

TODO/Think About Delegation: (do we want to do this?)

Inherit from or mixin the svn bindings directly, so method calls
not defined here explicitly can be run againt the bindings directly
(i.e. begin ; send(svn ruby binding method signature) ; rescue)

++

Defined Under Namespace

Classes: RepoAccess, RepoAccessError