const svn_opt_revision_range_t *RevisionRange::toRange(SVN::Pool &pool) const
{
  JNIEnv *env = JNIUtil::getEnv();

  jclass clazz = env->FindClass(JAVA_PACKAGE"/types/RevisionRange");
  if (JNIUtil::isExceptionThrown())
    return NULL;

  static jmethodID fmid = 0;
  if (fmid == 0)
    {
      fmid = env->GetMethodID(clazz, "getFromRevision",
                              "()L"JAVA_PACKAGE"/types/Revision;");
      if (JNIUtil::isJavaExceptionThrown())
        return NULL;
    }

  static jmethodID tmid = 0;
  if (tmid == 0)
    {
      tmid = env->GetMethodID(clazz, "getToRevision",
                              "()L"JAVA_PACKAGE"/types/Revision;");
      if (JNIUtil::isJavaExceptionThrown())
        return NULL;
    }

  jobject jstartRevision = env->CallObjectMethod(m_range, fmid);
  if (JNIUtil::isExceptionThrown())
    return NULL;

  Revision startRevision(jstartRevision);
  if (JNIUtil::isExceptionThrown())
    return NULL;

  jobject jendRevision = env->CallObjectMethod(m_range, tmid);
  if (JNIUtil::isExceptionThrown())
    return NULL;

  Revision endRevision(jendRevision);
  if (JNIUtil::isExceptionThrown())
    return NULL;

  svn_opt_revision_range_t *range =
    (svn_opt_revision_range_t *) apr_palloc(pool.getPool(), sizeof(*range));

  range->start = *startRevision.revision();
  if (JNIUtil::isExceptionThrown())
    return NULL;

  range->end = *endRevision.revision();
  if (JNIUtil::isExceptionThrown())
    return NULL;

  return range;
}
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_io_OutputStream_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZZ
(JNIEnv *env, jobject jthis, jstring jtarget, jobject jpegRevision,
 jobject jstartRevision, jobject jendRevision, jstring jrelativeToDir,
 jobject jstream, jobject jdepth, jobject jchangelists,
 jboolean jignoreAncestry, jboolean jnoDiffDeleted, jboolean jforce,
 jboolean jcopiesAsAdds, jboolean jignoreProps)
{
  JNIEntry(SVNClient, diff);
  SVNClient *cl = SVNClient::getCppObject(jthis);
  if (cl == NULL)
    {
      JNIUtil::throwError(_("bad C++ this"));
      return;
    }
  JNIStringHolder target(jtarget);
  if (JNIUtil::isExceptionThrown())
    return;

  Revision pegRevision(jpegRevision);
  if (JNIUtil::isExceptionThrown())
    return;

  Revision startRevision(jstartRevision);
  if (JNIUtil::isExceptionThrown())
    return;

  Revision endRevision(jendRevision);
  if (JNIUtil::isExceptionThrown())
    return;

  OutputStream dataOut(jstream);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder relativeToDir(jrelativeToDir);
  if (JNIUtil::isExceptionThrown())
    return;

  StringArray changelists(jchangelists);
  if (JNIUtil::isExceptionThrown())
    return;

  cl->diff(target, pegRevision, startRevision, endRevision, relativeToDir,
           dataOut, EnumMapper::toDepth(jdepth), changelists,
           jignoreAncestry ? true:false,
           jnoDiffDeleted ? true:false, jforce ? true:false,
           jcopiesAsAdds ? true:false, jignoreProps ? true:false);
}
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_diffSummarize__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZLorg_apache_subversion_javahl_callback_DiffSummaryCallback_2
(JNIEnv *env, jobject jthis, jstring jtarget, jobject jPegRevision,
 jobject jStartRevision, jobject jEndRevision, jobject jdepth,
 jobject jchangelists, jboolean jignoreAncestry,
 jobject jdiffSummaryReceiver)
{
  JNIEntry(SVNClient, diffSummarize);

  SVNClient *cl = SVNClient::getCppObject(jthis);
  if (cl == NULL)
    {
      JNIUtil::throwError(_("bad C++ this"));
      return;
    }
  JNIStringHolder target(jtarget);
  if (JNIUtil::isExceptionThrown())
    return;
  Revision pegRevision(jPegRevision);
  if (JNIUtil::isExceptionThrown())
    return;
  Revision startRevision(jStartRevision);
  if (JNIUtil::isExceptionThrown())
    return;
  Revision endRevision(jEndRevision);
  if (JNIUtil::isExceptionThrown())
    return;
  DiffSummaryReceiver receiver(jdiffSummaryReceiver);
  if (JNIUtil::isExceptionThrown())
    return;

  StringArray changelists(jchangelists);
  if (JNIUtil::isExceptionThrown())
    return;

  cl->diffSummarize(target, pegRevision, startRevision, endRevision,
                    EnumMapper::toDepth(jdepth), changelists,
                    jignoreAncestry ? true : false, receiver);
}
示例#4
0
void SvnInternalLogJob::run()
{
    initBeforeRun();

    SvnClient cli(m_ctxt);
    connect( &cli, SIGNAL(logEventReceived(KDevelop::VcsEvent)),
             this, SIGNAL(logEvent(KDevelop::VcsEvent)) );
    try
    {
        QByteArray ba = location().toLocalFile( KUrl::RemoveTrailingSlash ).toUtf8();
        cli.log( ba.data(),
                 createSvnCppRevisionFromVcsRevision( startRevision() ),
                 createSvnCppRevisionFromVcsRevision( endRevision() ),
                 limit() );
    }catch( svn::ClientException ce )
    {
        kDebug(9510) << "Exception while logging file: "
                << location()
                << QString::fromUtf8( ce.message() );
        setErrorMessage( QString::fromUtf8( ce.message() ) );
        m_success = false;
    }
}
示例#5
0
void SvnInternalBlameJob::run()
{
    initBeforeRun();

    QByteArray ba = location().toLocalFile( KUrl::RemoveTrailingSlash ).toUtf8();
    
    svn::Client cli(m_ctxt);
    svn::AnnotatedFile* file;
    try
    {
        file = cli.annotate( ba.data(),
                             createSvnCppRevisionFromVcsRevision( startRevision() ),
                             createSvnCppRevisionFromVcsRevision( endRevision() ) );
    }catch( svn::ClientException ce )
    {
        kDebug(9510) << "Exception while blaming file: "
                << location()
                << QString::fromUtf8( ce.message() );
        setErrorMessage( QString::fromUtf8( ce.message() ) );
        m_success = false;
        return;
    }
    svn_revnum_t minrev = -1, maxrev = -1;
    for( svn::AnnotatedFile::const_iterator it = file->begin(); it != file->end(); it++ )
    {
        if( (*it).revision() < minrev || minrev == -1 )
        {
            minrev = (*it).revision();
        }
        if( (*it).revision() > maxrev || maxrev == -1 )
        {
            maxrev = (*it).revision();
        }
    }
    QHash<svn_revnum_t,QString> commitMessages;
    try
    {
        const svn::LogEntries* entries = cli.log( ba.data(), svn::Revision(minrev), svn::Revision(maxrev), false, false );
        for( svn::LogEntries::const_iterator it = entries->begin(); it != entries->end(); it++ )
        {
            commitMessages[(*it).revision] = QString::fromUtf8( (*it).message.c_str() );
        }
    }catch( svn::ClientException ce )
    {
        kDebug(9510) << "Exception while fetching log messages for blame: "
                     << location()
                     << QString::fromUtf8( ce.message() );
        setErrorMessage( QString::fromUtf8( ce.message() ) );
        m_success = false;
    }
    for( svn::AnnotatedFile::const_iterator it = file->begin(); it != file->end(); it++ )
    {
        KDevelop::VcsAnnotationLine line;
        line.setAuthor( QString::fromUtf8( it->author().c_str() ) );
        line.setDate( QDateTime::fromString( QString::fromUtf8( it->date().c_str() ), Qt::ISODate ) );
        line.setText( QString::fromUtf8( it->line().c_str() ) );
        KDevelop::VcsRevision rev;
        rev.setRevisionValue( QVariant( qlonglong( it->revision() ) ), KDevelop::VcsRevision::GlobalNumber );
        line.setRevision( rev );
        line.setLineNumber( it->lineNumber() );
        line.setCommitMessage( commitMessages[it->revision()] );
        emit blameLine( line );
    }
}