File indexing completed on 2024-05-12 17:16:24
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 * http://kdesvn.alwins-world.de 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 // svncpp 0032 #include "log_entry.h" 0033 #include "pool.h" 0034 #include "stringarray.h" 0035 #include "helper.h" 0036 0037 // subversion api 0038 #include "svn_time.h" 0039 #include "svn_compat.h" 0040 0041 #include <QDataStream> 0042 0043 namespace svn 0044 { 0045 0046 LogEntry::LogEntry() 0047 : revision(-1), date(0) 0048 { 0049 } 0050 0051 LogEntry::LogEntry(svn_log_entry_t *log_entry, const StringArray &excludeList) 0052 : revision(-1), date(0) 0053 { 0054 Pool pool; 0055 const char *author_ = nullptr; 0056 const char *date_ = nullptr; 0057 const char *message_ = nullptr; 0058 svn_compat_log_revprops_out(&author_, &date_, &message_, log_entry->revprops); 0059 0060 author = author_ == nullptr ? QString() : QString::fromUtf8(author_); 0061 message = message_ == nullptr ? QString() : QString::fromUtf8(message_); 0062 apr_time_t apr_time = 0; 0063 if (date_) { 0064 svn_error_t *err = svn_time_from_cstring(&apr_time, date_, pool); 0065 svn_error_clear(err); // clear possible error 0066 } 0067 date = apr_time; 0068 revision = log_entry->revision; 0069 if (log_entry->changed_paths2) { 0070 bool blocked = false; 0071 for (apr_hash_index_t *hi = apr_hash_first(pool, log_entry->changed_paths2); 0072 hi != nullptr; 0073 hi = apr_hash_next(hi)) { 0074 const void *pv; 0075 void *val; 0076 blocked = false; 0077 apr_hash_this(hi, &pv, nullptr, &val); 0078 svn_log_changed_path2_t *log_item = reinterpret_cast<svn_log_changed_path2_t *>(val); 0079 const char *path = reinterpret_cast<const char *>(pv); 0080 QString _p(QString::fromUtf8(path)); 0081 for (int _exnr = 0; _exnr < excludeList.size(); ++_exnr) { 0082 if (_p.startsWith(excludeList[_exnr])) { 0083 blocked = true; 0084 break; 0085 } 0086 } 0087 if (!blocked) { 0088 changedPaths.push_back(LogChangePathEntry(_p, 0089 log_item->action, 0090 QString::fromUtf8(log_item->copyfrom_path), 0091 log_item->copyfrom_rev)); 0092 } 0093 } 0094 } 0095 } 0096 } 0097 0098 0099 SVNQT_EXPORT QDataStream &operator<<(QDataStream &s, const svn::LogEntry &r) 0100 { 0101 s << r.revision 0102 << r.author 0103 << r.message 0104 << r.changedPaths 0105 << r.date; 0106 return s; 0107 } 0108 0109 SVNQT_EXPORT QDataStream &operator<<(QDataStream &s, const svn::LogChangePathEntry &r) 0110 { 0111 short ac = r.action; 0112 s << r.path 0113 << ac 0114 << r.copyFromPath 0115 << r.copyFromRevision 0116 << r.copyToPath 0117 << r.copyToRevision; 0118 return s; 0119 } 0120 0121 SVNQT_EXPORT QDataStream &operator>>(QDataStream &s, svn::LogEntry &r) 0122 { 0123 s >> r.revision 0124 >> r.author 0125 >> r.message 0126 >> r.changedPaths 0127 >> r.date; 0128 return s; 0129 } 0130 0131 SVNQT_EXPORT QDataStream &operator>>(QDataStream &s, svn::LogChangePathEntry &r) 0132 { 0133 short ac; 0134 s >> r.path 0135 >> ac 0136 >> r.copyFromPath 0137 >> r.copyFromRevision 0138 >> r.copyToPath 0139 >> r.copyToRevision; 0140 r.action = ac; 0141 return s; 0142 }