Class: DmSvn::Svn::Sync
- Inherits:
-
Object
- Object
- DmSvn::Svn::Sync
- Defined in:
- lib/dm-svn/svn/sync.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#repos ⇒ Object
readonly
Returns the value of attribute repos.
Instance Method Summary collapse
-
#changesets ⇒ Object
Get changesets.
-
#initialize(model_row) ⇒ Sync
constructor
A new instance of Sync.
-
#run ⇒ Object
There is the possibility for uneccessary updates, as a database row may be modified several times (if modified in multiple revisions) in a single call.
Constructor Details
#initialize(model_row) ⇒ Sync
Returns a new instance of Sync.
7 8 9 10 11 |
# File 'lib/dm-svn/svn/sync.rb', line 7 def initialize(model_row) @model_row = model_row @model = Object.const_get(@model_row.name) @config = @model_row.config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/dm-svn/svn/sync.rb', line 5 def config @config end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/dm-svn/svn/sync.rb', line 5 def model @model end |
#repos ⇒ Object (readonly)
Returns the value of attribute repos.
5 6 7 |
# File 'lib/dm-svn/svn/sync.rb', line 5 def repos @repos end |
Instance Method Details
#changesets ⇒ Object
Get changesets
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dm-svn/svn/sync.rb', line 14 def changesets sets = [] @repos.log('', @model_row.revision, @repos.latest_revnum, 0, true, false ) do |changes, rev, , date, msg| sets << Changeset.new(changes, rev, , date, self) end sets.sort end |
#run ⇒ Object
There is the possibility for uneccessary updates, as a database row may be modified several times (if modified in multiple revisions) in a single call. This is inefficient, but–for now–not enough to justify more complex code.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dm-svn/svn/sync.rb', line 29 def run connect(@config.uri) return false if @repos.latest_revnum <= @model_row.revision changesets.each do |c| # Sorted by revision, ascending c.process # Update model_row.revision row_update = @model_row.class.get(@model_row.id) row_update.update(:revision => c.revision) end # Ensure that @model_row.revision is now set to the latest (even if there # weren't applicable changes in the latest revision). row_update = @model_row.class.get(@model_row.id) row_update.update(:revision => @repos.latest_revnum) return true end |