subversionplugin.cpp 47.7 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11 12 13 14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18 19 20 21 22 23
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32 33 34 35 36 37
#include "subversionplugin.h"

#include "settingspage.h"
#include "subversioneditor.h"

#include "subversionsubmiteditor.h"
#include "subversionconstants.h"
#include "subversioncontrol.h"
38
#include "checkoutwizard.h"
con's avatar
con committed
39 40 41 42

#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
43
#include <vcsbase/vcsbaseoutputwindow.h>
con's avatar
con committed
44
#include <utils/synchronousprocess.h>
45
#include <utils/parameteraction.h>
con's avatar
con committed
46 47 48 49 50 51 52

#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/filemanager.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/uniqueidmanager.h>
53
#include <coreplugin/actionmanager/actionmanager.h>
con's avatar
con committed
54
#include <coreplugin/editormanager/editormanager.h>
Friedemann Kleint's avatar
Friedemann Kleint committed
55 56 57

#include <locator/commandlocator.h>

hjk's avatar
hjk committed
58
#include <utils/qtcassert.h>
con's avatar
con committed
59 60

#include <QtCore/QDebug>
61
#include <QtCore/QDir>
con's avatar
con committed
62 63
#include <QtCore/QFileInfo>
#include <QtCore/QTemporaryFile>
64 65
#include <QtCore/QTextCodec>
#include <QtCore/QtPlugin>
con's avatar
con committed
66
#include <QtGui/QAction>
67 68
#include <QtGui/QFileDialog>
#include <QtGui/QMainWindow>
con's avatar
con committed
69 70
#include <QtGui/QMenu>
#include <QtGui/QMessageBox>
71 72 73
#include <QtGui/QInputDialog>

#include <limits.h>
con's avatar
con committed
74 75 76

using namespace Subversion::Internal;

77 78 79 80 81 82 83 84 85
static const char * const CMD_ID_SUBVERSION_MENU    = "Subversion.Menu";
static const char * const CMD_ID_ADD                = "Subversion.Add";
static const char * const CMD_ID_DELETE_FILE        = "Subversion.Delete";
static const char * const CMD_ID_REVERT             = "Subversion.Revert";
static const char * const CMD_ID_SEPARATOR0         = "Subversion.Separator0";
static const char * const CMD_ID_DIFF_PROJECT       = "Subversion.DiffAll";
static const char * const CMD_ID_DIFF_CURRENT       = "Subversion.DiffCurrent";
static const char * const CMD_ID_SEPARATOR1         = "Subversion.Separator1";
static const char * const CMD_ID_COMMIT_ALL         = "Subversion.CommitAll";
86
static const char * const CMD_ID_REVERT_ALL         = "Subversion.RevertAll";
87 88 89 90 91
static const char * const CMD_ID_COMMIT_CURRENT     = "Subversion.CommitCurrent";
static const char * const CMD_ID_SEPARATOR2         = "Subversion.Separator2";
static const char * const CMD_ID_FILELOG_CURRENT    = "Subversion.FilelogCurrent";
static const char * const CMD_ID_ANNOTATE_CURRENT   = "Subversion.AnnotateCurrent";
static const char * const CMD_ID_SEPARATOR3         = "Subversion.Separator3";
92
static const char * const CMD_ID_SEPARATOR4         = "Subversion.Separator4";
93
static const char * const CMD_ID_STATUS             = "Subversion.Status";
94 95
static const char * const CMD_ID_PROJECTLOG         = "Subversion.ProjectLog";
static const char * const CMD_ID_REPOSITORYLOG      = "Subversion.RepositoryLog";
96 97
static const char * const CMD_ID_UPDATE             = "Subversion.Update";
static const char * const CMD_ID_DESCRIBE           = "Subversion.Describe";
con's avatar
con committed
98

99 100
static const char *nonInteractiveOptionC = "--non-interactive";

con's avatar
con committed
101 102 103
static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
{
    VCSBase::RegularCommandOutput,
104 105
    "Subversion Command Log Editor", // id
    QT_TRANSLATE_NOOP("VCS", "Subversion Command Log Editor"), // display name
106
    "Subversion Command Log Editor", // context
con's avatar
con committed
107 108 109
    "application/vnd.nokia.text.scs_svn_commandlog",
    "scslog"},
{   VCSBase::LogOutput,
110 111
    "Subversion File Log Editor",   // id
    QT_TRANSLATE_NOOP("VCS", "Subversion File Log Editor"),   // display_name
112
    "Subversion File Log Editor",   // context
con's avatar
con committed
113 114 115
    "application/vnd.nokia.text.scs_svn_filelog",
    "scsfilelog"},
{    VCSBase::AnnotateOutput,
116 117
    "Subversion Annotation Editor",  // id
    QT_TRANSLATE_NOOP("VCS", "Subversion Annotation Editor"),   // display_name
118
    "Subversion Annotation Editor",  // context
con's avatar
con committed
119 120 121
    "application/vnd.nokia.text.scs_svn_annotation",
    "scsannotate"},
{   VCSBase::DiffOutput,
122 123
    "Subversion Diff Editor",  // id
    QT_TRANSLATE_NOOP("VCS", "Subversion Diff Editor"),   // display_name
124
    "Subversion Diff Editor",  // context
con's avatar
con committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    "text/x-patch","diff"}
};

