File indexing completed on 2024-04-28 05:42:09
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or * 0006 * modify it under the terms of the GNU Lesser General Public * 0007 * License as published by the Free Software Foundation; either * 0008 * version 2.1 of the License, or (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 GNU * 0013 * Lesser General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU Lesser General Public * 0016 * License along with this program (in the file LGPL.txt); if not, * 0017 * write to the Free Software Foundation, Inc., 51 Franklin St, * 0018 * Fifth Floor, Boston, MA 02110-1301 USA * 0019 * * 0020 * This software consists of voluntary contributions made by many * 0021 * individuals. For exact contribution history, see the revision * 0022 * history and logs, available at https://commits.kde.org/kdesvn. * 0023 ***************************************************************************/ 0024 #include "commititem.h" 0025 0026 #include <svn_client.h> 0027 #include <svn_props.h> 0028 0029 namespace svn 0030 { 0031 0032 CommitItem::CommitItem(const svn_client_commit_item_t *_item) 0033 { 0034 init(); 0035 if (_item) { 0036 m_Path = QString::fromUtf8(_item->path); 0037 m_Kind = _item->kind; 0038 m_Url = QString::fromUtf8(_item->url); 0039 if (_item->state_flags & SVN_CLIENT_COMMIT_ITEM_IS_COPY) { 0040 m_CopyFromRevision = _item->revision; 0041 } else { 0042 m_Revision = _item->revision; 0043 } 0044 m_CopyFromUrl = QString::fromUtf8(_item->copyfrom_url); 0045 m_State = _item->state_flags; 0046 convertprop(_item->wcprop_changes); 0047 } 0048 } 0049 0050 CommitItem::CommitItem(const svn_client_commit_item2_t *_item) 0051 { 0052 init(); 0053 0054 if (_item) { 0055 m_Path = QString::fromUtf8(_item->path); 0056 m_Kind = _item->kind; 0057 m_Url = QString::fromUtf8(_item->url); 0058 m_Revision = _item->revision; 0059 m_CopyFromRevision = _item->copyfrom_rev; 0060 m_CopyFromUrl = QString::fromUtf8(_item->copyfrom_url); 0061 m_State = _item->state_flags; 0062 convertprop(_item->wcprop_changes); 0063 } 0064 } 0065 0066 CommitItem::CommitItem(const svn_client_commit_item3_t *_item) 0067 { 0068 init(); 0069 0070 if (_item) { 0071 m_Path = QString::fromUtf8(_item->path); 0072 m_Kind = _item->kind; 0073 m_Url = QString::fromUtf8(_item->url); 0074 m_Revision = _item->revision; 0075 m_CopyFromRevision = _item->copyfrom_rev; 0076 m_CopyFromUrl = QString::fromUtf8(_item->copyfrom_url); 0077 m_State = _item->state_flags; 0078 convertprop(_item->incoming_prop_changes); 0079 if (_item->outgoing_prop_changes) { 0080 convertprop(_item->outgoing_prop_changes); 0081 } 0082 } 0083 } 0084 0085 void CommitItem::convertprop(apr_array_header_t *list) 0086 { 0087 if (!list) { 0088 m_CommitProperties.clear(); 0089 return; 0090 } 0091 for (int j = 0; j < list->nelts; ++j) { 0092 svn_prop_t *item = ((svn_prop_t **)list->elts)[j]; 0093 if (!item) { 0094 continue; 0095 } 0096 m_CommitProperties[QString::fromUtf8(item->name)] = QString::fromUtf8(item->value->data, item->value->len); 0097 } 0098 } 0099 0100 void CommitItem::init() 0101 { 0102 m_Kind = svn_node_unknown; 0103 m_Revision = m_CopyFromRevision = -1; 0104 m_State = 0; 0105 m_CommitProperties.clear(); 0106 } 0107 0108 CommitItem::~CommitItem() 0109 { 0110 } 0111 0112 const QString &CommitItem::path() const 0113 { 0114 return m_Path; 0115 } 0116 0117 const QString &CommitItem::url() const 0118 { 0119 return m_Url; 0120 } 0121 0122 const QString &CommitItem::copyfromurl() const 0123 { 0124 return m_CopyFromUrl; 0125 } 0126 0127 const PropertiesMap &CommitItem::properties() const 0128 { 0129 return m_CommitProperties; 0130 } 0131 0132 svn_revnum_t CommitItem::revision() const 0133 { 0134 return m_Revision; 0135 } 0136 0137 svn_revnum_t CommitItem::copyfromrevision() const 0138 { 0139 return m_CopyFromRevision; 0140 } 0141 0142 svn_node_kind_t CommitItem::kind() const 0143 { 0144 return m_Kind; 0145 } 0146 0147 apr_byte_t CommitItem::state() const 0148 { 0149 return m_State; 0150 } 0151 0152 char CommitItem::actionType() const 0153 { 0154 char r = 0; 0155 if (m_State & SVN_CLIENT_COMMIT_ITEM_IS_COPY) { 0156 r = 'C'; 0157 } else if (m_State & SVN_CLIENT_COMMIT_ITEM_ADD) { 0158 r = 'A'; 0159 } else if (m_State & SVN_CLIENT_COMMIT_ITEM_DELETE) { 0160 r = 'D'; 0161 } else if (m_State & SVN_CLIENT_COMMIT_ITEM_PROP_MODS || m_State & SVN_CLIENT_COMMIT_ITEM_TEXT_MODS) { 0162 r = 'M'; 0163 } else if (m_State & SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN) { 0164 r = 'L'; 0165 } 0166 return r; 0167 } 0168 0169 }