/*
* ====================================================================
* Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved.
*
* This software is licensed as described in the file LICENSE.txt,
* which you should have received as part of this distribution.
*
* This software consists of voluntary contributions made by many
* individuals. For exact contribution history, see the revision
* history and logs, available at http://rapidsvn.tigris.org/.
* ====================================================================
*/
// stl
#include <string>
// subcpp
#include "log_entry.hpp"
#include "pool.hpp"
// subversion api
#include "svn_time.h"
#include <svn_string.h>
namespace svn
{
LogEntry::ChangedPath::ChangedPath( svn_log_changed_path2_t* svnLogChangedPath )
:
m_action( LogEntry::UnknownAction ),
m_copyFromPath(),
m_copyFromRevision( 0 ),
#if ( (SVN_VER_MAJOR > 1) || ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 7)) )
m_nodeKind( svn_node_unknown ),
m_textModified( svn_tristate_unknown ),
m_propertiesModified( svn_tristate_unknown )
#else
m_nodeKind( svn_node_unknown )
#endif
{
if ( !svnLogChangedPath )
{
return;
}
m_action = static_cast< LogEntry::Action >( svnLogChangedPath->action );
if ( svnLogChangedPath->copyfrom_path )
{
m_copyFromPath = svnLogChangedPath->copyfrom_path;
}
m_copyFromRevision = svnLogChangedPath->copyfrom_rev;
m_nodeKind = svnLogChangedPath->node_kind;
#if ( (SVN_VER_MAJOR > 1) || ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 7)) )
m_propertiesModified = svnLogChangedPath->props_modified;
m_textModified = svnLogChangedPath->text_modified;
#endif
}
LogEntry::LogEntry( svn_log_entry_t* svnLogEntry )
:
m_revision( 0 ),
m_hasChildren( false ),
m_nonInheritable( false ),
m_subtractiveMerge( false )
{
if ( !svnLogEntry )
{
return;
}
m_revision = svnLogEntry->revision;
m_hasChildren = (svnLogEntry->has_children != 0);
#if ( (SVN_VER_MAJOR > 1) || ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 7)) )
m_nonInheritable = (svnLogEntry->non_inheritable != 0);
m_subtractiveMerge = (svnLogEntry->subtractive_merge != 0 );
#endif
Pool pool;
if ( svnLogEntry->revprops )
{
for ( apr_hash_index_t* revProp = apr_hash_first( pool, svnLogEntry->revprops ); revProp != NULL; revProp = apr_hash_next( revProp ) )
{
const char* key;
apr_ssize_t keySize;
svn_string_t* val;
apr_hash_this( revProp, reinterpret_cast< const void** >( &key ), &keySize, reinterpret_cast< void** >( &val ) );
m_revisionProperties[ std::string( key, keySize ) ] = std::string( val->data, val->len );
}
}
if ( svnLogEntry->changed_paths2 )
{
for ( apr_hash_index_t* changedPath = apr_hash_first( pool, svnLogEntry->changed_paths2 ); changedPath != NULL; changedPath = apr_hash_next( changedPath ) )
{
const char* key;
apr_ssize_t keySize;
svn_log_changed_path2_t* val;
apr_hash_this( changedPath, reinterpret_cast< const void** >( &key ), &keySize, reinterpret_cast< void** >( &val ) );
m_changedPaths[ std::string( key, keySize ) ] = ChangedPath( val );
}
}
}
std::string LogEntry::GetRevisionPropertyOrDefault( const std::string& name, const std::string& defaultVal ) const
{
std::map< std::string, std::string >::const_iterator property = m_revisionProperties.find( name );
if ( property != m_revisionProperties.end() )
{
return property->second;
}
return defaultVal;
}
}