// Utility to find a parameter set by type
static inline const VCSBase::VCSBaseEditorParameters *findType(int ie)
{
    const VCSBase::EditorContentType et = static_cast<VCSBase::EditorContentType>(ie);
    return  VCSBase::VCSBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters), et);
}

static inline QString debugCodec(const QTextCodec *c)
{
    return c ? QString::fromAscii(c->name()) : QString::fromAscii("Null codec");
}

hjk's avatar
hjk committed
140
Core::IEditor* locateEditor(const char *property, const QString &entry)
con's avatar
con committed
141
{
142
    foreach (Core::IEditor *ed, Core::EditorManager::instance()->openedEditors())
con's avatar
con committed
143 144 145 146 147
        if (ed->property(property).toString() == entry)
            return ed;
    return 0;
}

148 149 150 151 152 153 154 155 156 157 158 159 160 161
// Parse "svn status" output for added/modified/deleted files
// "M<7blanks>file"
typedef QList<SubversionSubmitEditor::StatusFilePair> StatusList;

StatusList parseStatusOutput(const QString &output)
{
    StatusList changeSet;
    const QString newLine = QString(QLatin1Char('\n'));
    const QStringList list = output.split(newLine, QString::SkipEmptyParts);
    foreach (const QString &l, list) {
        const QString line =l.trimmed();
        if (line.size() > 8) {
            const QChar state = line.at(0);
            if (state == QLatin1Char('A') || state == QLatin1Char('D') || state == QLatin1Char('M')) {
162 163
                const QString fileName = line.mid(7); // Column 8 starting from svn 1.6
                changeSet.push_back(SubversionSubmitEditor::StatusFilePair(QString(state), fileName.trimmed()));
164 165 166 167 168 169 170
            }

        }
    }
    return changeSet;
}

171 172 173 174 175 176 177 178 179 180 181
// Return a list of names for the internal svn directories
static inline QStringList svnDirectories()
{
    QStringList rc(QLatin1String(".svn"));
#ifdef Q_OS_WIN
    // Option on Windows systems to avoid hassle with some IDEs
    rc.push_back(QLatin1String("_svn"));
#endif
    return rc;
}

con's avatar
con committed
182 183 184 185
// ------------- SubversionPlugin
SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0;

SubversionPlugin::SubversionPlugin() :
186
    VCSBase::VCSBasePlugin(QLatin1String(Subversion::Constants::SUBVERSIONCOMMITEDITOR_ID)),
187
    m_svnDirectories(svnDirectories()),
Friedemann Kleint's avatar
Friedemann Kleint committed
188
    m_commandLocator(0),
con's avatar
con committed
189 190 191 192 193
    m_addAction(0),
    m_deleteAction(0),
    m_revertAction(0),
    m_diffProjectAction(0),
    m_diffCurrentAction(0),
194 195
    m_logProjectAction(0),
    m_logRepositoryAction(0),
con's avatar
con committed
196
    m_commitAllAction(0),
197
    m_revertRepositoryAction(0),
con's avatar
con committed
198 199 200
    m_commitCurrentAction(0),
    m_filelogCurrentAction(0),
    m_annotateCurrentAction(0),
201
    m_statusProjectAction(0),
con's avatar
con committed
202
    m_updateProjectAction(0),
203
    m_describeAction(0),
con's avatar
con committed
204 205 206
    m_submitCurrentLogAction(0),
    m_submitDiffAction(0),
    m_submitUndoAction(0),
207
    m_submitRedoAction(0),
208
    m_menuAction(0),
209
    m_submitActionTriggered(false)
con's avatar
con committed
210 211 212 213 214
{
}

SubversionPlugin::~SubversionPlugin()
{
215
    cleanCommitMessageFile();
con's avatar
con committed
216 217
}

218
void SubversionPlugin::cleanCommitMessageFile()
con's avatar
con committed
219
{
220 221 222
    if (!m_commitMessageFileName.isEmpty()) {
        QFile::remove(m_commitMessageFileName);
        m_commitMessageFileName.clear();
223
        m_commitRepository.clear();
con's avatar
con committed
224 225 226
    }
}

227 228 229 230 231
bool SubversionPlugin::isCommitEditorOpen() const
{
    return !m_commitMessageFileName.isEmpty();
}

con's avatar
con committed
232 233
static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
    Subversion::Constants::SUBVERSION_SUBMIT_MIMETYPE,
234 235
    Subversion::Constants::SUBVERSIONCOMMITEDITOR_ID,
    Subversion::Constants::SUBVERSIONCOMMITEDITOR_DISPLAY_NAME,
