Esempio n. 1
0
void SvnDiffJob::setDiff( const QString& diff )
{
    m_diff = KDevelop::VcsDiff();
    m_diff.setBaseDiff(KUrl("/"));
    m_diff.setType( KDevelop::VcsDiff::DiffUnified );

    m_diff.setContentType( KDevelop::VcsDiff::Text );
    m_diff.setDiff( diff );

    QRegExp fileRe("(?:^|\n)Index: ([^\n]+)\n");

    QStringList paths;
    int pos = 0;

    while( ( pos = fileRe.indexIn( diff, pos ) ) != -1 )
    {
        paths << fileRe.cap(1);
        pos += fileRe.matchedLength();
    }

    if (paths.isEmpty()) {
        internalJobDone( m_job );
        emit resultsReady( this );
        return;
    }

    foreach( const QString &s, paths )
    {
        if( !s.isEmpty() )
        {
            SvnCatJob* job = new SvnCatJob( m_part );
            KDevelop::VcsLocation l = m_job->source();
            if( l.type() == KDevelop::VcsLocation::LocalLocation )
            {
                l.setLocalUrl( KUrl( s ) );
            }else
            {
                QString repoLocation = KUrl( l.repositoryServer() ).toLocalFile( KUrl::RemoveTrailingSlash );
                QFileInfo fi( repoLocation );
                if( s == fi.fileName() )
                {
                    l.setRepositoryServer( l.repositoryServer() );
                }else
                {
                    l.setRepositoryServer( l.repositoryServer() + '/' + s );
                }
            }

            job->setSource( l );
            job->setPegRevision( m_job->pegRevision() );
            job->setSrcRevision( m_job->srcRevision() );

            m_catJobMap[job] = l;

            connect( job, SIGNAL(resultsReady(KDevelop::VcsJob*)), this, SLOT(addLeftText(KDevelop::VcsJob*)) );
            connect( job, SIGNAL(result(KJob*)), this, SLOT(removeJob(KJob*)) );

            KDevelop::ICore::self()->runController()->registerJob(job);
        }
    }
KDevelop::VcsLocation SvnImportMetadataWidget::destination() const
{
    KDevelop::VcsLocation destloc;
    QString url = m_ui->dest->text();
    if( useSourceDirForDestination ) {
        url += '/' + m_ui->srcEdit->url().fileName();
    }
    destloc.setRepositoryServer(url);
    return destloc;
}