lib/damagecontrol/visitor/yaml_persister.rb in damagecontrol-0.5.0 vs lib/damagecontrol/visitor/yaml_persister.rb in damagecontrol-0.5.0.1391
- old
+ new
@@ -35,18 +35,27 @@
# Loads +prior+ number of changesets upto +last_changeset_identifier+.
# +last_changeset_identifier+ should be the dirname of the folder containing
# the last changeset.
#
def load_upto(last_changeset_identifier, prior)
+ Log.info "Loading #{prior} changesets from #{@changesets_dir} (from #{last_changeset_identifier} and down)"
last = identifiers.index(last_changeset_identifier)
changesets = RSCM::ChangeSets.new
if(last)
first = last - prior + 1
first = 0 if first < 0
identifiers[first..last].each do |identifier|
- changesets.add(YAML::load_file("#{@changesets_dir}/#{identifier.to_s}/changeset.yaml"))
+ changeset_yaml = "#{@changesets_dir}/#{identifier.to_s}/changeset.yaml"
+ Log.info "Loading changesets from #{changeset_yaml}"
+ begin
+ changesets.add(YAML::load_file(changeset_yaml))
+ rescue Exception => e
+ # Sometimes the yaml files get corrupted
+ Log.error "Error loading changesets file: #{File.expand_path(changeset_yaml)}"
+ # Todo: delete it and schedule it for re-retrieval somehow.
+ end
end
end
changesets
end