236
    Subversion::Constants::SUBVERSIONCOMMITEDITOR
con's avatar
con committed
237 238
};

239 240 241 242 243 244 245 246 247 248
static inline Core::Command *createSeparator(QObject *parent,
                                             Core::ActionManager *ami,
                                             const char*id,
                                             const QList<int> &globalcontext)
{
    QAction *tmpaction = new QAction(parent);
    tmpaction->setSeparator(true);
    return ami->registerAction(tmpaction, id, globalcontext);
}

249
bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
con's avatar
con committed
250 251 252 253 254 255 256 257
{
    typedef VCSBase::VCSSubmitEditorFactory<SubversionSubmitEditor> SubversionSubmitEditorFactory;
    typedef VCSBase::VCSEditorFactory<SubversionEditor> SubversionEditorFactory;
    using namespace Constants;

    using namespace Core::Constants;
    using namespace ExtensionSystem;

258 259
    VCSBase::VCSBasePlugin::initialize(new SubversionControl(this));

con's avatar
con committed
260
    m_subversionPluginInstance = this;
hjk's avatar
hjk committed
261
    Core::ICore *core = Core::ICore::instance();
con's avatar
con committed
262

hjk's avatar
hjk committed
263
    if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage))
con's avatar
con committed
264 265
        return false;

hjk's avatar
hjk committed
266
    if (QSettings *settings = core->settings())
con's avatar
con committed
267 268
        m_settings.fromSettings(settings);

269
    addAutoReleasedObject(new SettingsPage);
con's avatar
con committed
270

271
    addAutoReleasedObject(new SubversionSubmitEditorFactory(&submitParameters));
con's avatar
con committed
272 273 274

    static const char *describeSlot = SLOT(describe(QString,QString));
    const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters);
275 276
    for (int i = 0; i < editorCount; i++)
        addAutoReleasedObject(new SubversionEditorFactory(editorParameters + i, this, describeSlot));
con's avatar
con committed
277

278 279
    addAutoReleasedObject(new CheckoutWizard);

Friedemann Kleint's avatar
Friedemann Kleint committed
280 281 282 283 284
    const QString description = QLatin1String("Subversion");
    const QString prefix = QLatin1String("svn");
    m_commandLocator = new Locator::CommandLocator(description, prefix, prefix);
    addAutoReleasedObject(m_commandLocator);

con's avatar
con committed
285
    //register actions
hjk's avatar
hjk committed
286
    Core::ActionManager *ami = core->actionManager();
287
    Core::ActionContainer *toolsContainer = ami->actionContainer(M_TOOLS);
con's avatar
con committed
288

289
    Core::ActionContainer *subversionMenu =
290
        ami->createMenu(QLatin1String(CMD_ID_SUBVERSION_MENU));
con's avatar
con committed
291 292
    subversionMenu->menu()->setTitle(tr("&Subversion"));
    toolsContainer->addMenu(subversionMenu);
293
    m_menuAction = subversionMenu->menu()->menuAction();
con's avatar
con committed
294
    QList<int> globalcontext;
hjk's avatar
hjk committed
295
    globalcontext << core->uniqueIDManager()->uniqueIdentifier(C_GLOBAL);
con's avatar
con committed
296

con's avatar
con committed
297
    Core::Command *command;
298 299 300 301

    m_diffCurrentAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_diffCurrentAction,
        CMD_ID_DIFF_CURRENT, globalcontext);
con's avatar
con committed
302
    command->setAttribute(Core::Command::CA_UpdateText);
303 304
    command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+D")));
    connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
con's avatar
con committed
305
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
306
    m_commandLocator->appendCommand(command);
con's avatar
con committed
307

308 309 310
    m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_filelogCurrentAction,
        CMD_ID_FILELOG_CURRENT, globalcontext);
con's avatar
con committed
311
    command->setAttribute(Core::Command::CA_UpdateText);
312 313
    connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
        SLOT(filelogCurrentFile()));
con's avatar
con committed
314
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
315
    m_commandLocator->appendCommand(command);
con's avatar
con committed
316

317 318 319
    m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_annotateCurrentAction,
        CMD_ID_ANNOTATE_CURRENT, globalcontext);
con's avatar
con committed
320
    command->setAttribute(Core::Command::CA_UpdateText);
321 322
    connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
        SLOT(annotateCurrentFile()));
con's avatar
con committed
323
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
324
    m_commandLocator->appendCommand(command);
con's avatar
con committed
325

326
    subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR0, globalcontext));
con's avatar
con committed
327

328 329
    m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_addAction, CMD_ID_ADD,
con's avatar
con committed
330
        globalcontext);
331
    command->setAttribute(Core::Command::CA_UpdateText);
332 333
    command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+A")));
    connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
con's avatar
con committed
334
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
335
    m_commandLocator->appendCommand(command);
con's avatar
con committed
336

337
    m_commitCurrentAction = new Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
