File indexing completed on 2024-04-28 05:42:07

0001 /*
0002  * Port for usage with qt-framework and development for kdesvn
0003  * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de)
0004  * https://kde.org/applications/development/org.kde.kdesvn
0005  */
0006 /*
0007  * ====================================================================
0008  * Copyright (c) 2002-2005 The RapidSvn Group.  All rights reserved.
0009  * dev@rapidsvn.tigris.org
0010  *
0011  * This library is free software; you can redistribute it and/or
0012  * modify it under the terms of the GNU Lesser General Public
0013  * License as published by the Free Software Foundation; either
0014  * version 2.1 of the License, or (at your option) any later version.
0015  *
0016  * This library is distributed in the hope that it will be useful,
0017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0019  * Lesser General Public License for more details.
0020  *
0021  * You should have received a copy of the GNU Lesser General Public
0022  * License along with this library (in the file LGPL.txt); if not,
0023  * write to the Free Software Foundation, Inc., 51 Franklin St,
0024  * Fifth Floor, Boston, MA  02110-1301  USA
0025  *
0026  * This software consists of voluntary contributions made by many
0027  * individuals.  For exact contribution history, see the revision
0028  * history and logs, available at http://rapidsvn.tigris.org/.
0029  * ====================================================================
0030  */
0031 
0032 // svncpp
0033 #include "client_annotate_parameter.h"
0034 #include "client_impl.h"
0035 #include "helper.h"
0036 #include "svnqt_defines.h"
0037 
0038 // Subversion api
0039 #include <svn_client.h>
0040 
0041 namespace svn
0042 {
0043 static svn_error_t *annotateReceiver(void *baton,
0044                                      svn_revnum_t start_revnum,
0045                                      svn_revnum_t end_revnum,
0046                                      apr_int64_t line_no,
0047                                      svn_revnum_t revision,
0048                                      apr_hash_t *rev_props,
0049                                      svn_revnum_t merge_revision,
0050                                      apr_hash_t *merged_rev_props,
0051                                      const char *merge_path,
0052                                      const char *line,
0053                                      svn_boolean_t local_change,
0054                                      apr_pool_t *pool)
0055 {
0056     AnnotatedFile *entries = (AnnotatedFile *)baton;
0057     PropertiesMap _map = svn::internal::Hash2Map(rev_props, pool);
0058     PropertiesMap _merge_map = svn::internal::Hash2Map(merged_rev_props, pool);
0059     entries->push_back(AnnotateLine(line_no, revision, _map, line, merge_revision, _merge_map, merge_path, start_revnum, end_revnum, local_change));
0060     return nullptr;
0061 }
0062 
0063 void Client_impl::annotate(AnnotatedFile &target, const AnnotateParameter &params)
0064 {
0065     Pool pool;
0066     svn_error_t *error;
0067     error = svn_client_blame5(params.path().cstr(),
0068                               params.pegRevision().revision(),
0069                               params.revisionRange().first,
0070                               params.revisionRange().second,
0071                               params.diffOptions().options(pool),
0072                               params.ignoreMimeTypes(),
0073                               params.includeMerged(),
0074                               annotateReceiver,
0075                               &target,
0076                               *m_context, // client ctx
0077                               pool);
0078     if (error != nullptr) {
0079         throw ClientException(error);
0080     }
0081 }
0082 }