Class: SvnFixture::Revision
- Inherits:
-
Object
- Object
- SvnFixture::Revision
- Defined in:
- lib/svn-fixture/revision.rb
Overview
A Revision of the Repository. It can be added via Repository#revision to a specific Repository
repo = SvnFixture::Repository.get('test') do
revision(1, 'log msg')
end
repo.commit
or specified in Repository#commit:
rev = SvnFixture::Revision.new(1, 'log msg')
SvnFixture::Repository.get('test').commit(rev)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#commit(repo) ⇒ Object
Processes the changes made in this revision.
-
#initialize(name, message = "", options = {}, &block) ⇒ Revision
constructor
Initialize a Revision (normally called by Repository#revision).
Constructor Details
#initialize(name, message = "", options = {}, &block) ⇒ Revision
Initialize a Revision (normally called by Repository#revision).
-
name
: A name of the Revision, can be given in Array to Repository#commit instead of the Revision itself. Can be a revision number, but this does not affect the actual revision number in the Subversion repository. -
message
: Log message. Defaults to empty String. -
options
:-
:author
: The Revision’s author -
:date
: The date and time of the commit -
Additional options will set revprops
-
-
Optionally accepts a block. The block, if given, is run at the time #commit is called, within the context of the root directory of the Repository, which is an instance of SvnFixture::Directory. For example:
SvnFixture::Revision.new(1, 'log msg') do dir('test') # Or any other SvnFixture::Directory instance method. end
35 36 37 38 39 40 |
# File 'lib/svn-fixture/revision.rb', line 35 def initialize(name, = "", = {}, &block) @name, @message, @block = name, , block @author = .delete(:author) @date = SvnFixture.svn_time(.delete(:date)) @revprops = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/svn-fixture/revision.rb', line 15 def name @name end |
Instance Method Details
#commit(repo) ⇒ Object
Processes the changes made in this revision. Normally these would be made in a block given to Revision.new. #commit runs that block against the root directory of the working copy. This method is usually called by Repository#commit instead of directly. Also sets Revision properties for log message and, optionally, author and date, based on arguments to .new
. If there are no changes, the commit fails and a warning to that effect.
Only argument is an instance of SvnFixture::Repository that is the Repository to which this revision is committed.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/svn-fixture/revision.rb', line 52 def commit(repo) repo.ctx.update(repo.wc_path) # Ensure everything up-to-date root = Directory.new(repo.ctx, repo.wc_path) root.instance_eval(&@block) if @block ci = repo.ctx.ci(repo.wc_path) unless ci.revision == Svn::Core::INVALID_REVNUM rev = ci.revision repo.repos.fs.set_prop('svn:log', @message, rev) if @message repo.repos.fs.set_prop('svn:author', @author, rev) if @author repo.repos.fs.set_prop('svn:date', @date, rev) if @date @revprops.each do | key, val | val = SvnFixture.svn_time(val) if val.respond_to?(:strftime) repo.repos.fs.set_prop(key.to_s, val.to_s, rev) end else puts "Warning: No change in revision #{name} (SvnFixture::Revision#commit)" end return true end |