con's avatar
con committed
338
    command = ami->registerAction(m_commitCurrentAction,
339
        CMD_ID_COMMIT_CURRENT, globalcontext);
con's avatar
con committed
340
    command->setAttribute(Core::Command::CA_UpdateText);
con's avatar
con committed
341 342 343
    command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+C")));
    connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
344
    m_commandLocator->appendCommand(command);
con's avatar
con committed
345

346 347 348
    m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
        globalcontext);
con's avatar
con committed
349
    command->setAttribute(Core::Command::CA_UpdateText);
350
    connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
con's avatar
con committed
351
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
352
    m_commandLocator->appendCommand(command);
con's avatar
con committed
353

354 355 356
    m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
        globalcontext);
con's avatar
con committed
357
    command->setAttribute(Core::Command::CA_UpdateText);
358
    connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
con's avatar
con committed
359
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
360
    m_commandLocator->appendCommand(command);
con's avatar
con committed
361

362
    subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext));
363

364 365 366 367 368 369
    m_diffProjectAction = new Utils::ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT,
        globalcontext);
    command->setAttribute(Core::Command::CA_UpdateText);
    connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
370
    m_commandLocator->appendCommand(command);
con's avatar
con committed
371

372 373
    m_statusProjectAction = new Utils::ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_statusProjectAction, CMD_ID_STATUS,
con's avatar
con committed
374
        globalcontext);
375 376
    command->setAttribute(Core::Command::CA_UpdateText);
    connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus()));
con's avatar
con committed
377
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
378
    m_commandLocator->appendCommand(command);
con's avatar
con committed
379

380 381 382 383 384
    m_logProjectAction = new Utils::ParameterAction(tr("Log Project Log"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
    command = ami->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
    command->setAttribute(Core::Command::CA_UpdateText);
    connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
385
    m_commandLocator->appendCommand(command);
386

387
    m_updateProjectAction = new Utils::ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
388
    command = ami->registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
con's avatar
con committed
389
    connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
390
    command->setAttribute(Core::Command::CA_UpdateText);
con's avatar
con committed
391
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
392
    m_commandLocator->appendCommand(command);
con's avatar
con committed
393

394 395
    subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext));

396 397 398 399
    m_logRepositoryAction = new QAction(tr("Repository Log"), this);
    command = ami->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
    connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
400
    m_commandLocator->appendCommand(command);
401

402 403 404 405 406 407 408 409 410 411
    m_describeAction = new QAction(tr("Describe..."), this);
    command = ami->registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext);
    connect(m_describeAction, SIGNAL(triggered()), this, SLOT(slotDescribe()));
    subversionMenu->addAction(command);

    m_commitAllAction = new QAction(tr("Commit All Files"), this);
    command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL,
        globalcontext);
    connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
412
    m_commandLocator->appendCommand(command);
413 414 415 416 417 418

    m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this);
    command = ami->registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL,
        globalcontext);
    connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll()));
    subversionMenu->addAction(command);
Friedemann Kleint's avatar
Friedemann Kleint committed
419
    m_commandLocator->appendCommand(command);
420

con's avatar
con committed
421 422
    // Actions of the submit editor
    QList<int> svncommitcontext;
423
    svncommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::SUBVERSIONCOMMITEDITOR);
con's avatar
con committed
424

425
    m_submitCurrentLogAction = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Commit"), this);
con's avatar
con committed
426 427 428
    command = ami->registerAction(m_submitCurrentLogAction, Constants::SUBMIT_CURRENT, svncommitcontext);
    connect(m_submitCurrentLogAction, SIGNAL(triggered()), this, SLOT(submitCurrentLog()));

429
    m_submitDiffAction = new QAction(VCSBase::VCSBaseSubmitEditor::diffIcon(), tr("Diff Selected Files"), this);
con's avatar
con committed
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
    command = ami->registerAction(m_submitDiffAction , Constants::DIFF_SELECTED, svncommitcontext);

    m_submitUndoAction = new QAction(tr("&Undo"), this);
    command = ami->registerAction(m_submitUndoAction, Core::Constants::UNDO, svncommitcontext);

    m_submitRedoAction = new QAction(tr("&Redo"), this);
    command = ami->registerAction(m_submitRedoAction, Core::Constants::REDO, svncommitcontext);

    return true;
}

void SubversionPlugin::extensionsInitialized()
{
}

445
bool SubversionPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor)
con's avatar
con committed
446
{
447
    if (!isCommitEditorOpen())
con's avatar
con committed
448 449
        return true;

450 451
    Core::IFile *fileIFace = submitEditor->file();
    const SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor);
con's avatar
con committed
452 453 454 455 456 457
    if (!fileIFace || !editor)
        return true;

    // Submit editor closing. Make it write out the commit message
    // and retrieve files
    const QFileInfo editorFile(fileIFace->fileName());
458
    const QFileInfo changeFile(m_commitMessageFileName);
