File indexing completed on 2024-06-02 04:44:34

0001 /*
0002  * ====================================================================
0003  * Copyright (c) 2002-2009 The RapidSvn Group.  All rights reserved.
0004  *
0005  * This program is free software: you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation, either version 3 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program (in the file GPL.txt.  
0017  * If not, see <http://www.gnu.org/licenses/>.
0018  *
0019  * This software consists of voluntary contributions made by many
0020  * individuals.  For exact contribution history, see the revision
0021  * history and logs, available at http://rapidsvn.tigris.org/.
0022  * ====================================================================
0023  */
0024 #if defined( _MSC_VER) && _MSC_VER <= 1200
0025 #pragma warning( disable: 4786 )// debug symbol truncated
0026 #endif
0027 
0028 // Subversion api
0029 #include "svn_client.h"
0030 
0031 // svncpp
0032 #include "kdevsvncpp/client.hpp"
0033 
0034 
0035 namespace svn
0036 {
0037   static svn_error_t *
0038   annotateReceiver(void *baton,
0039                    apr_int64_t line_no,
0040                    svn_revnum_t revision,
0041                    const char *author,
0042                    const char *date,
0043                    const char *line,
0044                    apr_pool_t * /*pool*/)
0045   {
0046     AnnotatedFile * entries = (AnnotatedFile *) baton;
0047     entries->push_back(
0048       AnnotateLine(line_no, revision,
0049                    author?author:"unknown",
0050                    date?date:"unknown date",
0051                    line?line:"???"));
0052 
0053     return nullptr;
0054   }
0055 
0056   AnnotatedFile *
0057   Client::annotate(const Path & path,
0058                    const Revision & revisionStart,
0059                    const Revision & revisionEnd)
0060   {
0061     Pool pool;
0062     AnnotatedFile * entries = new AnnotatedFile;
0063     svn_error_t *error;
0064     error = svn_client_blame(
0065               path.c_str(),
0066               revisionStart.revision(),
0067               revisionEnd.revision(),
0068               annotateReceiver,
0069               entries,
0070               *m_context, // client ctx
0071               pool);
0072 
0073     if (error != nullptr)
0074     {
0075       delete entries;
0076       throw ClientException(error);
0077     }
0078 
0079     return entries;
0080   }
0081 }