annotate mainwindow.cpp @ 246:0fe81e1b26ce

* Be a bit less eager to suspend the fs watcher (e.g. don't suspend on potentially lengthy operations like diff)
author Chris Cannam
date Tue, 11 Jan 2011 20:18:37 +0000
parents 8fd71f570884
children 0689dada1419
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@125 32 #include <QRegExp>
Chris@199 33 #include <QShortcut>
Chris@237 34 #include <QUrl>
Chris@238 35 #include <QTimer>
jtkorhonen@0 36
Chris@53 37 #include "mainwindow.h"
Chris@69 38 #include "multichoicedialog.h"
Chris@64 39 #include "startupdialog.h"
Chris@53 40 #include "colourset.h"
Chris@62 41 #include "debug.h"
Chris@74 42 #include "logparser.h"
Chris@103 43 #include "confirmcommentdialog.h"
Chris@125 44 #include "incomingdialog.h"
Chris@175 45 #include "settingsdialog.h"
Chris@229 46 #include "version.h"
Chris@53 47
jtkorhonen@0 48
Chris@172 49 MainWindow::MainWindow(QString myDirPath) :
Chris@238 50 m_myDirPath(myDirPath),
Chris@238 51 m_fsWatcherGeneralTimer(0),
Chris@241 52 m_fsWatcherRestoreTimer(0),
Chris@241 53 m_fsWatcherSuspended(false)
jtkorhonen@0 54 {
Chris@197 55 setWindowIcon(QIcon(":images/easyhg-icon.png"));
Chris@197 56
jtkorhonen@0 57 QString wndTitle;
jtkorhonen@0 58
Chris@199 59 showAllFiles = false;
Chris@199 60
Chris@90 61 fsWatcher = 0;
Chris@133 62 commitsSincePush = 0;
Chris@163 63 shouldHgStat = true;
Chris@90 64
jtkorhonen@0 65 createActions();
jtkorhonen@0 66 createMenus();
jtkorhonen@0 67 createToolBars();
jtkorhonen@0 68 createStatusBar();
jtkorhonen@0 69
Chris@172 70 runner = new HgRunner(myDirPath, this);
Chris@241 71 connect(runner, SIGNAL(commandStarting(HgAction)),
Chris@241 72 this, SLOT(commandStarting(HgAction)));
Chris@109 73 connect(runner, SIGNAL(commandCompleted(HgAction, QString)),
Chris@109 74 this, SLOT(commandCompleted(HgAction, QString)));
Chris@109 75 connect(runner, SIGNAL(commandFailed(HgAction, QString)),
Chris@109 76 this, SLOT(commandFailed(HgAction, QString)));
jtkorhonen@0 77 statusBar()->addPermanentWidget(runner);
jtkorhonen@0 78
Chris@61 79 setWindowTitle(tr("EasyMercurial"));
jtkorhonen@0 80
jtkorhonen@0 81 remoteRepoPath = "";
jtkorhonen@0 82 workFolderPath = "";
jtkorhonen@0 83
jtkorhonen@0 84 readSettings();
jtkorhonen@0 85
jtkorhonen@33 86 justMerged = false;
Chris@210 87
Chris@210 88 QWidget *central = new QWidget(this);
Chris@210 89 setCentralWidget(central);
Chris@210 90
Chris@210 91 hgTabs = new HgTabWidget(central, remoteRepoPath, workFolderPath);
Chris@141 92 connectTabsSignals();
Chris@210 93
Chris@210 94 // Instead of setting the tab widget as our central widget
Chris@210 95 // directly, put it in a layout, so that we can have some space
Chris@210 96 // around it on the Mac where it looks very strange without
Chris@210 97
Chris@210 98 QGridLayout *cl = new QGridLayout(central);
Chris@210 99 cl->addWidget(hgTabs, 0, 0);
Chris@210 100
Chris@210 101 #ifndef Q_OS_MAC
Chris@210 102 cl->setMargin(0);
Chris@210 103 #endif
jtkorhonen@0 104
Chris@98 105 connect(hgTabs, SIGNAL(selectionChanged()),
Chris@95 106 this, SLOT(enableDisableActions()));
Chris@199 107 connect(hgTabs, SIGNAL(showAllChanged(bool)),
Chris@199 108 this, SLOT(showAllChanged(bool)));
Chris@95 109
jtkorhonen@0 110 setUnifiedTitleAndToolBarOnMac(true);
jtkorhonen@0 111 connectActions();
Chris@120 112 clearState();
jtkorhonen@0 113 enableDisableActions();
jtkorhonen@0 114
Chris@64 115 if (firstStart) {
Chris@64 116 startupDialog();
jtkorhonen@0 117 }
jtkorhonen@0 118
Chris@239 119 SettingsDialog::findDefaultLocations(m_myDirPath);
Chris@112 120
Chris@64 121 ColourSet *cs = ColourSet::instance();
Chris@64 122 cs->clearDefaultNames();
Chris@64 123 cs->addDefaultName("");
Chris@153 124 cs->addDefaultName("default");
Chris@64 125 cs->addDefaultName(getUserInfo());
Chris@62 126
Chris@72 127 if (workFolderPath == "") {
Chris@72 128 open();
Chris@72 129 }
Chris@72 130
Chris@175 131 hgTest();
jtkorhonen@0 132 }
jtkorhonen@0 133
jtkorhonen@0 134
jtkorhonen@0 135 void MainWindow::closeEvent(QCloseEvent *)
jtkorhonen@0 136 {
jtkorhonen@0 137 writeSettings();
Chris@90 138 delete fsWatcher;
jtkorhonen@0 139 }
jtkorhonen@0 140
jtkorhonen@0 141
Chris@64 142 QString MainWindow::getUserInfo() const
Chris@64 143 {
Chris@64 144 QSettings settings;
Chris@64 145 settings.beginGroup("User Information");
Chris@64 146 QString name = settings.value("name", getUserRealName()).toString();
Chris@64 147 QString email = settings.value("email", "").toString();
Chris@64 148
Chris@64 149 QString identifier;
Chris@64 150
Chris@64 151 if (email != "") {
Chris@64 152 identifier = QString("%1 <%2>").arg(name).arg(email);
Chris@64 153 } else {
Chris@64 154 identifier = name;
Chris@64 155 }
Chris@64 156
Chris@64 157 return identifier;
Chris@64 158 }
Chris@64 159
jtkorhonen@0 160 void MainWindow::about()
jtkorhonen@0 161 {
Chris@97 162 QMessageBox::about(this, tr("About EasyMercurial"),
Chris@229 163 tr("<qt><h2>EasyMercurial v%1</h2>"
Chris@228 164 #ifdef Q_OS_MAC
Chris@228 165 "<font size=-1>"
Chris@228 166 #endif
Chris@97 167 "<p>EasyMercurial is a simple user interface for the "
Chris@186 168 "Mercurial</a> version control system.</p>"
Chris@186 169 "<h4>Credits and Copyright</h4>"
Chris@186 170 "<p>Development carried out by Chris Cannam for "
Chris@186 171 "SoundSoftware.ac.uk at the Centre for Digital Music, "
Chris@186 172 "Queen Mary, University of London.</p>"
Chris@186 173 "<p>EasyMercurial is based on HgExplorer by "
Chris@186 174 "Jari Korhonen, with thanks.</p>"
Chris@186 175 "<p style=\"margin-left: 2em;\">"
Chris@244 176 "Copyright &copy; 2011 Queen Mary, University of London.<br>"
Chris@186 177 "Copyright &copy; 2010 Jari Korhonen.<br>"
Chris@244 178 "Copyright &copy; 2011 Chris Cannam."
Chris@186 179 "</p>"
Chris@186 180 "<p style=\"margin-left: 2em;\">"
Chris@186 181 "This program requires Mercurial, by Matt Mackall and others.<br>"
Chris@186 182 "This program uses Qt by Nokia.<br>"
Chris@186 183 "This program uses Nuvola icons by David Vignoni.<br>"
Chris@186 184 "This program may use KDiff3 by Joachim Eibl.<br>"
Chris@186 185 "This program may use PyQt by River Bank Computing.<br>"
Chris@186 186 "Packaging for Mercurial and other dependencies on Windows is derived from TortoiseHg by Steve Borho and others."
Chris@186 187 "</p>"
Chris@186 188 "<h4>License</h4>"
Chris@186 189 "<p>This program is free software; you can redistribute it and/or "
Chris@97 190 "modify it under the terms of the GNU General Public License as "
Chris@97 191 "published by the Free Software Foundation; either version 2 of the "
Chris@97 192 "License, or (at your option) any later version. See the file "
Chris@223 193 "COPYING included with this distribution for more information.</p>"
Chris@228 194 #ifdef Q_OS_MAC
Chris@228 195 "</font>"
Chris@228 196 #endif
Chris@229 197 ).arg(EASYHG_VERSION));
jtkorhonen@0 198 }
jtkorhonen@0 199
Chris@94 200 void MainWindow::clearSelections()
Chris@94 201 {
Chris@98 202 hgTabs->clearSelections();
Chris@94 203 }
jtkorhonen@0 204
Chris@199 205 void MainWindow::showAllChanged(bool s)
Chris@199 206 {
Chris@199 207 showAllFiles = s;
Chris@199 208 hgQueryPaths();
Chris@199 209 }
Chris@199 210
Chris@120 211 void MainWindow::hgRefresh()
Chris@120 212 {
Chris@120 213 clearState();
Chris@120 214 hgQueryPaths();
Chris@120 215 }
Chris@120 216
Chris@175 217 void MainWindow::hgTest()
Chris@175 218 {
Chris@175 219 QStringList params;
Chris@207 220 //!!! should we test version output? Really we want at least 1.7.x
Chris@207 221 //!!! for options such as merge --tool
Chris@175 222 params << "--version";
Chris@175 223 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@200 230 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@199 237 if (showAllFiles) {
Chris@199 238 params << "stat" << "-A";
Chris@199 239 } else {
Chris@199 240 params << "stat" << "-ardum";
Chris@199 241 }
Chris@153 242
Chris@163 243 lastStatOutput = "";
Chris@163 244
Chris@109 245 runner->requestAction(HgAction(ACT_STAT, 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@198 252 QFileInfo hgrc(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@210 262 remoteRepoPath = path;
Chris@198 263
Chris@210 264 // We have to do this here, because commandCompleted won't be called
Chris@210 265 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@210 266 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@210 267 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
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@109 276 runner->requestAction(HgAction(ACT_QUERY_PATHS, 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@198 284 QFile hgbr(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@210 293 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@109 303 runner->requestAction(HgAction(ACT_QUERY_BRANCH, 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@109 316 runner->requestAction(HgAction(ACT_QUERY_HEADS, 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@109 326 runner->requestAction(HgAction(ACT_LOG, workFolderPath, params));
Chris@109 327 }
Chris@109 328
Chris@150 329 void MainWindow::hgLogIncremental(QStringList prune)
Chris@120 330 {
Chris@120 331 QStringList params;
Chris@120 332 params << "log";
Chris@120 333
Chris@150 334 foreach (QString p, prune) {
Chris@153 335 params << "--prune" << Changeset::hashOf(p);
Chris@120 336 }
Chris@120 337
Chris@120 338 params << "--template";
Chris@125 339 params << Changeset::getLogTemplate();
Chris@120 340
Chris@120 341 runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, workFolderPath, params));
Chris@120 342 }
Chris@109 343
Chris@109 344 void MainWindow::hgQueryParents()
Chris@109 345 {
Chris@109 346 QStringList params;
Chris@109 347 params << "parents";
Chris@109 348 runner->requestAction(HgAction(ACT_QUERY_PARENTS, workFolderPath, params));
Chris@109 349 }
Chris@109 350
Chris@109 351 void MainWindow::hgAnnotate()
Chris@109 352 {
Chris@109 353 QStringList params;
Chris@109 354 QString currentFile;//!!! = hgTabs -> getCurrentFileListLine();
Chris@109 355
Chris@109 356 if (!currentFile.isEmpty())
jtkorhonen@0 357 {
Chris@109 358 params << "annotate" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
jtkorhonen@0 359
Chris@109 360 runner->requestAction(HgAction(ACT_ANNOTATE, workFolderPath, params));
jtkorhonen@0 361 }
jtkorhonen@0 362 }
jtkorhonen@0 363
Chris@109 364 void MainWindow::hgResolveList()
Chris@109 365 {
Chris@109 366 QStringList params;
jtkorhonen@0 367
Chris@109 368 params << "resolve" << "--list";
Chris@109 369 runner->requestAction(HgAction(ACT_RESOLVE_LIST, workFolderPath, params));
Chris@109 370 }
Chris@109 371
Chris@109 372 void MainWindow::hgAdd()
jtkorhonen@0 373 {
Chris@109 374 QStringList params;
jtkorhonen@0 375
Chris@109 376 // hgExplorer permitted adding "all" files -- I'm not sure
Chris@109 377 // that one is a good idea, let's require the user to select
jtkorhonen@0 378
Chris@109 379 QStringList files = hgTabs->getSelectedAddableFiles();
Chris@109 380
Chris@109 381 if (!files.empty()) {
Chris@109 382 params << "add" << "--" << files;
Chris@109 383 runner->requestAction(HgAction(ACT_ADD, workFolderPath, params));
jtkorhonen@0 384 }
jtkorhonen@0 385 }
jtkorhonen@0 386
jtkorhonen@0 387
Chris@98 388 void MainWindow::hgRemove()
Chris@98 389 {
Chris@109 390 QStringList params;
Chris@98 391
Chris@109 392 QStringList files = hgTabs->getSelectedRemovableFiles();
Chris@98 393
Chris@109 394 if (!files.empty()) {
Chris@109 395 params << "remove" << "--after" << "--force" << "--" << files;
Chris@109 396 runner->requestAction(HgAction(ACT_REMOVE, workFolderPath, params));
Chris@109 397 }
jtkorhonen@0 398 }
jtkorhonen@0 399
jtkorhonen@0 400 void MainWindow::hgCommit()
jtkorhonen@0 401 {
Chris@109 402 QStringList params;
Chris@109 403 QString comment;
Chris@94 404
Chris@157 405 if (justMerged) {
Chris@157 406 comment = mergeCommitComment;
Chris@157 407 }
Chris@157 408
Chris@109 409 QStringList files = hgTabs->getSelectedCommittableFiles();
Chris@237 410 QStringList allFiles = hgTabs->getAllCommittableFiles();
Chris@127 411 QStringList reportFiles = files;
Chris@237 412 if (reportFiles.empty()) {
Chris@237 413 reportFiles = allFiles;
Chris@237 414 }
Chris@103 415
Chris@237 416 QString subsetNote;
Chris@237 417 if (reportFiles != allFiles) {
Chris@237 418 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 419 }
Chris@237 420
Chris@155 421 QString cf(tr("Commit files"));
Chris@155 422
Chris@109 423 if (ConfirmCommentDialog::confirmAndGetLongComment
Chris@109 424 (this,
Chris@155 425 cf,
Chris@237 426 tr("<h3>%1</h3><p>%2%3").arg(cf)
Chris@237 427 .arg(tr("You are about to commit the following files."))
Chris@237 428 .arg(subsetNote),
Chris@237 429 tr("<h3>%1</h3><p>%2%3").arg(cf)
Chris@237 430 .arg(tr("You are about to commit %n file(s).", "", reportFiles.size()))
Chris@237 431 .arg(subsetNote),
Chris@127 432 reportFiles,
Chris@193 433 comment,
Chris@193 434 tr("Commit"))) {
Chris@103 435
Chris@157 436 if (!justMerged && !files.empty()) {
Chris@157 437 // User wants to commit selected file(s) (and this is not
Chris@157 438 // merge commit, which would fail if we selected files)
Chris@157 439 params << "commit" << "--message" << comment
Chris@157 440 << "--user" << getUserInfo() << "--" << files;
Chris@109 441 } else {
Chris@109 442 // Commit all changes
Chris@157 443 params << "commit" << "--message" << comment
Chris@157 444 << "--user" << getUserInfo();
jtkorhonen@0 445 }
Chris@109 446
Chris@109 447 runner->requestAction(HgAction(ACT_COMMIT, workFolderPath, params));
Chris@173 448 mergeCommitComment = "";
jtkorhonen@0 449 }
jtkorhonen@0 450 }
jtkorhonen@0 451
jtkorhonen@34 452 QString MainWindow::filterTag(QString tag)
jtkorhonen@34 453 {
jtkorhonen@34 454 for(int i = 0; i < tag.size(); i++)
jtkorhonen@34 455 {
jtkorhonen@34 456 if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
jtkorhonen@34 457 {
jtkorhonen@34 458 //ok
jtkorhonen@34 459 }
jtkorhonen@34 460 else
jtkorhonen@34 461 {
jtkorhonen@34 462 tag[i] = QChar('_');
jtkorhonen@34 463 }
jtkorhonen@34 464 }
jtkorhonen@34 465 return tag;
jtkorhonen@34 466 }
jtkorhonen@34 467
jtkorhonen@34 468
Chris@164 469 void MainWindow::hgTag(QString id)
jtkorhonen@34 470 {
Chris@109 471 QStringList params;
Chris@109 472 QString tag;
jtkorhonen@34 473
Chris@109 474 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@109 475 (this,
Chris@109 476 tr("Tag"),
Chris@109 477 tr("Enter tag:"),
Chris@193 478 tag,
Chris@193 479 tr("Add Tag"))) {
Chris@164 480 if (!tag.isEmpty()) {//!!! do something better if it is empty
Chris@164 481
Chris@164 482 params << "tag" << "--user" << getUserInfo();
Chris@164 483 params << "--rev" << Changeset::hashOf(id) << filterTag(tag);
Chris@109 484
Chris@109 485 runner->requestAction(HgAction(ACT_TAG, workFolderPath, params));
jtkorhonen@34 486 }
jtkorhonen@34 487 }
jtkorhonen@34 488 }
jtkorhonen@34 489
jtkorhonen@34 490
jtkorhonen@34 491 void MainWindow::hgIgnore()
jtkorhonen@34 492 {
Chris@109 493 QString hgIgnorePath;
Chris@109 494 QStringList params;
Chris@178 495
Chris@109 496 hgIgnorePath = workFolderPath;
Chris@178 497 hgIgnorePath += "/.hgignore";
Chris@109 498
Chris@109 499 params << hgIgnorePath;
Chris@179 500
Chris@239 501 QString editor = getEditorBinaryName();
Chris@112 502
Chris@179 503 if (editor == "") {
Chris@179 504 DEBUG << "Failed to find a text editor" << endl;
Chris@179 505 //!!! visible error!
Chris@179 506 return;
Chris@179 507 }
Chris@179 508
Chris@179 509 HgAction action(ACT_HG_IGNORE, workFolderPath, params);
Chris@179 510 action.executable = editor;
Chris@179 511
Chris@179 512 runner->requestAction(action);
Chris@179 513 }
Chris@179 514
Chris@239 515 QString MainWindow::getDiffBinaryName()
Chris@179 516 {
Chris@179 517 QSettings settings;
Chris@179 518 settings.beginGroup("Locations");
Chris@239 519 return settings.value("extdiffbinary", "").toString();
Chris@179 520 }
Chris@179 521
Chris@239 522 QString MainWindow::getMergeBinaryName()
Chris@179 523 {
Chris@179 524 QSettings settings;
Chris@179 525 settings.beginGroup("Locations");
Chris@239 526 return settings.value("mergebinary", "").toString();
Chris@179 527 }
Chris@179 528
Chris@239 529 QString MainWindow::getEditorBinaryName()
Chris@179 530 {
Chris@178 531 QSettings settings;
Chris@178 532 settings.beginGroup("Locations");
Chris@239 533 return settings.value("editorbinary", "").toString();
Chris@163 534 }
Chris@163 535
Chris@168 536 void MainWindow::hgShowSummary()
Chris@168 537 {
Chris@168 538 QStringList params;
Chris@168 539
Chris@168 540 params << "diff" << "--stat";
Chris@168 541
Chris@168 542 runner->requestAction(HgAction(ACT_DIFF_SUMMARY, workFolderPath, params));
Chris@168 543 }
Chris@168 544
jtkorhonen@0 545 void MainWindow::hgFolderDiff()
jtkorhonen@0 546 {
Chris@239 547 QString diff = getDiffBinaryName();
Chris@179 548 if (diff == "") return;
Chris@112 549
Chris@109 550 QStringList params;
jtkorhonen@0 551
Chris@112 552 // Diff parent against working folder (folder diff)
Chris@112 553
Chris@148 554 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@179 555 params << "--program" << diff;
Chris@109 556
Chris@153 557 params << hgTabs->getSelectedCommittableFiles(); // may be none: whole dir
Chris@153 558
Chris@109 559 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
jtkorhonen@0 560 }
jtkorhonen@0 561
jtkorhonen@0 562
Chris@148 563 void MainWindow::hgDiffToCurrent(QString id)
jtkorhonen@0 564 {
Chris@239 565 QString diff = getDiffBinaryName();
Chris@179 566 if (diff == "") return;
Chris@163 567
Chris@148 568 QStringList params;
jtkorhonen@0 569
Chris@148 570 // Diff given revision against working folder
jtkorhonen@0 571
Chris@148 572 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@179 573 params << "--program" << diff;
Chris@153 574 params << "--rev" << Changeset::hashOf(id);
Chris@148 575
Chris@148 576 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
jtkorhonen@0 577 }
jtkorhonen@0 578
jtkorhonen@0 579
Chris@148 580 void MainWindow::hgDiffToParent(QString child, QString parent)
Chris@148 581 {
Chris@239 582 QString diff = getDiffBinaryName();
Chris@179 583 if (diff == "") return;
Chris@163 584
Chris@148 585 QStringList params;
Chris@148 586
Chris@148 587 // Diff given revision against working folder
Chris@148 588
Chris@148 589 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@179 590 params << "--program" << diff;
Chris@153 591 params << "--rev" << Changeset::hashOf(parent)
Chris@153 592 << "--rev" << Changeset::hashOf(child);
Chris@148 593
Chris@148 594 runner->requestAction(HgAction(ACT_CHGSETDIFF, workFolderPath, params));
Chris@148 595 }
Chris@148 596
jtkorhonen@0 597
jtkorhonen@0 598 void MainWindow::hgUpdate()
jtkorhonen@0 599 {
Chris@109 600 QStringList params;
jtkorhonen@0 601
Chris@109 602 params << "update";
Chris@109 603
Chris@109 604 runner->requestAction(HgAction(ACT_UPDATE, workFolderPath, params));
jtkorhonen@0 605 }
jtkorhonen@0 606
jtkorhonen@0 607
Chris@148 608 void MainWindow::hgUpdateToRev(QString id)
jtkorhonen@0 609 {
Chris@148 610 QStringList params;
jtkorhonen@0 611
Chris@153 612 params << "update" << "--rev" << Changeset::hashOf(id) << "--check";
jtkorhonen@0 613
Chris@148 614 runner->requestAction(HgAction(ACT_UPDATE, workFolderPath, params));
jtkorhonen@0 615 }
jtkorhonen@0 616
jtkorhonen@0 617
jtkorhonen@0 618 void MainWindow::hgRevert()
jtkorhonen@0 619 {
Chris@109 620 QStringList params;
Chris@109 621 QString comment;
Chris@237 622 bool all = false;
Chris@98 623
Chris@109 624 QStringList files = hgTabs->getSelectedRevertableFiles();
Chris@237 625 QStringList allFiles = hgTabs->getAllRevertableFiles();
Chris@237 626 if (files.empty() || files == allFiles) {
Chris@237 627 files = allFiles;
Chris@237 628 all = true;
Chris@237 629 }
Chris@237 630
Chris@237 631 QString subsetNote;
Chris@237 632 if (!all) {
Chris@237 633 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 634 }
Chris@155 635
Chris@155 636 QString rf(tr("Revert files"));
Chris@237 637
Chris@237 638 // Set up params before asking for confirmation, because there is
Chris@237 639 // a failure case here that we would need to report on early
Chris@237 640
Chris@237 641 DEBUG << "hgRevert: justMerged = " << justMerged << ", mergeTargetRevision = " << mergeTargetRevision << endl;
Chris@237 642
Chris@237 643 if (justMerged) {
Chris@237 644
Chris@237 645 // This is a little fiddly. The proper way to "revert" the
Chris@237 646 // whole of an uncommitted merge is with "hg update --clean ."
Chris@237 647 // But if the user has selected only some files, we're sort of
Chris@237 648 // promising to revert only those, which means we need to
Chris@237 649 // specify which parent to revert to. We can only do that if
Chris@237 650 // we have a record of it, which we do if you just did the
Chris@237 651 // merge from within easyhg but don't if you've exited and
Chris@237 652 // restarted, or changed repository, since then. Hmmm.
Chris@237 653
Chris@237 654 if (all) {
Chris@237 655 params << "update" << "--clean" << ".";
Chris@237 656 } else {
Chris@237 657 if (mergeTargetRevision != "") {
Chris@237 658 params << "revert" << "--rev"
Chris@237 659 << Changeset::hashOf(mergeTargetRevision)
Chris@237 660 << "--" << files;
Chris@237 661 } else {
Chris@237 662 QMessageBox::information
Chris@237 663 (this, tr("Unable to revert"),
Chris@237 664 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 665 return;
Chris@237 666 }
Chris@237 667 }
Chris@237 668 } else {
Chris@237 669 params << "revert" << "--" << files;
Chris@237 670 }
Chris@237 671
Chris@109 672 if (ConfirmCommentDialog::confirmDangerousFilesAction
Chris@109 673 (this,
Chris@155 674 rf,
Chris@237 675 tr("<h3>%1</h3><p>%2%3").arg(rf)
Chris@237 676 .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 677 .arg(subsetNote),
Chris@237 678 tr("<h3>%1</h3><p>%2%3").arg(rf)
Chris@237 679 .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 680 .arg(subsetNote),
Chris@193 681 files,
Chris@193 682 tr("Revert"))) {
Chris@163 683
Chris@163 684 lastRevertedFiles = files;
Chris@109 685
Chris@109 686 runner->requestAction(HgAction(ACT_REVERT, workFolderPath, params));
jtkorhonen@0 687 }
jtkorhonen@0 688 }
jtkorhonen@0 689
Chris@163 690
Chris@163 691 void MainWindow::hgMarkResolved(QStringList files)
Chris@163 692 {
Chris@163 693 QStringList params;
Chris@163 694
Chris@163 695 params << "resolve" << "--mark";
Chris@163 696
Chris@163 697 if (files.empty()) {
Chris@163 698 params << "--all";
Chris@163 699 } else {
Chris@164 700 params << "--" << files;
Chris@163 701 }
Chris@163 702
Chris@163 703 runner->requestAction(HgAction(ACT_RESOLVE_MARK, workFolderPath, params));
Chris@163 704 }
Chris@163 705
Chris@163 706
jtkorhonen@33 707 void MainWindow::hgRetryMerge()
jtkorhonen@33 708 {
Chris@109 709 QStringList params;
jtkorhonen@33 710
Chris@163 711 params << "resolve";
Chris@163 712
Chris@239 713 QString merge = getMergeBinaryName();
Chris@179 714 if (merge != "") {
Chris@179 715 params << "--tool" << merge;
Chris@163 716 }
Chris@163 717
Chris@163 718 QStringList files = hgTabs->getSelectedUnresolvedFiles();
Chris@163 719 if (files.empty()) {
Chris@163 720 params << "--all";
Chris@163 721 } else {
Chris@164 722 params << "--" << files;
Chris@163 723 }
Chris@163 724
Chris@237 725 if (currentParents.size() == 1) {
Chris@237 726 mergeTargetRevision = currentParents[0]->id();
Chris@237 727 }
Chris@237 728
Chris@109 729 runner->requestAction(HgAction(ACT_RETRY_MERGE, workFolderPath, params));
Chris@163 730
Chris@163 731 mergeCommitComment = tr("Merge");
jtkorhonen@33 732 }
jtkorhonen@33 733
jtkorhonen@33 734
jtkorhonen@0 735 void MainWindow::hgMerge()
jtkorhonen@0 736 {
Chris@163 737 if (hgTabs->canResolve()) {
Chris@163 738 hgRetryMerge();
Chris@163 739 return;
Chris@163 740 }
Chris@163 741
Chris@109 742 QStringList params;
jtkorhonen@0 743
Chris@109 744 params << "merge";
Chris@163 745
Chris@239 746 QString merge = getMergeBinaryName();
Chris@179 747 if (merge != "") {
Chris@179 748 params << "--tool" << merge;
Chris@163 749 }
Chris@163 750
Chris@163 751 if (currentParents.size() == 1) {
Chris@163 752 mergeTargetRevision = currentParents[0]->id();
Chris@163 753 }
Chris@163 754
Chris@109 755 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
Chris@157 756
Chris@157 757 mergeCommitComment = tr("Merge");
jtkorhonen@0 758 }
jtkorhonen@0 759
jtkorhonen@0 760
Chris@148 761 void MainWindow::hgMergeFrom(QString id)
Chris@148 762 {
Chris@148 763 QStringList params;
Chris@148 764
Chris@148 765 params << "merge";
Chris@153 766 params << "--rev" << Changeset::hashOf(id);
Chris@163 767
Chris@239 768 QString merge = getMergeBinaryName();
Chris@179 769 if (merge != "") {
Chris@179 770 params << "--tool" << merge;
Chris@163 771 }
Chris@148 772
Chris@237 773 if (currentParents.size() == 1) {
Chris@237 774 mergeTargetRevision = currentParents[0]->id();
Chris@237 775 }
Chris@237 776
Chris@148 777 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
Chris@157 778
Chris@157 779 mergeCommitComment = "";
Chris@157 780
Chris@157 781 foreach (Changeset *cs, currentHeads) {
Chris@157 782 if (cs->id() == id && !cs->isOnBranch(currentBranch)) {
Chris@157 783 if (cs->branch() == "" || cs->branch() == "default") {
Chris@157 784 mergeCommitComment = tr("Merge from the default branch");
Chris@157 785 } else {
Chris@157 786 mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
Chris@157 787 }
Chris@157 788 }
Chris@157 789 }
Chris@157 790
Chris@157 791 if (mergeCommitComment == "") {
Chris@157 792 mergeCommitComment = tr("Merge from %1").arg(id);
Chris@157 793 }
Chris@148 794 }
Chris@148 795
Chris@148 796
jtkorhonen@0 797 void MainWindow::hgCloneFromRemote()
jtkorhonen@0 798 {
Chris@109 799 QStringList params;
jtkorhonen@0 800
Chris@109 801 if (!QDir(workFolderPath).exists()) {
Chris@109 802 if (!QDir().mkpath(workFolderPath)) {
Chris@109 803 DEBUG << "hgCloneFromRemote: Failed to create target path "
Chris@109 804 << workFolderPath << endl;
Chris@109 805 //!!! report error
Chris@109 806 return;
Chris@104 807 }
Chris@109 808 }
Chris@104 809
Chris@109 810 params << "clone" << remoteRepoPath << workFolderPath;
Chris@109 811
Chris@109 812 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
Chris@113 813 hgTabs->updateWorkFolderFileList("");
jtkorhonen@0 814
Chris@109 815 runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, workFolderPath, params));
jtkorhonen@0 816 }
jtkorhonen@0 817
jtkorhonen@0 818 void MainWindow::hgInit()
jtkorhonen@0 819 {
Chris@109 820 QStringList params;
jtkorhonen@0 821
Chris@109 822 params << "init";
Chris@109 823 params << workFolderPath;
jtkorhonen@0 824
Chris@109 825 runner->requestAction(HgAction(ACT_INIT, workFolderPath, params));
jtkorhonen@0 826 }
jtkorhonen@0 827
jtkorhonen@0 828 void MainWindow::hgIncoming()
jtkorhonen@0 829 {
Chris@109 830 QStringList params;
jtkorhonen@0 831
Chris@109 832 params << "incoming" << "--newest-first" << remoteRepoPath;
Chris@125 833 params << "--template" << Changeset::getLogTemplate();
jtkorhonen@0 834
Chris@109 835 runner->requestAction(HgAction(ACT_INCOMING, workFolderPath, params));
jtkorhonen@0 836 }
jtkorhonen@0 837
jtkorhonen@0 838 void MainWindow::hgPull()
jtkorhonen@0 839 {
Chris@193 840 if (ConfirmCommentDialog::confirm
Chris@126 841 (this, tr("Confirm pull"),
Chris@126 842 format3(tr("Confirm pull from remote repository"),
Chris@192 843 tr("You are about to pull changes from the following remote repository:"),
Chris@126 844 remoteRepoPath),
Chris@194 845 tr("Pull"))) {
jtkorhonen@0 846
Chris@126 847 QStringList params;
Chris@126 848 params << "pull" << remoteRepoPath;
Chris@126 849 runner->requestAction(HgAction(ACT_PULL, workFolderPath, params));
Chris@126 850 }
jtkorhonen@0 851 }
jtkorhonen@0 852
jtkorhonen@0 853 void MainWindow::hgPush()
jtkorhonen@0 854 {
Chris@193 855 if (ConfirmCommentDialog::confirm
Chris@126 856 (this, tr("Confirm push"),
Chris@126 857 format3(tr("Confirm push to remote repository"),
Chris@192 858 tr("You are about to push your changes to the following remote repository:"),
Chris@126 859 remoteRepoPath),
Chris@194 860 tr("Push"))) {
jtkorhonen@0 861
Chris@126 862 QStringList params;
Chris@154 863 params << "push" << "--new-branch" << remoteRepoPath;
Chris@126 864 runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params));
Chris@126 865 }
jtkorhonen@0 866 }
jtkorhonen@0 867
Chris@182 868 QStringList MainWindow::listAllUpIpV4Addresses()
jtkorhonen@26 869 {
Chris@182 870 QStringList ret;
jtkorhonen@26 871 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
jtkorhonen@26 872
Chris@182 873 for (int i = 0; i < ifaces.count(); i++) {
jtkorhonen@26 874 QNetworkInterface iface = ifaces.at(i);
Chris@182 875 if (iface.flags().testFlag(QNetworkInterface::IsUp)
Chris@182 876 && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
Chris@182 877 for (int j=0; j<iface.addressEntries().count(); j++) {
jtkorhonen@28 878 QHostAddress tmp = iface.addressEntries().at(j).ip();
Chris@182 879 if (QAbstractSocket::IPv4Protocol == tmp.protocol()) {
Chris@182 880 ret.push_back(tmp.toString());
jtkorhonen@24 881 }
jtkorhonen@24 882 }
jtkorhonen@22 883 }
jtkorhonen@17 884 }
jtkorhonen@28 885 return ret;
jtkorhonen@28 886 }
jtkorhonen@17 887
Chris@120 888 void MainWindow::clearState()
Chris@120 889 {
Chris@120 890 foreach (Changeset *cs, currentParents) delete cs;
Chris@120 891 currentParents.clear();
Chris@120 892 foreach (Changeset *cs, currentHeads) delete cs;
Chris@120 893 currentHeads.clear();
Chris@120 894 currentBranch = "";
Chris@163 895 lastStatOutput = "";
Chris@163 896 lastRevertedFiles.clear();
Chris@163 897 mergeTargetRevision = "";
Chris@163 898 mergeCommitComment = "";
Chris@173 899 stateUnknown = true;
Chris@120 900 needNewLog = true;
Chris@199 901 if (fsWatcher) {
Chris@241 902 delete m_fsWatcherGeneralTimer;
Chris@241 903 m_fsWatcherGeneralTimer = 0;
Chris@241 904 delete m_fsWatcherRestoreTimer;
Chris@241 905 m_fsWatcherRestoreTimer = 0;
Chris@199 906 delete fsWatcher;
Chris@199 907 fsWatcher = 0;
Chris@199 908 }
Chris@120 909 }
jtkorhonen@17 910
jtkorhonen@11 911 void MainWindow::hgServe()
jtkorhonen@11 912 {
Chris@109 913 QStringList params;
Chris@109 914 QString msg;
jtkorhonen@11 915
Chris@182 916 QStringList addrs = listAllUpIpV4Addresses();
Chris@182 917
Chris@182 918 if (addrs.empty()) {
Chris@182 919 QMessageBox::critical
Chris@182 920 (this, tr("Serve"), tr("Failed to identify an active IPv4 address"));
Chris@182 921 return;
Chris@182 922 }
Chris@182 923
Chris@182 924 //!!! should find available port as well
Chris@182 925
Chris@182 926 QTextStream ts(&msg);
Chris@182 927 ts << QString("<qt><p>%1</p>")
Chris@182 928 .arg(tr("Running temporary server at %n address(es):", "", addrs.size()));
Chris@182 929 foreach (QString addr, addrs) {
Chris@182 930 ts << QString("<pre>&nbsp;&nbsp;http://%1:8000</pre>").arg(xmlEncode(addr));
Chris@182 931 }
Chris@182 932 ts << tr("<p>Press Close to stop the server and return.</p>");
Chris@182 933 ts.flush();
Chris@182 934
Chris@109 935 params << "serve";
jtkorhonen@11 936
Chris@109 937 runner->requestAction(HgAction(ACT_SERVE, workFolderPath, params));
Chris@109 938
Chris@182 939 QMessageBox::information(this, tr("Serve"), msg, QMessageBox::Close);
Chris@182 940
Chris@182 941 runner->killCurrentActions();
jtkorhonen@11 942 }
jtkorhonen@11 943
Chris@64 944 void MainWindow::startupDialog()
Chris@64 945 {
Chris@64 946 StartupDialog *dlg = new StartupDialog(this);
Chris@65 947 if (dlg->exec()) firstStart = false;
Chris@64 948 }
jtkorhonen@11 949
Chris@69 950 void MainWindow::open()
Chris@69 951 {
Chris@86 952 bool done = false;
Chris@69 953
Chris@86 954 while (!done) {
Chris@69 955
Chris@86 956 MultiChoiceDialog *d = new MultiChoiceDialog
Chris@86 957 (tr("Open Repository"),
Chris@86 958 tr("<qt><big>What would you like to open?</big></qt>"),
Chris@86 959 this);
Chris@69 960
Chris@86 961 d->addChoice("remote",
Chris@86 962 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
Chris@86 963 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
Chris@86 964 MultiChoiceDialog::UrlToDirectoryArg);
Chris@69 965
Chris@86 966 d->addChoice("local",
Chris@86 967 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
Chris@86 968 tr("Open an existing local Mercurial repository."),
Chris@86 969 MultiChoiceDialog::DirectoryArg);
Chris@69 970
Chris@86 971 d->addChoice("init",
Chris@86 972 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
Chris@86 973 tr("Open a local folder, by creating a Mercurial repository in it."),
Chris@86 974 MultiChoiceDialog::DirectoryArg);
Chris@79 975
Chris@86 976 d->setCurrentChoice("local");
Chris@86 977
Chris@86 978 if (d->exec() == QDialog::Accepted) {
Chris@86 979
Chris@86 980 QString choice = d->getCurrentChoice();
Chris@86 981 QString arg = d->getArgument().trimmed();
Chris@86 982
Chris@86 983 bool result = false;
Chris@86 984
Chris@86 985 if (choice == "local") {
Chris@86 986 result = openLocal(arg);
Chris@86 987 } else if (choice == "remote") {
Chris@86 988 result = openRemote(arg, d->getAdditionalArgument().trimmed());
Chris@86 989 } else if (choice == "init") {
Chris@86 990 result = openInit(arg);
Chris@86 991 }
Chris@86 992
Chris@86 993 if (result) {
Chris@86 994 enableDisableActions();
Chris@120 995 clearState();
Chris@109 996 hgQueryPaths();
Chris@91 997 done = true;
Chris@91 998 }
Chris@86 999
Chris@86 1000 } else {
Chris@86 1001
Chris@86 1002 // cancelled
Chris@86 1003 done = true;
Chris@69 1004 }
Chris@79 1005
Chris@86 1006 delete d;
Chris@69 1007 }
Chris@69 1008 }
Chris@69 1009
Chris@182 1010 void MainWindow::changeRemoteRepo()
Chris@182 1011 {
Chris@183 1012 // This will involve rewriting the local .hgrc
Chris@183 1013
Chris@184 1014 QDir hgDir(workFolderPath + "/.hg");
Chris@184 1015 if (!hgDir.exists()) {
Chris@184 1016 //!!! visible error!
Chris@184 1017 return;
Chris@184 1018 }
Chris@184 1019
Chris@183 1020 QFileInfo hgrc(workFolderPath + "/.hg/hgrc");
Chris@184 1021 if (hgrc.exists() && !hgrc.isWritable()) {
Chris@183 1022 //!!! visible error!
Chris@183 1023 return;
Chris@183 1024 }
Chris@183 1025
Chris@183 1026 MultiChoiceDialog *d = new MultiChoiceDialog
Chris@183 1027 (tr("Change Remote Location"),
Chris@183 1028 tr("<qt><big>Change the remote location</big></qt>"),
Chris@183 1029 this);
Chris@183 1030
Chris@183 1031 d->addChoice("remote",
Chris@183 1032 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
Chris@183 1033 tr("Provide a new URL to use for push and pull actions from the current local repository."),
Chris@183 1034 MultiChoiceDialog::UrlArg);
Chris@183 1035
Chris@183 1036 if (d->exec() == QDialog::Accepted) {
Chris@210 1037
Chris@210 1038 // New block to ensure QSettings is deleted before
Chris@210 1039 // hgQueryPaths called. NB use of absoluteFilePath instead of
Chris@210 1040 // canonicalFilePath, which would fail if the file did not yet
Chris@210 1041 // exist
Chris@210 1042
Chris@210 1043 {
Chris@210 1044 QSettings s(hgrc.absoluteFilePath(), QSettings::IniFormat);
Chris@210 1045 s.beginGroup("paths");
Chris@210 1046 s.setValue("default", d->getArgument());
Chris@210 1047 }
Chris@210 1048
Chris@186 1049 stateUnknown = true;
Chris@183 1050 hgQueryPaths();
Chris@183 1051 }
Chris@183 1052
Chris@183 1053 delete d;
Chris@182 1054 }
Chris@182 1055
Chris@145 1056 void MainWindow::open(QString local)
Chris@145 1057 {
Chris@145 1058 if (openLocal(local)) {
Chris@145 1059 enableDisableActions();
Chris@145 1060 clearState();
Chris@145 1061 hgQueryPaths();
Chris@145 1062 }
Chris@145 1063 }
Chris@145 1064
Chris@79 1065 bool MainWindow::complainAboutFilePath(QString arg)
Chris@79 1066 {
Chris@79 1067 QMessageBox::critical
Chris@79 1068 (this, tr("File chosen"),
Chris@84 1069 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 1070 return false;
Chris@79 1071 }
Chris@79 1072
Chris@79 1073 bool MainWindow::complainAboutUnknownFolder(QString arg)
Chris@79 1074 {
Chris@79 1075 QMessageBox::critical
Chris@79 1076 (this, tr("Folder does not exist"),
Chris@84 1077 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 1078 return false;
Chris@84 1079 }
Chris@84 1080
Chris@84 1081 bool MainWindow::complainAboutInitInRepo(QString arg)
Chris@84 1082 {
Chris@84 1083 QMessageBox::critical
Chris@84 1084 (this, tr("Path is in existing repository"),
Chris@84 1085 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 1086 return false;
Chris@84 1087 }
Chris@84 1088
Chris@84 1089 bool MainWindow::complainAboutInitFile(QString arg)
Chris@84 1090 {
Chris@84 1091 QMessageBox::critical
Chris@84 1092 (this, tr("Path is a file"),
Chris@84 1093 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 1094 return false;
Chris@84 1095 }
Chris@84 1096
Chris@84 1097 bool MainWindow::complainAboutCloneToExisting(QString arg)
Chris@84 1098 {
Chris@84 1099 QMessageBox::critical
Chris@84 1100 (this, tr("Path is in existing repository"),
Chris@237 1101 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 1102 return false;
Chris@84 1103 }
Chris@84 1104
Chris@84 1105 bool MainWindow::complainAboutCloneToFile(QString arg)
Chris@84 1106 {
Chris@84 1107 QMessageBox::critical
Chris@84 1108 (this, tr("Path is a file"),
Chris@84 1109 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 1110 return false;
Chris@84 1111 }
Chris@84 1112
Chris@237 1113 QString MainWindow::complainAboutCloneToExistingFolder(QString arg, QString remote)
Chris@84 1114 {
Chris@237 1115 // If the directory "arg" exists but "arg" plus the last path
Chris@237 1116 // component of "remote" does not, then offer the latter as an
Chris@237 1117 // alternative path
Chris@237 1118
Chris@237 1119 QString offer;
Chris@237 1120
Chris@237 1121 QDir d(arg);
Chris@237 1122 if (d.exists()) {
Chris@237 1123 if (QRegExp("^\\w+://").indexIn(remote) >= 0) {
Chris@237 1124 QString rpath = QUrl(remote).path();
Chris@237 1125 if (rpath != "") {
Chris@237 1126 rpath = QDir(rpath).dirName();
Chris@237 1127 if (rpath != "" && !d.exists(rpath)) {
Chris@237 1128 offer = d.filePath(rpath);
Chris@237 1129 }
Chris@237 1130 }
Chris@237 1131 }
Chris@237 1132 }
Chris@237 1133
Chris@237 1134 if (offer != "") {
Chris@237 1135 bool result = (QMessageBox::question
Chris@237 1136 (this, tr("Folder exists"),
Chris@237 1137 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 1138 .arg(xmlEncode(arg)).arg(xmlEncode(offer)),
Chris@237 1139 QMessageBox::Ok | QMessageBox::Cancel,
Chris@237 1140 QMessageBox::Cancel)
Chris@237 1141 == QMessageBox::Ok);
Chris@237 1142 if (result) return offer;
Chris@237 1143 else return "";
Chris@237 1144 }
Chris@237 1145
Chris@84 1146 QMessageBox::critical
Chris@84 1147 (this, tr("Folder exists"),
Chris@237 1148 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 1149 return "";
Chris@79 1150 }
Chris@79 1151
Chris@79 1152 bool MainWindow::askToOpenParentRepo(QString arg, QString parent)
Chris@79 1153 {
Chris@79 1154 return (QMessageBox::question
Chris@84 1155 (this, tr("Path is inside a repository"),
Chris@86 1156 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 1157 .arg(xmlEncode(arg)).arg(xmlEncode(parent)),
Chris@79 1158 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 1159 QMessageBox::Ok)
Chris@79 1160 == QMessageBox::Ok);
Chris@79 1161 }
Chris@79 1162
Chris@79 1163 bool MainWindow::askToInitExisting(QString arg)
Chris@79 1164 {
Chris@79 1165 return (QMessageBox::question
Chris@84 1166 (this, tr("Folder has no repository"),
Chris@84 1167 tr("<qt><b>Initialise a repository here?</b><br><br>You asked to open \"%1\".<br>This folder does not contain a Mercurial repository.<br><br>Would you like to initialise a repository here?</qt>")
Chris@79 1168 .arg(xmlEncode(arg)),
Chris@79 1169 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 1170 QMessageBox::Ok)
Chris@79 1171 == QMessageBox::Ok);
Chris@79 1172 }
Chris@79 1173
Chris@79 1174 bool MainWindow::askToInitNew(QString arg)
Chris@79 1175 {
Chris@79 1176 return (QMessageBox::question
Chris@84 1177 (this, tr("Folder does not exist"),
Chris@84 1178 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 1179 .arg(xmlEncode(arg)),
Chris@84 1180 QMessageBox::Ok | QMessageBox::Cancel,
Chris@84 1181 QMessageBox::Ok)
Chris@84 1182 == QMessageBox::Ok);
Chris@84 1183 }
Chris@84 1184
Chris@84 1185 bool MainWindow::askToOpenInsteadOfInit(QString arg)
Chris@84 1186 {
Chris@84 1187 return (QMessageBox::question
Chris@84 1188 (this, tr("Repository exists"),
Chris@84 1189 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 1190 .arg(xmlEncode(arg)),
Chris@79 1191 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 1192 QMessageBox::Ok)
Chris@79 1193 == QMessageBox::Ok);
Chris@79 1194 }
Chris@79 1195
Chris@79 1196 bool MainWindow::openLocal(QString local)
Chris@79 1197 {
Chris@79 1198 DEBUG << "open " << local << endl;
Chris@79 1199
Chris@79 1200 FolderStatus status = getFolderStatus(local);
Chris@79 1201 QString containing = getContainingRepoFolder(local);
Chris@79 1202
Chris@79 1203 switch (status) {
Chris@79 1204
Chris@79 1205 case FolderHasRepo:
Chris@79 1206 // fine
Chris@79 1207 break;
Chris@79 1208
Chris@79 1209 case FolderExists:
Chris@79 1210 if (containing != "") {
Chris@79 1211 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1212 local = containing;
Chris@79 1213 } else {
Chris@86 1214 //!!! No -- this is likely to happen far more by accident
Chris@86 1215 // than because the user actually wanted to init something.
Chris@86 1216 // Don't ask, just politely reject.
Chris@79 1217 if (!askToInitExisting(local)) return false;
Chris@79 1218 return openInit(local);
Chris@79 1219 }
Chris@79 1220 break;
Chris@79 1221
Chris@79 1222 case FolderParentExists:
Chris@79 1223 if (containing != "") {
Chris@79 1224 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1225 local = containing;
Chris@79 1226 } else {
Chris@79 1227 if (!askToInitNew(local)) return false;
Chris@79 1228 return openInit(local);
Chris@79 1229 }
Chris@79 1230 break;
Chris@79 1231
Chris@79 1232 case FolderUnknown:
Chris@84 1233 if (containing != "") {
Chris@84 1234 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1235 local = containing;
Chris@84 1236 } else {
Chris@84 1237 return complainAboutUnknownFolder(local);
Chris@84 1238 }
Chris@84 1239 break;
Chris@79 1240
Chris@79 1241 case FolderIsFile:
Chris@79 1242 return complainAboutFilePath(local);
Chris@79 1243 }
Chris@79 1244
Chris@79 1245 workFolderPath = local;
Chris@79 1246 remoteRepoPath = "";
Chris@79 1247 return true;
Chris@79 1248 }
Chris@79 1249
Chris@79 1250 bool MainWindow::openRemote(QString remote, QString local)
Chris@79 1251 {
Chris@79 1252 DEBUG << "clone " << remote << " to " << local << endl;
Chris@84 1253
Chris@84 1254 FolderStatus status = getFolderStatus(local);
Chris@84 1255 QString containing = getContainingRepoFolder(local);
Chris@84 1256
Chris@84 1257 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 1258
Chris@84 1259 if (status == FolderHasRepo || containing != "") {
Chris@84 1260 return complainAboutCloneToExisting(local);
Chris@84 1261 }
Chris@84 1262
Chris@84 1263 if (status == FolderIsFile) {
Chris@84 1264 return complainAboutCloneToFile(local);
Chris@84 1265 }
Chris@84 1266
Chris@84 1267 if (status == FolderUnknown) {
Chris@84 1268 return complainAboutUnknownFolder(local);
Chris@84 1269 }
Chris@84 1270
Chris@84 1271 if (status == FolderExists) {
Chris@237 1272 local = complainAboutCloneToExistingFolder(local, remote);
Chris@237 1273 if (local == "") return false;
Chris@84 1274 }
Chris@84 1275
Chris@84 1276 workFolderPath = local;
Chris@84 1277 remoteRepoPath = remote;
Chris@84 1278 hgCloneFromRemote();
Chris@84 1279
Chris@79 1280 return true;
Chris@79 1281 }
Chris@79 1282
Chris@84 1283 bool MainWindow::openInit(QString local)
Chris@79 1284 {
Chris@84 1285 DEBUG << "openInit " << local << endl;
Chris@84 1286
Chris@84 1287 FolderStatus status = getFolderStatus(local);
Chris@84 1288 QString containing = getContainingRepoFolder(local);
Chris@84 1289
Chris@84 1290 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 1291
Chris@84 1292 if (status == FolderHasRepo) {
Chris@84 1293 if (!askToOpenInsteadOfInit(local)) return false;
Chris@84 1294 }
Chris@84 1295
Chris@84 1296 if (containing != "") {
Chris@84 1297 return complainAboutInitInRepo(local);
Chris@84 1298 }
Chris@84 1299
Chris@84 1300 if (status == FolderIsFile) {
Chris@84 1301 return complainAboutInitFile(local);
Chris@84 1302 }
Chris@84 1303
Chris@84 1304 if (status == FolderUnknown) {
Chris@84 1305 return complainAboutUnknownFolder(local);
Chris@84 1306 }
Chris@84 1307
Chris@84 1308 workFolderPath = local;
Chris@84 1309 remoteRepoPath = "";
Chris@84 1310 hgInit();
Chris@79 1311 return true;
Chris@79 1312 }
Chris@79 1313
jtkorhonen@0 1314 void MainWindow::settings()
jtkorhonen@0 1315 {
jtkorhonen@0 1316 SettingsDialog *settingsDlg = new SettingsDialog(this);
jtkorhonen@0 1317 settingsDlg->exec();
Chris@230 1318
Chris@230 1319 if (settingsDlg->presentationChanged()) {
Chris@230 1320 hgTabs->updateFileStates();
Chris@230 1321 updateToolBarStyle();
Chris@230 1322 }
jtkorhonen@0 1323 }
jtkorhonen@0 1324
jtkorhonen@2 1325 #define STDOUT_NEEDS_BIG_WINDOW 512
jtkorhonen@2 1326 #define SMALL_WND_W 500
jtkorhonen@2 1327 #define SMALL_WND_H 300
jtkorhonen@2 1328
jtkorhonen@2 1329 #define BIG_WND_W 1024
jtkorhonen@2 1330 #define BIG_WND_H 768
jtkorhonen@2 1331
jtkorhonen@2 1332
jtkorhonen@2 1333 void MainWindow::presentLongStdoutToUser(QString stdo)
jtkorhonen@0 1334 {
jtkorhonen@2 1335 if (!stdo.isEmpty())
jtkorhonen@2 1336 {
jtkorhonen@2 1337 QDialog dlg;
jtkorhonen@0 1338
jtkorhonen@2 1339 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
jtkorhonen@2 1340 {
jtkorhonen@2 1341 dlg.setMinimumWidth(BIG_WND_W);
jtkorhonen@2 1342 dlg.setMinimumHeight(BIG_WND_H);
jtkorhonen@2 1343 }
jtkorhonen@2 1344 else
jtkorhonen@2 1345 {
jtkorhonen@2 1346 dlg.setMinimumWidth(SMALL_WND_W);
jtkorhonen@2 1347 dlg.setMinimumHeight(SMALL_WND_H);
jtkorhonen@2 1348 }
jtkorhonen@0 1349
jtkorhonen@2 1350 QVBoxLayout *box = new QVBoxLayout;
jtkorhonen@2 1351 QListWidget *list = new QListWidget;
jtkorhonen@2 1352 list-> addItems(stdo.split("\n"));
jtkorhonen@2 1353 QPushButton *btn = new QPushButton(tr("Ok"));
jtkorhonen@2 1354 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
jtkorhonen@0 1355
jtkorhonen@2 1356 box -> addWidget(list);
jtkorhonen@2 1357 box -> addWidget(btn);
jtkorhonen@2 1358 dlg.setLayout(box);
jtkorhonen@2 1359
jtkorhonen@2 1360 dlg.exec();
jtkorhonen@2 1361 }
jtkorhonen@2 1362 else
jtkorhonen@2 1363 {
Chris@98 1364 QMessageBox::information(this, tr("EasyMercurial"), tr("Mercurial command did not return any output."));
jtkorhonen@2 1365 }
jtkorhonen@0 1366 }
jtkorhonen@0 1367
Chris@90 1368 void MainWindow::updateFileSystemWatcher()
Chris@90 1369 {
Chris@199 1370 bool justCreated = false;
Chris@199 1371 if (!fsWatcher) {
Chris@199 1372 fsWatcher = new QFileSystemWatcher();
Chris@199 1373 justCreated = true;
Chris@199 1374 }
Chris@199 1375
Chris@199 1376 // QFileSystemWatcher will refuse to add a file or directory to
Chris@199 1377 // its watch list that it is already watching -- fine, that's what
Chris@199 1378 // we want -- but it prints a warning when this happens, which is
Chris@199 1379 // annoying because it would be the normal case for us. So we'll
Chris@199 1380 // check for duplicates ourselves.
Chris@199 1381 QSet<QString> alreadyWatched;
Chris@199 1382 QStringList dl(fsWatcher->directories());
Chris@199 1383 foreach (QString d, dl) alreadyWatched.insert(d);
Chris@199 1384
Chris@90 1385 std::deque<QString> pending;
Chris@90 1386 pending.push_back(workFolderPath);
Chris@199 1387
Chris@90 1388 while (!pending.empty()) {
Chris@199 1389
Chris@90 1390 QString path = pending.front();
Chris@90 1391 pending.pop_front();
Chris@199 1392 if (!alreadyWatched.contains(path)) {
Chris@199 1393 fsWatcher->addPath(path);
Chris@199 1394 DEBUG << "Added to file system watcher: " << path << endl;
Chris@199 1395 }
Chris@199 1396
Chris@90 1397 QDir d(path);
Chris@90 1398 if (d.exists()) {
Chris@199 1399 d.setFilter(QDir::Dirs | QDir::NoDotAndDotDot |
Chris@199 1400 QDir::Readable | QDir::NoSymLinks);
Chris@90 1401 foreach (QString entry, d.entryList()) {
Chris@199 1402 if (entry.startsWith('.')) continue;
Chris@90 1403 QString entryPath = d.absoluteFilePath(entry);
Chris@90 1404 pending.push_back(entryPath);
Chris@90 1405 }
Chris@90 1406 }
Chris@90 1407 }
Chris@199 1408
Chris@238 1409 // The general timer isn't really related to the fs watcher
Chris@238 1410 // object, it just does something similar -- every now and then we
Chris@238 1411 // do a refresh just to update the history dates etc
Chris@238 1412
Chris@238 1413 m_fsWatcherGeneralTimer = new QTimer(this);
Chris@238 1414 connect(m_fsWatcherGeneralTimer, SIGNAL(timeout()),
Chris@238 1415 this, SLOT(checkFilesystem()));
Chris@238 1416 m_fsWatcherGeneralTimer->setInterval(30 * 60 * 1000); // half an hour
Chris@238 1417 m_fsWatcherGeneralTimer->start();
Chris@238 1418
Chris@199 1419 if (justCreated) {
Chris@199 1420 connect(fsWatcher, SIGNAL(directoryChanged(QString)),
Chris@199 1421 this, SLOT(fsDirectoryChanged(QString)));
Chris@199 1422 connect(fsWatcher, SIGNAL(fileChanged(QString)),
Chris@199 1423 this, SLOT(fsFileChanged(QString)));
Chris@199 1424 }
Chris@90 1425 }
Chris@90 1426
Chris@238 1427 void MainWindow::suspendFileSystemWatcher()
Chris@238 1428 {
Chris@238 1429 DEBUG << "MainWindow::suspendFileSystemWatcher" << endl;
Chris@238 1430 if (fsWatcher) {
Chris@241 1431 m_fsWatcherSuspended = true;
Chris@241 1432 if (m_fsWatcherRestoreTimer) {
Chris@241 1433 delete m_fsWatcherRestoreTimer;
Chris@241 1434 m_fsWatcherRestoreTimer = 0;
Chris@241 1435 }
Chris@238 1436 m_fsWatcherGeneralTimer->stop();
Chris@238 1437 }
Chris@238 1438 }
Chris@238 1439
Chris@238 1440 void MainWindow::restoreFileSystemWatcher()
Chris@238 1441 {
Chris@238 1442 DEBUG << "MainWindow::restoreFileSystemWatcher" << endl;
Chris@238 1443 if (m_fsWatcherRestoreTimer) delete m_fsWatcherRestoreTimer;
Chris@238 1444
Chris@238 1445 // The restore timer is used to leave a polite interval between
Chris@238 1446 // being asked to restore the watcher and actually doing so. It's
Chris@238 1447 // a single shot timer each time it's used, but we don't use
Chris@238 1448 // QTimer::singleShot because we want to stop the previous one if
Chris@238 1449 // it's running (via deleting it)
Chris@238 1450
Chris@238 1451 m_fsWatcherRestoreTimer = new QTimer(this);
Chris@238 1452 connect(m_fsWatcherRestoreTimer, SIGNAL(timeout()),
Chris@238 1453 this, SLOT(actuallyRestoreFileSystemWatcher()));
Chris@238 1454 m_fsWatcherRestoreTimer->setInterval(1000);
Chris@238 1455 m_fsWatcherRestoreTimer->setSingleShot(true);
Chris@238 1456 m_fsWatcherRestoreTimer->start();
Chris@238 1457 }
Chris@238 1458
Chris@238 1459 void MainWindow::actuallyRestoreFileSystemWatcher()
Chris@238 1460 {
Chris@238 1461 DEBUG << "MainWindow::actuallyRestoreFileSystemWatcher" << endl;
Chris@241 1462 if (fsWatcher) {
Chris@241 1463 m_fsWatcherSuspended = false;
Chris@241 1464 m_fsWatcherGeneralTimer->start();
Chris@241 1465 }
Chris@238 1466 }
Chris@238 1467
Chris@238 1468 void MainWindow::checkFilesystem()
Chris@238 1469 {
Chris@238 1470 DEBUG << "MainWindow::checkFilesystem" << endl;
Chris@238 1471 hgStat();
Chris@238 1472 }
Chris@238 1473
Chris@122 1474 void MainWindow::fsDirectoryChanged(QString d)
Chris@90 1475 {
Chris@122 1476 DEBUG << "MainWindow::fsDirectoryChanged " << d << endl;
Chris@241 1477 if (!m_fsWatcherSuspended) {
Chris@241 1478 hgStat();
Chris@241 1479 }
Chris@90 1480 }
Chris@90 1481
Chris@122 1482 void MainWindow::fsFileChanged(QString f)
Chris@90 1483 {
Chris@122 1484 DEBUG << "MainWindow::fsFileChanged " << f << endl;
Chris@241 1485 if (!m_fsWatcherSuspended) {
Chris@241 1486 hgStat();
Chris@241 1487 }
Chris@90 1488 }
Chris@90 1489
Chris@125 1490 QString MainWindow::format3(QString head, QString intro, QString code)
Chris@125 1491 {
Chris@196 1492 code = xmlEncode(code).replace("\n", "<br>")
Chris@196 1493 #ifndef Q_OS_WIN32
Chris@196 1494 // The hard hyphen comes out funny on Windows
Chris@196 1495 .replace("-", "&#8209;")
Chris@196 1496 #endif
Chris@196 1497 .replace(" ", "&nbsp;");
Chris@125 1498 if (intro == "") {
Chris@168 1499 return QString("<qt><h3>%1</h3><p><code>%2</code></p>")
Chris@168 1500 .arg(head).arg(code);
Chris@126 1501 } else if (code == "") {
Chris@126 1502 return QString("<qt><h3>%1</h3><p>%2</p>")
Chris@126 1503 .arg(head).arg(intro);
Chris@125 1504 } else {
Chris@168 1505 return QString("<qt><h3>%1</h3><p>%2</p><p><code>%3</code></p>")
Chris@168 1506 .arg(head).arg(intro).arg(code);
Chris@125 1507 }
Chris@125 1508 }
Chris@125 1509
Chris@120 1510 void MainWindow::showIncoming(QString output)
Chris@120 1511 {
Chris@120 1512 runner->hide();
Chris@125 1513 IncomingDialog *d = new IncomingDialog(this, output);
Chris@125 1514 d->exec();
Chris@125 1515 delete d;
Chris@125 1516 }
Chris@125 1517
Chris@125 1518 int MainWindow::extractChangeCount(QString text)
Chris@125 1519 {
Chris@125 1520 QRegExp re("added (\\d+) ch\\w+ with (\\d+) ch\\w+ to (\\d+) f\\w+");
Chris@125 1521 if (re.indexIn(text) >= 0) {
Chris@125 1522 return re.cap(1).toInt();
Chris@125 1523 } else if (text.contains("no changes")) {
Chris@125 1524 return 0;
Chris@125 1525 } else {
Chris@125 1526 return -1; // unknown
Chris@125 1527 }
Chris@120 1528 }
Chris@120 1529
Chris@120 1530 void MainWindow::showPushResult(QString output)
Chris@120 1531 {
Chris@125 1532 QString report;
Chris@125 1533 int n = extractChangeCount(output);
Chris@125 1534 if (n > 0) {
Chris@125 1535 report = tr("Pushed %n changeset(s)", "", n);
Chris@125 1536 } else if (n == 0) {
Chris@125 1537 report = tr("No changes to push");
Chris@125 1538 } else {
Chris@125 1539 report = tr("Push complete");
Chris@125 1540 }
Chris@125 1541 report = format3(report, tr("The push command output was:"), output);
Chris@120 1542 runner->hide();
Chris@125 1543 QMessageBox::information(this, "Push complete", report);
Chris@120 1544 }
Chris@120 1545
Chris@120 1546 void MainWindow::showPullResult(QString output)
Chris@120 1547 {
Chris@125 1548 QString report;
Chris@125 1549 int n = extractChangeCount(output);
Chris@125 1550 if (n > 0) {
Chris@125 1551 report = tr("Pulled %n changeset(s)", "", n);
Chris@125 1552 } else if (n == 0) {
Chris@125 1553 report = tr("No changes to pull");
Chris@125 1554 } else {
Chris@125 1555 report = tr("Pull complete");
Chris@125 1556 }
Chris@125 1557 report = format3(report, tr("The pull command output was:"), output);
Chris@120 1558 runner->hide();
Chris@125 1559
Chris@125 1560 //!!! and something about updating
Chris@125 1561
Chris@125 1562 QMessageBox::information(this, "Pull complete", report);
Chris@120 1563 }
Chris@120 1564
Chris@174 1565 void MainWindow::reportNewRemoteHeads(QString output)
Chris@174 1566 {
Chris@174 1567 bool headsAreLocal = false;
Chris@174 1568
Chris@174 1569 if (currentParents.size() == 1) {
Chris@174 1570 int currentBranchHeads = 0;
Chris@174 1571 bool parentIsHead = false;
Chris@174 1572 Changeset *parent = currentParents[0];
Chris@174 1573 foreach (Changeset *head, currentHeads) {
Chris@174 1574 if (head->isOnBranch(currentBranch)) {
Chris@174 1575 ++currentBranchHeads;
Chris@174 1576 }
Chris@174 1577 if (parent->id() == head->id()) {
Chris@174 1578 parentIsHead = true;
Chris@174 1579 }
Chris@174 1580 }
Chris@174 1581 if (currentBranchHeads == 2 && parentIsHead) {
Chris@174 1582 headsAreLocal = true;
Chris@174 1583 }
Chris@174 1584 }
Chris@174 1585
Chris@174 1586 if (headsAreLocal) {
Chris@174 1587 QMessageBox::warning
Chris@174 1588 (this, tr("Push failed"),
Chris@174 1589 format3(tr("Push failed"),
Chris@174 1590 tr("Your local repository could not be pushed to the remote repository.<br><br>You may need to merge the changes locally first.<br><br>The output of the push command was:"),
Chris@174 1591 output));
Chris@174 1592 } else {
Chris@174 1593 QMessageBox::warning
Chris@174 1594 (this, tr("Push failed"),
Chris@174 1595 format3(tr("Push failed"),
Chris@174 1596 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.<br><br>The output of the push command was:"),
Chris@174 1597 output));
Chris@174 1598 }
Chris@174 1599 }
Chris@174 1600
Chris@238 1601 void MainWindow::commandStarting(HgAction action)
Chris@238 1602 {
Chris@238 1603 // Annoyingly, hg stat actually modifies the working directory --
Chris@238 1604 // it creates files called hg-checklink and hg-checkexec to test
Chris@238 1605 // properties of the filesystem. For safety's sake, suspend the
Chris@238 1606 // fs watcher while running commands, and restore it shortly after
Chris@238 1607 // a command has finished.
Chris@238 1608
Chris@246 1609 if (action.action == ACT_STAT) {
Chris@246 1610 suspendFileSystemWatcher();
Chris@246 1611 }
Chris@238 1612 }
Chris@238 1613
Chris@143 1614 void MainWindow::commandFailed(HgAction action, QString output)
Chris@62 1615 {
Chris@62 1616 DEBUG << "MainWindow::commandFailed" << endl;
Chris@238 1617 restoreFileSystemWatcher();
Chris@74 1618
Chris@210 1619 QString setstr;
Chris@210 1620 #ifdef Q_OS_MAC
Chris@210 1621 setstr = tr("Preferences");
Chris@210 1622 #else
Chris@210 1623 setstr = tr("Settings");
Chris@210 1624 #endif
Chris@210 1625
Chris@113 1626 // Some commands we just have to ignore bad return values from:
Chris@113 1627
Chris@113 1628 switch(action.action) {
Chris@113 1629 case ACT_NONE:
Chris@113 1630 // uh huh
Chris@113 1631 return;
Chris@175 1632 case ACT_TEST_HG:
Chris@175 1633 QMessageBox::warning
Chris@175 1634 (this, tr("Failed to run Mercurial"),
Chris@175 1635 format3(tr("Failed to run Mercurial"),
Chris@210 1636 tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.<br><br>%2").arg(setstr).arg(output == "" ? QString("") : tr("The test command said:")),
Chris@200 1637 output));
Chris@200 1638 settings();
Chris@200 1639 return;
Chris@200 1640 case ACT_TEST_HG_EXT:
Chris@200 1641 QMessageBox::warning
Chris@200 1642 (this, tr("Failed to run Mercurial"),
Chris@200 1643 format3(tr("Failed to run Mercurial with extension enabled"),
Chris@210 1644 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem with EasyMercurial.<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 may not work if you do this.<br><br>%2").arg(setstr).arg(output == "" ? QString("") : tr("The test command said:")),
Chris@175 1645 output));
Chris@175 1646 settings();
Chris@175 1647 return;
Chris@113 1648 case ACT_INCOMING:
Chris@211 1649 // returns non-zero code and no output if the check was
Chris@211 1650 // successful but there are no changes pending
Chris@211 1651 if (output.trimmed() == "") {
Chris@211 1652 showIncoming("");
Chris@211 1653 return;
Chris@211 1654 }
Chris@211 1655 break;
Chris@162 1656 case ACT_QUERY_HEADS:
Chris@162 1657 // fails if repo is empty; we don't care (if there's a genuine
Chris@202 1658 // problem, something else will fail too). Pretend it
Chris@202 1659 // succeeded, so that any further actions that are contingent
Chris@202 1660 // on the success of the heads query get carried out properly.
Chris@202 1661 commandCompleted(action, "");
Chris@162 1662 return;
Chris@113 1663 case ACT_FOLDERDIFF:
Chris@113 1664 case ACT_CHGSETDIFF:
Chris@113 1665 // external program, unlikely to be anything useful in stderr
Chris@113 1666 // and some return with failure codes when something as basic
Chris@113 1667 // as the user closing the window via the wm happens
Chris@113 1668 return;
Chris@174 1669 case ACT_PUSH:
Chris@174 1670 if (output.contains("creates new remote heads")) {
Chris@174 1671 reportNewRemoteHeads(output);
Chris@174 1672 return;
Chris@174 1673 }
Chris@199 1674 case ACT_STAT:
Chris@199 1675 break; // go on and report
Chris@113 1676 default:
Chris@114 1677 break;
Chris@113 1678 }
Chris@113 1679
Chris@113 1680 QString command = action.executable;
Chris@113 1681 if (command == "") command = "hg";
Chris@113 1682 foreach (QString arg, action.params) {
Chris@113 1683 command += " " + arg;
Chris@113 1684 }
Chris@113 1685
Chris@113 1686 QString message = tr("<qt><h3>Command failed</h3>"
Chris@113 1687 "<p>The following command failed:</p>"
Chris@113 1688 "<code>%1</code>"
Chris@113 1689 "%2</qt>")
Chris@113 1690 .arg(command)
Chris@143 1691 .arg((output.trimmed() != "") ?
Chris@113 1692 tr("<p>Its output said:</p><code>%1</code>")
Chris@143 1693 .arg(xmlEncode(output.left(800))
Chris@113 1694 .replace("\n", "<br>"))
Chris@113 1695 : "");
Chris@113 1696
Chris@113 1697 QMessageBox::warning(this, tr("Command failed"), message);
Chris@62 1698 }
Chris@62 1699
Chris@109 1700 void MainWindow::commandCompleted(HgAction completedAction, QString output)
jtkorhonen@0 1701 {
Chris@238 1702 restoreFileSystemWatcher();
Chris@109 1703 HGACTIONS action = completedAction.action;
Chris@109 1704
Chris@109 1705 if (action == ACT_NONE) return;
Chris@109 1706
Chris@150 1707 bool headsChanged = false;
Chris@150 1708 QStringList oldHeadIds;
Chris@150 1709
Chris@150 1710 switch (action) {
Chris@109 1711
Chris@175 1712 case ACT_TEST_HG:
Chris@175 1713 break;
Chris@175 1714
Chris@200 1715 case ACT_TEST_HG_EXT:
Chris@200 1716 break;
Chris@200 1717
Chris@109 1718 case ACT_QUERY_PATHS:
jtkorhonen@0 1719 {
Chris@109 1720 DEBUG << "stdout is " << output << endl;
Chris@109 1721 LogParser lp(output, "=");
Chris@109 1722 LogList ll = lp.parse();
Chris@109 1723 DEBUG << ll.size() << " results" << endl;
Chris@109 1724 if (!ll.empty()) {
Chris@109 1725 remoteRepoPath = lp.parse()[0]["default"].trimmed();
Chris@109 1726 DEBUG << "Set remote path to " << remoteRepoPath << endl;
Chris@210 1727 } else {
Chris@210 1728 remoteRepoPath = "";
Chris@109 1729 }
Chris@109 1730 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1731 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@109 1732 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
Chris@109 1733 break;
Chris@109 1734 }
jtkorhonen@0 1735
Chris@109 1736 case ACT_QUERY_BRANCH:
Chris@109 1737 currentBranch = output.trimmed();
Chris@109 1738 break;
jtkorhonen@0 1739
Chris@109 1740 case ACT_STAT:
Chris@163 1741 lastStatOutput = output;
Chris@109 1742 updateFileSystemWatcher();
Chris@109 1743 break;
Chris@163 1744
Chris@163 1745 case ACT_RESOLVE_LIST:
Chris@163 1746 if (output != "") {
Chris@163 1747 // Remove lines beginning with R (they are resolved,
Chris@163 1748 // and the file stat parser treats R as removed)
Chris@163 1749 QStringList outList = output.split('\n');
Chris@163 1750 QStringList winnowed;
Chris@163 1751 foreach (QString line, outList) {
Chris@163 1752 if (!line.startsWith("R ")) winnowed.push_back(line);
Chris@163 1753 }
Chris@163 1754 output = winnowed.join("\n");
Chris@163 1755 }
Chris@163 1756 DEBUG << "lastStatOutput = " << lastStatOutput << endl;
Chris@199 1757 DEBUG << "resolve output = " << output << endl;
Chris@163 1758 hgTabs->updateWorkFolderFileList(lastStatOutput + output);
Chris@163 1759 break;
Chris@163 1760
Chris@163 1761 case ACT_RESOLVE_MARK:
Chris@163 1762 shouldHgStat = true;
Chris@163 1763 break;
Chris@109 1764
Chris@109 1765 case ACT_INCOMING:
Chris@120 1766 showIncoming(output);
Chris@120 1767 break;
Chris@120 1768
Chris@109 1769 case ACT_ANNOTATE:
Chris@109 1770 presentLongStdoutToUser(output);
Chris@109 1771 shouldHgStat = true;
Chris@109 1772 break;
Chris@109 1773
Chris@109 1774 case ACT_PULL:
Chris@120 1775 showPullResult(output);
Chris@109 1776 shouldHgStat = true;
Chris@109 1777 break;
Chris@109 1778
Chris@109 1779 case ACT_PUSH:
Chris@120 1780 showPushResult(output);
Chris@109 1781 break;
Chris@109 1782
Chris@109 1783 case ACT_INIT:
Chris@109 1784 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
Chris@109 1785 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1786 enableDisableActions();
Chris@109 1787 shouldHgStat = true;
Chris@109 1788 break;
Chris@109 1789
Chris@109 1790 case ACT_CLONEFROMREMOTE:
Chris@109 1791 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1792 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@109 1793 MultiChoiceDialog::addRecentArgument("remote", workFolderPath, true);
Chris@237 1794 QMessageBox::information(this, tr("Clone"), tr("<qt><h3>Clone successful</h3><pre>%1</pre>").arg(xmlEncode(output)));
Chris@109 1795 enableDisableActions();
Chris@109 1796 shouldHgStat = true;
Chris@109 1797 break;
Chris@109 1798
Chris@109 1799 case ACT_LOG:
Chris@120 1800 hgTabs->setNewLog(output);
Chris@120 1801 needNewLog = false;
Chris@120 1802 break;
Chris@120 1803
Chris@120 1804 case ACT_LOG_INCREMENTAL:
Chris@120 1805 hgTabs->addIncrementalLog(output);
Chris@109 1806 break;
Chris@109 1807
Chris@109 1808 case ACT_QUERY_PARENTS:
Chris@152 1809 {
Chris@109 1810 foreach (Changeset *cs, currentParents) delete cs;
Chris@109 1811 currentParents = Changeset::parseChangesets(output);
Chris@152 1812 QStringList parentIds = Changeset::getIds(currentParents);
Chris@153 1813 hgTabs->setCurrent(parentIds, currentBranch);
Chris@152 1814 }
Chris@109 1815 break;
Chris@109 1816
Chris@109 1817 case ACT_QUERY_HEADS:
Chris@150 1818 {
Chris@150 1819 oldHeadIds = Changeset::getIds(currentHeads);
Chris@150 1820 Changesets newHeads = Changeset::parseChangesets(output);
Chris@150 1821 QStringList newHeadIds = Changeset::getIds(newHeads);
Chris@150 1822 if (oldHeadIds != newHeadIds) {
Chris@150 1823 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl;
Chris@150 1824 headsChanged = true;
Chris@150 1825 foreach (Changeset *cs, currentHeads) delete cs;
Chris@150 1826 currentHeads = newHeads;
Chris@150 1827 }
Chris@150 1828 }
Chris@109 1829 break;
Chris@130 1830
Chris@130 1831 case ACT_COMMIT:
Chris@130 1832 hgTabs->clearSelections();
Chris@163 1833 justMerged = false;
Chris@130 1834 shouldHgStat = true;
Chris@130 1835 break;
Chris@163 1836
Chris@163 1837 case ACT_REVERT:
Chris@163 1838 hgMarkResolved(lastRevertedFiles);
Chris@163 1839 justMerged = false;
Chris@163 1840 break;
Chris@109 1841
Chris@109 1842 case ACT_REMOVE:
Chris@109 1843 case ACT_ADD:
Chris@116 1844 hgTabs->clearSelections();
Chris@116 1845 shouldHgStat = true;
Chris@116 1846 break;
Chris@116 1847
Chris@164 1848 case ACT_TAG:
Chris@164 1849 needNewLog = true;
Chris@164 1850 shouldHgStat = true;
Chris@164 1851 break;
Chris@164 1852
Chris@168 1853 case ACT_DIFF_SUMMARY:
Chris@168 1854 QMessageBox::information(this, tr("Change summary"),
Chris@168 1855 format3(tr("Summary of uncommitted changes"),
Chris@168 1856 "",
Chris@168 1857 output));
Chris@168 1858 break;
Chris@168 1859
Chris@109 1860 case ACT_FOLDERDIFF:
Chris@109 1861 case ACT_CHGSETDIFF:
Chris@109 1862 case ACT_SERVE:
Chris@109 1863 case ACT_HG_IGNORE:
Chris@109 1864 shouldHgStat = true;
Chris@109 1865 break;
Chris@109 1866
Chris@109 1867 case ACT_UPDATE:
Chris@162 1868 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output)));
Chris@109 1869 shouldHgStat = true;
Chris@109 1870 break;
Chris@109 1871
Chris@109 1872 case ACT_MERGE:
Chris@196 1873 //!!! use format3?
Chris@196 1874 QMessageBox::information(this, tr("Merge"), tr("<qt><h3>Merge successful</h3><pre>%1</pre>").arg(xmlEncode(output)));
Chris@109 1875 shouldHgStat = true;
Chris@109 1876 justMerged = true;
Chris@109 1877 break;
Chris@109 1878
Chris@109 1879 case ACT_RETRY_MERGE:
Chris@163 1880 QMessageBox::information(this, tr("Resolved"),
Chris@163 1881 tr("<qt><h3>Merge resolved</h3><p>Merge resolved successfully.</p>"));
Chris@109 1882 shouldHgStat = true;
Chris@109 1883 justMerged = true;
Chris@109 1884 break;
Chris@109 1885
Chris@109 1886 default:
Chris@109 1887 break;
Chris@109 1888 }
Chris@108 1889
Chris@121 1890 // Sequence when no full log required:
Chris@163 1891 // paths -> branch -> stat -> resolve-list -> heads ->
Chris@150 1892 // incremental-log (only if heads changed) -> parents
Chris@150 1893 //
Chris@121 1894 // Sequence when full log required:
Chris@163 1895 // paths -> branch -> stat -> resolve-list -> heads -> parents -> log
Chris@150 1896 //
Chris@150 1897 // Note we want to call enableDisableActions only once, at the end
Chris@150 1898 // of whichever sequence is in use.
Chris@150 1899
Chris@156 1900 bool noMore = false;
Chris@156 1901
Chris@150 1902 switch (action) {
Chris@175 1903
Chris@175 1904 case ACT_TEST_HG:
Chris@200 1905 hgTestExtension();
Chris@200 1906 break;
Chris@200 1907
Chris@200 1908 case ACT_TEST_HG_EXT:
Chris@175 1909 hgQueryPaths();
Chris@175 1910 break;
Chris@150 1911
Chris@150 1912 case ACT_QUERY_PATHS:
Chris@109 1913 hgQueryBranch();
Chris@150 1914 break;
Chris@150 1915
Chris@150 1916 case ACT_QUERY_BRANCH:
Chris@109 1917 hgStat();
Chris@150 1918 break;
Chris@150 1919
Chris@150 1920 case ACT_STAT:
Chris@163 1921 hgResolveList();
Chris@163 1922 break;
Chris@163 1923
Chris@163 1924 case ACT_RESOLVE_LIST:
Chris@150 1925 hgQueryHeads();
Chris@150 1926 break;
Chris@150 1927
Chris@150 1928 case ACT_QUERY_HEADS:
Chris@150 1929 if (headsChanged && !needNewLog) {
Chris@150 1930 hgLogIncremental(oldHeadIds);
Chris@121 1931 } else {
Chris@150 1932 hgQueryParents();
Chris@121 1933 }
Chris@150 1934 break;
Chris@150 1935
Chris@150 1936 case ACT_LOG_INCREMENTAL:
Chris@109 1937 hgQueryParents();
Chris@150 1938 break;
Chris@150 1939
Chris@150 1940 case ACT_QUERY_PARENTS:
Chris@120 1941 if (needNewLog) {
Chris@120 1942 hgLog();
Chris@150 1943 } else {
Chris@150 1944 // we're done
Chris@156 1945 noMore = true;
Chris@120 1946 }
Chris@150 1947 break;
Chris@150 1948
Chris@150 1949 case ACT_LOG:
Chris@150 1950 // we're done
Chris@156 1951 noMore = true;
Chris@198 1952 break;
Chris@150 1953
Chris@150 1954 default:
Chris@109 1955 if (shouldHgStat) {
Chris@163 1956 shouldHgStat = false;
Chris@109 1957 hgQueryPaths();
Chris@150 1958 } else {
Chris@156 1959 noMore = true;
jtkorhonen@0 1960 }
Chris@150 1961 break;
Chris@150 1962 }
Chris@156 1963
Chris@156 1964 if (noMore) {
Chris@173 1965 stateUnknown = false;
Chris@156 1966 enableDisableActions();
Chris@156 1967 hgTabs->updateHistory();
Chris@156 1968 }
jtkorhonen@0 1969 }
jtkorhonen@0 1970
jtkorhonen@0 1971 void MainWindow::connectActions()
jtkorhonen@0 1972 {
jtkorhonen@0 1973 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
jtkorhonen@0 1974 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
jtkorhonen@0 1975
Chris@120 1976 connect(hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
jtkorhonen@0 1977 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
jtkorhonen@0 1978 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
jtkorhonen@0 1979 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
jtkorhonen@0 1980 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
jtkorhonen@0 1981 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
jtkorhonen@0 1982 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
jtkorhonen@0 1983 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
jtkorhonen@34 1984 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
jtkorhonen@0 1985
jtkorhonen@0 1986 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
Chris@69 1987 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
Chris@182 1988 connect(changeRemoteRepoAct, SIGNAL(triggered()), this, SLOT(changeRemoteRepo()));
jtkorhonen@0 1989
jtkorhonen@0 1990 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
jtkorhonen@0 1991 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
jtkorhonen@0 1992 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
jtkorhonen@0 1993
jtkorhonen@0 1994 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
jtkorhonen@11 1995 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
jtkorhonen@0 1996 }
Chris@141 1997
Chris@141 1998 void MainWindow::connectTabsSignals()
Chris@141 1999 {
Chris@141 2000 connect(hgTabs, SIGNAL(commit()),
Chris@141 2001 this, SLOT(hgCommit()));
Chris@141 2002
Chris@141 2003 connect(hgTabs, SIGNAL(revert()),
Chris@141 2004 this, SLOT(hgRevert()));
Chris@141 2005
Chris@141 2006 connect(hgTabs, SIGNAL(diffWorkingFolder()),
Chris@141 2007 this, SLOT(hgFolderDiff()));
Chris@168 2008
Chris@168 2009 connect(hgTabs, SIGNAL(showSummary()),
Chris@168 2010 this, SLOT(hgShowSummary()));
Chris@148 2011
Chris@141 2012 connect(hgTabs, SIGNAL(updateTo(QString)),
Chris@148 2013 this, SLOT(hgUpdateToRev(QString)));
Chris@141 2014
Chris@141 2015 connect(hgTabs, SIGNAL(diffToCurrent(QString)),
Chris@148 2016 this, SLOT(hgDiffToCurrent(QString)));
Chris@141 2017
Chris@148 2018 connect(hgTabs, SIGNAL(diffToParent(QString, QString)),
Chris@148 2019 this, SLOT(hgDiffToParent(QString, QString)));
Chris@141 2020
Chris@141 2021 connect(hgTabs, SIGNAL(mergeFrom(QString)),
Chris@148 2022 this, SLOT(hgMergeFrom(QString)));
Chris@164 2023
Chris@141 2024 connect(hgTabs, SIGNAL(tag(QString)),
Chris@148 2025 this, SLOT(hgTag(QString)));
Chris@141 2026 }
Chris@141 2027
jtkorhonen@0 2028 void MainWindow::enableDisableActions()
jtkorhonen@0 2029 {
Chris@90 2030 DEBUG << "MainWindow::enableDisableActions" << endl;
Chris@90 2031
Chris@202 2032 QString dirname = QDir(workFolderPath).dirName();
Chris@202 2033 if (dirname != "") {
Chris@202 2034 setWindowTitle(tr("EasyMercurial: %1").arg(dirname));
Chris@202 2035 } else {
Chris@202 2036 setWindowTitle(tr("EasyMercurial"));
Chris@202 2037 }
Chris@202 2038
Chris@115 2039 //!!! should also do things like set the status texts for the
Chris@115 2040 //!!! actions appropriately by context
Chris@115 2041
jtkorhonen@0 2042 QDir localRepoDir;
jtkorhonen@0 2043 QDir workFolderDir;
Chris@145 2044 bool workFolderExist = true;
Chris@145 2045 bool localRepoExist = true;
jtkorhonen@0 2046
jtkorhonen@0 2047 remoteRepoActionsEnabled = true;
Chris@90 2048 if (remoteRepoPath.isEmpty()) {
jtkorhonen@0 2049 remoteRepoActionsEnabled = false;
jtkorhonen@0 2050 }
jtkorhonen@0 2051
jtkorhonen@0 2052 localRepoActionsEnabled = true;
Chris@90 2053 if (workFolderPath.isEmpty()) {
jtkorhonen@0 2054 localRepoActionsEnabled = false;
jtkorhonen@0 2055 workFolderExist = false;
jtkorhonen@0 2056 }
jtkorhonen@0 2057
Chris@90 2058 if (!workFolderDir.exists(workFolderPath)) {
jtkorhonen@0 2059 localRepoActionsEnabled = false;
jtkorhonen@0 2060 workFolderExist = false;
Chris@90 2061 } else {
jtkorhonen@0 2062 workFolderExist = true;
jtkorhonen@0 2063 }
jtkorhonen@0 2064
Chris@112 2065 if (!localRepoDir.exists(workFolderPath + "/.hg")) {
jtkorhonen@0 2066 localRepoActionsEnabled = false;
jtkorhonen@0 2067 localRepoExist = false;
jtkorhonen@0 2068 }
jtkorhonen@0 2069
jtkorhonen@0 2070 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
jtkorhonen@0 2071 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
jtkorhonen@0 2072 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
Chris@169 2073
Chris@179 2074 bool haveDiff = false;
Chris@179 2075 QSettings settings;
Chris@179 2076 settings.beginGroup("Locations");
Chris@179 2077 if (settings.value("extdiffbinary", "").toString() != "") {
Chris@179 2078 haveDiff = true;
Chris@179 2079 }
Chris@179 2080 settings.endGroup();
Chris@112 2081
Chris@120 2082 hgRefreshAct -> setEnabled(localRepoActionsEnabled);
Chris@112 2083 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
jtkorhonen@0 2084 hgRevertAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 2085 hgAddAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 2086 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 2087 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 2088 hgCommitAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 2089 hgMergeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@2 2090 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@11 2091 hgServeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@34 2092 hgIgnoreAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 2093
Chris@90 2094 DEBUG << "localRepoActionsEnabled = " << localRepoActionsEnabled << endl;
Chris@98 2095 DEBUG << "canCommit = " << hgTabs->canCommit() << endl;
Chris@90 2096
Chris@98 2097 hgAddAct->setEnabled(localRepoActionsEnabled && hgTabs->canAdd());
Chris@98 2098 hgRemoveAct->setEnabled(localRepoActionsEnabled && hgTabs->canRemove());
Chris@98 2099 hgCommitAct->setEnabled(localRepoActionsEnabled && hgTabs->canCommit());
Chris@163 2100 hgRevertAct->setEnabled(localRepoActionsEnabled && hgTabs->canRevert());
Chris@163 2101 hgFolderDiffAct->setEnabled(localRepoActionsEnabled && hgTabs->canDiff());
Chris@90 2102
Chris@108 2103 // A default merge makes sense if:
Chris@108 2104 // * there is only one parent (if there are two, we have an uncommitted merge) and
Chris@108 2105 // * there are exactly two heads that have the same branch as the current branch and
Chris@108 2106 // * our parent is one of those heads
Chris@108 2107 //
Chris@108 2108 // A default update makes sense if:
Chris@108 2109 // * there is only one parent and
Chris@108 2110 // * the parent is not one of the current heads
Chris@156 2111
Chris@108 2112 bool canMerge = false;
Chris@108 2113 bool canUpdate = false;
Chris@156 2114 bool haveMerge = false;
Chris@162 2115 bool emptyRepo = false;
Chris@225 2116 bool noWorkingCopy = false;
Chris@235 2117 bool newBranch = false;
Chris@156 2118 int currentBranchHeads = 0;
Chris@156 2119
Chris@108 2120 if (currentParents.size() == 1) {
Chris@156 2121 bool parentIsHead = false;
Chris@108 2122 Changeset *parent = currentParents[0];
Chris@108 2123 foreach (Changeset *head, currentHeads) {
Chris@108 2124 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl;
Chris@108 2125 if (head->isOnBranch(currentBranch)) {
Chris@108 2126 ++currentBranchHeads;
Chris@235 2127 }
Chris@235 2128 if (parent->id() == head->id()) {
Chris@235 2129 parentIsHead = true;
Chris@108 2130 }
Chris@108 2131 }
Chris@108 2132 if (currentBranchHeads == 2 && parentIsHead) {
Chris@108 2133 canMerge = true;
Chris@108 2134 }
Chris@235 2135 if (currentBranchHeads == 0 && parentIsHead) {
Chris@235 2136 // Just created a new branch
Chris@235 2137 newBranch = true;
Chris@235 2138 }
Chris@108 2139 if (!parentIsHead) {
Chris@108 2140 canUpdate = true;
Chris@108 2141 DEBUG << "parent id = " << parent->id() << endl;
Chris@108 2142 DEBUG << " head ids "<<endl;
Chris@108 2143 foreach (Changeset *h, currentHeads) {
Chris@108 2144 DEBUG << "head id = " << h->id() << endl;
Chris@108 2145 }
Chris@108 2146 }
Chris@237 2147 justMerged = false;
Chris@162 2148 } else if (currentParents.size() == 0) {
Chris@225 2149 if (currentHeads.size() == 0) {
Chris@225 2150 // No heads -> empty repo
Chris@225 2151 emptyRepo = true;
Chris@225 2152 } else {
Chris@225 2153 // Heads, but no parents -> no working copy, e.g. we have
Chris@225 2154 // just converted this repo but haven't updated in it yet.
Chris@225 2155 // Uncommon but confusing; probably merits a special case
Chris@225 2156 noWorkingCopy = true;
Chris@225 2157 canUpdate = true;
Chris@225 2158 }
Chris@237 2159 justMerged = false;
Chris@156 2160 } else {
Chris@156 2161 haveMerge = true;
Chris@163 2162 justMerged = true;
Chris@108 2163 }
Chris@156 2164
Chris@163 2165 hgMergeAct->setEnabled(localRepoActionsEnabled &&
Chris@163 2166 (canMerge || hgTabs->canResolve()));
Chris@163 2167 hgUpdateAct->setEnabled(localRepoActionsEnabled &&
Chris@172 2168 (canUpdate && !hgTabs->haveChangesToCommit()));
Chris@115 2169
Chris@115 2170 // Set the state field on the file status widget
Chris@115 2171
Chris@115 2172 QString branchText;
Chris@115 2173 if (currentBranch == "" || currentBranch == "default") {
Chris@115 2174 branchText = tr("the default branch");
Chris@115 2175 } else {
Chris@115 2176 branchText = tr("branch \"%1\"").arg(currentBranch);
Chris@115 2177 }
Chris@156 2178
Chris@173 2179 if (stateUnknown) {
Chris@173 2180 hgTabs->setState(tr("(Examining repository)"));
Chris@173 2181 } else if (emptyRepo) {
Chris@162 2182 hgTabs->setState(tr("Nothing committed to this repository yet"));
Chris@225 2183 } else if (noWorkingCopy) {
Chris@225 2184 hgTabs->setState(tr("No working copy yet: consider updating"));
Chris@162 2185 } else if (canMerge) {
Chris@156 2186 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
Chris@163 2187 } else if (!hgTabs->getAllUnresolvedFiles().empty()) {
Chris@163 2188 hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText));
Chris@156 2189 } else if (haveMerge) {
Chris@157 2190 hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
Chris@235 2191 } else if (newBranch) {
Chris@235 2192 hgTabs->setState(tr("On %1. New branch: has not yet been committed").arg(branchText));
Chris@156 2193 } else if (canUpdate) {
Chris@172 2194 if (hgTabs->haveChangesToCommit()) {
Chris@163 2195 // have uncommitted changes
Chris@163 2196 hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText));
Chris@163 2197 } else {
Chris@163 2198 // no uncommitted changes
Chris@163 2199 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
Chris@163 2200 }
Chris@156 2201 } else if (currentBranchHeads > 1) {
Chris@156 2202 hgTabs->setState(tr("At one of %n heads of %1", "", currentBranchHeads).arg(branchText));
Chris@115 2203 } else {
Chris@115 2204 hgTabs->setState(tr("At the head of %1").arg(branchText));
Chris@115 2205 }
jtkorhonen@0 2206 }
jtkorhonen@0 2207
jtkorhonen@0 2208 void MainWindow::createActions()
jtkorhonen@0 2209 {
jtkorhonen@0 2210 //File actions
Chris@69 2211 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
Chris@199 2212 openAct -> setStatusTip(tr("Open an existing repository or working folder"));
Chris@69 2213
Chris@182 2214 changeRemoteRepoAct = new QAction(tr("Change Remote Location..."), this);
Chris@182 2215 changeRemoteRepoAct->setStatusTip(tr("Change the default remote repository for pull and push actions"));
Chris@182 2216
jtkorhonen@0 2217 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
jtkorhonen@0 2218 settingsAct -> setStatusTip(tr("View and change application settings"));
jtkorhonen@0 2219
Chris@169 2220 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Quit"), this);
jtkorhonen@0 2221 exitAct->setShortcuts(QKeySequence::Quit);
Chris@169 2222 exitAct->setStatusTip(tr("Quit EasyMercurial"));
jtkorhonen@0 2223
jtkorhonen@0 2224 //Repository actions
Chris@120 2225 hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
Chris@178 2226 hgRefreshAct->setStatusTip(tr("Refresh the window to show the current state of the working folder"));
Chris@61 2227
Chris@61 2228 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
Chris@169 2229 hgIncomingAct -> setStatusTip(tr("See what changes are available in the remote repository waiting to be pulled"));
jtkorhonen@0 2230
Chris@61 2231 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
Chris@169 2232 hgPullAct -> setStatusTip(tr("Pull changes from the remote repository to the local repository"));
jtkorhonen@0 2233
Chris@61 2234 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push"), this);
Chris@169 2235 hgPushAct->setStatusTip(tr("Push changes from the local repository to the remote repository"));
jtkorhonen@0 2236
jtkorhonen@0 2237 //Workfolder actions
Chris@99 2238 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("Diff"), this);
Chris@169 2239 hgFolderDiffAct->setStatusTip(tr("See what has changed in the working folder compared with the last committed state"));
jtkorhonen@0 2240
Chris@61 2241 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Revert"), this);
Chris@169 2242 hgRevertAct->setStatusTip(tr("Throw away your changes and return to the last committed state"));
jtkorhonen@0 2243
Chris@61 2244 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add"), this);
Chris@169 2245 hgAddAct -> setStatusTip(tr("Mark the selected file(s) to be added on the next commit"));
jtkorhonen@0 2246
Chris@169 2247 //!!! needs to be modified for number
Chris@61 2248 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove"), this);
Chris@169 2249 hgRemoveAct -> setStatusTip(tr("Mark the selected file(s) to be removed from version control on the next commit"));
jtkorhonen@0 2250
Chris@61 2251 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update"), this);
Chris@169 2252 hgUpdateAct->setStatusTip(tr("Update the working folder to the head of the current repository branch"));
jtkorhonen@0 2253
Chris@169 2254 //!!! needs to be modified when files selected
Chris@61 2255 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit"), this);
Chris@169 2256 hgCommitAct->setStatusTip(tr("Commit your changes to the local repository"));
jtkorhonen@0 2257
jtkorhonen@0 2258 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
Chris@169 2259 hgMergeAct->setStatusTip(tr("Merge the two independent sets of changes in the local repository into the working folder"));
jtkorhonen@0 2260
jtkorhonen@0 2261 //Advanced actions
Chris@169 2262 //!!! needs to be modified for number
jtkorhonen@0 2263 hgAnnotateAct = new QAction(tr("Annotate"), this);
jtkorhonen@0 2264 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
jtkorhonen@0 2265
Chris@182 2266 hgIgnoreAct = new QAction(tr("Edit .hgignore File"), this);
Chris@169 2267 hgIgnoreAct -> setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial"));
jtkorhonen@34 2268
Chris@182 2269 hgServeAct = new QAction(tr("Serve via HTTP"), this);
jtkorhonen@11 2270 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
jtkorhonen@11 2271
jtkorhonen@0 2272 //Help actions
Chris@190 2273 aboutAct = new QAction(tr("About EasyMercurial"), this);
Chris@94 2274
Chris@94 2275 // Miscellaneous
Chris@199 2276 QShortcut *clearSelectionsShortcut = new QShortcut(Qt::Key_Escape, this);
Chris@199 2277 connect(clearSelectionsShortcut, SIGNAL(activated()),
Chris@199 2278 this, SLOT(clearSelections()));
jtkorhonen@0 2279 }
jtkorhonen@0 2280
jtkorhonen@0 2281 void MainWindow::createMenus()
jtkorhonen@0 2282 {
jtkorhonen@0 2283 fileMenu = menuBar()->addMenu(tr("File"));
Chris@169 2284
Chris@69 2285 fileMenu -> addAction(openAct);
Chris@182 2286 fileMenu -> addAction(changeRemoteRepoAct);
Chris@191 2287 fileMenu -> addSeparator();
Chris@191 2288
Chris@191 2289 advancedMenu = fileMenu->addMenu(tr("Advanced"));
Chris@191 2290
jtkorhonen@0 2291 fileMenu -> addAction(settingsAct);
Chris@191 2292
jtkorhonen@0 2293 fileMenu -> addSeparator();
jtkorhonen@0 2294 fileMenu -> addAction(exitAct);
jtkorhonen@0 2295
jtkorhonen@34 2296 advancedMenu -> addAction(hgIgnoreAct);
Chris@199 2297 advancedMenu -> addSeparator();
jtkorhonen@11 2298 advancedMenu -> addAction(hgServeAct);
jtkorhonen@0 2299
jtkorhonen@0 2300 helpMenu = menuBar()->addMenu(tr("Help"));
jtkorhonen@0 2301 helpMenu->addAction(aboutAct);
jtkorhonen@0 2302 }
jtkorhonen@0 2303
jtkorhonen@0 2304 void MainWindow::createToolBars()
jtkorhonen@0 2305 {
jtkorhonen@0 2306 fileToolBar = addToolBar(tr("File"));
jtkorhonen@0 2307 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@69 2308 fileToolBar -> addAction(openAct);
Chris@120 2309 fileToolBar -> addAction(hgRefreshAct);
jtkorhonen@0 2310 fileToolBar -> addSeparator();
jtkorhonen@0 2311 fileToolBar -> setMovable(false);
jtkorhonen@0 2312
jtkorhonen@0 2313 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
jtkorhonen@0 2314 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
jtkorhonen@0 2315 repoToolBar->addAction(hgIncomingAct);
jtkorhonen@0 2316 repoToolBar->addAction(hgPullAct);
jtkorhonen@0 2317 repoToolBar->addAction(hgPushAct);
jtkorhonen@0 2318 repoToolBar -> setMovable(false);
jtkorhonen@0 2319
jtkorhonen@0 2320 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
jtkorhonen@0 2321 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
jtkorhonen@0 2322 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@95 2323 workFolderToolBar->addAction(hgFolderDiffAct);
jtkorhonen@0 2324 workFolderToolBar->addSeparator();
jtkorhonen@0 2325 workFolderToolBar->addAction(hgRevertAct);
jtkorhonen@0 2326 workFolderToolBar->addAction(hgUpdateAct);
jtkorhonen@0 2327 workFolderToolBar->addAction(hgCommitAct);
jtkorhonen@0 2328 workFolderToolBar->addAction(hgMergeAct);
jtkorhonen@0 2329 workFolderToolBar->addSeparator();
jtkorhonen@0 2330 workFolderToolBar->addAction(hgAddAct);
jtkorhonen@0 2331 workFolderToolBar->addAction(hgRemoveAct);
jtkorhonen@0 2332 workFolderToolBar -> setMovable(false);
Chris@61 2333
Chris@230 2334 updateToolBarStyle();
jtkorhonen@0 2335 }
jtkorhonen@0 2336
Chris@230 2337 void MainWindow::updateToolBarStyle()
Chris@230 2338 {
Chris@230 2339 QSettings settings;
Chris@230 2340 settings.beginGroup("Presentation");
Chris@230 2341 bool showText = settings.value("showiconlabels", true).toBool();
Chris@230 2342 settings.endGroup();
Chris@230 2343
Chris@230 2344 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
Chris@230 2345 tb->setToolButtonStyle(showText ?
Chris@230 2346 Qt::ToolButtonTextUnderIcon :
Chris@230 2347 Qt::ToolButtonIconOnly);
Chris@230 2348 }
Chris@230 2349 }
jtkorhonen@0 2350
jtkorhonen@0 2351 void MainWindow::createStatusBar()
jtkorhonen@0 2352 {
jtkorhonen@0 2353 statusBar()->showMessage(tr("Ready"));
jtkorhonen@0 2354 }
jtkorhonen@0 2355
Chris@69 2356
Chris@69 2357 //!!! review these:
Chris@69 2358
jtkorhonen@0 2359 void MainWindow::readSettings()
jtkorhonen@0 2360 {
jtkorhonen@0 2361 QDir workFolder;
jtkorhonen@0 2362
Chris@61 2363 QSettings settings;
jtkorhonen@0 2364
jtkorhonen@30 2365 remoteRepoPath = settings.value("remoterepopath", "").toString();
jtkorhonen@0 2366 workFolderPath = settings.value("workfolderpath", "").toString();
jtkorhonen@0 2367 if (!workFolder.exists(workFolderPath))
jtkorhonen@0 2368 {
jtkorhonen@0 2369 workFolderPath = "";
jtkorhonen@0 2370 }
jtkorhonen@0 2371
jtkorhonen@0 2372 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
jtkorhonen@0 2373 QSize size = settings.value("size", QSize(400, 400)).toSize();
jtkorhonen@0 2374 firstStart = settings.value("firststart", QVariant(true)).toBool();
jtkorhonen@0 2375
Chris@109 2376 //!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
jtkorhonen@0 2377 resize(size);
jtkorhonen@0 2378 move(pos);
jtkorhonen@0 2379 }
jtkorhonen@0 2380
jtkorhonen@17 2381
jtkorhonen@0 2382 void MainWindow::writeSettings()
jtkorhonen@0 2383 {
Chris@61 2384 QSettings settings;
jtkorhonen@0 2385 settings.setValue("pos", pos());
jtkorhonen@0 2386 settings.setValue("size", size());
jtkorhonen@0 2387 settings.setValue("remoterepopath", remoteRepoPath);
jtkorhonen@0 2388 settings.setValue("workfolderpath", workFolderPath);
jtkorhonen@0 2389 settings.setValue("firststart", firstStart);
Chris@98 2390 //!!!settings.setValue("viewFileTypes", hgTabs -> getFileTypesBits());
jtkorhonen@0 2391 }
jtkorhonen@0 2392
jtkorhonen@0 2393
jtkorhonen@0 2394
jtkorhonen@0 2395