con's avatar
con committed
459 460 461
    if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
        return true; // Oops?!

462 463
    // Prompt user. Force a prompt unless submit was actually invoked (that
    // is, the editor was closed or shutdown).
464
    SubversionSettings newSettings = m_settings;
465 466 467
    const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
            editor->promptSubmit(tr("Closing Subversion Editor"),
                                 tr("Do you want to commit the change?"),
468
                                 tr("The commit message check failed. Do you want to commit the change?"),
469
                                 &newSettings.promptToSubmit, !m_submitActionTriggered);
470
    m_submitActionTriggered = false;
con's avatar
con committed
471
    switch (answer) {
472
    case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
con's avatar
con committed
473
        return false; // Keep editing and change file
474
    case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded:
475
        cleanCommitMessageFile();
con's avatar
con committed
476 477 478 479
        return true; // Cancel all
    default:
        break;
    }
480
    setSettings(newSettings); // in case someone turned prompting off
con's avatar
con committed
481
    const QStringList fileList = editor->checkedFiles();
482
    bool closeEditor = true;
con's avatar
con committed
483 484
    if (!fileList.empty()) {
        // get message & commit
hjk's avatar
hjk committed
485
        Core::ICore::instance()->fileManager()->blockFileChange(fileIFace);
con's avatar
con committed
486
        fileIFace->save();
hjk's avatar
hjk committed
487
        Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace);
488
        closeEditor= commit(m_commitMessageFileName, fileList);
con's avatar
con committed
489
    }
490
    if (closeEditor)
491
        cleanCommitMessageFile();
492
    return closeEditor;
con's avatar
con committed
493 494
}

495
void SubversionPlugin::diffCommitFiles(const QStringList &files)
con's avatar
con committed
496
{
497
    svnDiff(m_commitRepository, files);
con's avatar
con committed
498 499
}

500 501 502 503 504 505
static inline void setDiffBaseDirectory(Core::IEditor *editor, const QString &db)
{
    if (VCSBase::VCSBaseEditor *ve = qobject_cast<VCSBase::VCSBaseEditor*>(editor->widget()))
        ve->setDiffBaseDirectory(db);
}

506
void SubversionPlugin::svnDiff(const QString &workingDir, const QStringList &files, QString diffname)
con's avatar
con committed
507 508 509
{
    if (Subversion::Constants::debug)
        qDebug() << Q_FUNC_INFO << files << diffname;
510
    const QString source = VCSBase::VCSBaseEditor::getSource(workingDir, files);
511
    QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(source);
con's avatar
con committed
512 513 514 515 516 517 518

    if (files.count() == 1 && diffname.isEmpty())
        diffname = QFileInfo(files.front()).fileName();

    QStringList args(QLatin1String("diff"));
    args << files;

519
    const SubversionResponse response = runSvn(workingDir, args, m_settings.timeOutMS(), false, codec);
con's avatar
con committed
520 521 522 523 524 525 526
    if (response.error)
        return;

    // diff of a single file? re-use an existing view if possible to support
    // the common usage pattern of continuously changing and diffing a file
    if (files.count() == 1) {
        // Show in the same editor if diff has been executed before
hjk's avatar
hjk committed
527
        if (Core::IEditor *editor = locateEditor("originalFileName", files.front())) {
con's avatar
con committed
528
            editor->createNew(response.stdOut);
529
            Core::EditorManager::instance()->activateEditor(editor);
530
            setDiffBaseDirectory(editor, workingDir);
con's avatar
con committed
531 532 533
            return;
        }
    }
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
534
    const QString title = QString::fromLatin1("svn diff %1").arg(diffname);
con's avatar
con committed
535
    Core::IEditor *editor = showOutputInEditor(title, response.stdOut, VCSBase::DiffOutput, source, codec);
536
    setDiffBaseDirectory(editor, workingDir);
con's avatar
con committed
537 538 539 540 541 542
    if (files.count() == 1)
        editor->setProperty("originalFileName", files.front());
}

SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QString &fileName)
{
543
    Core::IEditor *editor = Core::EditorManager::instance()->openEditor(fileName, QLatin1String(Constants::SUBVERSIONCOMMITEDITOR_ID));
con's avatar
con committed
544
    SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
hjk's avatar
hjk committed
545
    QTC_ASSERT(submitEditor, /**/);
546
    submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
547
    connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffCommitFiles(QStringList)));
548
    submitEditor->setCheckScriptWorkingDirectory(m_commitRepository);
con's avatar
con committed
549 550 551
    return submitEditor;
}

