lib/rim/upload_module_helper.rb
def get_branches_and_revision_infos(src_session, dest_session, parent_sha1, sha1s)
    infos = []
    branches = []
    dest_parent_sha1 = nil
    (sha1s.size() - 1).step(0, -1) do |i|
      info = get_revision_info(src_session, dest_session, sha1s[i])
      if !info.dest_sha1 && info.rim_info.target_revision
        infos.unshift(info)
        branches.push(info.rim_info.target_revision) if !branches.include?(info.rim_info.target_revision)
      else
        dest_parent_sha1 = info.dest_sha1
        break
      end
    end
    dest_parent_sha1 = get_riminfo_for_revision(src_session, parent_sha1).revision_sha1 if !dest_parent_sha1
    dest_parent_sha1 = infos.first.rim_info.revision_sha1 if !dest_parent_sha1 && !infos.empty?
    return Struct.new(:branches, :parent_sha1, :rev_infos).new(branches, dest_parent_sha1, infos)      
  end
def get_branches_and_revision_infos(src_session, dest_session, parent_sha1, sha1s)
    infos = []
    branches = []
    dest_parent_sha1 = nil
    (sha1s.size() - 1).step(0, -1) do |i|
      info = get_revision_info(src_session, dest_session, sha1s[i])
      if !info.dest_sha1 && info.rim_info.target_revision
        infos.unshift(info)
        branches.push(info.rim_info.target_revision) if !branches.include?(info.rim_info.target_revision)
      else
        dest_parent_sha1 = info.dest_sha1
        break
      end
    end
    dest_parent_sha1 = get_riminfo_for_revision(src_session, parent_sha1).revision_sha1 if !dest_parent_sha1
    dest_parent_sha1 = infos.first.rim_info.revision_sha1 if !dest_parent_sha1 && !infos.empty?
    return Struct.new(:branches, :parent_sha1, :rev_infos).new(branches, dest_parent_sha1, infos)      
  end
search backwards for all revision infos