annotate src/mainwindow.cpp @ 379:d2e4bf428cfc

Try to make kdiff3 a bit clearer
author Chris Cannam
date Wed, 13 Apr 2011 17:09:57 +0100
parents ad2e56d1e4c4
children f7dc2c5d8650
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
jtkorhonen@0 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@98 6 Based on hgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@244 8 Copyright (c) 2011 Chris Cannam
Chris@244 9 Copyright (c) 2011 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@50 17
jtkorhonen@0 18 #include <QStringList>
jtkorhonen@0 19 #include <QDir>
jtkorhonen@24 20 #include <QNetworkInterface>
jtkorhonen@17 21 #include <QHostAddress>
jtkorhonen@17 22 #include <QHostInfo>
jtkorhonen@34 23 #include <QDesktopServices>
Chris@50 24 #include <QStatusBar>
Chris@50 25 #include <QMessageBox>
Chris@50 26 #include <QMenuBar>
Chris@50 27 #include <QApplication>
Chris@50 28 #include <QToolBar>
Chris@61 29 #include <QToolButton>
Chris@50 30 #include <QSettings>
Chris@90 31 #include <QInputDialog>
Chris@359 32 #include <QWidgetAction>
Chris@125 33 #include <QRegExp>
Chris@199 34 #include <QShortcut>
Chris@237 35 #include <QUrl>
Chris@238 36 #include <QTimer>
jtkorhonen@0 37
Chris@53 38 #include "mainwindow.h"
Chris@69 39 #include "multichoicedialog.h"
Chris@64 40 #include "startupdialog.h"
Chris@53 41 #include "colourset.h"
Chris@62 42 #include "debug.h"
Chris@74 43 #include "logparser.h"
Chris@103 44 #include "confirmcommentdialog.h"
Chris@125 45 #include "incomingdialog.h"
Chris@175 46 #include "settingsdialog.h"
Chris@275 47 #include "moreinformationdialog.h"
Chris@331 48 #include "annotatedialog.h"
Chris@229 49 #include "version.h"
Chris@287 50 #include "workstatuswidget.h"
Chris@53 51
jtkorhonen@0 52
Chris@172 53 MainWindow::MainWindow(QString myDirPath) :
Chris@238 54 m_myDirPath(myDirPath),
Chris@238 55 m_fsWatcherGeneralTimer(0),
Chris@241 56 m_fsWatcherRestoreTimer(0),
Chris@241 57 m_fsWatcherSuspended(false)
jtkorhonen@0 58 {
Chris@197 59 setWindowIcon(QIcon(":images/easyhg-icon.png"));
Chris@197 60
jtkorhonen@0 61 QString wndTitle;
jtkorhonen@0 62
Chris@284 63 m_showAllFiles = false;
Chris@273 64
Chris@284 65 m_fsWatcher = 0;
Chris@284 66 m_commitsSincePush = 0;
Chris@284 67 m_shouldHgStat = true;
Chris@90 68
jtkorhonen@0 69 createActions();
jtkorhonen@0 70 createMenus();
jtkorhonen@0 71 createToolBars();
jtkorhonen@0 72 createStatusBar();
jtkorhonen@0 73
Chris@284 74 m_runner = new HgRunner(m_myDirPath, this);
Chris@284 75 connect(m_runner, SIGNAL(commandStarting(HgAction)),
Chris@241 76 this, SLOT(commandStarting(HgAction)));
Chris@284 77 connect(m_runner, SIGNAL(commandCompleted(HgAction, QString)),
Chris@109 78 this, SLOT(commandCompleted(HgAction, QString)));
Chris@284 79 connect(m_runner, SIGNAL(commandFailed(HgAction, QString)),
Chris@109 80 this, SLOT(commandFailed(HgAction, QString)));
Chris@284 81 statusBar()->addPermanentWidget(m_runner);
jtkorhonen@0 82
Chris@61 83 setWindowTitle(tr("EasyMercurial"));
jtkorhonen@0 84
Chris@284 85 m_remoteRepoPath = "";
Chris@284 86 m_workFolderPath = "";
jtkorhonen@0 87
jtkorhonen@0 88 readSettings();
jtkorhonen@0 89
Chris@284 90 m_justMerged = false;
Chris@210 91
Chris@210 92 QWidget *central = new QWidget(this);
Chris@210 93 setCentralWidget(central);
Chris@210 94
Chris@210 95 QGridLayout *cl = new QGridLayout(central);
Chris@287 96 int row = 0;
Chris@210 97
Chris@210 98 #ifndef Q_OS_MAC
Chris@210 99 cl->setMargin(0);
Chris@210 100 #endif
jtkorhonen@0 101
Chris@287 102 m_workStatus = new WorkStatusWidget(this);
Chris@287 103 cl->addWidget(m_workStatus, row++, 0);
Chris@287 104
Chris@287 105 m_hgTabs = new HgTabWidget(central, m_workFolderPath);
Chris@287 106 connectTabsSignals();
Chris@287 107
Chris@287 108 cl->addWidget(m_hgTabs, row++, 0);
Chris@287 109
Chris@284 110 connect(m_hgTabs, SIGNAL(selectionChanged()),
Chris@95 111 this, SLOT(enableDisableActions()));
Chris@284 112 connect(m_hgTabs, SIGNAL(showAllChanged(bool)),
Chris@199 113 this, SLOT(showAllChanged(bool)));
Chris@95 114
jtkorhonen@0 115 setUnifiedTitleAndToolBarOnMac(true);
jtkorhonen@0 116 connectActions();
Chris@120 117 clearState();
jtkorhonen@0 118 enableDisableActions();
jtkorhonen@0 119
Chris@284 120 if (m_firstStart) {
Chris@64 121 startupDialog();
jtkorhonen@0 122 }
jtkorhonen@0 123
Chris@239 124 SettingsDialog::findDefaultLocations(m_myDirPath);
Chris@112 125
Chris@64 126 ColourSet *cs = ColourSet::instance();
Chris@64 127 cs->clearDefaultNames();
Chris@64 128 cs->addDefaultName("");
Chris@153 129 cs->addDefaultName("default");
Chris@64 130 cs->addDefaultName(getUserInfo());
Chris@62 131
Chris@175 132 hgTest();
Chris@359 133 updateRecentMenu();
jtkorhonen@0 134 }
jtkorhonen@0 135
jtkorhonen@0 136
jtkorhonen@0 137 void MainWindow::closeEvent(QCloseEvent *)
jtkorhonen@0 138 {
jtkorhonen@0 139 writeSettings();
Chris@284 140 delete m_fsWatcher;
jtkorhonen@0 141 }
jtkorhonen@0 142
jtkorhonen@0 143
Chris@64 144 QString MainWindow::getUserInfo() const
Chris@64 145 {
Chris@64 146 QSettings settings;
Chris@64 147 settings.beginGroup("User Information");
Chris@64 148 QString name = settings.value("name", getUserRealName()).toString();
Chris@64 149 QString email = settings.value("email", "").toString();
Chris@64 150
Chris@64 151 QString identifier;
Chris@64 152
Chris@64 153 if (email != "") {
Chris@64 154 identifier = QString("%1 <%2>").arg(name).arg(email);
Chris@64 155 } else {
Chris@64 156 identifier = name;
Chris@64 157 }
Chris@64 158
Chris@64 159 return identifier;
Chris@64 160 }
Chris@64 161
jtkorhonen@0 162 void MainWindow::about()
jtkorhonen@0 163 {
Chris@97 164 QMessageBox::about(this, tr("About EasyMercurial"),
Chris@229 165 tr("<qt><h2>EasyMercurial v%1</h2>"
Chris@228 166 #ifdef Q_OS_MAC
Chris@228 167 "<font size=-1>"
Chris@228 168 #endif
Chris@97 169 "<p>EasyMercurial is a simple user interface for the "
Chris@186 170 "Mercurial</a> version control system.</p>"
Chris@186 171 "<h4>Credits and Copyright</h4>"
Chris@186 172 "<p>Development carried out by Chris Cannam for "
Chris@186 173 "SoundSoftware.ac.uk at the Centre for Digital Music, "
Chris@186 174 "Queen Mary, University of London.</p>"
Chris@186 175 "<p>EasyMercurial is based on HgExplorer by "
Chris@186 176 "Jari Korhonen, with thanks.</p>"
Chris@186 177 "<p style=\"margin-left: 2em;\">"
Chris@244 178 "Copyright &copy; 2011 Queen Mary, University of London.<br>"
Chris@186 179 "Copyright &copy; 2010 Jari Korhonen.<br>"
Chris@244 180 "Copyright &copy; 2011 Chris Cannam."
Chris@186 181 "</p>"
Chris@186 182 "<p style=\"margin-left: 2em;\">"
Chris@186 183 "This program requires Mercurial, by Matt Mackall and others.<br>"
Chris@186 184 "This program uses Qt by Nokia.<br>"
Chris@186 185 "This program uses Nuvola icons by David Vignoni.<br>"
Chris@186 186 "This program may use KDiff3 by Joachim Eibl.<br>"
Chris@186 187 "This program may use PyQt by River Bank Computing.<br>"
Chris@186 188 "Packaging for Mercurial and other dependencies on Windows is derived from TortoiseHg by Steve Borho and others."
Chris@186 189 "</p>"
Chris@186 190 "<h4>License</h4>"
Chris@186 191 "<p>This program is free software; you can redistribute it and/or "
Chris@97 192 "modify it under the terms of the GNU General Public License as "
Chris@97 193 "published by the Free Software Foundation; either version 2 of the "
Chris@97 194 "License, or (at your option) any later version. See the file "
Chris@223 195 "COPYING included with this distribution for more information.</p>"
Chris@228 196 #ifdef Q_OS_MAC
Chris@228 197 "</font>"
Chris@228 198 #endif
Chris@229 199 ).arg(EASYHG_VERSION));
jtkorhonen@0 200 }
jtkorhonen@0 201
Chris@94 202 void MainWindow::clearSelections()
Chris@94 203 {
Chris@284 204 m_hgTabs->clearSelections();
Chris@94 205 }
jtkorhonen@0 206
Chris@199 207 void MainWindow::showAllChanged(bool s)
Chris@199 208 {
Chris@284 209 m_showAllFiles = s;
Chris@199 210 hgQueryPaths();
Chris@199 211 }
Chris@199 212
Chris@120 213 void MainWindow::hgRefresh()
Chris@120 214 {
Chris@120 215 clearState();
Chris@120 216 hgQueryPaths();
Chris@120 217 }
Chris@120 218
Chris@175 219 void MainWindow::hgTest()
Chris@175 220 {
Chris@175 221 QStringList params;
Chris@175 222 params << "--version";
Chris@284 223 m_runner->requestAction(HgAction(ACT_TEST_HG, m_myDirPath, params));
Chris@175 224 }
Chris@175 225
Chris@200 226 void MainWindow::hgTestExtension()
Chris@200 227 {
Chris@200 228 QStringList params;
Chris@200 229 params << "--version";
Chris@284 230 m_runner->requestAction(HgAction(ACT_TEST_HG_EXT, m_myDirPath, params));
Chris@200 231 }
Chris@200 232
jtkorhonen@0 233 void MainWindow::hgStat()
jtkorhonen@0 234 {
Chris@109 235 QStringList params;
Chris@199 236
Chris@284 237 if (m_showAllFiles) {
Chris@199 238 params << "stat" << "-A";
Chris@199 239 } else {
Chris@199 240 params << "stat" << "-ardum";
Chris@199 241 }
Chris@153 242
Chris@284 243 m_lastStatOutput = "";
Chris@273 244
Chris@284 245 m_runner->requestAction(HgAction(ACT_STAT, m_workFolderPath, params));
jtkorhonen@0 246 }
jtkorhonen@0 247
Chris@109 248 void MainWindow::hgQueryPaths()
Chris@74 249 {
Chris@210 250 // Quickest is to just read the file
Chris@198 251
Chris@284 252 QFileInfo hgrc(m_workFolderPath + "/.hg/hgrc");
Chris@198 253
Chris@210 254 QString path;
Chris@210 255
Chris@198 256 if (hgrc.exists()) {
Chris@198 257 QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat);
Chris@198 258 s.beginGroup("paths");
Chris@210 259 path = s.value("default").toString();
Chris@210 260 }
Chris@198 261
Chris@284 262 m_remoteRepoPath = path;
Chris@198 263
Chris@210 264 // We have to do this here, because commandCompleted won't be called
Chris@284 265 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
Chris@284 266 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
Chris@287 267 updateWorkFolderAndRepoNames();
Chris@210 268
Chris@210 269 hgQueryBranch();
Chris@210 270 return;
Chris@210 271
Chris@210 272 /* The classic method!
Chris@198 273
Chris@109 274 QStringList params;
Chris@109 275 params << "paths";
Chris@284 276 m_runner->requestAction(HgAction(ACT_QUERY_PATHS, m_workFolderPath, params));
Chris@210 277 */
Chris@74 278 }
Chris@74 279
Chris@109 280 void MainWindow::hgQueryBranch()
Chris@106 281 {
Chris@210 282 // Quickest is to just read the file
Chris@198 283
Chris@284 284 QFile hgbr(m_workFolderPath + "/.hg/branch");
Chris@198 285
Chris@210 286 QString br = "default";
Chris@210 287
Chris@198 288 if (hgbr.exists() && hgbr.open(QFile::ReadOnly)) {
Chris@210 289 QByteArray ba = hgbr.readLine();
Chris@210 290 br = QString::fromUtf8(ba).trimmed();
Chris@210 291 }
Chris@210 292
Chris@284 293 m_currentBranch = br;
Chris@210 294
Chris@210 295 // We have to do this here, because commandCompleted won't be called
Chris@210 296 hgStat();
Chris@210 297 return;
Chris@198 298
Chris@210 299 /* The classic method!
Chris@198 300
Chris@109 301 QStringList params;
Chris@109 302 params << "branch";
Chris@284 303 m_runner->requestAction(HgAction(ACT_QUERY_BRANCH, m_workFolderPath, params));
Chris@210 304 */
Chris@106 305 }
Chris@106 306
Chris@109 307 void MainWindow::hgQueryHeads()
jtkorhonen@0 308 {
Chris@109 309 QStringList params;
Chris@137 310 // On empty repos, "hg heads" will fail -- we don't care about
Chris@137 311 // that. Use --closed option so as to include closed branches;
Chris@137 312 // otherwise we'll be stuck if the user updates into one, and our
Chris@137 313 // incremental log will end up with spurious stuff in it because
Chris@137 314 // we won't be pruning at the ends of closed branches
Chris@137 315 params << "heads" << "--closed";
Chris@284 316 m_runner->requestAction(HgAction(ACT_QUERY_HEADS, m_workFolderPath, params));
jtkorhonen@0 317 }
jtkorhonen@0 318
jtkorhonen@0 319 void MainWindow::hgLog()
jtkorhonen@0 320 {
Chris@109 321 QStringList params;
Chris@109 322 params << "log";
Chris@109 323 params << "--template";
Chris@125 324 params << Changeset::getLogTemplate();
Chris@109 325
Chris@284 326 m_runner->requestAction(HgAction(ACT_LOG, m_workFolderPath, params));
Chris@109 327 }
Chris@109 328
Chris@150 329 void MainWindow::hgLogIncremental(QStringList prune)
Chris@120 330 {
Chris@305 331 // Sometimes we can be called with prune empty -- it represents
Chris@305 332 // the current heads, but if we have none already and for some
Chris@305 333 // reason are being prompted for an incremental update, we may run
Chris@305 334 // into trouble. In that case, make this a full log instead
Chris@305 335
Chris@305 336 if (prune.empty()) {
Chris@305 337 hgLog();
Chris@305 338 return;
Chris@305 339 }
Chris@305 340
Chris@120 341 QStringList params;
Chris@120 342 params << "log";
Chris@120 343
Chris@150 344 foreach (QString p, prune) {
Chris@153 345 params << "--prune" << Changeset::hashOf(p);
Chris@120 346 }
Chris@120 347
Chris@120 348 params << "--template";
Chris@125 349 params << Changeset::getLogTemplate();
Chris@120 350
Chris@284 351 m_runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, m_workFolderPath, params));
Chris@120 352 }
Chris@109 353
Chris@109 354 void MainWindow::hgQueryParents()
Chris@109 355 {
Chris@109 356 QStringList params;
Chris@109 357 params << "parents";
Chris@284 358 m_runner->requestAction(HgAction(ACT_QUERY_PARENTS, m_workFolderPath, params));
Chris@109 359 }
Chris@109 360
Chris@326 361 void MainWindow::hgAnnotateFiles(QStringList files)
Chris@326 362 {
Chris@326 363 QStringList params;
Chris@326 364
Chris@326 365 if (!files.isEmpty()) {
Chris@332 366 params << "annotate" << "-udqc" << "--" << files;
Chris@326 367 m_runner->requestAction(HgAction(ACT_ANNOTATE, m_workFolderPath, params));
Chris@326 368 }
Chris@326 369 }
Chris@326 370
Chris@109 371 void MainWindow::hgResolveList()
Chris@109 372 {
Chris@109 373 QStringList params;
jtkorhonen@0 374
Chris@109 375 params << "resolve" << "--list";
Chris@284 376 m_runner->requestAction(HgAction(ACT_RESOLVE_LIST, m_workFolderPath, params));
Chris@109 377 }
Chris@109 378
Chris@109 379 void MainWindow::hgAdd()
jtkorhonen@0 380 {
Chris@109 381 // hgExplorer permitted adding "all" files -- I'm not sure
Chris@109 382 // that one is a good idea, let's require the user to select
jtkorhonen@0 383
Chris@326 384 hgAddFiles(m_hgTabs->getSelectedAddableFiles());
Chris@326 385 }
Chris@326 386
Chris@326 387 void MainWindow::hgAddFiles(QStringList files)
Chris@326 388 {
Chris@326 389 QStringList params;
Chris@109 390
Chris@109 391 if (!files.empty()) {
Chris@109 392 params << "add" << "--" << files;
Chris@284 393 m_runner->requestAction(HgAction(ACT_ADD, m_workFolderPath, params));
jtkorhonen@0 394 }
jtkorhonen@0 395 }
jtkorhonen@0 396
Chris@98 397 void MainWindow::hgRemove()
Chris@98 398 {
Chris@326 399 hgRemoveFiles(m_hgTabs->getSelectedRemovableFiles());
Chris@326 400 }
Chris@326 401
Chris@326 402 void MainWindow::hgRemoveFiles(QStringList files)
Chris@326 403 {
Chris@109 404 QStringList params;
Chris@98 405
Chris@109 406 if (!files.empty()) {
Chris@109 407 params << "remove" << "--after" << "--force" << "--" << files;
Chris@284 408 m_runner->requestAction(HgAction(ACT_REMOVE, m_workFolderPath, params));
Chris@109 409 }
jtkorhonen@0 410 }
jtkorhonen@0 411
jtkorhonen@0 412 void MainWindow::hgCommit()
jtkorhonen@0 413 {
Chris@326 414 hgCommitFiles(QStringList());
Chris@326 415 }
Chris@326 416
Chris@326 417 void MainWindow::hgCommitFiles(QStringList files)
Chris@326 418 {
Chris@109 419 QStringList params;
Chris@109 420 QString comment;
Chris@94 421
Chris@284 422 if (m_justMerged) {
Chris@284 423 comment = m_mergeCommitComment;
Chris@157 424 }
Chris@157 425
Chris@284 426 QStringList allFiles = m_hgTabs->getAllCommittableFiles();
Chris@127 427 QStringList reportFiles = files;
Chris@237 428 if (reportFiles.empty()) {
Chris@237 429 reportFiles = allFiles;
Chris@237 430 }
Chris@103 431
Chris@237 432 QString subsetNote;
Chris@237 433 if (reportFiles != allFiles) {
Chris@237 434 subsetNote = tr("<p><b>Note:</b> you are committing only the files you have selected, not all of the files that have been changed!");
Chris@237 435 }
Chris@237 436
Chris@155 437 QString cf(tr("Commit files"));
Chris@155 438
Chris@311 439 QString branchText;
Chris@311 440 if (m_currentBranch == "" || m_currentBranch == "default") {
Chris@311 441 branchText = tr("the default branch");
Chris@311 442 } else {
Chris@311 443 branchText = tr("branch \"%1\"").arg(m_currentBranch);
Chris@311 444 }
Chris@311 445
Chris@109 446 if (ConfirmCommentDialog::confirmAndGetLongComment
Chris@109 447 (this,
Chris@155 448 cf,
Chris@237 449 tr("<h3>%1</h3><p>%2%3").arg(cf)
Chris@313 450 .arg(tr("You are about to commit the following files to %1:").arg(branchText))
Chris@237 451 .arg(subsetNote),
Chris@237 452 tr("<h3>%1</h3><p>%2%3").arg(cf)
Chris@311 453 .arg(tr("You are about to commit %n file(s) to %1.", "", reportFiles.size()).arg(branchText))
Chris@237 454 .arg(subsetNote),
Chris@127 455 reportFiles,
Chris@193 456 comment,
Chris@365 457 tr("Co&mmit"))) {
Chris@103 458
Chris@284 459 if (!m_justMerged && !files.empty()) {
Chris@157 460 // User wants to commit selected file(s) (and this is not
Chris@157 461 // merge commit, which would fail if we selected files)
Chris@157 462 params << "commit" << "--message" << comment
Chris@157 463 << "--user" << getUserInfo() << "--" << files;
Chris@109 464 } else {
Chris@109 465 // Commit all changes
Chris@157 466 params << "commit" << "--message" << comment
Chris@157 467 << "--user" << getUserInfo();
jtkorhonen@0 468 }
Chris@109 469
Chris@284 470 m_runner->requestAction(HgAction(ACT_COMMIT, m_workFolderPath, params));
Chris@284 471 m_mergeCommitComment = "";
jtkorhonen@0 472 }
jtkorhonen@0 473 }
jtkorhonen@0 474
jtkorhonen@34 475 QString MainWindow::filterTag(QString tag)
jtkorhonen@34 476 {
Chris@278 477 for(int i = 0; i < tag.size(); i++) {
Chris@278 478 if (tag[i].isLower() || tag[i].isUpper() ||
Chris@278 479 tag[i].isDigit() || (tag[i] == QChar('.'))) {
jtkorhonen@34 480 //ok
Chris@278 481 } else {
jtkorhonen@34 482 tag[i] = QChar('_');
jtkorhonen@34 483 }
jtkorhonen@34 484 }
jtkorhonen@34 485 return tag;
jtkorhonen@34 486 }
jtkorhonen@34 487
jtkorhonen@34 488
Chris@311 489 void MainWindow::hgNewBranch()
Chris@278 490 {
Chris@278 491 QStringList params;
Chris@278 492 QString branch;
Chris@278 493
Chris@278 494 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@278 495 (this,
Chris@278 496 tr("New Branch"),
Chris@278 497 tr("Enter new branch name:"),
Chris@278 498 branch,
Chris@365 499 tr("Start &Branch"))) {
Chris@278 500 if (!branch.isEmpty()) {//!!! do something better if it is empty
Chris@278 501
Chris@278 502 params << "branch" << filterTag(branch);
Chris@307 503 m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params));
Chris@278 504 }
Chris@278 505 }
Chris@278 506 }
Chris@278 507
Chris@311 508 void MainWindow::hgNoBranch()
Chris@311 509 {
Chris@311 510 if (m_currentParents.empty()) return;
Chris@311 511
Chris@311 512 QString parentBranch = m_currentParents[0]->branch();
Chris@311 513 if (parentBranch == "") parentBranch = "default";
Chris@311 514
Chris@311 515 QStringList params;
Chris@311 516 params << "branch" << parentBranch;
Chris@311 517 m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params));
Chris@311 518 }
Chris@311 519
Chris@164 520 void MainWindow::hgTag(QString id)
jtkorhonen@34 521 {
Chris@109 522 QStringList params;
Chris@109 523 QString tag;
jtkorhonen@34 524
Chris@109 525 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@109 526 (this,
Chris@109 527 tr("Tag"),
Chris@109 528 tr("Enter tag:"),
Chris@193 529 tag,
Chris@365 530 tr("Add &Tag"))) {
Chris@164 531 if (!tag.isEmpty()) {//!!! do something better if it is empty
Chris@164 532
Chris@164 533 params << "tag" << "--user" << getUserInfo();
Chris@164 534 params << "--rev" << Changeset::hashOf(id) << filterTag(tag);
Chris@109 535
Chris@284 536 m_runner->requestAction(HgAction(ACT_TAG, m_workFolderPath, params));
jtkorhonen@34 537 }
jtkorhonen@34 538 }
jtkorhonen@34 539 }
jtkorhonen@34 540
jtkorhonen@34 541 void MainWindow::hgIgnore()
jtkorhonen@34 542 {
Chris@109 543 QString hgIgnorePath;
Chris@109 544 QStringList params;
Chris@178 545
Chris@284 546 hgIgnorePath = m_workFolderPath;
Chris@178 547 hgIgnorePath += "/.hgignore";
Chris@249 548
Chris@284 549 if (!QDir(m_workFolderPath).exists()) return;
Chris@249 550 QFile f(hgIgnorePath);
Chris@249 551 if (!f.exists()) {
Chris@249 552 f.open(QFile::WriteOnly);
Chris@249 553 QTextStream *ts = new QTextStream(&f);
Chris@249 554 *ts << "syntax: glob\n";
Chris@249 555 delete ts;
Chris@249 556 f.close();
Chris@249 557 }
Chris@109 558
Chris@109 559 params << hgIgnorePath;
Chris@179 560
Chris@239 561 QString editor = getEditorBinaryName();
Chris@112 562
Chris@179 563 if (editor == "") {
Chris@179 564 DEBUG << "Failed to find a text editor" << endl;
Chris@179 565 //!!! visible error!
Chris@179 566 return;
Chris@179 567 }
Chris@179 568
Chris@284 569 HgAction action(ACT_HG_IGNORE, m_workFolderPath, params);
Chris@179 570 action.executable = editor;
Chris@179 571
Chris@284 572 m_runner->requestAction(action);
Chris@179 573 }
Chris@179 574
Chris@326 575 void MainWindow::hgIgnoreFiles(QStringList files)
Chris@326 576 {
Chris@326 577 //!!! not implemented yet
Chris@326 578 DEBUG << "MainWindow::hgIgnoreFiles: Not implemented" << endl;
Chris@326 579 }
Chris@326 580
Chris@326 581 void MainWindow::hgUnIgnoreFiles(QStringList files)
Chris@326 582 {
Chris@326 583 //!!! not implemented yet
Chris@326 584 DEBUG << "MainWindow::hgUnIgnoreFiles: Not implemented" << endl;
Chris@326 585 }
Chris@326 586
Chris@239 587 QString MainWindow::getDiffBinaryName()
Chris@179 588 {
Chris@179 589 QSettings settings;
Chris@179 590 settings.beginGroup("Locations");
Chris@239 591 return settings.value("extdiffbinary", "").toString();
Chris@179 592 }
Chris@179 593
Chris@239 594 QString MainWindow::getMergeBinaryName()
Chris@179 595 {
Chris@179 596 QSettings settings;
Chris@179 597 settings.beginGroup("Locations");
Chris@239 598 return settings.value("mergebinary", "").toString();
Chris@179 599 }
Chris@179 600
Chris@239 601 QString MainWindow::getEditorBinaryName()
Chris@179 602 {
Chris@178 603 QSettings settings;
Chris@178 604 settings.beginGroup("Locations");
Chris@239 605 return settings.value("editorbinary", "").toString();
Chris@163 606 }
Chris@163 607
Chris@168 608 void MainWindow::hgShowSummary()
Chris@168 609 {
Chris@168 610 QStringList params;
Chris@168 611
Chris@168 612 params << "diff" << "--stat";
Chris@168 613
Chris@288 614 m_runner->requestAction(HgAction(ACT_UNCOMMITTED_SUMMARY, m_workFolderPath, params));
Chris@168 615 }
Chris@168 616
jtkorhonen@0 617 void MainWindow::hgFolderDiff()
jtkorhonen@0 618 {
Chris@326 619 hgDiffFiles(QStringList());
Chris@326 620 }
Chris@326 621
Chris@326 622 void MainWindow::hgDiffFiles(QStringList files)
Chris@326 623 {
Chris@239 624 QString diff = getDiffBinaryName();
Chris@179 625 if (diff == "") return;
Chris@112 626
Chris@109 627 QStringList params;
jtkorhonen@0 628
Chris@112 629 // Diff parent against working folder (folder diff)
Chris@112 630
Chris@148 631 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@179 632 params << "--program" << diff;
Chris@109 633
Chris@331 634 params << "--" << files; // may be none: whole dir
Chris@273 635
Chris@284 636 m_runner->requestAction(HgAction(ACT_FOLDERDIFF, m_workFolderPath, params));
jtkorhonen@0 637 }
jtkorhonen@0 638
Chris@148 639 void MainWindow::hgDiffToCurrent(QString id)
jtkorhonen@0 640 {
Chris@239 641 QString diff = getDiffBinaryName();
Chris@179 642 if (diff == "") return;
Chris@163 643
Chris@148 644 QStringList params;
jtkorhonen@0 645
Chris@148 646 // Diff given revision against working folder
jtkorhonen@0 647
Chris@148 648 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@179 649 params << "--program" << diff;
Chris@153 650 params << "--rev" << Changeset::hashOf(id);
Chris@148 651
Chris@284 652 m_runner->requestAction(HgAction(ACT_FOLDERDIFF, m_workFolderPath, params));
jtkorhonen@0 653 }
jtkorhonen@0 654
Chris@148 655 void MainWindow::hgDiffToParent(QString child, QString parent)
Chris@148 656 {
Chris@239 657 QString diff = getDiffBinaryName();
Chris@179 658 if (diff == "") return;
Chris@163 659
Chris@148 660 QStringList params;
Chris@148 661
Chris@281 662 // Diff given revision against parent revision
Chris@148 663
Chris@148 664 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@179 665 params << "--program" << diff;
Chris@153 666 params << "--rev" << Changeset::hashOf(parent)
Chris@153 667 << "--rev" << Changeset::hashOf(child);
Chris@148 668
Chris@284 669 m_runner->requestAction(HgAction(ACT_CHGSETDIFF, m_workFolderPath, params));
Chris@273 670 }
Chris@326 671
Chris@273 672
Chris@289 673 void MainWindow::hgShowSummaryFor(Changeset *cs)
Chris@288 674 {
Chris@288 675 QStringList params;
Chris@288 676
Chris@289 677 // This will pick a default parent if there is more than one
Chris@289 678 // (whereas with diff we need to supply one). But it does need a
Chris@289 679 // bit more parsing
Chris@289 680 params << "log" << "--stat" << "--rev" << Changeset::hashOf(cs->id());
Chris@289 681
Chris@289 682 m_runner->requestAction(HgAction(ACT_DIFF_SUMMARY, m_workFolderPath,
Chris@289 683 params, cs));
Chris@148 684 }
Chris@148 685
jtkorhonen@0 686
jtkorhonen@0 687 void MainWindow::hgUpdate()
jtkorhonen@0 688 {
Chris@109 689 QStringList params;
jtkorhonen@0 690
Chris@109 691 params << "update";
Chris@109 692
Chris@284 693 m_runner->requestAction(HgAction(ACT_UPDATE, m_workFolderPath, params));
jtkorhonen@0 694 }
jtkorhonen@0 695
jtkorhonen@0 696
Chris@148 697 void MainWindow::hgUpdateToRev(QString id)
jtkorhonen@0 698 {
Chris@148 699 QStringList params;
jtkorhonen@0 700
Chris@153 701 params << "update" << "--rev" << Changeset::hashOf(id) << "--check";
jtkorhonen@0 702
Chris@284 703 m_runner->requestAction(HgAction(ACT_UPDATE, m_workFolderPath, params));
jtkorhonen@0 704 }
jtkorhonen@0 705
jtkorhonen@0 706
jtkorhonen@0 707 void MainWindow::hgRevert()
jtkorhonen@0 708 {
Chris@326 709 hgRevertFiles(QStringList());
Chris@326 710 }
Chris@326 711
Chris@326 712 void MainWindow::hgRevertFiles(QStringList files)
Chris@326 713 {
Chris@109 714 QStringList params;
Chris@109 715 QString comment;
Chris@237 716 bool all = false;
Chris@98 717
Chris@284 718 QStringList allFiles = m_hgTabs->getAllRevertableFiles();
Chris@237 719 if (files.empty() || files == allFiles) {
Chris@237 720 files = allFiles;
Chris@237 721 all = true;
Chris@237 722 }
Chris@237 723
Chris@237 724 QString subsetNote;
Chris@237 725 if (!all) {
Chris@237 726 subsetNote = tr("<p><b>Note:</b> you are reverting only the files you have selected, not all of the files that have been changed!");
Chris@237 727 }
Chris@155 728
Chris@155 729 QString rf(tr("Revert files"));
Chris@237 730
Chris@237 731 // Set up params before asking for confirmation, because there is
Chris@237 732 // a failure case here that we would need to report on early
Chris@237 733
Chris@284 734 DEBUG << "hgRevert: m_justMerged = " << m_justMerged << ", m_mergeTargetRevision = " << m_mergeTargetRevision << endl;
Chris@273 735
Chris@284 736 if (m_justMerged) {
Chris@237 737
Chris@237 738 // This is a little fiddly. The proper way to "revert" the
Chris@237 739 // whole of an uncommitted merge is with "hg update --clean ."
Chris@237 740 // But if the user has selected only some files, we're sort of
Chris@237 741 // promising to revert only those, which means we need to
Chris@237 742 // specify which parent to revert to. We can only do that if
Chris@237 743 // we have a record of it, which we do if you just did the
Chris@237 744 // merge from within easyhg but don't if you've exited and
Chris@237 745 // restarted, or changed repository, since then. Hmmm.
Chris@237 746
Chris@237 747 if (all) {
Chris@237 748 params << "update" << "--clean" << ".";
Chris@237 749 } else {
Chris@284 750 if (m_mergeTargetRevision != "") {
Chris@237 751 params << "revert" << "--rev"
Chris@284 752 << Changeset::hashOf(m_mergeTargetRevision)
Chris@237 753 << "--" << files;
Chris@237 754 } else {
Chris@237 755 QMessageBox::information
Chris@237 756 (this, tr("Unable to revert"),
Chris@237 757 tr("<qt><b>Sorry, unable to revert these files</b><br><br>EasyMercurial can only revert a subset of files during a merge if it still has a record of which parent was the original merge target; that information is no longer available.<br><br>This is a limitation of EasyMercurial. Consider reverting all files, or using hg revert with a specific revision at the command-line instead.</qt>"));
Chris@237 758 return;
Chris@237 759 }
Chris@237 760 }
Chris@237 761 } else {
Chris@237 762 params << "revert" << "--" << files;
Chris@237 763 }
Chris@237 764
Chris@109 765 if (ConfirmCommentDialog::confirmDangerousFilesAction
Chris@109 766 (this,
Chris@155 767 rf,
Chris@237 768 tr("<h3>%1</h3><p>%2%3").arg(rf)
Chris@237 769 .arg(tr("You are about to <b>revert</b> the following files to their previous committed state.<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed."))
Chris@237 770 .arg(subsetNote),
Chris@237 771 tr("<h3>%1</h3><p>%2%3").arg(rf)
Chris@237 772 .arg(tr("You are about to <b>revert</b> %n file(s).<br><br>This will <b>throw away any changes</b> that you have made to these files but have not committed.", "", files.size()))
Chris@237 773 .arg(subsetNote),
Chris@193 774 files,
Chris@365 775 tr("Re&vert"))) {
Chris@163 776
Chris@284 777 m_lastRevertedFiles = files;
Chris@109 778
Chris@284 779 m_runner->requestAction(HgAction(ACT_REVERT, m_workFolderPath, params));
jtkorhonen@0 780 }
jtkorhonen@0 781 }
jtkorhonen@0 782
Chris@163 783
Chris@361 784 void MainWindow::hgRenameFiles(QStringList files)
Chris@361 785 {
Chris@361 786 QString renameTo;
Chris@361 787
Chris@361 788 QString file;
Chris@361 789 if (files.empty()) return;
Chris@361 790 file = files[0];
Chris@361 791
Chris@361 792 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@361 793 (this,
Chris@361 794 tr("Rename"),
Chris@361 795 tr("Rename <code>%1</code> to:").arg(xmlEncode(file)),
Chris@361 796 renameTo,
Chris@365 797 tr("Re&name"))) {
Chris@361 798
Chris@361 799 if (renameTo != "" && renameTo != file) {
Chris@361 800
Chris@361 801 QStringList params;
Chris@361 802
Chris@361 803 params << "rename" << "--" << file << renameTo;
Chris@361 804
Chris@361 805 m_runner->requestAction(HgAction(ACT_RENAME_FILE, m_workFolderPath, params));
Chris@361 806 }
Chris@361 807 }
Chris@361 808 }
Chris@361 809
Chris@361 810
Chris@361 811 void MainWindow::hgCopyFiles(QStringList files)
Chris@361 812 {
Chris@361 813 QString copyTo;
Chris@361 814
Chris@361 815 QString file;
Chris@361 816 if (files.empty()) return;
Chris@361 817 file = files[0];
Chris@361 818
Chris@361 819 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@361 820 (this,
Chris@361 821 tr("Copy"),
Chris@361 822 tr("Copy <code>%1</code> to:").arg(xmlEncode(file)),
Chris@361 823 copyTo,
Chris@365 824 tr("Co&py"))) {
Chris@361 825
Chris@361 826 if (copyTo != "" && copyTo != file) {
Chris@361 827
Chris@361 828 QStringList params;
Chris@361 829
Chris@361 830 params << "copy" << "--" << file << copyTo;
Chris@361 831
Chris@361 832 m_runner->requestAction(HgAction(ACT_COPY_FILE, m_workFolderPath, params));
Chris@361 833 }
Chris@361 834 }
Chris@361 835 }
Chris@361 836
Chris@361 837
Chris@326 838 void MainWindow::hgMarkFilesResolved(QStringList files)
Chris@163 839 {
Chris@163 840 QStringList params;
Chris@163 841
Chris@163 842 params << "resolve" << "--mark";
Chris@163 843
Chris@163 844 if (files.empty()) {
Chris@163 845 params << "--all";
Chris@163 846 } else {
Chris@164 847 params << "--" << files;
Chris@163 848 }
Chris@163 849
Chris@284 850 m_runner->requestAction(HgAction(ACT_RESOLVE_MARK, m_workFolderPath, params));
Chris@163 851 }
Chris@163 852
Chris@163 853
Chris@326 854 void MainWindow::hgRedoMerge()
Chris@326 855 {
Chris@326 856 hgRedoFileMerges(QStringList());
Chris@326 857 }
Chris@326 858
Chris@326 859
Chris@326 860 void MainWindow::hgRedoFileMerges(QStringList files)
jtkorhonen@33 861 {
Chris@109 862 QStringList params;
jtkorhonen@33 863
Chris@163 864 params << "resolve";
Chris@163 865
Chris@239 866 QString merge = getMergeBinaryName();
Chris@179 867 if (merge != "") {
Chris@179 868 params << "--tool" << merge;
Chris@163 869 }
Chris@163 870
Chris@163 871 if (files.empty()) {
Chris@163 872 params << "--all";
Chris@163 873 } else {
Chris@164 874 params << "--" << files;
Chris@163 875 }
Chris@163 876
Chris@284 877 if (m_currentParents.size() == 1) {
Chris@284 878 m_mergeTargetRevision = m_currentParents[0]->id();
Chris@237 879 }
Chris@237 880
Chris@284 881 m_runner->requestAction(HgAction(ACT_RETRY_MERGE, m_workFolderPath, params));
Chris@273 882
Chris@284 883 m_mergeCommitComment = tr("Merge");
jtkorhonen@33 884 }
Chris@326 885
jtkorhonen@33 886
jtkorhonen@0 887 void MainWindow::hgMerge()
jtkorhonen@0 888 {
Chris@284 889 if (m_hgTabs->canResolve()) {
Chris@326 890 hgRedoMerge();
Chris@163 891 return;
Chris@163 892 }
Chris@163 893
Chris@109 894 QStringList params;
jtkorhonen@0 895
Chris@109 896 params << "merge";
Chris@163 897
Chris@239 898 QString merge = getMergeBinaryName();
Chris@179 899 if (merge != "") {
Chris@179 900 params << "--tool" << merge;
Chris@163 901 }
Chris@163 902
Chris@284 903 if (m_currentParents.size() == 1) {
Chris@284 904 m_mergeTargetRevision = m_currentParents[0]->id();
Chris@163 905 }
Chris@163 906
Chris@284 907 m_runner->requestAction(HgAction(ACT_MERGE, m_workFolderPath, params));
Chris@273 908
Chris@284 909 m_mergeCommitComment = tr("Merge");
jtkorhonen@0 910 }
jtkorhonen@0 911
jtkorhonen@0 912
Chris@148 913 void MainWindow::hgMergeFrom(QString id)
Chris@148 914 {
Chris@148 915 QStringList params;
Chris@148 916
Chris@148 917 params << "merge";
Chris@153 918 params << "--rev" << Changeset::hashOf(id);
Chris@163 919
Chris@239 920 QString merge = getMergeBinaryName();
Chris@179 921 if (merge != "") {
Chris@179 922 params << "--tool" << merge;
Chris@163 923 }
Chris@148 924
Chris@284 925 if (m_currentParents.size() == 1) {
Chris@284 926 m_mergeTargetRevision = m_currentParents[0]->id();
Chris@237 927 }
Chris@237 928
Chris@284 929 m_runner->requestAction(HgAction(ACT_MERGE, m_workFolderPath, params));
Chris@273 930
Chris@284 931 m_mergeCommitComment = "";
Chris@273 932
Chris@284 933 foreach (Changeset *cs, m_currentHeads) {
Chris@284 934 if (cs->id() == id && !cs->isOnBranch(m_currentBranch)) {
Chris@157 935 if (cs->branch() == "" || cs->branch() == "default") {
Chris@284 936 m_mergeCommitComment = tr("Merge from the default branch");
Chris@157 937 } else {
Chris@284 938 m_mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
Chris@157 939 }
Chris@157 940 }
Chris@157 941 }
Chris@157 942
Chris@284 943 if (m_mergeCommitComment == "") {
Chris@284 944 m_mergeCommitComment = tr("Merge from %1").arg(id);
Chris@157 945 }
Chris@148 946 }
Chris@148 947
Chris@148 948
jtkorhonen@0 949 void MainWindow::hgCloneFromRemote()
jtkorhonen@0 950 {
Chris@109 951 QStringList params;
jtkorhonen@0 952
Chris@284 953 if (!QDir(m_workFolderPath).exists()) {
Chris@284 954 if (!QDir().mkpath(m_workFolderPath)) {
Chris@109 955 DEBUG << "hgCloneFromRemote: Failed to create target path "
Chris@284 956 << m_workFolderPath << endl;
Chris@109 957 //!!! report error
Chris@109 958 return;
Chris@104 959 }
Chris@109 960 }
Chris@104 961
Chris@284 962 params << "clone" << m_remoteRepoPath << m_workFolderPath;
Chris@109 963
Chris@287 964 updateWorkFolderAndRepoNames();
Chris@284 965 m_hgTabs->updateWorkFolderFileList("");
Chris@273 966
Chris@284 967 m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params));
jtkorhonen@0 968 }
jtkorhonen@0 969
jtkorhonen@0 970 void MainWindow::hgInit()
jtkorhonen@0 971 {
Chris@109 972 QStringList params;
jtkorhonen@0 973
Chris@109 974 params << "init";
Chris@284 975 params << m_workFolderPath;
Chris@273 976
Chris@284 977 m_runner->requestAction(HgAction(ACT_INIT, m_workFolderPath, params));
jtkorhonen@0 978 }
jtkorhonen@0 979
jtkorhonen@0 980 void MainWindow::hgIncoming()
jtkorhonen@0 981 {
Chris@109 982 QStringList params;
jtkorhonen@0 983
Chris@284 984 params << "incoming" << "--newest-first" << m_remoteRepoPath;
Chris@125 985 params << "--template" << Changeset::getLogTemplate();
jtkorhonen@0 986
Chris@284 987 m_runner->requestAction(HgAction(ACT_INCOMING, m_workFolderPath, params));
jtkorhonen@0 988 }
jtkorhonen@0 989
jtkorhonen@0 990 void MainWindow::hgPull()
jtkorhonen@0 991 {
Chris@193 992 if (ConfirmCommentDialog::confirm
Chris@126 993 (this, tr("Confirm pull"),
Chris@299 994 tr("<qt><h3>Pull from remote repository?</h3></qt>"),
Chris@299 995 tr("<qt><p>You are about to pull changes from the remote repository at <code>%1</code>.</p></qt>").arg(xmlEncode(m_remoteRepoPath)),
Chris@365 996 tr("&Pull"))) {
jtkorhonen@0 997
Chris@126 998 QStringList params;
Chris@284 999 params << "pull" << m_remoteRepoPath;
Chris@284 1000 m_runner->requestAction(HgAction(ACT_PULL, m_workFolderPath, params));
Chris@126 1001 }
jtkorhonen@0 1002 }
jtkorhonen@0 1003
jtkorhonen@0 1004 void MainWindow::hgPush()
jtkorhonen@0 1005 {
Chris@363 1006 if (m_remoteRepoPath.isEmpty()) {
Chris@363 1007 changeRemoteRepo(true);
Chris@363 1008 if (m_remoteRepoPath.isEmpty()) return;
Chris@363 1009 }
Chris@363 1010
Chris@356 1011 QString uncommittedNote;
Chris@356 1012 if (m_hgTabs->canCommit()) {
Chris@356 1013 uncommittedNote = tr("<p><b>Note:</b> You have uncommitted changes. If you want to push these changes to the remote repository, you need to commit them first.");
Chris@356 1014 }
Chris@356 1015
Chris@193 1016 if (ConfirmCommentDialog::confirm
Chris@126 1017 (this, tr("Confirm push"),
Chris@299 1018 tr("<qt><h3>Push to remote repository?</h3></qt>"),
Chris@356 1019 tr("<qt><p>You are about to push your commits to the remote repository at <code>%1</code>.</p>%2</qt>").arg(xmlEncode(m_remoteRepoPath)).arg(uncommittedNote),
Chris@365 1020 tr("&Push"))) {
jtkorhonen@0 1021
Chris@126 1022 QStringList params;
Chris@284 1023 params << "push" << "--new-branch" << m_remoteRepoPath;
Chris@284 1024 m_runner->requestAction(HgAction(ACT_PUSH, m_workFolderPath, params));
Chris@126 1025 }
jtkorhonen@0 1026 }
jtkorhonen@0 1027
Chris@182 1028 QStringList MainWindow::listAllUpIpV4Addresses()
jtkorhonen@26 1029 {
Chris@182 1030 QStringList ret;
jtkorhonen@26 1031 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
jtkorhonen@26 1032
Chris@182 1033 for (int i = 0; i < ifaces.count(); i++) {
jtkorhonen@26 1034 QNetworkInterface iface = ifaces.at(i);
Chris@182 1035 if (iface.flags().testFlag(QNetworkInterface::IsUp)
Chris@182 1036 && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
Chris@182 1037 for (int j=0; j<iface.addressEntries().count(); j++) {
jtkorhonen@28 1038 QHostAddress tmp = iface.addressEntries().at(j).ip();
Chris@182 1039 if (QAbstractSocket::IPv4Protocol == tmp.protocol()) {
Chris@182 1040 ret.push_back(tmp.toString());
jtkorhonen@24 1041 }
jtkorhonen@24 1042 }
jtkorhonen@22 1043 }
jtkorhonen@17 1044 }
jtkorhonen@28 1045 return ret;
jtkorhonen@28 1046 }
jtkorhonen@17 1047
Chris@120 1048 void MainWindow::clearState()
Chris@120 1049 {
Chris@305 1050 DEBUG << "MainWindow::clearState" << endl;
Chris@284 1051 foreach (Changeset *cs, m_currentParents) delete cs;
Chris@284 1052 m_currentParents.clear();
Chris@284 1053 foreach (Changeset *cs, m_currentHeads) delete cs;
Chris@284 1054 m_currentHeads.clear();
Chris@284 1055 m_currentBranch = "";
Chris@284 1056 m_lastStatOutput = "";
Chris@284 1057 m_lastRevertedFiles.clear();
Chris@284 1058 m_mergeTargetRevision = "";
Chris@284 1059 m_mergeCommitComment = "";
Chris@284 1060 m_stateUnknown = true;
Chris@284 1061 m_needNewLog = true;
Chris@284 1062 if (m_fsWatcher) {
Chris@241 1063 delete m_fsWatcherGeneralTimer;
Chris@241 1064 m_fsWatcherGeneralTimer = 0;
Chris@241 1065 delete m_fsWatcherRestoreTimer;
Chris@241 1066 m_fsWatcherRestoreTimer = 0;
Chris@284 1067 delete m_fsWatcher;
Chris@284 1068 m_fsWatcher = 0;
Chris@199 1069 }
Chris@120 1070 }
jtkorhonen@17 1071
jtkorhonen@11 1072 void MainWindow::hgServe()
jtkorhonen@11 1073 {
Chris@109 1074 QStringList params;
Chris@109 1075 QString msg;
jtkorhonen@11 1076
Chris@182 1077 QStringList addrs = listAllUpIpV4Addresses();
Chris@182 1078
Chris@182 1079 if (addrs.empty()) {
Chris@182 1080 QMessageBox::critical
Chris@182 1081 (this, tr("Serve"), tr("Failed to identify an active IPv4 address"));
Chris@182 1082 return;
Chris@182 1083 }
Chris@182 1084
Chris@182 1085 //!!! should find available port as well
Chris@182 1086
Chris@182 1087 QTextStream ts(&msg);
Chris@182 1088 ts << QString("<qt><p>%1</p>")
Chris@182 1089 .arg(tr("Running temporary server at %n address(es):", "", addrs.size()));
Chris@182 1090 foreach (QString addr, addrs) {
Chris@182 1091 ts << QString("<pre>&nbsp;&nbsp;http://%1:8000</pre>").arg(xmlEncode(addr));
Chris@182 1092 }
Chris@182 1093 ts << tr("<p>Press Close to stop the server and return.</p>");
Chris@182 1094 ts.flush();
Chris@182 1095
Chris@109 1096 params << "serve";
jtkorhonen@11 1097
Chris@284 1098 m_runner->requestAction(HgAction(ACT_SERVE, m_workFolderPath, params));
Chris@109 1099
Chris@182 1100 QMessageBox::information(this, tr("Serve"), msg, QMessageBox::Close);
Chris@182 1101
Chris@284 1102 m_runner->killCurrentActions();
jtkorhonen@11 1103 }
jtkorhonen@11 1104
Chris@64 1105 void MainWindow::startupDialog()
Chris@64 1106 {
Chris@64 1107 StartupDialog *dlg = new StartupDialog(this);
Chris@284 1108 if (dlg->exec()) m_firstStart = false;
Chris@344 1109 else exit(0);
Chris@64 1110 }
jtkorhonen@11 1111
Chris@69 1112 void MainWindow::open()
Chris@69 1113 {
Chris@86 1114 bool done = false;
Chris@69 1115
Chris@86 1116 while (!done) {
Chris@69 1117
Chris@86 1118 MultiChoiceDialog *d = new MultiChoiceDialog
Chris@86 1119 (tr("Open Repository"),
Chris@86 1120 tr("<qt><big>What would you like to open?</big></qt>"),
Chris@86 1121 this);
Chris@69 1122
Chris@345 1123 d->addChoice("remote",
Chris@345 1124 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
Chris@345 1125 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
Chris@345 1126 MultiChoiceDialog::UrlToDirectoryArg);
Chris@345 1127
Chris@339 1128 d->addChoice("local",
Chris@339 1129 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
Chris@339 1130 tr("Open an existing local Mercurial repository."),
Chris@339 1131 MultiChoiceDialog::DirectoryArg);
Chris@339 1132
Chris@339 1133 d->addChoice("init",
Chris@339 1134 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
Chris@339 1135 tr("Open a local folder, by creating a Mercurial repository in it."),
Chris@339 1136 MultiChoiceDialog::DirectoryArg);
Chris@339 1137
Chris@248 1138 QSettings settings;
Chris@248 1139 settings.beginGroup("General");
Chris@359 1140 QString lastChoice = settings.value("lastopentype", "remote").toString();
Chris@248 1141 if (lastChoice != "local" &&
Chris@248 1142 lastChoice != "remote" &&
Chris@248 1143 lastChoice != "init") {
Chris@359 1144 lastChoice = "remote";
Chris@248 1145 }
Chris@248 1146
Chris@248 1147 d->setCurrentChoice(lastChoice);
Chris@86 1148
Chris@86 1149 if (d->exec() == QDialog::Accepted) {
Chris@86 1150
Chris@86 1151 QString choice = d->getCurrentChoice();
Chris@248 1152 settings.setValue("lastopentype", choice);
Chris@248 1153
Chris@86 1154 QString arg = d->getArgument().trimmed();
Chris@86 1155
Chris@86 1156 bool result = false;
Chris@86 1157
Chris@86 1158 if (choice == "local") {
Chris@86 1159 result = openLocal(arg);
Chris@86 1160 } else if (choice == "remote") {
Chris@86 1161 result = openRemote(arg, d->getAdditionalArgument().trimmed());
Chris@86 1162 } else if (choice == "init") {
Chris@86 1163 result = openInit(arg);
Chris@86 1164 }
Chris@86 1165
Chris@86 1166 if (result) {
Chris@86 1167 enableDisableActions();
Chris@120 1168 clearState();
Chris@109 1169 hgQueryPaths();
Chris@91 1170 done = true;
Chris@91 1171 }
Chris@86 1172
Chris@86 1173 } else {
Chris@86 1174
Chris@86 1175 // cancelled
Chris@86 1176 done = true;
Chris@69 1177 }
Chris@79 1178
Chris@86 1179 delete d;
Chris@69 1180 }
Chris@69 1181 }
Chris@69 1182
Chris@359 1183 void MainWindow::recentMenuActivated()
Chris@359 1184 {
Chris@359 1185 QAction *a = qobject_cast<QAction *>(sender());
Chris@359 1186 if (!a) return;
Chris@359 1187 QString local = a->text();
Chris@359 1188 open(local);
Chris@359 1189 }
Chris@359 1190
Chris@182 1191 void MainWindow::changeRemoteRepo()
Chris@182 1192 {
Chris@363 1193 changeRemoteRepo(false);
Chris@363 1194 }
Chris@363 1195
Chris@363 1196 void MainWindow::changeRemoteRepo(bool initial)
Chris@363 1197 {
Chris@183 1198 // This will involve rewriting the local .hgrc
Chris@183 1199
Chris@284 1200 QDir hgDir(m_workFolderPath + "/.hg");
Chris@184 1201 if (!hgDir.exists()) {
Chris@184 1202 //!!! visible error!
Chris@184 1203 return;
Chris@184 1204 }
Chris@184 1205
Chris@284 1206 QFileInfo hgrc(m_workFolderPath + "/.hg/hgrc");
Chris@184 1207 if (hgrc.exists() && !hgrc.isWritable()) {
Chris@183 1208 //!!! visible error!
Chris@183 1209 return;
Chris@183 1210 }
Chris@183 1211
Chris@183 1212 MultiChoiceDialog *d = new MultiChoiceDialog
Chris@363 1213 (tr("Set Remote Location"),
Chris@363 1214 tr("<qt><big>Set the remote location</big></qt>"),
Chris@183 1215 this);
Chris@183 1216
Chris@363 1217 QString explanation;
Chris@363 1218 if (initial) {
Chris@363 1219 explanation = tr("Provide a URL to use for push and pull actions from the current local repository.<br>This will be the default for subsequent pushes and pulls.<br>You can change it using &ldquo;Set Remote Location&rdquo; on the File menu.");
Chris@363 1220 } else {
Chris@363 1221 explanation = tr("Provide a new URL to use for push and pull actions from the current local repository.");
Chris@363 1222 }
Chris@363 1223
Chris@183 1224 d->addChoice("remote",
Chris@183 1225 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
Chris@363 1226 explanation,
Chris@183 1227 MultiChoiceDialog::UrlArg);
Chris@183 1228
Chris@183 1229 if (d->exec() == QDialog::Accepted) {
Chris@210 1230
Chris@210 1231 // New block to ensure QSettings is deleted before
Chris@210 1232 // hgQueryPaths called. NB use of absoluteFilePath instead of
Chris@210 1233 // canonicalFilePath, which would fail if the file did not yet
Chris@210 1234 // exist
Chris@210 1235
Chris@210 1236 {
Chris@210 1237 QSettings s(hgrc.absoluteFilePath(), QSettings::IniFormat);
Chris@210 1238 s.beginGroup("paths");
Chris@210 1239 s.setValue("default", d->getArgument());
Chris@210 1240 }
Chris@210 1241
Chris@284 1242 m_stateUnknown = true;
Chris@183 1243 hgQueryPaths();
Chris@183 1244 }
Chris@183 1245
Chris@183 1246 delete d;
Chris@182 1247 }
Chris@182 1248
Chris@145 1249 void MainWindow::open(QString local)
Chris@145 1250 {
Chris@145 1251 if (openLocal(local)) {
Chris@145 1252 enableDisableActions();
Chris@145 1253 clearState();
Chris@145 1254 hgQueryPaths();
Chris@145 1255 }
Chris@145 1256 }
Chris@145 1257
Chris@79 1258 bool MainWindow::complainAboutFilePath(QString arg)
Chris@79 1259 {
Chris@79 1260 QMessageBox::critical
Chris@79 1261 (this, tr("File chosen"),
Chris@84 1262 tr("<qt><b>Folder required</b><br><br>You asked to open \"%1\".<br>This is a file; to open a repository, you need to choose a folder.</qt>").arg(xmlEncode(arg)));
Chris@79 1263 return false;
Chris@79 1264 }
Chris@79 1265
Chris@248 1266 bool MainWindow::askAboutUnknownFolder(QString arg)
Chris@248 1267 {
Chris@248 1268 bool result = (QMessageBox::question
Chris@248 1269 (this, tr("Path does not exist"),
Chris@248 1270 tr("<qt><b>Path does not exist: create it?</b><br><br>You asked to open a remote repository by cloning it to \"%1\". This folder does not exist, and neither does its parent.<br><br>Would you like to create the parent folder as well?</qt>").arg(xmlEncode(arg)),
Chris@248 1271 QMessageBox::Ok | QMessageBox::Cancel,
Chris@248 1272 QMessageBox::Cancel)
Chris@248 1273 == QMessageBox::Ok);
Chris@248 1274 if (result) {
Chris@248 1275 QDir dir(arg);
Chris@248 1276 dir.cdUp();
Chris@248 1277 if (!dir.mkpath(dir.absolutePath())) {
Chris@248 1278 QMessageBox::critical
Chris@248 1279 (this, tr("Failed to create folder"),
Chris@248 1280 tr("<qt><b>Failed to create folder</b><br><br>Sorry, the path for the parent folder \"%1\" could not be created.</qt>").arg(dir.absolutePath()));
Chris@248 1281 return false;
Chris@248 1282 }
Chris@248 1283 return true;
Chris@248 1284 }
Chris@248 1285 return false;
Chris@248 1286 }
Chris@248 1287
Chris@79 1288 bool MainWindow::complainAboutUnknownFolder(QString arg)
Chris@79 1289 {
Chris@79 1290 QMessageBox::critical
Chris@79 1291 (this, tr("Folder does not exist"),
Chris@84 1292 tr("<qt><b>Folder does not exist</b><br><br>You asked to open \"%1\".<br>This folder does not exist, and it cannot be created because its parent does not exist either.</qt>").arg(xmlEncode(arg)));
Chris@84 1293 return false;
Chris@84 1294 }
Chris@84 1295
Chris@84 1296 bool MainWindow::complainAboutInitInRepo(QString arg)
Chris@84 1297 {
Chris@84 1298 QMessageBox::critical
Chris@84 1299 (this, tr("Path is in existing repository"),
Chris@84 1300 tr("<qt><b>Path is in an existing repository</b><br><br>You asked to initialise a repository at \"%1\".<br>This path is already inside an existing repository.</qt>").arg(xmlEncode(arg)));
Chris@84 1301 return false;
Chris@84 1302 }
Chris@84 1303
Chris@84 1304 bool MainWindow::complainAboutInitFile(QString arg)
Chris@84 1305 {
Chris@84 1306 QMessageBox::critical
Chris@84 1307 (this, tr("Path is a file"),
Chris@84 1308 tr("<qt><b>Path is a file</b><br><br>You asked to initialise a repository at \"%1\".<br>This is an existing file; it is only possible to initialise in folders.</qt>").arg(xmlEncode(arg)));
Chris@84 1309 return false;
Chris@84 1310 }
Chris@84 1311
Chris@84 1312 bool MainWindow::complainAboutCloneToExisting(QString arg)
Chris@84 1313 {
Chris@84 1314 QMessageBox::critical
Chris@84 1315 (this, tr("Path is in existing repository"),
Chris@237 1316 tr("<qt><b>Local path is in an existing repository</b><br><br>You asked to open a remote repository by cloning it to the local path \"%1\".<br>This path is already inside an existing repository.<br>Please provide a different folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@84 1317 return false;
Chris@84 1318 }
Chris@84 1319
Chris@84 1320 bool MainWindow::complainAboutCloneToFile(QString arg)
Chris@84 1321 {
Chris@84 1322 QMessageBox::critical
Chris@84 1323 (this, tr("Path is a file"),
Chris@84 1324 tr("<qt><b>Local path is a file</b><br><br>You asked to open a remote repository by cloning it to the local path \"%1\".<br>This path is an existing file.<br>Please provide a new folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@84 1325 return false;
Chris@84 1326 }
Chris@84 1327
Chris@237 1328 QString MainWindow::complainAboutCloneToExistingFolder(QString arg, QString remote)
Chris@84 1329 {
Chris@348 1330 // If the directory "arg" exists but is empty, then we accept it.
Chris@348 1331
Chris@348 1332 // If the directory "arg" exists and is non-empty, but "arg" plus
Chris@348 1333 // the last path component of "remote" does not exist, then offer
Chris@348 1334 // the latter as an alternative path.
Chris@237 1335
Chris@237 1336 QString offer;
Chris@237 1337
Chris@237 1338 QDir d(arg);
Chris@348 1339
Chris@237 1340 if (d.exists()) {
Chris@348 1341
Chris@348 1342 if (d.entryList(QDir::Dirs | QDir::Files |
Chris@348 1343 QDir::NoDotAndDotDot |
Chris@348 1344 QDir::Hidden | QDir::System).empty()) {
Chris@348 1345 // directory is empty; accept it
Chris@348 1346 return arg;
Chris@348 1347 }
Chris@348 1348
Chris@237 1349 if (QRegExp("^\\w+://").indexIn(remote) >= 0) {
Chris@237 1350 QString rpath = QUrl(remote).path();
Chris@237 1351 if (rpath != "") {
Chris@237 1352 rpath = QDir(rpath).dirName();
Chris@237 1353 if (rpath != "" && !d.exists(rpath)) {
Chris@237 1354 offer = d.filePath(rpath);
Chris@237 1355 }
Chris@237 1356 }
Chris@237 1357 }
Chris@237 1358 }
Chris@237 1359
Chris@237 1360 if (offer != "") {
Chris@237 1361 bool result = (QMessageBox::question
Chris@237 1362 (this, tr("Folder exists"),
Chris@237 1363 tr("<qt><b>Local folder already exists</b><br><br>You asked to open a remote repository by cloning it to \"%1\", but this folder already exists and so cannot be cloned to.<br><br>Would you like to create the new folder \"%2\" instead?</qt>")
Chris@237 1364 .arg(xmlEncode(arg)).arg(xmlEncode(offer)),
Chris@237 1365 QMessageBox::Ok | QMessageBox::Cancel,
Chris@237 1366 QMessageBox::Cancel)
Chris@237 1367 == QMessageBox::Ok);
Chris@237 1368 if (result) return offer;
Chris@237 1369 else return "";
Chris@237 1370 }
Chris@237 1371
Chris@84 1372 QMessageBox::critical
Chris@84 1373 (this, tr("Folder exists"),
Chris@237 1374 tr("<qt><b>Local folder already exists</b><br><br>You asked to open a remote repository by cloning it to \"%1\", but this file or folder already exists and so cannot be cloned to.<br>Please provide a different folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@237 1375 return "";
Chris@79 1376 }
Chris@79 1377
Chris@79 1378 bool MainWindow::askToOpenParentRepo(QString arg, QString parent)
Chris@79 1379 {
Chris@79 1380 return (QMessageBox::question
Chris@84 1381 (this, tr("Path is inside a repository"),
Chris@86 1382 tr("<qt><b>Open the repository that contains this path?</b><br><br>You asked to open \"%1\".<br>This is not the root folder of a repository.<br>But it is inside a repository, whose root is at \"%2\". <br><br>Would you like to open that repository instead?</qt>")
Chris@79 1383 .arg(xmlEncode(arg)).arg(xmlEncode(parent)),
Chris@79 1384 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 1385 QMessageBox::Ok)
Chris@79 1386 == QMessageBox::Ok);
Chris@79 1387 }
Chris@79 1388
Chris@79 1389 bool MainWindow::askToInitExisting(QString arg)
Chris@79 1390 {
Chris@79 1391 return (QMessageBox::question
Chris@84 1392 (this, tr("Folder has no repository"),
Chris@359 1393 tr("<qt><b>Initialise a repository here?</b><br><br>You asked to open \"%1\".<br>This folder is not a Mercurial working copy.<br><br>Would you like to initialise a repository here?</qt>")
Chris@79 1394 .arg(xmlEncode(arg)),
Chris@79 1395 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 1396 QMessageBox::Ok)
Chris@79 1397 == QMessageBox::Ok);
Chris@79 1398 }
Chris@79 1399
Chris@79 1400 bool MainWindow::askToInitNew(QString arg)
Chris@79 1401 {
Chris@79 1402 return (QMessageBox::question
Chris@84 1403 (this, tr("Folder does not exist"),
Chris@84 1404 tr("<qt><b>Initialise a new repository?</b><br><br>You asked to open \"%1\".<br>This folder does not yet exist.<br><br>Would you like to create the folder and initialise a new empty repository in it?</qt>")
Chris@84 1405 .arg(xmlEncode(arg)),
Chris@84 1406 QMessageBox::Ok | QMessageBox::Cancel,
Chris@84 1407 QMessageBox::Ok)
Chris@84 1408 == QMessageBox::Ok);
Chris@84 1409 }
Chris@84 1410
Chris@84 1411 bool MainWindow::askToOpenInsteadOfInit(QString arg)
Chris@84 1412 {
Chris@84 1413 return (QMessageBox::question
Chris@84 1414 (this, tr("Repository exists"),
Chris@84 1415 tr("<qt><b>Open existing repository?</b><br><br>You asked to initialise a new repository at \"%1\".<br>This folder already contains a repository. Would you like to open it?</qt>")
Chris@79 1416 .arg(xmlEncode(arg)),
Chris@79 1417 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 1418 QMessageBox::Ok)
Chris@79 1419 == QMessageBox::Ok);
Chris@79 1420 }
Chris@79 1421
Chris@79 1422 bool MainWindow::openLocal(QString local)
Chris@79 1423 {
Chris@79 1424 DEBUG << "open " << local << endl;
Chris@79 1425
Chris@79 1426 FolderStatus status = getFolderStatus(local);
Chris@79 1427 QString containing = getContainingRepoFolder(local);
Chris@79 1428
Chris@79 1429 switch (status) {
Chris@79 1430
Chris@79 1431 case FolderHasRepo:
Chris@79 1432 // fine
Chris@79 1433 break;
Chris@79 1434
Chris@79 1435 case FolderExists:
Chris@79 1436 if (containing != "") {
Chris@79 1437 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1438 local = containing;
Chris@79 1439 } else {
Chris@86 1440 //!!! No -- this is likely to happen far more by accident
Chris@86 1441 // than because the user actually wanted to init something.
Chris@86 1442 // Don't ask, just politely reject.
Chris@79 1443 if (!askToInitExisting(local)) return false;
Chris@79 1444 return openInit(local);
Chris@79 1445 }
Chris@79 1446 break;
Chris@79 1447
Chris@79 1448 case FolderParentExists:
Chris@79 1449 if (containing != "") {
Chris@79 1450 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1451 local = containing;
Chris@79 1452 } else {
Chris@79 1453 if (!askToInitNew(local)) return false;
Chris@79 1454 return openInit(local);
Chris@79 1455 }
Chris@79 1456 break;
Chris@79 1457
Chris@79 1458 case FolderUnknown:
Chris@84 1459 if (containing != "") {
Chris@84 1460 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1461 local = containing;
Chris@84 1462 } else {
Chris@84 1463 return complainAboutUnknownFolder(local);
Chris@84 1464 }
Chris@84 1465 break;
Chris@79 1466
Chris@79 1467 case FolderIsFile:
Chris@79 1468 return complainAboutFilePath(local);
Chris@79 1469 }
Chris@79 1470
Chris@284 1471 m_workFolderPath = local;
Chris@284 1472 m_remoteRepoPath = "";
Chris@79 1473 return true;
Chris@79 1474 }
Chris@79 1475
Chris@79 1476 bool MainWindow::openRemote(QString remote, QString local)
Chris@79 1477 {
Chris@79 1478 DEBUG << "clone " << remote << " to " << local << endl;
Chris@84 1479
Chris@84 1480 FolderStatus status = getFolderStatus(local);
Chris@84 1481 QString containing = getContainingRepoFolder(local);
Chris@84 1482
Chris@84 1483 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 1484
Chris@84 1485 if (status == FolderHasRepo || containing != "") {
Chris@84 1486 return complainAboutCloneToExisting(local);
Chris@84 1487 }
Chris@84 1488
Chris@84 1489 if (status == FolderIsFile) {
Chris@84 1490 return complainAboutCloneToFile(local);
Chris@84 1491 }
Chris@84 1492
Chris@84 1493 if (status == FolderUnknown) {
Chris@248 1494 if (!askAboutUnknownFolder(local)) {
Chris@248 1495 return false;
Chris@248 1496 }
Chris@84 1497 }
Chris@84 1498
Chris@84 1499 if (status == FolderExists) {
Chris@237 1500 local = complainAboutCloneToExistingFolder(local, remote);
Chris@237 1501 if (local == "") return false;
Chris@84 1502 }
Chris@84 1503
Chris@284 1504 m_workFolderPath = local;
Chris@284 1505 m_remoteRepoPath = remote;
Chris@84 1506 hgCloneFromRemote();
Chris@84 1507
Chris@79 1508 return true;
Chris@79 1509 }
Chris@79 1510
Chris@84 1511 bool MainWindow::openInit(QString local)
Chris@79 1512 {
Chris@84 1513 DEBUG << "openInit " << local << endl;
Chris@84 1514
Chris@84 1515 FolderStatus status = getFolderStatus(local);
Chris@84 1516 QString containing = getContainingRepoFolder(local);
Chris@84 1517
Chris@84 1518 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 1519
Chris@84 1520 if (status == FolderHasRepo) {
Chris@84 1521 if (!askToOpenInsteadOfInit(local)) return false;
Chris@84 1522 }
Chris@84 1523
Chris@84 1524 if (containing != "") {
Chris@84 1525 return complainAboutInitInRepo(local);
Chris@84 1526 }
Chris@84 1527
Chris@84 1528 if (status == FolderIsFile) {
Chris@84 1529 return complainAboutInitFile(local);
Chris@84 1530 }
Chris@84 1531
Chris@84 1532 if (status == FolderUnknown) {
Chris@84 1533 return complainAboutUnknownFolder(local);
Chris@84 1534 }
Chris@84 1535
Chris@284 1536 m_workFolderPath = local;
Chris@284 1537 m_remoteRepoPath = "";
Chris@84 1538 hgInit();
Chris@79 1539 return true;
Chris@79 1540 }
Chris@79 1541
jtkorhonen@0 1542 void MainWindow::settings()
jtkorhonen@0 1543 {
jtkorhonen@0 1544 SettingsDialog *settingsDlg = new SettingsDialog(this);
jtkorhonen@0 1545 settingsDlg->exec();
Chris@230 1546
Chris@230 1547 if (settingsDlg->presentationChanged()) {
Chris@284 1548 m_hgTabs->updateFileStates();
Chris@230 1549 updateToolBarStyle();
Chris@273 1550 hgRefresh();
Chris@230 1551 }
jtkorhonen@0 1552 }
jtkorhonen@0 1553
Chris@90 1554 void MainWindow::updateFileSystemWatcher()
Chris@90 1555 {
Chris@199 1556 bool justCreated = false;
Chris@284 1557 if (!m_fsWatcher) {
Chris@284 1558 m_fsWatcher = new QFileSystemWatcher();
Chris@199 1559 justCreated = true;
Chris@199 1560 }
Chris@199 1561
Chris@199 1562 // QFileSystemWatcher will refuse to add a file or directory to
Chris@199 1563 // its watch list that it is already watching -- fine, that's what
Chris@199 1564 // we want -- but it prints a warning when this happens, which is
Chris@199 1565 // annoying because it would be the normal case for us. So we'll
Chris@199 1566 // check for duplicates ourselves.
Chris@199 1567 QSet<QString> alreadyWatched;
Chris@284 1568 QStringList dl(m_fsWatcher->directories());
Chris@199 1569 foreach (QString d, dl) alreadyWatched.insert(d);
Chris@199 1570
Chris@90 1571 std::deque<QString> pending;
Chris@284 1572 pending.push_back(m_workFolderPath);
Chris@199 1573
Chris@90 1574 while (!pending.empty()) {
Chris@199 1575
Chris@90 1576 QString path = pending.front();
Chris@90 1577 pending.pop_front();
Chris@199 1578 if (!alreadyWatched.contains(path)) {
Chris@284 1579 m_fsWatcher->addPath(path);
Chris@199 1580 DEBUG << "Added to file system watcher: " << path << endl;
Chris@199 1581 }
Chris@199 1582
Chris@90 1583 QDir d(path);
Chris@90 1584 if (d.exists()) {
Chris@199 1585 d.setFilter(QDir::Dirs | QDir::NoDotAndDotDot |
Chris@199 1586 QDir::Readable | QDir::NoSymLinks);
Chris@90 1587 foreach (QString entry, d.entryList()) {
Chris@199 1588 if (entry.startsWith('.')) continue;
Chris@90 1589 QString entryPath = d.absoluteFilePath(entry);
Chris@90 1590 pending.push_back(entryPath);
Chris@90 1591 }
Chris@90 1592 }
Chris@90 1593 }
Chris@199 1594
Chris@238 1595 // The general timer isn't really related to the fs watcher
Chris@238 1596 // object, it just does something similar -- every now and then we
Chris@238 1597 // do a refresh just to update the history dates etc
Chris@238 1598
Chris@238 1599 m_fsWatcherGeneralTimer = new QTimer(this);
Chris@238 1600 connect(m_fsWatcherGeneralTimer, SIGNAL(timeout()),
Chris@238 1601 this, SLOT(checkFilesystem()));
Chris@238 1602 m_fsWatcherGeneralTimer->setInterval(30 * 60 * 1000); // half an hour
Chris@238 1603 m_fsWatcherGeneralTimer->start();
Chris@238 1604
Chris@199 1605 if (justCreated) {
Chris@284 1606 connect(m_fsWatcher, SIGNAL(directoryChanged(QString)),
Chris@199 1607 this, SLOT(fsDirectoryChanged(QString)));
Chris@284 1608 connect(m_fsWatcher, SIGNAL(fileChanged(QString)),
Chris@199 1609 this, SLOT(fsFileChanged(QString)));
Chris@199 1610 }
Chris@90 1611 }
Chris@90 1612
Chris@238 1613 void MainWindow::suspendFileSystemWatcher()
Chris@238 1614 {
Chris@238 1615 DEBUG << "MainWindow::suspendFileSystemWatcher" << endl;
Chris@284 1616 if (m_fsWatcher) {
Chris@241 1617 m_fsWatcherSuspended = true;
Chris@241 1618 if (m_fsWatcherRestoreTimer) {
Chris@241 1619 delete m_fsWatcherRestoreTimer;
Chris@241 1620 m_fsWatcherRestoreTimer = 0;
Chris@241 1621 }
Chris@238 1622 m_fsWatcherGeneralTimer->stop();
Chris@238 1623 }
Chris@238 1624 }
Chris@238 1625
Chris@238 1626 void MainWindow::restoreFileSystemWatcher()
Chris@238 1627 {
Chris@238 1628 DEBUG << "MainWindow::restoreFileSystemWatcher" << endl;
Chris@238 1629 if (m_fsWatcherRestoreTimer) delete m_fsWatcherRestoreTimer;
Chris@238 1630
Chris@238 1631 // The restore timer is used to leave a polite interval between
Chris@238 1632 // being asked to restore the watcher and actually doing so. It's
Chris@238 1633 // a single shot timer each time it's used, but we don't use
Chris@238 1634 // QTimer::singleShot because we want to stop the previous one if
Chris@238 1635 // it's running (via deleting it)
Chris@238 1636
Chris@238 1637 m_fsWatcherRestoreTimer = new QTimer(this);
Chris@238 1638 connect(m_fsWatcherRestoreTimer, SIGNAL(timeout()),
Chris@238 1639 this, SLOT(actuallyRestoreFileSystemWatcher()));
Chris@238 1640 m_fsWatcherRestoreTimer->setInterval(1000);
Chris@238 1641 m_fsWatcherRestoreTimer->setSingleShot(true);
Chris@238 1642 m_fsWatcherRestoreTimer->start();
Chris@238 1643 }
Chris@238 1644
Chris@238 1645 void MainWindow::actuallyRestoreFileSystemWatcher()
Chris@238 1646 {
Chris@238 1647 DEBUG << "MainWindow::actuallyRestoreFileSystemWatcher" << endl;
Chris@284 1648 if (m_fsWatcher) {
Chris@241 1649 m_fsWatcherSuspended = false;
Chris@241 1650 m_fsWatcherGeneralTimer->start();
Chris@241 1651 }
Chris@238 1652 }
Chris@238 1653
Chris@238 1654 void MainWindow::checkFilesystem()
Chris@238 1655 {
Chris@238 1656 DEBUG << "MainWindow::checkFilesystem" << endl;
Chris@273 1657 hgRefresh();
Chris@238 1658 }
Chris@238 1659
Chris@122 1660 void MainWindow::fsDirectoryChanged(QString d)
Chris@90 1661 {
Chris@122 1662 DEBUG << "MainWindow::fsDirectoryChanged " << d << endl;
Chris@241 1663 if (!m_fsWatcherSuspended) {
Chris@241 1664 hgStat();
Chris@241 1665 }
Chris@90 1666 }
Chris@90 1667
Chris@122 1668 void MainWindow::fsFileChanged(QString f)
Chris@90 1669 {
Chris@122 1670 DEBUG << "MainWindow::fsFileChanged " << f << endl;
Chris@241 1671 if (!m_fsWatcherSuspended) {
Chris@241 1672 hgStat();
Chris@241 1673 }
Chris@90 1674 }
Chris@90 1675
Chris@275 1676 QString MainWindow::format1(QString head)
Chris@275 1677 {
Chris@275 1678 return QString("<qt><h3>%1</h3></qt>").arg(head);
Chris@275 1679 }
Chris@275 1680
Chris@125 1681 QString MainWindow::format3(QString head, QString intro, QString code)
Chris@125 1682 {
Chris@196 1683 code = xmlEncode(code).replace("\n", "<br>")
Chris@196 1684 #ifndef Q_OS_WIN32
Chris@196 1685 // The hard hyphen comes out funny on Windows
Chris@196 1686 .replace("-", "&#8209;")
Chris@196 1687 #endif
Chris@196 1688 .replace(" ", "&nbsp;");
Chris@125 1689 if (intro == "") {
Chris@168 1690 return QString("<qt><h3>%1</h3><p><code>%2</code></p>")
Chris@168 1691 .arg(head).arg(code);
Chris@126 1692 } else if (code == "") {
Chris@126 1693 return QString("<qt><h3>%1</h3><p>%2</p>")
Chris@126 1694 .arg(head).arg(intro);
Chris@125 1695 } else {
Chris@168 1696 return QString("<qt><h3>%1</h3><p>%2</p><p><code>%3</code></p>")
Chris@168 1697 .arg(head).arg(intro).arg(code);
Chris@125 1698 }
Chris@125 1699 }
Chris@125 1700
Chris@120 1701 void MainWindow::showIncoming(QString output)
Chris@120 1702 {
Chris@284 1703 m_runner->hide();
Chris@125 1704 IncomingDialog *d = new IncomingDialog(this, output);
Chris@125 1705 d->exec();
Chris@125 1706 delete d;
Chris@125 1707 }
Chris@125 1708
Chris@125 1709 int MainWindow::extractChangeCount(QString text)
Chris@125 1710 {
Chris@125 1711 QRegExp re("added (\\d+) ch\\w+ with (\\d+) ch\\w+ to (\\d+) f\\w+");
Chris@125 1712 if (re.indexIn(text) >= 0) {
Chris@125 1713 return re.cap(1).toInt();
Chris@125 1714 } else if (text.contains("no changes")) {
Chris@125 1715 return 0;
Chris@125 1716 } else {
Chris@125 1717 return -1; // unknown
Chris@125 1718 }
Chris@120 1719 }
Chris@120 1720
Chris@120 1721 void MainWindow::showPushResult(QString output)
Chris@120 1722 {
Chris@291 1723 QString head;
Chris@125 1724 QString report;
Chris@125 1725 int n = extractChangeCount(output);
Chris@125 1726 if (n > 0) {
Chris@291 1727 head = tr("Pushed %n changeset(s)", "", n);
Chris@300 1728 report = tr("<qt>Successfully pushed to the remote repository at <code>%1</code>.</qt>").arg(xmlEncode(m_remoteRepoPath));
Chris@125 1729 } else if (n == 0) {
Chris@291 1730 head = tr("No changes to push");
Chris@291 1731 report = tr("The remote repository already contains all changes that have been committed locally.");
Chris@294 1732 if (m_hgTabs->canCommit()) {
Chris@291 1733 report = tr("%1<p>You do have some uncommitted changes. If you wish to push those to the remote repository, commit them locally first.").arg(report);
Chris@291 1734 }
Chris@125 1735 } else {
Chris@291 1736 head = tr("Push complete");
Chris@125 1737 }
Chris@284 1738 m_runner->hide();
Chris@291 1739
Chris@291 1740 MoreInformationDialog::information(this, tr("Push complete"),
Chris@291 1741 head, report, output);
Chris@120 1742 }
Chris@120 1743
Chris@120 1744 void MainWindow::showPullResult(QString output)
Chris@120 1745 {
Chris@291 1746 QString head;
Chris@125 1747 QString report;
Chris@125 1748 int n = extractChangeCount(output);
Chris@125 1749 if (n > 0) {
Chris@291 1750 head = tr("Pulled %n changeset(s)", "", n);
Chris@322 1751 report = tr("New changes will be highlighted in yellow in the history.");
Chris@125 1752 } else if (n == 0) {
Chris@291 1753 head = tr("No changes to pull");
Chris@291 1754 report = tr("Your local repository already contains all changes found in the remote repository.");
Chris@125 1755 } else {
Chris@291 1756 head = tr("Pull complete");
Chris@125 1757 }
Chris@284 1758 m_runner->hide();
Chris@275 1759
Chris@275 1760 MoreInformationDialog::information(this, tr("Pull complete"),
Chris@291 1761 head, report, output);
Chris@120 1762 }
Chris@120 1763
Chris@174 1764 void MainWindow::reportNewRemoteHeads(QString output)
Chris@174 1765 {
Chris@174 1766 bool headsAreLocal = false;
Chris@174 1767
Chris@284 1768 if (m_currentParents.size() == 1) {
Chris@284 1769 int m_currentBranchHeads = 0;
Chris@174 1770 bool parentIsHead = false;
Chris@284 1771 Changeset *parent = m_currentParents[0];
Chris@284 1772 foreach (Changeset *head, m_currentHeads) {
Chris@284 1773 if (head->isOnBranch(m_currentBranch)) {
Chris@284 1774 ++m_currentBranchHeads;
Chris@174 1775 }
Chris@174 1776 if (parent->id() == head->id()) {
Chris@174 1777 parentIsHead = true;
Chris@174 1778 }
Chris@174 1779 }
Chris@284 1780 if (m_currentBranchHeads == 2 && parentIsHead) {
Chris@174 1781 headsAreLocal = true;
Chris@174 1782 }
Chris@174 1783 }
Chris@174 1784
Chris@174 1785 if (headsAreLocal) {
Chris@291 1786 MoreInformationDialog::warning
Chris@291 1787 (this,
Chris@291 1788 tr("Push failed"),
Chris@291 1789 tr("Push failed"),
Chris@291 1790 tr("Your local repository could not be pushed to the remote repository.<br><br>You may need to merge the changes locally first."),
Chris@291 1791 output);
Chris@318 1792 } else if (m_hgTabs->canCommit() && m_currentParents.size() > 1) {
Chris@318 1793 MoreInformationDialog::warning
Chris@318 1794 (this,
Chris@318 1795 tr("Push failed"),
Chris@318 1796 tr("Push failed"),
Chris@318 1797 tr("Your local repository could not be pushed to the remote repository.<br><br>You have an uncommitted merge in your local folder. You probably need to commit it before you push."),
Chris@318 1798 output);
Chris@174 1799 } else {
Chris@291 1800 MoreInformationDialog::warning
Chris@291 1801 (this,
Chris@291 1802 tr("Push failed"),
Chris@291 1803 tr("Push failed"),
Chris@291 1804 tr("Your local repository could not be pushed to the remote repository.<br><br>The remote repository may have been changed by someone else since you last pushed. Try pulling and merging their changes into your local repository first."),
Chris@291 1805 output);
Chris@174 1806 }
Chris@174 1807 }
Chris@174 1808
Chris@353 1809 void MainWindow::reportAuthFailed(QString output)
Chris@353 1810 {
Chris@353 1811 MoreInformationDialog::warning
Chris@353 1812 (this,
Chris@353 1813 tr("Authorization failed"),
Chris@353 1814 tr("Authorization failed"),
Chris@353 1815 tr("You may have entered an incorrect user name or password, or the remote URL may be wrong.<br><br>Or you may lack the necessary permissions on the remote repository.<br><br>Check with the administrator of your remote repository if necessary."),
Chris@353 1816 output);
Chris@353 1817 }
Chris@353 1818
Chris@238 1819 void MainWindow::commandStarting(HgAction action)
Chris@238 1820 {
Chris@238 1821 // Annoyingly, hg stat actually modifies the working directory --
Chris@238 1822 // it creates files called hg-checklink and hg-checkexec to test
Chris@238 1823 // properties of the filesystem. For safety's sake, suspend the
Chris@238 1824 // fs watcher while running commands, and restore it shortly after
Chris@238 1825 // a command has finished.
Chris@238 1826
Chris@246 1827 if (action.action == ACT_STAT) {
Chris@246 1828 suspendFileSystemWatcher();
Chris@246 1829 }
Chris@238 1830 }
Chris@238 1831
Chris@143 1832 void MainWindow::commandFailed(HgAction action, QString output)
Chris@62 1833 {
Chris@62 1834 DEBUG << "MainWindow::commandFailed" << endl;
Chris@238 1835 restoreFileSystemWatcher();
Chris@74 1836
Chris@210 1837 QString setstr;
Chris@210 1838 #ifdef Q_OS_MAC
Chris@210 1839 setstr = tr("Preferences");
Chris@210 1840 #else
Chris@210 1841 setstr = tr("Settings");
Chris@210 1842 #endif
Chris@210 1843
Chris@353 1844 // Some commands we just have to ignore bad return values from,
Chris@353 1845 // and some output gets special treatment.
Chris@353 1846
Chris@353 1847 // Note our fallback case should always be to report a
Chris@353 1848 // non-specific error and show the text -- in case output scraping
Chris@353 1849 // fails (as it surely will). Note also that we must force the
Chris@353 1850 // locale in order to ensure the output is scrapable; this happens
Chris@353 1851 // in HgRunner and may break some system encodings.
Chris@113 1852
Chris@113 1853 switch(action.action) {
Chris@113 1854 case ACT_NONE:
Chris@113 1855 // uh huh
Chris@113 1856 return;
Chris@175 1857 case ACT_TEST_HG:
Chris@291 1858 MoreInformationDialog::warning
Chris@291 1859 (this,
Chris@291 1860 tr("Failed to run Mercurial"),
Chris@291 1861 tr("Failed to run Mercurial"),
Chris@291 1862 tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.").arg(setstr),
Chris@291 1863 output);
Chris@200 1864 settings();
Chris@200 1865 return;
Chris@200 1866 case ACT_TEST_HG_EXT:
Chris@309 1867 MoreInformationDialog::warning
Chris@291 1868 (this,
Chris@291 1869 tr("Failed to run Mercurial"),
Chris@291 1870 tr("Failed to run Mercurial with extension enabled"),
Chris@310 1871 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem.<br><br>You may be able to continue working if you switch off &ldquo;Use EasyHg Mercurial Extension&rdquo; in %1. Note that remote repositories that require authentication might not work if you do this.").arg(setstr),
Chris@291 1872 output);
Chris@175 1873 settings();
Chris@175 1874 return;
Chris@252 1875 case ACT_CLONEFROMREMOTE:
Chris@252 1876 // if clone fails, we have no repo
Chris@284 1877 m_workFolderPath = "";
Chris@252 1878 enableDisableActions();
Chris@330 1879 break; // go on to default report
Chris@113 1880 case ACT_INCOMING:
Chris@353 1881 if (output.contains("authorization failed")) {
Chris@353 1882 reportAuthFailed(output);
Chris@353 1883 return;
Chris@358 1884 } else if (output.contains("entry cancelled")) {
Chris@358 1885 // ignore this, user cancelled username or password dialog
Chris@358 1886 return;
Chris@353 1887 } else {
Chris@353 1888 // Incoming returns non-zero code and no output if the
Chris@353 1889 // check was successful but there are no changes
Chris@353 1890 // pending. This is the only case where we need to remove
Chris@353 1891 // warning messages, because it's the only case where a
Chris@353 1892 // non-zero code can be returned even though the command
Chris@353 1893 // has for our purposes succeeded
Chris@352 1894 QString replaced = output;
Chris@352 1895 while (1) {
Chris@352 1896 QString r1 = replaced;
Chris@352 1897 r1.replace(QRegExp("warning: [^\\n]*"), "");
Chris@352 1898 if (r1 == replaced) break;
Chris@352 1899 replaced = r1.trimmed();
Chris@352 1900 }
Chris@352 1901 if (replaced == "") {
Chris@352 1902 showIncoming("");
Chris@352 1903 return;
Chris@352 1904 }
Chris@211 1905 }
Chris@330 1906 break; // go on to default report
Chris@353 1907 case ACT_PULL:
Chris@353 1908 if (output.contains("authorization failed")) {
Chris@353 1909 reportAuthFailed(output);
Chris@353 1910 return;
Chris@358 1911 } else if (output.contains("entry cancelled")) {
Chris@358 1912 // ignore this, user cancelled username or password dialog
Chris@358 1913 return;
Chris@353 1914 }
Chris@353 1915 break; // go on to default report
Chris@353 1916 case ACT_PUSH:
Chris@353 1917 if (output.contains("creates new remote heads")) {
Chris@353 1918 reportNewRemoteHeads(output);
Chris@353 1919 return;
Chris@353 1920 } else if (output.contains("authorization failed")) {
Chris@353 1921 reportAuthFailed(output);
Chris@353 1922 return;
Chris@358 1923 } else if (output.contains("entry cancelled")) {
Chris@358 1924 // ignore this, user cancelled username or password dialog
Chris@358 1925 return;
Chris@353 1926 }
Chris@353 1927 break; // go on to default report
Chris@162 1928 case ACT_QUERY_HEADS:
Chris@162 1929 // fails if repo is empty; we don't care (if there's a genuine
Chris@202 1930 // problem, something else will fail too). Pretend it
Chris@202 1931 // succeeded, so that any further actions that are contingent
Chris@202 1932 // on the success of the heads query get carried out properly.
Chris@202 1933 commandCompleted(action, "");
Chris@162 1934 return;
Chris@113 1935 case ACT_FOLDERDIFF:
Chris@113 1936 case ACT_CHGSETDIFF:
Chris@113 1937 // external program, unlikely to be anything useful in stderr
Chris@113 1938 // and some return with failure codes when something as basic
Chris@113 1939 // as the user closing the window via the wm happens
Chris@113 1940 return;
Chris@328 1941 case ACT_MERGE:
Chris@328 1942 case ACT_RETRY_MERGE:
Chris@328 1943 MoreInformationDialog::information
Chris@328 1944 (this, tr("Merge"), tr("Merge failed"),
Chris@328 1945 tr("Some files were not merged successfully.<p>You can Merge again to repeat the interactive merge; use Revert to abandon the merge entirely; or edit the files that are in conflict in an editor and, when you are happy with them, choose Mark Resolved in each file's right-button menu."),
Chris@328 1946 output);
Chris@378 1947 m_mergeCommitComment = "";
Chris@328 1948 return;
Chris@199 1949 case ACT_STAT:
Chris@330 1950 break; // go on to default report
Chris@113 1951 default:
Chris@114 1952 break;
Chris@113 1953 }
Chris@113 1954
Chris@113 1955 QString command = action.executable;
Chris@113 1956 if (command == "") command = "hg";
Chris@113 1957 foreach (QString arg, action.params) {
Chris@113 1958 command += " " + arg;
Chris@113 1959 }
Chris@113 1960
Chris@309 1961 MoreInformationDialog::warning
Chris@309 1962 (this,
Chris@309 1963 tr("Command failed"),
Chris@309 1964 tr("Command failed"),
Chris@309 1965 tr("A Mercurial command failed to run correctly. This may indicate an installation problem or some other problem with EasyMercurial.<br><br>See &ldquo;More Details&rdquo; for the command output."),
Chris@309 1966 output);
Chris@62 1967 }
Chris@62 1968
Chris@109 1969 void MainWindow::commandCompleted(HgAction completedAction, QString output)
jtkorhonen@0 1970 {
Chris@238 1971 restoreFileSystemWatcher();
Chris@109 1972 HGACTIONS action = completedAction.action;
Chris@109 1973
Chris@109 1974 if (action == ACT_NONE) return;
Chris@109 1975
Chris@150 1976 bool headsChanged = false;
Chris@150 1977 QStringList oldHeadIds;
Chris@150 1978
Chris@150 1979 switch (action) {
Chris@109 1980
Chris@175 1981 case ACT_TEST_HG:
Chris@377 1982 {
Chris@377 1983 QRegExp versionRE("^Mercurial.*version ([\\d+])\\.([\\d+])");
Chris@377 1984 int pos = versionRE.indexIn(output);
Chris@377 1985 if (pos >= 0) {
Chris@377 1986 int major = versionRE.cap(1).toInt();
Chris@377 1987 int minor = versionRE.cap(2).toInt();
Chris@377 1988 // We need v1.7 or newer
Chris@377 1989 if (major < 1 || (major == 1 && minor < 7)) {
Chris@377 1990 MoreInformationDialog::warning
Chris@377 1991 (this,
Chris@377 1992 tr("Newer Mercurial version required"),
Chris@377 1993 tr("Newer Mercurial version required"),
Chris@377 1994 tr("To use EasyMercurial, you should have at least Mercurial v1.7 installed.<br><br>The version found on this system (v%1.%2) does not support all of the features required by EasyMercurial.").arg(major).arg(minor),
Chris@377 1995 output);
Chris@377 1996 }
Chris@377 1997 }
Chris@175 1998 break;
Chris@377 1999 }
Chris@175 2000
Chris@200 2001 case ACT_TEST_HG_EXT:
Chris@200 2002 break;
Chris@200 2003
Chris@109 2004 case ACT_QUERY_PATHS:
jtkorhonen@0 2005 {
Chris@109 2006 DEBUG << "stdout is " << output << endl;
Chris@109 2007 LogParser lp(output, "=");
Chris@109 2008 LogList ll = lp.parse();
Chris@109 2009 DEBUG << ll.size() << " results" << endl;
Chris@109 2010 if (!ll.empty()) {
Chris@284 2011 m_remoteRepoPath = lp.parse()[0]["default"].trimmed();
Chris@284 2012 DEBUG << "Set remote path to " << m_remoteRepoPath << endl;
Chris@210 2013 } else {
Chris@284 2014 m_remoteRepoPath = "";
Chris@109 2015 }
Chris@284 2016 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
Chris@284 2017 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
Chris@287 2018 updateWorkFolderAndRepoNames();
Chris@109 2019 break;
Chris@109 2020 }
jtkorhonen@0 2021
Chris@109 2022 case ACT_QUERY_BRANCH:
Chris@284 2023 m_currentBranch = output.trimmed();
Chris@109 2024 break;
jtkorhonen@0 2025
Chris@109 2026 case ACT_STAT:
Chris@284 2027 m_lastStatOutput = output;
Chris@109 2028 updateFileSystemWatcher();
Chris@109 2029 break;
Chris@163 2030
Chris@163 2031 case ACT_RESOLVE_LIST:
Chris@163 2032 if (output != "") {
Chris@163 2033 // Remove lines beginning with R (they are resolved,
Chris@163 2034 // and the file stat parser treats R as removed)
Chris@163 2035 QStringList outList = output.split('\n');
Chris@163 2036 QStringList winnowed;
Chris@163 2037 foreach (QString line, outList) {
Chris@163 2038 if (!line.startsWith("R ")) winnowed.push_back(line);
Chris@163 2039 }
Chris@163 2040 output = winnowed.join("\n");
Chris@163 2041 }
Chris@284 2042 DEBUG << "m_lastStatOutput = " << m_lastStatOutput << endl;
Chris@199 2043 DEBUG << "resolve output = " << output << endl;
Chris@284 2044 m_hgTabs->updateWorkFolderFileList(m_lastStatOutput + output);
Chris@163 2045 break;
Chris@163 2046
Chris@163 2047 case ACT_RESOLVE_MARK:
Chris@284 2048 m_shouldHgStat = true;
Chris@163 2049 break;
Chris@109 2050
Chris@109 2051 case ACT_INCOMING:
Chris@120 2052 showIncoming(output);
Chris@120 2053 break;
Chris@120 2054
Chris@109 2055 case ACT_ANNOTATE:
Chris@331 2056 {
Chris@331 2057 AnnotateDialog dialog(this, output);
Chris@331 2058 dialog.exec();
Chris@284 2059 m_shouldHgStat = true;
Chris@109 2060 break;
Chris@331 2061 }
Chris@109 2062
Chris@109 2063 case ACT_PULL:
Chris@120 2064 showPullResult(output);
Chris@284 2065 m_shouldHgStat = true;
Chris@109 2066 break;
Chris@109 2067
Chris@109 2068 case ACT_PUSH:
Chris@120 2069 showPushResult(output);
Chris@109 2070 break;
Chris@109 2071
Chris@109 2072 case ACT_INIT:
Chris@284 2073 MultiChoiceDialog::addRecentArgument("init", m_workFolderPath);
Chris@284 2074 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
Chris@109 2075 enableDisableActions();
Chris@284 2076 m_shouldHgStat = true;
Chris@109 2077 break;
Chris@109 2078
Chris@109 2079 case ACT_CLONEFROMREMOTE:
Chris@284 2080 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
Chris@284 2081 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
Chris@284 2082 MultiChoiceDialog::addRecentArgument("remote", m_workFolderPath, true);
Chris@291 2083 MoreInformationDialog::information
Chris@291 2084 (this,
Chris@291 2085 tr("Clone"),
Chris@291 2086 tr("Clone successful"),
Chris@295 2087 tr("The remote repository was successfully cloned to the local folder <code>%1</code>.").arg(xmlEncode(m_workFolderPath)),
Chris@291 2088 output);
Chris@109 2089 enableDisableActions();
Chris@284 2090 m_shouldHgStat = true;
Chris@109 2091 break;
Chris@109 2092
Chris@109 2093 case ACT_LOG:
Chris@284 2094 m_hgTabs->setNewLog(output);
Chris@284 2095 m_needNewLog = false;
Chris@120 2096 break;
Chris@120 2097
Chris@120 2098 case ACT_LOG_INCREMENTAL:
Chris@284 2099 m_hgTabs->addIncrementalLog(output);
Chris@109 2100 break;
Chris@109 2101
Chris@109 2102 case ACT_QUERY_PARENTS:
Chris@152 2103 {
Chris@284 2104 foreach (Changeset *cs, m_currentParents) delete cs;
Chris@284 2105 m_currentParents = Changeset::parseChangesets(output);
Chris@284 2106 QStringList parentIds = Changeset::getIds(m_currentParents);
Chris@284 2107 m_hgTabs->setCurrent(parentIds, m_currentBranch);
Chris@152 2108 }
Chris@109 2109 break;
Chris@109 2110
Chris@109 2111 case ACT_QUERY_HEADS:
Chris@150 2112 {
Chris@284 2113 oldHeadIds = Changeset::getIds(m_currentHeads);
Chris@150 2114 Changesets newHeads = Changeset::parseChangesets(output);
Chris@150 2115 QStringList newHeadIds = Changeset::getIds(newHeads);
Chris@150 2116 if (oldHeadIds != newHeadIds) {
Chris@150 2117 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl;
Chris@305 2118 DEBUG << "Old heads: " << oldHeadIds.join(",") << endl;
Chris@305 2119 DEBUG << "New heads: " << newHeadIds.join(",") << endl;
Chris@150 2120 headsChanged = true;
Chris@284 2121 foreach (Changeset *cs, m_currentHeads) delete cs;
Chris@284 2122 m_currentHeads = newHeads;
Chris@150 2123 }
Chris@150 2124 }
Chris@109 2125 break;
Chris@130 2126
Chris@130 2127 case ACT_COMMIT:
Chris@347 2128 if (m_currentParents.empty()) {
Chris@347 2129 // first commit to empty repo
Chris@347 2130 m_needNewLog = true;
Chris@347 2131 }
Chris@284 2132 m_hgTabs->clearSelections();
Chris@284 2133 m_justMerged = false;
Chris@284 2134 m_shouldHgStat = true;
Chris@130 2135 break;
Chris@163 2136
Chris@163 2137 case ACT_REVERT:
Chris@326 2138 hgMarkFilesResolved(m_lastRevertedFiles);
Chris@284 2139 m_justMerged = false;
Chris@163 2140 break;
Chris@109 2141
Chris@109 2142 case ACT_REMOVE:
Chris@109 2143 case ACT_ADD:
Chris@284 2144 m_hgTabs->clearSelections();
Chris@284 2145 m_shouldHgStat = true;
Chris@116 2146 break;
Chris@116 2147
Chris@164 2148 case ACT_TAG:
Chris@284 2149 m_needNewLog = true;
Chris@284 2150 m_shouldHgStat = true;
Chris@164 2151 break;
Chris@164 2152
Chris@278 2153 case ACT_NEW_BRANCH:
Chris@307 2154 m_shouldHgStat = true;
Chris@278 2155 break;
Chris@278 2156
Chris@288 2157 case ACT_UNCOMMITTED_SUMMARY:
Chris@168 2158 QMessageBox::information(this, tr("Change summary"),
Chris@168 2159 format3(tr("Summary of uncommitted changes"),
Chris@168 2160 "",
Chris@168 2161 output));
Chris@168 2162 break;
Chris@168 2163
Chris@288 2164 case ACT_DIFF_SUMMARY:
Chris@289 2165 {
Chris@289 2166 // Output has log info first, diff following after a blank line
Chris@289 2167 output.replace("\r\n", "\n");
Chris@289 2168 QStringList olist = output.split("\n\n", QString::SkipEmptyParts);
Chris@289 2169 if (olist.size() > 1) output = olist[1];
Chris@289 2170
Chris@289 2171 Changeset *cs = (Changeset *)completedAction.extraData;
Chris@289 2172 if (cs) {
Chris@289 2173 QMessageBox::information
Chris@289 2174 (this, tr("Change summary"),
Chris@289 2175 format3(tr("Summary of changes"),
Chris@289 2176 cs->formatHtml(),
Chris@289 2177 output));
Chris@289 2178 } else if (output == "") {
Chris@289 2179 // Can happen, for a merge commit (depending on parent)
Chris@288 2180 QMessageBox::information(this, tr("Change summary"),
Chris@288 2181 format3(tr("Summary of changes"),
Chris@288 2182 tr("No changes"),
Chris@288 2183 output));
Chris@288 2184 } else {
Chris@288 2185 QMessageBox::information(this, tr("Change summary"),
Chris@288 2186 format3(tr("Summary of changes"),
Chris@288 2187 "",
Chris@288 2188 output));
Chris@288 2189 }
Chris@288 2190 break;
Chris@289 2191 }
Chris@288 2192
Chris@109 2193 case ACT_FOLDERDIFF:
Chris@109 2194 case ACT_CHGSETDIFF:
Chris@109 2195 case ACT_SERVE:
Chris@109 2196 case ACT_HG_IGNORE:
Chris@284 2197 m_shouldHgStat = true;
Chris@109 2198 break;
Chris@109 2199
Chris@109 2200 case ACT_UPDATE:
Chris@162 2201 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output)));
Chris@284 2202 m_shouldHgStat = true;
Chris@109 2203 break;
Chris@109 2204
Chris@109 2205 case ACT_MERGE:
Chris@294 2206 MoreInformationDialog::information
Chris@294 2207 (this, tr("Merge"), tr("Merge successful"),
Chris@302 2208 tr("Remember to test and commit the result before making any further changes."),
Chris@294 2209 output);
Chris@284 2210 m_shouldHgStat = true;
Chris@284 2211 m_justMerged = true;
Chris@109 2212 break;
Chris@109 2213
Chris@109 2214 case ACT_RETRY_MERGE:
Chris@163 2215 QMessageBox::information(this, tr("Resolved"),
Chris@302 2216 tr("<qt><h3>Merge resolved</h3><p>Merge resolved successfully.<br>Remember to test and commit the result before making any further changes.</p>"));
Chris@284 2217 m_shouldHgStat = true;
Chris@284 2218 m_justMerged = true;
Chris@109 2219 break;
Chris@109 2220
Chris@109 2221 default:
Chris@109 2222 break;
Chris@109 2223 }
Chris@108 2224
Chris@121 2225 // Sequence when no full log required:
Chris@163 2226 // paths -> branch -> stat -> resolve-list -> heads ->
Chris@150 2227 // incremental-log (only if heads changed) -> parents
Chris@150 2228 //
Chris@121 2229 // Sequence when full log required:
Chris@163 2230 // paths -> branch -> stat -> resolve-list -> heads -> parents -> log
Chris@150 2231 //
Chris@150 2232 // Note we want to call enableDisableActions only once, at the end
Chris@150 2233 // of whichever sequence is in use.
Chris@150 2234
Chris@156 2235 bool noMore = false;
Chris@156 2236
Chris@150 2237 switch (action) {
Chris@175 2238
Chris@175 2239 case ACT_TEST_HG:
Chris@248 2240 {
Chris@248 2241 QSettings settings;
Chris@248 2242 settings.beginGroup("General");
Chris@248 2243 if (settings.value("useextension", true).toBool()) {
Chris@248 2244 hgTestExtension();
Chris@284 2245 } else if (m_workFolderPath == "") {
Chris@248 2246 open();
Chris@248 2247 } else {
Chris@248 2248 hgQueryPaths();
Chris@248 2249 }
Chris@200 2250 break;
Chris@248 2251 }
Chris@200 2252
Chris@200 2253 case ACT_TEST_HG_EXT:
Chris@284 2254 if (m_workFolderPath == "") {
Chris@248 2255 open();
Chris@248 2256 } else{
Chris@248 2257 hgQueryPaths();
Chris@248 2258 }
Chris@175 2259 break;
Chris@150 2260
Chris@150 2261 case ACT_QUERY_PATHS:
Chris@109 2262 hgQueryBranch();
Chris@150 2263 break;
Chris@150 2264
Chris@150 2265 case ACT_QUERY_BRANCH:
Chris@109 2266 hgStat();
Chris@150 2267 break;
Chris@150 2268
Chris@150 2269 case ACT_STAT:
Chris@163 2270 hgResolveList();
Chris@163 2271 break;
Chris@163 2272
Chris@163 2273 case ACT_RESOLVE_LIST:
Chris@150 2274 hgQueryHeads();
Chris@150 2275 break;
Chris@150 2276
Chris@150 2277 case ACT_QUERY_HEADS:
Chris@284 2278 if (headsChanged && !m_needNewLog) {
Chris@150 2279 hgLogIncremental(oldHeadIds);
Chris@121 2280 } else {
Chris@150 2281 hgQueryParents();
Chris@121 2282 }
Chris@150 2283 break;
Chris@150 2284
Chris@150 2285 case ACT_LOG_INCREMENTAL:
Chris@109 2286 hgQueryParents();
Chris@150 2287 break;
Chris@150 2288
Chris@150 2289 case ACT_QUERY_PARENTS:
Chris@284 2290 if (m_needNewLog) {
Chris@120 2291 hgLog();
Chris@150 2292 } else {
Chris@150 2293 // we're done
Chris@156 2294 noMore = true;
Chris@120 2295 }
Chris@150 2296 break;
Chris@150 2297
Chris@150 2298 case ACT_LOG:
Chris@150 2299 // we're done
Chris@156 2300 noMore = true;
Chris@198 2301 break;
Chris@150 2302
Chris@150 2303 default:
Chris@284 2304 if (m_shouldHgStat) {
Chris@284 2305 m_shouldHgStat = false;
Chris@109 2306 hgQueryPaths();
Chris@150 2307 } else {
Chris@156 2308 noMore = true;
jtkorhonen@0 2309 }
Chris@150 2310 break;
Chris@150 2311 }
Chris@156 2312
Chris@156 2313 if (noMore) {
Chris@284 2314 m_stateUnknown = false;
Chris@156 2315 enableDisableActions();
Chris@284 2316 m_hgTabs->updateHistory();
Chris@359 2317 updateRecentMenu();
Chris@156 2318 }
jtkorhonen@0 2319 }
jtkorhonen@0 2320
jtkorhonen@0 2321 void MainWindow::connectActions()
jtkorhonen@0 2322 {
Chris@284 2323 connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close()));
Chris@284 2324 connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
Chris@273 2325
Chris@284 2326 connect(m_hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
Chris@284 2327 connect(m_hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
Chris@284 2328 connect(m_hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
Chris@284 2329 connect(m_hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
Chris@284 2330 connect(m_hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
Chris@284 2331 connect(m_hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
Chris@284 2332 connect(m_hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
Chris@284 2333 connect(m_hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
Chris@284 2334 connect(m_hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
Chris@273 2335
Chris@284 2336 connect(m_settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
Chris@284 2337 connect(m_openAct, SIGNAL(triggered()), this, SLOT(open()));
Chris@284 2338 connect(m_changeRemoteRepoAct, SIGNAL(triggered()), this, SLOT(changeRemoteRepo()));
Chris@273 2339
Chris@284 2340 connect(m_hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
Chris@284 2341 connect(m_hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
Chris@284 2342 connect(m_hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
Chris@273 2343
Chris@284 2344 connect(m_hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
jtkorhonen@0 2345 }
Chris@141 2346
Chris@141 2347 void MainWindow::connectTabsSignals()
Chris@141 2348 {
Chris@327 2349 connect(m_hgTabs, SIGNAL(currentChanged(int)),
Chris@327 2350 this, SLOT(enableDisableActions()));
Chris@327 2351
Chris@284 2352 connect(m_hgTabs, SIGNAL(commit()),
Chris@141 2353 this, SLOT(hgCommit()));
Chris@141 2354
Chris@284 2355 connect(m_hgTabs, SIGNAL(revert()),
Chris@141 2356 this, SLOT(hgRevert()));
Chris@141 2357
Chris@284 2358 connect(m_hgTabs, SIGNAL(diffWorkingFolder()),
Chris@141 2359 this, SLOT(hgFolderDiff()));
Chris@168 2360
Chris@284 2361 connect(m_hgTabs, SIGNAL(showSummary()),
Chris@168 2362 this, SLOT(hgShowSummary()));
Chris@311 2363
Chris@311 2364 connect(m_hgTabs, SIGNAL(newBranch()),
Chris@311 2365 this, SLOT(hgNewBranch()));
Chris@311 2366
Chris@311 2367 connect(m_hgTabs, SIGNAL(noBranch()),
Chris@311 2368 this, SLOT(hgNoBranch()));
Chris@148 2369
Chris@284 2370 connect(m_hgTabs, SIGNAL(updateTo(QString)),
Chris@148 2371 this, SLOT(hgUpdateToRev(QString)));
Chris@141 2372
Chris@284 2373 connect(m_hgTabs, SIGNAL(diffToCurrent(QString)),
Chris@148 2374 this, SLOT(hgDiffToCurrent(QString)));
Chris@141 2375
Chris@284 2376 connect(m_hgTabs, SIGNAL(diffToParent(QString, QString)),
Chris@148 2377 this, SLOT(hgDiffToParent(QString, QString)));
Chris@141 2378
Chris@289 2379 connect(m_hgTabs, SIGNAL(showSummary(Changeset *)),
Chris@289 2380 this, SLOT(hgShowSummaryFor(Changeset *)));
Chris@288 2381
Chris@284 2382 connect(m_hgTabs, SIGNAL(mergeFrom(QString)),
Chris@148 2383 this, SLOT(hgMergeFrom(QString)));
Chris@164 2384
Chris@307 2385 connect(m_hgTabs, SIGNAL(newBranch(QString)),
Chris@311 2386 this, SLOT(hgNewBranch()));
Chris@278 2387
Chris@284 2388 connect(m_hgTabs, SIGNAL(tag(QString)),
Chris@148 2389 this, SLOT(hgTag(QString)));
Chris@326 2390
Chris@326 2391 connect(m_hgTabs, SIGNAL(annotateFiles(QStringList)),
Chris@326 2392 this, SLOT(hgAnnotateFiles(QStringList)));
Chris@326 2393
Chris@326 2394 connect(m_hgTabs, SIGNAL(diffFiles(QStringList)),
Chris@326 2395 this, SLOT(hgDiffFiles(QStringList)));
Chris@326 2396
Chris@326 2397 connect(m_hgTabs, SIGNAL(commitFiles(QStringList)),
Chris@326 2398 this, SLOT(hgCommitFiles(QStringList)));
Chris@326 2399
Chris@326 2400 connect(m_hgTabs, SIGNAL(revertFiles(QStringList)),
Chris@326 2401 this, SLOT(hgRevertFiles(QStringList)));
Chris@326 2402
Chris@361 2403 connect(m_hgTabs, SIGNAL(renameFiles(QStringList)),
Chris@361 2404 this, SLOT(hgRenameFiles(QStringList)));
Chris@361 2405
Chris@361 2406 connect(m_hgTabs, SIGNAL(copyFiles(QStringList)),
Chris@361 2407 this, SLOT(hgCopyFiles(QStringList)));
Chris@361 2408
Chris@326 2409 connect(m_hgTabs, SIGNAL(addFiles(QStringList)),
Chris@326 2410 this, SLOT(hgAddFiles(QStringList)));
Chris@326 2411
Chris@326 2412 connect(m_hgTabs, SIGNAL(removeFiles(QStringList)),
Chris@326 2413 this, SLOT(hgRemoveFiles(QStringList)));
Chris@326 2414
Chris@326 2415 connect(m_hgTabs, SIGNAL(redoFileMerges(QStringList)),
Chris@326 2416 this, SLOT(hgRedoFileMerges(QStringList)));
Chris@326 2417
Chris@326 2418 connect(m_hgTabs, SIGNAL(markFilesResolved(QStringList)),
Chris@326 2419 this, SLOT(hgMarkFilesResolved(QStringList)));
Chris@326 2420
Chris@326 2421 connect(m_hgTabs, SIGNAL(ignoreFiles(QStringList)),
Chris@326 2422 this, SLOT(hgIgnoreFiles(QStringList)));
Chris@326 2423
Chris@326 2424 connect(m_hgTabs, SIGNAL(unIgnoreFiles(QStringList)),
Chris@326 2425 this, SLOT(hgUnIgnoreFiles(QStringList)));
Chris@141 2426 }
Chris@141 2427
jtkorhonen@0 2428 void MainWindow::enableDisableActions()
jtkorhonen@0 2429 {
Chris@90 2430 DEBUG << "MainWindow::enableDisableActions" << endl;
Chris@90 2431
Chris@284 2432 QString dirname = QDir(m_workFolderPath).dirName();
Chris@340 2433
Chris@340 2434 if (m_workFolderPath != "") { // dirname of "" is ".", so test path instead
Chris@202 2435 setWindowTitle(tr("EasyMercurial: %1").arg(dirname));
Chris@202 2436 } else {
Chris@202 2437 setWindowTitle(tr("EasyMercurial"));
Chris@202 2438 }
Chris@202 2439
Chris@115 2440 //!!! should also do things like set the status texts for the
Chris@115 2441 //!!! actions appropriately by context
Chris@115 2442
jtkorhonen@0 2443 QDir localRepoDir;
jtkorhonen@0 2444 QDir workFolderDir;
Chris@145 2445 bool workFolderExist = true;
Chris@145 2446 bool localRepoExist = true;
jtkorhonen@0 2447
Chris@284 2448 m_remoteRepoActionsEnabled = true;
Chris@284 2449 if (m_remoteRepoPath.isEmpty()) {
Chris@284 2450 m_remoteRepoActionsEnabled = false;
jtkorhonen@0 2451 }
jtkorhonen@0 2452
Chris@284 2453 m_localRepoActionsEnabled = true;
Chris@284 2454 if (m_workFolderPath.isEmpty()) {
Chris@284 2455 m_localRepoActionsEnabled = false;
jtkorhonen@0 2456 workFolderExist = false;
jtkorhonen@0 2457 }
jtkorhonen@0 2458
Chris@284 2459 if (m_workFolderPath == "" || !workFolderDir.exists(m_workFolderPath)) {
Chris@284 2460 m_localRepoActionsEnabled = false;
jtkorhonen@0 2461 workFolderExist = false;
Chris@90 2462 } else {
jtkorhonen@0 2463 workFolderExist = true;
jtkorhonen@0 2464 }
jtkorhonen@0 2465
Chris@284 2466 if (!localRepoDir.exists(m_workFolderPath + "/.hg")) {
Chris@284 2467 m_localRepoActionsEnabled = false;
jtkorhonen@0 2468 localRepoExist = false;
jtkorhonen@0 2469 }
jtkorhonen@0 2470
Chris@179 2471 bool haveDiff = false;
Chris@179 2472 QSettings settings;
Chris@179 2473 settings.beginGroup("Locations");
Chris@179 2474 if (settings.value("extdiffbinary", "").toString() != "") {
Chris@179 2475 haveDiff = true;
Chris@179 2476 }
Chris@179 2477 settings.endGroup();
Chris@112 2478
Chris@365 2479 m_hgRefreshAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2480 m_hgFolderDiffAct->setEnabled(m_localRepoActionsEnabled && haveDiff);
Chris@365 2481 m_hgRevertAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2482 m_hgAddAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2483 m_hgRemoveAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2484 m_hgUpdateAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2485 m_hgCommitAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2486 m_hgMergeAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2487 m_hgServeAct->setEnabled(m_localRepoActionsEnabled);
Chris@365 2488 m_hgIgnoreAct->setEnabled(m_localRepoActionsEnabled);
Chris@273 2489
Chris@284 2490 DEBUG << "m_localRepoActionsEnabled = " << m_localRepoActionsEnabled << endl;
Chris@284 2491 DEBUG << "canCommit = " << m_hgTabs->canCommit() << endl;
Chris@273 2492
Chris@284 2493 m_hgAddAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canAdd());
Chris@284 2494 m_hgRemoveAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canRemove());
Chris@284 2495 m_hgCommitAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canCommit());
Chris@284 2496 m_hgRevertAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canRevert());
Chris@284 2497 m_hgFolderDiffAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canDiff());
Chris@90 2498
Chris@108 2499 // A default merge makes sense if:
Chris@108 2500 // * there is only one parent (if there are two, we have an uncommitted merge) and
Chris@108 2501 // * there are exactly two heads that have the same branch as the current branch and
Chris@108 2502 // * our parent is one of those heads
Chris@108 2503 //
Chris@108 2504 // A default update makes sense if:
Chris@108 2505 // * there is only one parent and
Chris@108 2506 // * the parent is not one of the current heads
Chris@156 2507
Chris@108 2508 bool canMerge = false;
Chris@108 2509 bool canUpdate = false;
Chris@156 2510 bool haveMerge = false;
Chris@162 2511 bool emptyRepo = false;
Chris@225 2512 bool noWorkingCopy = false;
Chris@235 2513 bool newBranch = false;
Chris@284 2514 int m_currentBranchHeads = 0;
Chris@273 2515
Chris@284 2516 if (m_currentParents.size() == 1) {
Chris@156 2517 bool parentIsHead = false;
Chris@284 2518 Changeset *parent = m_currentParents[0];
Chris@284 2519 foreach (Changeset *head, m_currentHeads) {
Chris@284 2520 DEBUG << "head branch " << head->branch() << ", current branch " << m_currentBranch << endl;
Chris@284 2521 if (head->isOnBranch(m_currentBranch)) {
Chris@284 2522 ++m_currentBranchHeads;
Chris@235 2523 }
Chris@235 2524 if (parent->id() == head->id()) {
Chris@235 2525 parentIsHead = true;
Chris@108 2526 }
Chris@108 2527 }
Chris@284 2528 if (m_currentBranchHeads == 2 && parentIsHead) {
Chris@108 2529 canMerge = true;
Chris@108 2530 }
Chris@284 2531 if (m_currentBranchHeads == 0 && parentIsHead) {
Chris@235 2532 // Just created a new branch
Chris@235 2533 newBranch = true;
Chris@235 2534 }
Chris@108 2535 if (!parentIsHead) {
Chris@108 2536 canUpdate = true;
Chris@108 2537 DEBUG << "parent id = " << parent->id() << endl;
Chris@108 2538 DEBUG << " head ids "<<endl;
Chris@284 2539 foreach (Changeset *h, m_currentHeads) {
Chris@108 2540 DEBUG << "head id = " << h->id() << endl;
Chris@108 2541 }
Chris@108 2542 }
Chris@284 2543 m_justMerged = false;
Chris@284 2544 } else if (m_currentParents.size() == 0) {
Chris@284 2545 if (m_currentHeads.size() == 0) {
Chris@225 2546 // No heads -> empty repo
Chris@225 2547 emptyRepo = true;
Chris@225 2548 } else {
Chris@225 2549 // Heads, but no parents -> no working copy, e.g. we have
Chris@225 2550 // just converted this repo but haven't updated in it yet.
Chris@225 2551 // Uncommon but confusing; probably merits a special case
Chris@225 2552 noWorkingCopy = true;
Chris@225 2553 canUpdate = true;
Chris@225 2554 }
Chris@284 2555 m_justMerged = false;
Chris@156 2556 } else {
Chris@156 2557 haveMerge = true;
Chris@284 2558 m_justMerged = true;
Chris@108 2559 }
Chris@156 2560
Chris@363 2561 m_hgIncomingAct->setEnabled(m_remoteRepoActionsEnabled);
Chris@363 2562 m_hgPullAct->setEnabled(m_remoteRepoActionsEnabled);
Chris@363 2563 // permit push even if no remote yet; we'll ask for one
Chris@363 2564 m_hgPushAct->setEnabled(m_localRepoActionsEnabled && !emptyRepo);
Chris@363 2565
Chris@284 2566 m_hgMergeAct->setEnabled(m_localRepoActionsEnabled &&
Chris@284 2567 (canMerge || m_hgTabs->canResolve()));
Chris@284 2568 m_hgUpdateAct->setEnabled(m_localRepoActionsEnabled &&
Chris@284 2569 (canUpdate && !m_hgTabs->haveChangesToCommit()));
Chris@115 2570
Chris@115 2571 // Set the state field on the file status widget
Chris@115 2572
Chris@115 2573 QString branchText;
Chris@284 2574 if (m_currentBranch == "" || m_currentBranch == "default") {
Chris@115 2575 branchText = tr("the default branch");
Chris@115 2576 } else {
Chris@284 2577 branchText = tr("branch \"%1\"").arg(m_currentBranch);
Chris@115 2578 }
Chris@156 2579
Chris@284 2580 if (m_stateUnknown) {
Chris@284 2581 if (m_workFolderPath == "") {
Chris@287 2582 m_workStatus->setState(tr("No repository open"));
Chris@248 2583 } else {
Chris@287 2584 m_workStatus->setState(tr("(Examining repository)"));
Chris@248 2585 }
Chris@173 2586 } else if (emptyRepo) {
Chris@287 2587 m_workStatus->setState(tr("Nothing committed to this repository yet"));
Chris@225 2588 } else if (noWorkingCopy) {
Chris@287 2589 m_workStatus->setState(tr("No working copy yet: consider updating"));
Chris@162 2590 } else if (canMerge) {
Chris@287 2591 m_workStatus->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
Chris@284 2592 } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) {
Chris@287 2593 m_workStatus->setState(tr("Have unresolved files following merge on %1").arg(branchText));
Chris@156 2594 } else if (haveMerge) {
Chris@287 2595 m_workStatus->setState(tr("Have merged but not yet committed on %1").arg(branchText));
Chris@235 2596 } else if (newBranch) {
Chris@287 2597 m_workStatus->setState(tr("On %1. New branch: has not yet been committed").arg(branchText));
Chris@156 2598 } else if (canUpdate) {
Chris@284 2599 if (m_hgTabs->haveChangesToCommit()) {
Chris@163 2600 // have uncommitted changes
Chris@287 2601 m_workStatus->setState(tr("On %1. Not at the head of the branch").arg(branchText));
Chris@163 2602 } else {
Chris@163 2603 // no uncommitted changes
Chris@287 2604 m_workStatus->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
Chris@163 2605 }
Chris@284 2606 } else if (m_currentBranchHeads > 1) {
Chris@287 2607 m_workStatus->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText));
Chris@115 2608 } else {
Chris@287 2609 m_workStatus->setState(tr("At the head of %1").arg(branchText));
Chris@115 2610 }
jtkorhonen@0 2611 }
jtkorhonen@0 2612
Chris@359 2613
Chris@359 2614 void MainWindow::updateRecentMenu()
Chris@359 2615 {
Chris@359 2616 m_recentMenu->clear();
Chris@359 2617 RecentFiles rf("Recent-local");
Chris@359 2618 QStringList recent = rf.getRecent();
Chris@359 2619 if (recent.empty()) {
Chris@359 2620 QLabel *label = new QLabel(tr("No recent local repositories"));
Chris@359 2621 QWidgetAction *wa = new QWidgetAction(m_recentMenu);
Chris@359 2622 wa->setDefaultWidget(label);
Chris@359 2623 return;
Chris@359 2624 }
Chris@359 2625 foreach (QString r, recent) {
Chris@359 2626 QAction *a = m_recentMenu->addAction(r);
Chris@359 2627 connect(a, SIGNAL(activated()), this, SLOT(recentMenuActivated()));
Chris@359 2628 }
Chris@359 2629 }
Chris@359 2630
jtkorhonen@0 2631 void MainWindow::createActions()
jtkorhonen@0 2632 {
jtkorhonen@0 2633 //File actions
Chris@365 2634 m_openAct = new QAction(QIcon(":/images/fileopen.png"), tr("&Open..."), this);
Chris@365 2635 m_openAct->setStatusTip(tr("Open an existing repository or working folder"));
Chris@365 2636 m_openAct->setShortcut(tr("Ctrl+O"));
Chris@365 2637
Chris@365 2638 m_changeRemoteRepoAct = new QAction(tr("Set Remote &Location..."), this);
Chris@363 2639 m_changeRemoteRepoAct->setStatusTip(tr("Set or change the default remote repository for pull and push actions"));
Chris@273 2640
Chris@365 2641 m_settingsAct = new QAction(QIcon(":/images/settings.png"), tr("&Settings..."), this);
Chris@365 2642 m_settingsAct->setStatusTip(tr("View and change application settings"));
Chris@273 2643
Chris@343 2644 #ifdef Q_OS_WIN32
Chris@365 2645 m_exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
Chris@343 2646 #else
Chris@365 2647 m_exitAct = new QAction(QIcon(":/images/exit.png"), tr("&Quit"), this);
Chris@343 2648 #endif
Chris@284 2649 m_exitAct->setShortcuts(QKeySequence::Quit);
Chris@365 2650 m_exitAct->setStatusTip(tr("Exit EasyMercurial"));
jtkorhonen@0 2651
jtkorhonen@0 2652 //Repository actions
Chris@365 2653 m_hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("&Refresh"), this);
Chris@365 2654 m_hgRefreshAct->setShortcut(tr("Ctrl+R"));
Chris@284 2655 m_hgRefreshAct->setStatusTip(tr("Refresh the window to show the current state of the working folder"));
Chris@273 2656
Chris@365 2657 m_hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Pre&view Incoming Changes"), this);
Chris@365 2658 m_hgIncomingAct->setIconText(tr("Preview"));
Chris@365 2659 m_hgIncomingAct->setStatusTip(tr("See what changes are available in the remote repository waiting to be pulled"));
Chris@365 2660
Chris@365 2661 m_hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pu&ll from Remote Repository"), this);
Chris@365 2662 m_hgPullAct->setIconText(tr("Pull"));
Chris@365 2663 m_hgPullAct->setShortcut(tr("Ctrl+L"));
Chris@365 2664 m_hgPullAct->setStatusTip(tr("Pull changes from the remote repository to the local repository"));
Chris@365 2665
Chris@365 2666 m_hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Pus&h to Remote Repository"), this);
Chris@365 2667 m_hgPushAct->setIconText(tr("Push"));
Chris@365 2668 m_hgPushAct->setShortcut(tr("Ctrl+H"));
Chris@284 2669 m_hgPushAct->setStatusTip(tr("Push changes from the local repository to the remote repository"));
jtkorhonen@0 2670
jtkorhonen@0 2671 //Workfolder actions
Chris@365 2672 m_hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("&Diff"), this);
Chris@365 2673 m_hgFolderDiffAct->setIconText(tr("Diff"));
Chris@365 2674 m_hgFolderDiffAct->setShortcut(tr("Ctrl+D"));
Chris@284 2675 m_hgFolderDiffAct->setStatusTip(tr("See what has changed in the working folder compared with the last committed state"));
Chris@273 2676
Chris@365 2677 m_hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Re&vert"), this);
Chris@284 2678 m_hgRevertAct->setStatusTip(tr("Throw away your changes and return to the last committed state"));
Chris@273 2679
Chris@365 2680 m_hgAddAct = new QAction(QIcon(":/images/add.png"), tr("&Add Files"), this);
Chris@365 2681 m_hgAddAct->setIconText(tr("Add"));
Chris@365 2682 m_hgAddAct->setShortcut(tr("+"));
Chris@365 2683 m_hgAddAct->setStatusTip(tr("Mark the selected files to be added on the next commit"));
Chris@365 2684
Chris@365 2685 m_hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("&Remove Files"), this);
Chris@365 2686 m_hgRemoveAct->setIconText(tr("Remove"));
Chris@365 2687 m_hgRemoveAct->setShortcut(tr("Del"));
Chris@365 2688 m_hgRemoveAct->setStatusTip(tr("Mark the selected files to be removed from version control on the next commit"));
Chris@365 2689
Chris@365 2690 m_hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("&Update to Branch Head"), this);
Chris@365 2691 m_hgUpdateAct->setIconText(tr("Update"));
Chris@365 2692 m_hgUpdateAct->setShortcut(tr("Ctrl+U"));
Chris@284 2693 m_hgUpdateAct->setStatusTip(tr("Update the working folder to the head of the current repository branch"));
jtkorhonen@0 2694
Chris@365 2695 m_hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("&Commit..."), this);
Chris@365 2696 m_hgCommitAct->setShortcut(tr("Ctrl+Return"));
Chris@284 2697 m_hgCommitAct->setStatusTip(tr("Commit your changes to the local repository"));
Chris@273 2698
Chris@365 2699 m_hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("&Merge"), this);
Chris@365 2700 m_hgMergeAct->setShortcut(tr("Ctrl+M"));
Chris@284 2701 m_hgMergeAct->setStatusTip(tr("Merge the two independent sets of changes in the local repository into the working folder"));
jtkorhonen@0 2702
jtkorhonen@0 2703 //Advanced actions
Chris@273 2704
Chris@284 2705 m_hgIgnoreAct = new QAction(tr("Edit .hgignore File"), this);
Chris@365 2706 m_hgIgnoreAct->setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial"));
Chris@273 2707
Chris@284 2708 m_hgServeAct = new QAction(tr("Serve via HTTP"), this);
Chris@365 2709 m_hgServeAct->setStatusTip(tr("Serve local repository via http for workgroup access"));
jtkorhonen@11 2710
jtkorhonen@0 2711 //Help actions
Chris@284 2712 m_aboutAct = new QAction(tr("About EasyMercurial"), this);
Chris@94 2713
Chris@94 2714 // Miscellaneous
Chris@199 2715 QShortcut *clearSelectionsShortcut = new QShortcut(Qt::Key_Escape, this);
Chris@199 2716 connect(clearSelectionsShortcut, SIGNAL(activated()),
Chris@199 2717 this, SLOT(clearSelections()));
jtkorhonen@0 2718 }
jtkorhonen@0 2719
jtkorhonen@0 2720 void MainWindow::createMenus()
jtkorhonen@0 2721 {
Chris@365 2722 m_fileMenu = menuBar()->addMenu(tr("&File"));
Chris@365 2723
Chris@365 2724 m_fileMenu->addAction(m_openAct);
Chris@365 2725 m_recentMenu = m_fileMenu->addMenu(tr("Open Re&cent"));
Chris@365 2726 m_fileMenu->addAction(m_hgRefreshAct);
Chris@365 2727 m_fileMenu->addSeparator();
Chris@365 2728 m_fileMenu->addAction(m_settingsAct);
Chris@365 2729 m_fileMenu->addSeparator();
Chris@365 2730 m_fileMenu->addAction(m_exitAct);
Chris@365 2731
Chris@365 2732 QMenu *workMenu;
Chris@365 2733 workMenu = menuBar()->addMenu(tr("&Work"));
Chris@365 2734 workMenu->addAction(m_hgFolderDiffAct);
Chris@365 2735 workMenu->addSeparator();
Chris@365 2736 workMenu->addAction(m_hgUpdateAct);
Chris@365 2737 workMenu->addAction(m_hgCommitAct);
Chris@365 2738 workMenu->addAction(m_hgMergeAct);
Chris@365 2739 workMenu->addSeparator();
Chris@365 2740 workMenu->addAction(m_hgAddAct);
Chris@365 2741 workMenu->addAction(m_hgRemoveAct);
Chris@365 2742 workMenu->addSeparator();
Chris@365 2743 workMenu->addAction(m_hgRevertAct);
Chris@365 2744
Chris@365 2745 QMenu *remoteMenu;
Chris@365 2746 remoteMenu = menuBar()->addMenu(tr("&Remote"));
Chris@365 2747 remoteMenu->addAction(m_hgIncomingAct);
Chris@365 2748 remoteMenu->addSeparator();
Chris@365 2749 remoteMenu->addAction(m_hgPullAct);
Chris@365 2750 remoteMenu->addAction(m_hgPushAct);
Chris@365 2751 remoteMenu->addSeparator();
Chris@365 2752 remoteMenu->addAction(m_changeRemoteRepoAct);
Chris@365 2753
Chris@365 2754 m_advancedMenu = menuBar()->addMenu(tr("&Advanced"));
Chris@365 2755 m_advancedMenu->addAction(m_hgIgnoreAct);
Chris@365 2756 m_advancedMenu->addSeparator();
Chris@365 2757 m_advancedMenu->addAction(m_hgServeAct);
Chris@273 2758
Chris@378 2759 m_helpMenu = menuBar()->addMenu(tr("&Help"));
Chris@284 2760 m_helpMenu->addAction(m_aboutAct);
jtkorhonen@0 2761 }
jtkorhonen@0 2762
jtkorhonen@0 2763 void MainWindow::createToolBars()
jtkorhonen@0 2764 {
Chris@284 2765 m_fileToolBar = addToolBar(tr("File"));
Chris@365 2766 m_fileToolBar->setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@365 2767 m_fileToolBar->addAction(m_openAct);
Chris@365 2768 m_fileToolBar->addAction(m_hgRefreshAct);
Chris@365 2769 m_fileToolBar->setMovable(false);
Chris@273 2770
Chris@284 2771 m_repoToolBar = addToolBar(tr(REPOMENU_TITLE));
Chris@365 2772 m_repoToolBar->setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@284 2773 m_repoToolBar->addAction(m_hgIncomingAct);
Chris@284 2774 m_repoToolBar->addAction(m_hgPullAct);
Chris@284 2775 m_repoToolBar->addAction(m_hgPushAct);
Chris@365 2776 m_repoToolBar->setMovable(false);
Chris@273 2777
Chris@284 2778 m_workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
Chris@284 2779 addToolBar(Qt::LeftToolBarArea, m_workFolderToolBar);
Chris@365 2780 m_workFolderToolBar->setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@284 2781 m_workFolderToolBar->addAction(m_hgFolderDiffAct);
Chris@284 2782 m_workFolderToolBar->addSeparator();
Chris@284 2783 m_workFolderToolBar->addAction(m_hgRevertAct);
Chris@284 2784 m_workFolderToolBar->addAction(m_hgUpdateAct);
Chris@284 2785 m_workFolderToolBar->addAction(m_hgCommitAct);
Chris@284 2786 m_workFolderToolBar->addAction(m_hgMergeAct);
Chris@284 2787 m_workFolderToolBar->addSeparator();
Chris@284 2788 m_workFolderToolBar->addAction(m_hgAddAct);
Chris@284 2789 m_workFolderToolBar->addAction(m_hgRemoveAct);
Chris@365 2790 m_workFolderToolBar->setMovable(false);
Chris@61 2791
Chris@230 2792 updateToolBarStyle();
jtkorhonen@0 2793 }
jtkorhonen@0 2794
Chris@230 2795 void MainWindow::updateToolBarStyle()
Chris@230 2796 {
Chris@230 2797 QSettings settings;
Chris@230 2798 settings.beginGroup("Presentation");
Chris@230 2799 bool showText = settings.value("showiconlabels", true).toBool();
Chris@230 2800 settings.endGroup();
Chris@230 2801
Chris@230 2802 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
Chris@230 2803 tb->setToolButtonStyle(showText ?
Chris@230 2804 Qt::ToolButtonTextUnderIcon :
Chris@230 2805 Qt::ToolButtonIconOnly);
Chris@230 2806 }
Chris@230 2807 }
jtkorhonen@0 2808
Chris@287 2809 void MainWindow::updateWorkFolderAndRepoNames()
Chris@287 2810 {
Chris@287 2811 m_hgTabs->setLocalPath(m_workFolderPath);
Chris@287 2812
Chris@287 2813 m_workStatus->setLocalPath(m_workFolderPath);
Chris@287 2814 m_workStatus->setRemoteURL(m_remoteRepoPath);
Chris@287 2815 }
Chris@287 2816
jtkorhonen@0 2817 void MainWindow::createStatusBar()
jtkorhonen@0 2818 {
jtkorhonen@0 2819 statusBar()->showMessage(tr("Ready"));
jtkorhonen@0 2820 }
jtkorhonen@0 2821
jtkorhonen@0 2822 void MainWindow::readSettings()
jtkorhonen@0 2823 {
jtkorhonen@0 2824 QDir workFolder;
jtkorhonen@0 2825
Chris@61 2826 QSettings settings;
jtkorhonen@0 2827
Chris@284 2828 m_remoteRepoPath = settings.value("remoterepopath", "").toString();
Chris@284 2829 m_workFolderPath = settings.value("workfolderpath", "").toString();
Chris@284 2830 if (!workFolder.exists(m_workFolderPath))
jtkorhonen@0 2831 {
Chris@284 2832 m_workFolderPath = "";
jtkorhonen@0 2833 }
jtkorhonen@0 2834
jtkorhonen@0 2835 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
Chris@340 2836 QSize size = settings.value("size", QSize(550, 550)).toSize();
Chris@284 2837 m_firstStart = settings.value("firststart", QVariant(true)).toBool();
jtkorhonen@0 2838
jtkorhonen@0 2839 resize(size);
jtkorhonen@0 2840 move(pos);
jtkorhonen@0 2841 }
jtkorhonen@0 2842
jtkorhonen@0 2843 void MainWindow::writeSettings()
jtkorhonen@0 2844 {
Chris@61 2845 QSettings settings;
jtkorhonen@0 2846 settings.setValue("pos", pos());
jtkorhonen@0 2847 settings.setValue("size", size());
Chris@284 2848 settings.setValue("remoterepopath", m_remoteRepoPath);
Chris@284 2849 settings.setValue("workfolderpath", m_workFolderPath);
Chris@284 2850 settings.setValue("firststart", m_firstStart);
jtkorhonen@0 2851 }
jtkorhonen@0 2852
jtkorhonen@0 2853
jtkorhonen@0 2854
jtkorhonen@0 2855