552
void SubversionPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
con's avatar
con committed
553
{
Friedemann Kleint's avatar
Friedemann Kleint committed
554 555
    if (!enableMenuAction(as, m_menuAction)) {
        m_commandLocator->setEnabled(false);
556
        return;
Friedemann Kleint's avatar
Friedemann Kleint committed
557 558 559 560
    }
    const bool hasTopLevel = currentState().hasTopLevel();
    m_commandLocator->setEnabled(hasTopLevel);
    m_logRepositoryAction->setEnabled(hasTopLevel);
561

562 563 564 565
    const QString projectName = currentState().currentProjectName();
    m_diffProjectAction->setParameter(projectName);
    m_statusProjectAction->setParameter(projectName);
    m_updateProjectAction->setParameter(projectName);
566
    m_logProjectAction->setParameter(projectName);
567 568 569 570

    const bool repoEnabled = currentState().hasTopLevel();
    m_commitAllAction->setEnabled(repoEnabled);
    m_describeAction->setEnabled(repoEnabled);
571
    m_revertRepositoryAction->setEnabled(repoEnabled);
572 573 574 575 576 577 578 579 580 581

    const QString fileName = currentState().currentFileName();

    m_addAction->setParameter(fileName);
    m_deleteAction->setParameter(fileName);
    m_revertAction->setParameter(fileName);
    m_diffCurrentAction->setParameter(fileName);
    m_commitCurrentAction->setParameter(fileName);
    m_filelogCurrentAction->setParameter(fileName);
    m_annotateCurrentAction->setParameter(fileName);
con's avatar
con committed
582 583 584 585
}

void SubversionPlugin::addCurrentFile()
{
586 587 588
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasFile(), return)
    vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
con's avatar
con committed
589 590
}

591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
void SubversionPlugin::revertAll()
{
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasTopLevel(), return)
    const QString title = tr("Revert repository");
    if (QMessageBox::warning(0, title, tr("Would you like to revert all changes to the repository?"),
                             QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
        return;
    // NoteL: Svn "revert ." doesn not work.
    QStringList args;
    args << QLatin1String("revert") << QLatin1String("--recursive") << state.topLevel();
    const SubversionResponse revertResponse = runSvn(state.topLevel(), args, m_settings.timeOutMS(), true);
    if (revertResponse.error) {
        QMessageBox::warning(0, title, tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok);
    } else {
        subVersionControl()->emitRepositoryChanged(state.topLevel());
    }
}

con's avatar
con committed
610 611
void SubversionPlugin::revertCurrentFile()
{
612 613
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasFile(), return)
con's avatar
con committed
614 615

    QStringList args(QLatin1String("diff"));
616
    args.push_back(state.relativeCurrentFile());
con's avatar
con committed
617

618
    const SubversionResponse diffResponse = runSvn(state.currentFileTopLevel(), args, m_settings.timeOutMS(), false);
con's avatar
con committed
619 620 621 622 623
    if (diffResponse.error)
        return;

    if (diffResponse.stdOut.isEmpty())
        return;
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
624
    if (QMessageBox::warning(0, QLatin1String("svn revert"), tr("The file has been changed. Do you want to revert it?"),
con's avatar
con committed
625 626 627
                             QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
        return;

628

629
    Core::FileChangeBlocker fcb(state.currentFile());
con's avatar
con committed
630 631 632

    // revert
    args.clear();
633
    args << QLatin1String("revert") << state.relativeCurrentFile();
con's avatar
con committed
634

635
    const SubversionResponse revertResponse = runSvn(state.currentFileTopLevel(), args, m_settings.timeOutMS(), true);
636
    if (!revertResponse.error) {
637
        subVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
con's avatar
con committed
638 639 640 641 642
    }
}

void SubversionPlugin::diffProject()
{
643 644 645
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasProject(), return)
    svnDiff(state.currentProjectTopLevel(), state.relativeCurrentProject(), state.currentProjectName());
con's avatar
con committed
646 647 648 649
}

void SubversionPlugin::diffCurrentFile()
{
650 651 652
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasFile(), return)
    svnDiff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
con's avatar
con committed
653 654 655 656
}

void SubversionPlugin::startCommitCurrentFile()
{
657 658 659
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasFile(), return)
    startCommit(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
con's avatar
con committed
660 661 662 663
}

void SubversionPlugin::startCommitAll()
{
664 665 666
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasTopLevel(), return);
    startCommit(state.topLevel());
con's avatar
con committed
667 668 669 670 671
}

/* Start commit of files of a single repository by displaying
 * template and files in a submit editor. On closing, the real
 * commit will start. */
672
void SubversionPlugin::startCommit(const QString &workingDir, const QStringList &files)
con's avatar
con committed
673
{
674 675
    if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
        return;
676
    if (isCommitEditorOpen()) {
677
        VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
con's avatar
con committed
678 679 680 681 682 683
        return;
    }

    QStringList args(QLatin1String("status"));
    args += files;

684
    const SubversionResponse response = runSvn(workingDir, args, m_settings.timeOutMS(), false);
con's avatar
con committed
685 686
    if (response.error)
        return;
687

con's avatar
con committed
688
    // Get list of added/modified/deleted files
689
    const StatusList statusOutput = parseStatusOutput(response.stdOut);
con's avatar
con committed
690
    if (statusOutput.empty()) {
691
        VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("There are no modified files."));
con's avatar
con committed
692 693
        return;
    }
