| 40 | } |
| 41 | |
| 42 | void LocalPatchSource::update() |
| 43 | { |
| 44 | if( !m_command.isEmpty() ) { |
| 45 | QTemporaryFile temp(QDir::tempPath() + QLatin1String("/patchreview_XXXXXX.diff")); |
| 46 | if( temp.open() ) { |
| 47 | temp.setAutoRemove( false ); |
| 48 | QString filename = temp.fileName(); |
| 49 | qCDebug(PLUGIN_PATCHREVIEW) << "temp file: " << filename; |
| 50 | temp.close(); |
| 51 | KProcess proc; |
| 52 | proc.setWorkingDirectory( m_baseDir.toLocalFile() ); |
| 53 | proc.setOutputChannelMode( KProcess::OnlyStdoutChannel ); |
| 54 | proc.setStandardOutputFile( filename ); |
| 55 | ///Try to apply, if it works, the patch is not applied |
| 56 | proc << KShell::splitArgs( m_command ); |
| 57 | |
| 58 | qCDebug(PLUGIN_PATCHREVIEW) << "calling " << m_command; |
| 59 | |
| 60 | if ( proc.execute() ) { |
| 61 | qCWarning(PLUGIN_PATCHREVIEW) << "returned with bad exit code"; |
| 62 | return; |
| 63 | } |
| 64 | if ( !m_filename.isEmpty() ) { |
| 65 | QFile::remove( m_filename.toLocalFile() ); |
| 66 | } |
| 67 | m_filename = QUrl::fromLocalFile( filename ); |
| 68 | qCDebug(PLUGIN_PATCHREVIEW) << "success, diff: " << m_filename; |
| 69 | }else{ |
| 70 | qCWarning(PLUGIN_PATCHREVIEW) << "PROBLEM"; |
| 71 | } |
| 72 | } |
| 73 | if (m_widget) { |
| 74 | m_widget->updatePatchFromEdit(); |
| 75 | } |
| 76 | emit patchChanged(); |
| 77 | } |
| 78 | |
| 79 | void LocalPatchSource::createWidget() |
| 80 | { |
no test coverage detected