示例#1
0
void
StateReporter::setPath(jstring jpath, jlong jrevision, jobject jdepth,
                       jboolean jstart_empty, jstring jlock_token)
{
  //DEBUG:fprintf(stderr, "  (n) StateReporter::setPath()\n");

  if (!m_valid) { throw_reporter_inactive(); return; }

  JNIStringHolder lock_token(jlock_token);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN::Pool subPool(pool);
  Relpath path(jpath, subPool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  svn_depth_t depth = EnumMapper::toDepth(jdepth);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN_JNI_ERR(m_raw_reporter->set_path(m_report_baton, path.c_str(),
                                       svn_revnum_t(jrevision), depth,
                                       bool(jstart_empty), lock_token.c_str(),
                                       subPool.getPool()),);
}
示例#2
0
void CommitEditor::alterFile(jstring jrelpath, jlong jrevision,
                             jobject jchecksum, jobject jcontents,
                             jobject jproperties)
{
  if (!m_valid) { throw_editor_inactive(); return; }
  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);

  InputStream contents(jcontents);
  PropertyTable properties(jproperties, true, false);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN::Pool subPool(pool);
  Relpath relpath(jrelpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(relpath.error_occurred(),);

  svn_checksum_t checksum = build_checksum(jchecksum, subPool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(svn_editor_alter_file(
                  m_editor, relpath.c_str(), svn_revnum_t(jrevision),
                  (jcontents ? &checksum : NULL),
                  (jcontents ? contents.getStream(subPool) : NULL),
                  properties.hash(subPool)),);
}
示例#3
0
void CommitEditor::addDirectory(jstring jrelpath,
                                jobject jchildren, jobject jproperties,
                                jlong jreplaces_revision)
{
  if (!m_valid) { throw_editor_inactive(); return; }
  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);

  Iterator children(jchildren);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  PropertyTable properties(jproperties, true, true);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN::Pool subPool(pool);
  Relpath relpath(jrelpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(relpath.error_occurred(),);

  SVN_JNI_ERR(svn_editor_add_directory(m_editor, relpath.c_str(),
                                       build_children(children, subPool),
                                       properties.hash(subPool),
                                       svn_revnum_t(jreplaces_revision)),);
}
示例#4
0
void
StateReporter::abortReport()
{
  //DEBUG:fprintf(stderr, "  (n) StateReporter::abortReport()\n");

  if (!m_valid) { throw_reporter_inactive(); return; }

  SVN::Pool subPool(pool);
  SVN_JNI_ERR(m_raw_reporter->abort_report(m_report_baton,
                                           subPool.getPool()),);
  m_valid = false;
}
示例#5
0
jlong
StateReporter::finishReport()
{
  //DEBUG:fprintf(stderr, "  (n) StateReporter::finishReport()\n");

  if (!m_valid) { throw_reporter_inactive(); return SVN_INVALID_REVNUM; }

  SVN::Pool subPool(pool);
  SVN_JNI_ERR(m_raw_reporter->finish_report(m_report_baton,
                                            subPool.getPool()),
              SVN_INVALID_REVNUM);
  m_valid = false;
  return jlong(m_target_revision);
}
示例#6
0
void CommitEditor::remove(jstring jrelpath, jlong jrevision)
{
  if (!m_valid) { throw_editor_inactive(); return; }
  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);

  SVN::Pool subPool(pool);
  Relpath relpath(jrelpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(relpath.error_occurred(),);

  SVN_JNI_ERR(svn_editor_delete(m_editor, relpath.c_str(),
                                svn_revnum_t(jrevision)),);
}
示例#7
0
CommitEditor::CommitEditor(RemoteSession* session,
                           jobject jrevprops, jobject jcommit_callback,
                           jobject jlock_tokens, jboolean jkeep_locks,
                           jobject jget_base_cb, jobject jget_props_cb,
                           jobject jget_kind_cb)

  : m_valid(false),
    m_callback(jcommit_callback),
    m_session(session),
    m_editor(NULL),
    m_get_base_cb(Java::Env(), jget_base_cb),
    m_get_props_cb(Java::Env(), jget_props_cb),
    m_get_kind_cb(Java::Env(), jget_kind_cb),
    m_callback_session(NULL),
    m_callback_session_url(NULL),
    m_callback_session_uuid(NULL)
{
  // Store the repository root identity from the current session as we
  // may need it to open another session in get_copysrc_kind_cb.
  SVN_JNI_ERR(svn_ra_get_repos_root2(session->m_session,
                                     &m_callback_session_url,
                                     pool.getPool()),);
  SVN_JNI_ERR(svn_ra_get_uuid2(session->m_session,
                               &m_callback_session_uuid,
                               pool.getPool()),);

  PropertyTable revprops(jrevprops, true, true);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  LockTokenTable lock_tokens(jlock_tokens);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN::Pool subPool(pool);
  SVN_JNI_ERR(svn_ra__get_commit_ev2(
                  &m_editor,
                  session->m_session,
                  revprops.hash(subPool),
                  m_callback.callback, &m_callback,
                  lock_tokens.hash(subPool, true),
                  bool(jkeep_locks),
                  this->provide_base_cb,
                  this->provide_props_cb,
                  this->get_copysrc_kind_cb, this,
                  pool.getPool(),     // result pool
                  subPool.getPool()), // scratch pool
              );
  m_valid = true;
}
示例#8
0
void
StateReporter::deletePath(jstring jpath)
{
  //DEBUG:fprintf(stderr, "  (n) StateReporter::deletePath()\n");

  if (!m_valid) { throw_reporter_inactive(); return; }

  SVN::Pool subPool(pool);
  Relpath path(jpath, subPool);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  SVN_JNI_ERR(m_raw_reporter->delete_path(m_report_baton, path.c_str(),
                                          subPool.getPool()),);
}
示例#9
0
void CommitEditor::addAbsent(jstring jrelpath, jobject jkind,
                             jlong jreplaces_revision)
{
  if (!m_valid) { throw_editor_inactive(); return; }
  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);

  SVN::Pool subPool(pool);
  Relpath relpath(jrelpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(relpath.error_occurred(),);

  SVN_JNI_ERR(svn_editor_add_absent(m_editor, relpath.c_str(),
                                    EnumMapper::toNodeKind(jkind),
                                    svn_revnum_t(jreplaces_revision)),);
}
示例#10
0
void CommitEditor::copy(jstring jsrc_relpath, jlong jsrc_revision,
                        jstring jdst_relpath, jlong jreplaces_revision)
{
  if (!m_valid) { throw_editor_inactive(); return; }
  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);

  SVN::Pool subPool(pool);
  Relpath src_relpath(jsrc_relpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(src_relpath.error_occurred(),);
  Relpath dst_relpath(jdst_relpath, subPool);
  if (JNIUtil::isExceptionThrown())
    return;
  SVN_JNI_ERR(dst_relpath.error_occurred(),);

  SVN_JNI_ERR(svn_editor_copy(m_editor,
                              src_relpath.c_str(),
                              svn_revnum_t(jsrc_revision),
                              dst_relpath.c_str(),
                              svn_revnum_t(jreplaces_revision)),);
}
示例#11
0
bool
CCachedDirectory::SvnUpdateMembersStatus()
{
    if (InterlockedExchange(&m_FetchingStatus, TRUE))
        return false;

    svn_opt_revision_t revision;
    revision.kind = svn_opt_revision_unspecified;

    SVNPool subPool(CSVNStatusCache::Instance().m_svnHelp.Pool());
    CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": stat for %s\n"), m_directoryPath.GetWinPath());

    const char * svnapipath = m_directoryPath.GetSVNApiPath(subPool);
    if ((svnapipath == 0)||(svnapipath[0] == 0))
    {
        InterlockedExchange(&m_FetchingStatus, FALSE);
        m_currentFullStatus = m_mostImportantFileStatus = svn_wc_status_none;
        CSVNStatusCache::Instance().BlockPath(m_directoryPath, true, 5);
        return false;
    }
    m_pCtx = CSVNStatusCache::Instance().m_svnHelp.ClientContext(subPool);
    svn_error_t * pErr = nullptr;
    if (m_pCtx)
    {
        pErr = svn_client_status5 (
                                   NULL,
                                   m_pCtx,
                                   svnapipath,
                                   &revision,
                                   svn_depth_immediates,
                                   TRUE,       // get all
                                   FALSE,      // update
                                   TRUE,       // no ignores
                                   FALSE,      // ignore externals
                                   TRUE,       // depth as sticky
                                   NULL,       // changelists
                                   GetStatusCallback,
                                   this,
                                   subPool
                                   );

        svn_wc_context_destroy(m_pCtx->wc_ctx);
        m_pCtx->wc_ctx = NULL;
        m_pCtx = NULL;
    }
    else
    {
        CTraceToOutputDebugString::Instance()(__FUNCTION__ ": error creating client context!\n");
        m_currentFullStatus = m_mostImportantFileStatus = svn_wc_status_none;
        // Since we only assume a none status here due to the fact that we couldn't get a client context,
        // make sure that this status times out soon.
        CSVNStatusCache::Instance().m_folderCrawler.BlockPath(m_directoryPath, 20);
        CSVNStatusCache::Instance().AddFolderForCrawling(m_directoryPath);
    }
    InterlockedExchange(&m_FetchingStatus, FALSE);
    if (pErr)
    {
        // Handle an error
        // The most likely error on a folder is that it's not part of a WC
        // In most circumstances, this will have been caught earlier,
        // but in some situations, we'll get this error.
        // If we allow ourselves to fall on through, then folders will be asked
        // for their own status, and will set themselves as unversioned, for the
        // benefit of future requests
        CTraceToOutputDebugString::Instance()(__FUNCTION__ ": svn_cli_stat error '%s'\n", pErr->message);
        // No assert here! Since we _can_ get here, an assertion is not an option!
        // Reasons to get here:
        // - renaming a folder with many sub folders --> results in "not a working copy" if the revert
        //   happens between our checks and the svn_client_status() call.
        // - reverting a move/copy --> results in "not a working copy" (as above)
        switch (pErr->apr_err)
        {
        case SVN_ERR_WC_NOT_WORKING_COPY:
            {
                m_currentFullStatus = m_mostImportantFileStatus = svn_wc_status_none;
                CSVNStatusCache::Instance().BlockPath(m_directoryPath, true);
            }
            break;
        case SVN_ERR_WC_PATH_NOT_FOUND:
        case SVN_ERR_WC_NOT_FILE:
        case SVN_ERR_WC_CORRUPT:
        case SVN_ERR_WC_CORRUPT_TEXT_BASE:
        case SVN_ERR_WC_UNSUPPORTED_FORMAT:
        case SVN_ERR_WC_DB_ERROR:
        case SVN_ERR_WC_MISSING:
        case SVN_ERR_WC_PATH_UNEXPECTED_STATUS:
        case SVN_ERR_WC_UPGRADE_REQUIRED:
        case SVN_ERR_WC_CLEANUP_REQUIRED:
            {
                m_currentFullStatus = m_mostImportantFileStatus = svn_wc_status_none;
            }
            break;
        default:
            {
                // Since we only assume a none status here due to svn_client_status()
                // returning an error, make sure that this status times out soon.
                CSVNStatusCache::Instance().m_folderCrawler.BlockPath(m_directoryPath, 20);
                CSVNStatusCache::Instance().AddFolderForCrawling(m_directoryPath);
            }
            break;
        }
        svn_error_clear(pErr);

        return false;
    }

    RefreshMostImportant(false);
    return true;
}