694
    m_commitRepository = workingDir;
con's avatar
con committed
695
    // Create a new submit change file containing the submit template
696 697 698 699
    QTemporaryFile changeTmpFile;
    changeTmpFile.setAutoRemove(false);
    if (!changeTmpFile.open()) {
        VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString()));
con's avatar
con committed
700 701
        return;
    }
702
    m_commitMessageFileName = changeTmpFile.fileName();
703
    // TODO: Regitctrieve submit template from
con's avatar
con committed
704 705
    const QString submitTemplate;
    // Create a submit
706 707 708
    changeTmpFile.write(submitTemplate.toUtf8());
    changeTmpFile.flush();
    changeTmpFile.close();
con's avatar
con committed
709
    // Create a submit editor and set file list
710
    SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_commitMessageFileName);
711
    editor->setStatusList(statusOutput);
con's avatar
con committed
712 713 714 715 716 717 718 719 720 721 722
}

bool SubversionPlugin::commit(const QString &messageFile,
                              const QStringList &subVersionFileList)
{
    if (Subversion::Constants::debug)
        qDebug() << Q_FUNC_INFO << messageFile << subVersionFileList;
    // Transform the status list which is sth
    // "[ADM]<blanks>file" into an args list. The files of the status log
    // can be relative or absolute depending on where the command was run.
    QStringList args = QStringList(QLatin1String("commit"));
723
    args << QLatin1String(nonInteractiveOptionC) << QLatin1String("--file") << messageFile;
con's avatar
con committed
724
    args.append(subVersionFileList);
725
    const SubversionResponse response = runSvn(m_commitRepository, args, m_settings.longTimeOutMS(), true);
con's avatar
con committed
726 727 728 729 730
    return !response.error ;
}

void SubversionPlugin::filelogCurrentFile()
{
731 732
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasFile(), return)
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
   filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
}

void SubversionPlugin::logProject()
{
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasProject(), return)
    filelog(state.currentProjectTopLevel(), state.relativeCurrentProject());
}

void SubversionPlugin::logRepository()
{
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasTopLevel(), return)
    filelog(state.topLevel());
con's avatar
con committed
748 749
}

750 751 752
void SubversionPlugin::filelog(const QString &workingDir,
                               const QStringList &files,
                               bool enableAnnotationContextMenu)
con's avatar
con committed
753
{
754
    QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(workingDir, files);
con's avatar
con committed
755 756
    // no need for temp file
    QStringList args(QLatin1String("log"));
757 758
    if (m_settings.logCount > 0)
        args << QLatin1String("-l") << QString::number(m_settings.logCount);
759 760
    foreach(const QString &file, files)
        args.append(QDir::toNativeSeparators(file));
con's avatar
con committed
761

762
    const SubversionResponse response = runSvn(workingDir, args, m_settings.timeOutMS(), false, codec);
con's avatar
con committed
763 764 765 766 767 768
    if (response.error)
        return;

    // Re-use an existing view if possible to support
    // the common usage pattern of continuously changing and diffing a file

769 770
    const QString id = VCSBase::VCSBaseEditor::getTitleId(workingDir, files);
    if (Core::IEditor *editor = locateEditor("logFileName", id)) {
con's avatar
con committed
771
        editor->createNew(response.stdOut);
772
        Core::EditorManager::instance()->activateEditor(editor);
con's avatar
con committed
773
    } else {
774 775 776 777
        const QString title = QString::fromLatin1("svn log %1").arg(id);
        const QString source = VCSBase::VCSBaseEditor::getSource(workingDir, files);
        Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, source, codec);
        newEditor->setProperty("logFileName", id);
778 779
        if (enableAnnotationContextMenu)
            VCSBase::VCSBaseEditor::getVcsBaseEditor(newEditor)->setFileLogAnnotateEnabled(true);
con's avatar
con committed
780 781 782 783 784
    }
}

void SubversionPlugin::updateProject()
{
785 786
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasProject(), return);
con's avatar
con committed
787 788

    QStringList args(QLatin1String("update"));
789
    args.push_back(QLatin1String(nonInteractiveOptionC));
790
    args.append(state.relativeCurrentProject());
791
    const SubversionResponse response = runSvn(state.currentProjectTopLevel(), args, m_settings.longTimeOutMS(), true);
792 793
    if (!response.error)
        subVersionControl()->emitRepositoryChanged(state.currentProjectTopLevel());
con's avatar
con committed
794 795 796 797
}

void SubversionPlugin::annotateCurrentFile()
{
798 799 800
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasFile(), return);
    annotate(state.currentFileTopLevel(), state.relativeCurrentFile());
con's avatar
con committed
801 802
}

803 804 805 806 807 808 809 810 811 812 813
void SubversionPlugin::annotateVersion(const QString &file,
                                       const QString &revision,
                                       int lineNr)
{
    const QFileInfo fi(file);
    annotate(fi.absolutePath(), fi.fileName(), revision, lineNr);
}

void SubversionPlugin::annotate(const QString &workingDir, const QString &file,
                                const QString &revision /* = QString() */,
                                int lineNumber /* = -1 */)
con's avatar
con committed
814
{
815
    QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(file);
con's avatar
con committed
816 817

    QStringList args(QLatin1String("annotate"));
818 819
    if (m_settings.spaceIgnorantAnnotation)
        args << QLatin1String("-x") << QLatin1String("-uw");
820 821
    if (!revision.isEmpty())
        args << QLatin1String("-r") << revision;
con's avatar
con committed
822 823 824
    args.push_back(QLatin1String("-v"));
    args.append(QDir::toNativeSeparators(file));

825
    const SubversionResponse response = runSvn(workingDir, args, m_settings.timeOutMS(), false, codec);
con's avatar
con committed
826 827 828 829 830
    if (response.error)
        return;

    // Re-use an existing view if possible to support
    // the common usage pattern of continuously changing and diffing a file
831
    const QString source = workingDir + QLatin1Char('/') + file;
832 833 834 835
    if (lineNumber <= 0)
        lineNumber = VCSBase::VCSBaseEditor::lineNumberOfCurrentEditor(source);
    // Determine id
    const QString id = VCSBase::VCSBaseEditor::getTitleId(workingDir, QStringList(file), revision);
con's avatar
con committed
836

837
    if (Core::IEditor *editor = locateEditor("annotateFileName", id)) {
con's avatar
con committed
838
        editor->createNew(response.stdOut);
839
        VCSBase::VCSBaseEditor::gotoLineOfEditor(editor, lineNumber);
840
        Core::EditorManager::instance()->activateEditor(editor);
con's avatar
con committed
841
    } else {
842 843 844
        const QString title = QString::fromLatin1("svn annotate %1").arg(id);
        Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, source, codec);
        newEditor->setProperty("annotateFileName", id);
845
        VCSBase::VCSBaseEditor::gotoLineOfEditor(newEditor, lineNumber);
con's avatar
con committed
846 847 848 849 850
    }
}

void SubversionPlugin::projectStatus()
{
851 852
    const VCSBase::VCSBasePluginState state = currentState();
    QTC_ASSERT(state.hasProject(), return);
con's avatar
con committed
853
    QStringList args(QLatin1String("status"));
854
    args += state.relativeCurrentProject();
855 856
    VCSBase::VCSBaseOutputWindow *outwin = VCSBase::VCSBaseOutputWindow::instance();
    outwin->setRepository(state.currentProjectTopLevel());
857
    runSvn(state.currentProjectTopLevel(), args, m_settings.timeOutMS(), true);
858
    outwin->clearRepository();
con's avatar
con committed
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875
}

void SubversionPlugin::describe(const QString &source, const QString &changeNr)
{
    // To describe a complete change, find the top level and then do
    //svn diff -r 472958:472959 <top level>
    const QFileInfo fi(source);
    const QString topLevel = findTopLevelForDirectory(fi.isDir() ? source : fi.absolutePath());
    if (topLevel.isEmpty())
        return;
    if (Subversion::Constants::debug)
        qDebug() << Q_FUNC_INFO << source << topLevel << changeNr;
    // Number must be > 1
    bool ok;
    const int number = changeNr.toInt(&ok);
    if (!ok || number < 2)
        return;
876 877 878 879 880
    // Run log to obtain message (local utf8)
    QString description;
    QStringList args(QLatin1String("log"));
    args.push_back(QLatin1String("-r"));
    args.push_back(changeNr);
881
    const SubversionResponse logResponse = runSvn(topLevel, args, m_settings.timeOutMS(), false);
882 883 884 885 886 887 888
    if (logResponse.error)
        return;
    description = logResponse.stdOut;

    // Run diff (encoding via source codec)
    args.clear();
    args.push_back(QLatin1String("diff"));
con's avatar
con committed
889 890 891 892 893
    args.push_back(QLatin1String("-r"));
    QString diffArg;
    QTextStream(&diffArg) << (number - 1) << ':' << number;
    args.push_back(diffArg);

894
    QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(source);
895
    const SubversionResponse response = runSvn(topLevel, args, m_settings.timeOutMS(), false, codec);
con's avatar
con committed
896 897
    if (response.error)
        return;
898
    description += response.stdOut;
con's avatar
con committed
899 900 901 902

    // Re-use an existing view if possible to support
    // the common usage pattern of continuously changing and diffing a file
    const QString id = diffArg + source;
hjk's avatar
hjk committed
903
    if (Core::IEditor *editor = locateEditor("describeChange", id)) {
904
        editor->createNew(description);
hjk's avatar
hjk committed
905
        Core::EditorManager::instance()->activateEditor(editor);
con's avatar
con committed
906
    } else {
907
        const QString title = QString::fromLatin1("svn describe %1#%2").arg(fi.fileName(), changeNr);