annotate mainwindow.cpp @ 173:a6d336837ebe

* Add (examining repository) message for initial state * Reduce panner glitches when dragging * Clear merge commit comment after use
author Chris Cannam
date Thu, 16 Dec 2010 12:03:09 +0000
parents b6dd1ee0e486
children 4dc802a4d5ae
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@57 8 Copyright (c) 2010 Chris Cannam
Chris@57 9 Copyright (c) 2010 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>
jtkorhonen@0 33
Chris@53 34 #include "mainwindow.h"
Chris@69 35 #include "multichoicedialog.h"
Chris@64 36 #include "startupdialog.h"
Chris@53 37 #include "colourset.h"
Chris@62 38 #include "debug.h"
Chris@74 39 #include "logparser.h"
Chris@103 40 #include "confirmcommentdialog.h"
Chris@125 41 #include "incomingdialog.h"
Chris@53 42
jtkorhonen@0 43
Chris@172 44 MainWindow::MainWindow(QString myDirPath) :
Chris@172 45 m_myDirPath(myDirPath)
jtkorhonen@0 46 {
jtkorhonen@0 47 QString wndTitle;
jtkorhonen@0 48
Chris@90 49 fsWatcher = 0;
Chris@133 50 commitsSincePush = 0;
Chris@163 51 shouldHgStat = true;
Chris@90 52
jtkorhonen@0 53 createActions();
jtkorhonen@0 54 createMenus();
jtkorhonen@0 55 createToolBars();
jtkorhonen@0 56 createStatusBar();
jtkorhonen@0 57
Chris@172 58 runner = new HgRunner(myDirPath, this);
Chris@109 59 connect(runner, SIGNAL(commandCompleted(HgAction, QString)),
Chris@109 60 this, SLOT(commandCompleted(HgAction, QString)));
Chris@109 61 connect(runner, SIGNAL(commandFailed(HgAction, QString)),
Chris@109 62 this, SLOT(commandFailed(HgAction, QString)));
jtkorhonen@0 63 statusBar()->addPermanentWidget(runner);
jtkorhonen@0 64
Chris@61 65 setWindowTitle(tr("EasyMercurial"));
jtkorhonen@0 66
jtkorhonen@0 67 remoteRepoPath = "";
jtkorhonen@0 68 workFolderPath = "";
jtkorhonen@0 69
jtkorhonen@0 70 readSettings();
jtkorhonen@0 71
jtkorhonen@33 72 justMerged = false;
Chris@98 73 hgTabs = new HgTabWidget((QWidget *) this, remoteRepoPath, workFolderPath);
Chris@141 74 connectTabsSignals();
Chris@98 75 setCentralWidget(hgTabs);
jtkorhonen@0 76
Chris@98 77 connect(hgTabs, SIGNAL(selectionChanged()),
Chris@95 78 this, SLOT(enableDisableActions()));
Chris@95 79
jtkorhonen@0 80 setUnifiedTitleAndToolBarOnMac(true);
jtkorhonen@0 81 connectActions();
Chris@120 82 clearState();
jtkorhonen@0 83 enableDisableActions();
jtkorhonen@0 84
Chris@64 85 if (firstStart) {
Chris@64 86 startupDialog();
jtkorhonen@0 87 }
jtkorhonen@0 88
Chris@112 89 findDiffBinaryName();
Chris@163 90 findMergeBinaryName();
Chris@112 91
Chris@64 92 ColourSet *cs = ColourSet::instance();
Chris@64 93 cs->clearDefaultNames();
Chris@64 94 cs->addDefaultName("");
Chris@153 95 cs->addDefaultName("default");
Chris@64 96 cs->addDefaultName(getUserInfo());
Chris@62 97
Chris@72 98 if (workFolderPath == "") {
Chris@72 99 open();
Chris@72 100 }
Chris@72 101
Chris@109 102 hgQueryPaths();
jtkorhonen@0 103 }
jtkorhonen@0 104
jtkorhonen@0 105
jtkorhonen@0 106 void MainWindow::closeEvent(QCloseEvent *)
jtkorhonen@0 107 {
jtkorhonen@0 108 writeSettings();
Chris@90 109 delete fsWatcher;
jtkorhonen@0 110 }
jtkorhonen@0 111
jtkorhonen@0 112
Chris@64 113 QString MainWindow::getUserInfo() const
Chris@64 114 {
Chris@64 115 QSettings settings;
Chris@64 116 settings.beginGroup("User Information");
Chris@64 117 QString name = settings.value("name", getUserRealName()).toString();
Chris@64 118 QString email = settings.value("email", "").toString();
Chris@64 119
Chris@64 120 QString identifier;
Chris@64 121
Chris@64 122 if (email != "") {
Chris@64 123 identifier = QString("%1 <%2>").arg(name).arg(email);
Chris@64 124 } else {
Chris@64 125 identifier = name;
Chris@64 126 }
Chris@64 127
Chris@64 128 return identifier;
Chris@64 129 }
Chris@64 130
jtkorhonen@0 131 void MainWindow::about()
jtkorhonen@0 132 {
Chris@97 133 QMessageBox::about(this, tr("About EasyMercurial"),
Chris@97 134 tr("<qt><h2>About EasyMercurial</h2>"
Chris@97 135 "<p>EasyMercurial is a simple user interface for the "
Chris@97 136 "Mercurial version control system.</p>"
Chris@98 137 "<p>EasyMercurial is based on hgExplorer by "
Chris@97 138 "Jari Korhonen, with thanks.<br>EasyMercurial development carried out by "
Chris@97 139 "Chris Cannam for soundsoftware.ac.uk at the Centre for Digital Music, Queen Mary, University of London."
Chris@97 140 "<ul><li>Copyright &copy; 2010 Jari Korhonen</li>"
Chris@97 141 "<li>Copyright &copy; 2010 Chris Cannam</li>"
Chris@97 142 "<li>Copyright &copy; 2010 Queen Mary, University of London</li>"
Chris@97 143 "</ul>"
Chris@97 144 "<p> This program is free software; you can redistribute it and/or "
Chris@97 145 "modify it under the terms of the GNU General Public License as "
Chris@97 146 "published by the Free Software Foundation; either version 2 of the "
Chris@97 147 "License, or (at your option) any later version. See the file "
Chris@97 148 "COPYING included with this distribution for more information."));
jtkorhonen@0 149 }
jtkorhonen@0 150
Chris@94 151 void MainWindow::clearSelections()
Chris@94 152 {
Chris@98 153 hgTabs->clearSelections();
Chris@94 154 }
jtkorhonen@0 155
Chris@120 156 void MainWindow::hgRefresh()
Chris@120 157 {
Chris@120 158 clearState();
Chris@120 159 hgQueryPaths();
Chris@120 160 }
Chris@120 161
jtkorhonen@0 162 void MainWindow::hgStat()
jtkorhonen@0 163 {
Chris@109 164 QStringList params;
Chris@109 165 params << "stat" << "-ardum";
Chris@153 166
Chris@163 167 lastStatOutput = "";
Chris@163 168
Chris@153 169 // annoyingly, hg stat actually modifies the working directory --
Chris@153 170 // it creates files called hg-checklink and hg-checkexec to test
Chris@153 171 // properties of the filesystem
Chris@153 172 if (fsWatcher) fsWatcher->blockSignals(true);
Chris@153 173
Chris@109 174 runner->requestAction(HgAction(ACT_STAT, workFolderPath, params));
jtkorhonen@0 175 }
jtkorhonen@0 176
Chris@109 177 void MainWindow::hgQueryPaths()
Chris@74 178 {
Chris@109 179 QStringList params;
Chris@109 180 params << "paths";
Chris@109 181 runner->requestAction(HgAction(ACT_QUERY_PATHS, workFolderPath, params));
Chris@74 182 }
Chris@74 183
Chris@109 184 void MainWindow::hgQueryBranch()
Chris@106 185 {
Chris@109 186 QStringList params;
Chris@109 187 params << "branch";
Chris@109 188 runner->requestAction(HgAction(ACT_QUERY_BRANCH, workFolderPath, params));
Chris@106 189 }
Chris@106 190
Chris@109 191 void MainWindow::hgQueryHeads()
jtkorhonen@0 192 {
Chris@109 193 QStringList params;
Chris@137 194 // On empty repos, "hg heads" will fail -- we don't care about
Chris@137 195 // that. Use --closed option so as to include closed branches;
Chris@137 196 // otherwise we'll be stuck if the user updates into one, and our
Chris@137 197 // incremental log will end up with spurious stuff in it because
Chris@137 198 // we won't be pruning at the ends of closed branches
Chris@137 199 params << "heads" << "--closed";
Chris@109 200 runner->requestAction(HgAction(ACT_QUERY_HEADS, workFolderPath, params));
jtkorhonen@0 201 }
jtkorhonen@0 202
jtkorhonen@0 203 void MainWindow::hgLog()
jtkorhonen@0 204 {
Chris@109 205 QStringList params;
Chris@109 206 params << "log";
Chris@109 207 params << "--template";
Chris@125 208 params << Changeset::getLogTemplate();
Chris@109 209
Chris@109 210 runner->requestAction(HgAction(ACT_LOG, workFolderPath, params));
Chris@109 211 }
Chris@109 212
Chris@150 213 void MainWindow::hgLogIncremental(QStringList prune)
Chris@120 214 {
Chris@120 215 QStringList params;
Chris@120 216 params << "log";
Chris@120 217
Chris@150 218 foreach (QString p, prune) {
Chris@153 219 params << "--prune" << Changeset::hashOf(p);
Chris@120 220 }
Chris@120 221
Chris@120 222 params << "--template";
Chris@125 223 params << Changeset::getLogTemplate();
Chris@120 224
Chris@120 225 runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, workFolderPath, params));
Chris@120 226 }
Chris@109 227
Chris@109 228 void MainWindow::hgQueryParents()
Chris@109 229 {
Chris@109 230 QStringList params;
Chris@109 231 params << "parents";
Chris@109 232 runner->requestAction(HgAction(ACT_QUERY_PARENTS, workFolderPath, params));
Chris@109 233 }
Chris@109 234
Chris@109 235 void MainWindow::hgAnnotate()
Chris@109 236 {
Chris@109 237 QStringList params;
Chris@109 238 QString currentFile;//!!! = hgTabs -> getCurrentFileListLine();
Chris@109 239
Chris@109 240 if (!currentFile.isEmpty())
jtkorhonen@0 241 {
Chris@109 242 params << "annotate" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
jtkorhonen@0 243
Chris@109 244 runner->requestAction(HgAction(ACT_ANNOTATE, workFolderPath, params));
jtkorhonen@0 245 }
jtkorhonen@0 246 }
jtkorhonen@0 247
Chris@109 248 void MainWindow::hgResolveList()
Chris@109 249 {
Chris@109 250 QStringList params;
jtkorhonen@0 251
Chris@109 252 params << "resolve" << "--list";
Chris@109 253 runner->requestAction(HgAction(ACT_RESOLVE_LIST, workFolderPath, params));
Chris@109 254 }
Chris@109 255
Chris@109 256 void MainWindow::hgAdd()
jtkorhonen@0 257 {
Chris@109 258 QStringList params;
jtkorhonen@0 259
Chris@109 260 // hgExplorer permitted adding "all" files -- I'm not sure
Chris@109 261 // that one is a good idea, let's require the user to select
jtkorhonen@0 262
Chris@109 263 QStringList files = hgTabs->getSelectedAddableFiles();
Chris@109 264
Chris@109 265 if (!files.empty()) {
Chris@109 266 params << "add" << "--" << files;
Chris@109 267 runner->requestAction(HgAction(ACT_ADD, workFolderPath, params));
jtkorhonen@0 268 }
jtkorhonen@0 269 }
jtkorhonen@0 270
jtkorhonen@0 271
Chris@98 272 void MainWindow::hgRemove()
Chris@98 273 {
Chris@109 274 QStringList params;
Chris@98 275
Chris@109 276 QStringList files = hgTabs->getSelectedRemovableFiles();
Chris@98 277
Chris@109 278 //!!! todo: confirmation dialog (with file list in it) (or do we
Chris@109 279 // need that? all it does is move the files to the removed
Chris@109 280 // list... doesn't it?)
Chris@98 281
Chris@109 282 if (!files.empty()) {
Chris@109 283 params << "remove" << "--after" << "--force" << "--" << files;
Chris@109 284 runner->requestAction(HgAction(ACT_REMOVE, workFolderPath, params));
Chris@109 285 }
jtkorhonen@0 286 }
jtkorhonen@0 287
jtkorhonen@0 288 void MainWindow::hgCommit()
jtkorhonen@0 289 {
Chris@109 290 QStringList params;
Chris@109 291 QString comment;
Chris@94 292
Chris@157 293 if (justMerged) {
Chris@157 294 comment = mergeCommitComment;
Chris@157 295 }
Chris@157 296
Chris@109 297 QStringList files = hgTabs->getSelectedCommittableFiles();
Chris@127 298 QStringList reportFiles = files;
Chris@127 299 if (reportFiles.empty()) reportFiles = hgTabs->getAllCommittableFiles();
Chris@103 300
Chris@155 301 QString cf(tr("Commit files"));
Chris@155 302
Chris@109 303 if (ConfirmCommentDialog::confirmAndGetLongComment
Chris@109 304 (this,
Chris@155 305 cf,
Chris@155 306 tr("<h3>%1</h3><p>%2").arg(cf)
Chris@155 307 .arg(tr("You are about to commit the following files:")),
Chris@155 308 tr("<h3>%1</h3><p>%2").arg(cf)
Chris@168 309 .arg(tr("You are about to commit %n file(s).", "", reportFiles.size())),
Chris@127 310 reportFiles,
Chris@109 311 comment)) {
Chris@103 312
Chris@157 313 if (!justMerged && !files.empty()) {
Chris@157 314 // User wants to commit selected file(s) (and this is not
Chris@157 315 // merge commit, which would fail if we selected files)
Chris@157 316 params << "commit" << "--message" << comment
Chris@157 317 << "--user" << getUserInfo() << "--" << files;
Chris@109 318 } else {
Chris@109 319 // Commit all changes
Chris@157 320 params << "commit" << "--message" << comment
Chris@157 321 << "--user" << getUserInfo();
jtkorhonen@0 322 }
Chris@109 323
Chris@109 324 runner->requestAction(HgAction(ACT_COMMIT, workFolderPath, params));
Chris@173 325 mergeCommitComment = "";
jtkorhonen@0 326 }
jtkorhonen@0 327 }
jtkorhonen@0 328
jtkorhonen@34 329 QString MainWindow::filterTag(QString tag)
jtkorhonen@34 330 {
jtkorhonen@34 331 for(int i = 0; i < tag.size(); i++)
jtkorhonen@34 332 {
jtkorhonen@34 333 if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
jtkorhonen@34 334 {
jtkorhonen@34 335 //ok
jtkorhonen@34 336 }
jtkorhonen@34 337 else
jtkorhonen@34 338 {
jtkorhonen@34 339 tag[i] = QChar('_');
jtkorhonen@34 340 }
jtkorhonen@34 341 }
jtkorhonen@34 342 return tag;
jtkorhonen@34 343 }
jtkorhonen@34 344
jtkorhonen@34 345
Chris@164 346 void MainWindow::hgTag(QString id)
jtkorhonen@34 347 {
Chris@109 348 QStringList params;
Chris@109 349 QString tag;
jtkorhonen@34 350
Chris@109 351 if (ConfirmCommentDialog::confirmAndGetShortComment
Chris@109 352 (this,
Chris@109 353 tr("Tag"),
Chris@109 354 tr("Enter tag:"),
Chris@109 355 tag)) {
Chris@164 356 if (!tag.isEmpty()) {//!!! do something better if it is empty
Chris@164 357
Chris@164 358 params << "tag" << "--user" << getUserInfo();
Chris@164 359 params << "--rev" << Changeset::hashOf(id) << filterTag(tag);
Chris@109 360
Chris@109 361 runner->requestAction(HgAction(ACT_TAG, workFolderPath, params));
jtkorhonen@34 362 }
jtkorhonen@34 363 }
jtkorhonen@34 364 }
jtkorhonen@34 365
jtkorhonen@34 366
jtkorhonen@34 367 void MainWindow::hgIgnore()
jtkorhonen@34 368 {
Chris@109 369 QString hgIgnorePath;
Chris@109 370 QStringList params;
Chris@109 371 QString editorName;
Chris@109 372
Chris@109 373 hgIgnorePath = workFolderPath;
Chris@109 374 hgIgnorePath += ".hgignore";
Chris@109 375
Chris@109 376 params << hgIgnorePath;
Chris@112 377
Chris@112 378 //!!!
Chris@112 379 #ifdef Q_OS_LINUX
Chris@112 380
Chris@109 381 editorName = "gedit";
Chris@112 382
Chris@112 383 #else
Chris@112 384
Chris@109 385 editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe""";
Chris@112 386
Chris@112 387 #endif
jtkorhonen@34 388
Chris@109 389 HgAction action(ACT_HG_IGNORE, workFolderPath, params);
Chris@109 390 action.executable = editorName;
jtkorhonen@34 391
Chris@109 392 runner->requestAction(action);
jtkorhonen@34 393 }
jtkorhonen@34 394
Chris@112 395 void MainWindow::findDiffBinaryName()
Chris@112 396 {
Chris@112 397 QSettings settings;
Chris@112 398 QString diff = settings.value("extdiffbinary", "").toString();
Chris@112 399 if (diff == "") {
Chris@112 400 QStringList bases;
Chris@112 401 bases << "opendiff" << "kompare" << "kdiff3" << "meld";
Chris@112 402 bool found = false;
Chris@112 403 foreach (QString base, bases) {
Chris@172 404 diff = findInPath(base, m_myDirPath, true);
Chris@112 405 if (diff != base) {
Chris@112 406 found = true;
Chris@112 407 break;
Chris@112 408 }
Chris@112 409 }
Chris@112 410 if (found) {
Chris@112 411 settings.setValue("extdiffbinary", diff);
Chris@112 412 } else {
Chris@112 413 diff = "";
Chris@112 414 }
Chris@112 415 }
Chris@112 416 diffBinaryName = diff;
Chris@112 417 }
jtkorhonen@34 418
Chris@163 419 void MainWindow::findMergeBinaryName()
Chris@163 420 {
Chris@163 421 QSettings settings;
Chris@163 422 QString merge = settings.value("mergebinary", "").toString();
Chris@163 423 if (merge == "") {
Chris@163 424 QStringList bases;
Chris@164 425 bases << "fmdiff3" << "meld" << "diffuse" << "kdiff3";
Chris@163 426 bool found = false;
Chris@163 427 foreach (QString base, bases) {
Chris@172 428 merge = findInPath(base, m_myDirPath, true);
Chris@163 429 if (merge != base) {
Chris@163 430 found = true;
Chris@163 431 break;
Chris@163 432 }
Chris@163 433 }
Chris@163 434 if (found) {
Chris@163 435 settings.setValue("mergebinary", merge);
Chris@163 436 } else {
Chris@163 437 merge = "";
Chris@163 438 }
Chris@163 439 }
Chris@163 440 mergeBinaryName = merge;
Chris@163 441 }
Chris@163 442
Chris@168 443 void MainWindow::hgShowSummary()
Chris@168 444 {
Chris@168 445 QStringList params;
Chris@168 446
Chris@168 447 params << "diff" << "--stat";
Chris@168 448
Chris@168 449 runner->requestAction(HgAction(ACT_DIFF_SUMMARY, workFolderPath, params));
Chris@168 450 }
Chris@168 451
jtkorhonen@0 452 void MainWindow::hgFolderDiff()
jtkorhonen@0 453 {
Chris@112 454 if (diffBinaryName == "") return;
Chris@112 455
Chris@109 456 QStringList params;
jtkorhonen@0 457
Chris@112 458 // Diff parent against working folder (folder diff)
Chris@112 459
Chris@148 460 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@148 461 params << "--program" << diffBinaryName;
Chris@109 462
Chris@153 463 params << hgTabs->getSelectedCommittableFiles(); // may be none: whole dir
Chris@153 464
Chris@109 465 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
jtkorhonen@0 466 }
jtkorhonen@0 467
jtkorhonen@0 468
Chris@148 469 void MainWindow::hgDiffToCurrent(QString id)
jtkorhonen@0 470 {
Chris@163 471 if (diffBinaryName == "") return;
Chris@163 472
Chris@148 473 QStringList params;
jtkorhonen@0 474
Chris@148 475 // Diff given revision against working folder
jtkorhonen@0 476
Chris@148 477 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@148 478 params << "--program" << diffBinaryName;
Chris@153 479 params << "--rev" << Changeset::hashOf(id);
Chris@148 480
Chris@148 481 runner->requestAction(HgAction(ACT_FOLDERDIFF, workFolderPath, params));
jtkorhonen@0 482 }
jtkorhonen@0 483
jtkorhonen@0 484
Chris@148 485 void MainWindow::hgDiffToParent(QString child, QString parent)
Chris@148 486 {
Chris@163 487 if (diffBinaryName == "") return;
Chris@163 488
Chris@148 489 QStringList params;
Chris@148 490
Chris@148 491 // Diff given revision against working folder
Chris@148 492
Chris@148 493 params << "--config" << "extensions.extdiff=" << "extdiff";
Chris@148 494 params << "--program" << diffBinaryName;
Chris@153 495 params << "--rev" << Changeset::hashOf(parent)
Chris@153 496 << "--rev" << Changeset::hashOf(child);
Chris@148 497
Chris@148 498 runner->requestAction(HgAction(ACT_CHGSETDIFF, workFolderPath, params));
Chris@148 499 }
Chris@148 500
jtkorhonen@0 501
jtkorhonen@0 502 void MainWindow::hgUpdate()
jtkorhonen@0 503 {
Chris@109 504 QStringList params;
jtkorhonen@0 505
Chris@109 506 params << "update";
Chris@109 507
Chris@109 508 runner->requestAction(HgAction(ACT_UPDATE, workFolderPath, params));
jtkorhonen@0 509 }
jtkorhonen@0 510
jtkorhonen@0 511
Chris@148 512 void MainWindow::hgUpdateToRev(QString id)
jtkorhonen@0 513 {
Chris@148 514 QStringList params;
jtkorhonen@0 515
Chris@153 516 params << "update" << "--rev" << Changeset::hashOf(id) << "--check";
jtkorhonen@0 517
Chris@148 518 runner->requestAction(HgAction(ACT_UPDATE, workFolderPath, params));
jtkorhonen@0 519 }
jtkorhonen@0 520
jtkorhonen@0 521
jtkorhonen@0 522 void MainWindow::hgRevert()
jtkorhonen@0 523 {
Chris@109 524 QStringList params;
Chris@109 525 QString comment;
Chris@98 526
Chris@109 527 QStringList files = hgTabs->getSelectedRevertableFiles();
Chris@109 528 if (files.empty()) files = hgTabs->getAllRevertableFiles();
Chris@155 529
Chris@155 530 QString rf(tr("Revert files"));
Chris@109 531
Chris@109 532 if (ConfirmCommentDialog::confirmDangerousFilesAction
Chris@109 533 (this,
Chris@155 534 rf,
Chris@155 535 tr("<h3>%1</h3><p>%2").arg(rf)
Chris@155 536 .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@155 537 tr("<h3>%1</h3><p>%2").arg(rf)
Chris@155 538 .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@109 539 files)) {
Chris@163 540
Chris@163 541 lastRevertedFiles = files;
Chris@109 542
Chris@98 543 if (files.empty()) {
Chris@98 544 params << "revert" << "--no-backup";
Chris@98 545 } else {
Chris@164 546 params << "revert" << "--" << files;
Chris@98 547 }
Chris@163 548
Chris@163 549 //!!! This is problematic. If you've got an uncommitted
Chris@163 550 //!!! merge, you can't revert it without declaring which
Chris@163 551 //!!! parent of the merge you want to revert to (reasonably
Chris@163 552 //!!! enough). We're OK if we just did the merge in easyhg a
Chris@163 553 //!!! moment ago, because we have a record of which parent was
Chris@163 554 //!!! the target -- but if you exit and restart, we've lost
Chris@163 555 //!!! that record and it doesn't appear to be possible to get
Chris@163 556 //!!! it back from Hg. Even if you just switched from one
Chris@163 557 //!!! repo to another, the record is lost. What to do?
Chris@163 558
Chris@163 559 if (justMerged && mergeTargetRevision != "") {
Chris@163 560 params << "--rev" << mergeTargetRevision;
Chris@163 561 }
Chris@109 562
Chris@109 563 runner->requestAction(HgAction(ACT_REVERT, workFolderPath, params));
jtkorhonen@0 564 }
jtkorhonen@0 565 }
jtkorhonen@0 566
Chris@163 567
Chris@163 568 void MainWindow::hgMarkResolved(QStringList files)
Chris@163 569 {
Chris@163 570 QStringList params;
Chris@163 571
Chris@163 572 params << "resolve" << "--mark";
Chris@163 573
Chris@163 574 if (files.empty()) {
Chris@163 575 params << "--all";
Chris@163 576 } else {
Chris@164 577 params << "--" << files;
Chris@163 578 }
Chris@163 579
Chris@163 580 runner->requestAction(HgAction(ACT_RESOLVE_MARK, workFolderPath, params));
Chris@163 581 }
Chris@163 582
Chris@163 583
jtkorhonen@33 584 void MainWindow::hgRetryMerge()
jtkorhonen@33 585 {
Chris@109 586 QStringList params;
jtkorhonen@33 587
Chris@163 588 params << "resolve";
Chris@163 589
Chris@163 590 if (mergeBinaryName != "") {
Chris@163 591 params << "--tool" << mergeBinaryName;
Chris@163 592 }
Chris@163 593
Chris@163 594 QStringList files = hgTabs->getSelectedUnresolvedFiles();
Chris@163 595 if (files.empty()) {
Chris@163 596 params << "--all";
Chris@163 597 } else {
Chris@164 598 params << "--" << files;
Chris@163 599 }
Chris@163 600
Chris@109 601 runner->requestAction(HgAction(ACT_RETRY_MERGE, workFolderPath, params));
Chris@163 602
Chris@163 603 mergeCommitComment = tr("Merge");
jtkorhonen@33 604 }
jtkorhonen@33 605
jtkorhonen@33 606
jtkorhonen@0 607 void MainWindow::hgMerge()
jtkorhonen@0 608 {
Chris@163 609 if (hgTabs->canResolve()) {
Chris@163 610 hgRetryMerge();
Chris@163 611 return;
Chris@163 612 }
Chris@163 613
Chris@109 614 QStringList params;
jtkorhonen@0 615
Chris@109 616 params << "merge";
Chris@163 617
Chris@163 618 if (mergeBinaryName != "") {
Chris@163 619 params << "--tool" << mergeBinaryName;
Chris@163 620 }
Chris@163 621
Chris@163 622 if (currentParents.size() == 1) {
Chris@163 623 mergeTargetRevision = currentParents[0]->id();
Chris@163 624 }
Chris@163 625
Chris@109 626 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
Chris@157 627
Chris@157 628 mergeCommitComment = tr("Merge");
jtkorhonen@0 629 }
jtkorhonen@0 630
jtkorhonen@0 631
Chris@148 632 void MainWindow::hgMergeFrom(QString id)
Chris@148 633 {
Chris@148 634 QStringList params;
Chris@148 635
Chris@148 636 params << "merge";
Chris@153 637 params << "--rev" << Changeset::hashOf(id);
Chris@163 638
Chris@163 639 if (mergeBinaryName != "") {
Chris@163 640 params << "--tool" << mergeBinaryName;
Chris@163 641 }
Chris@148 642
Chris@148 643 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
Chris@157 644
Chris@157 645 mergeCommitComment = "";
Chris@157 646
Chris@157 647 foreach (Changeset *cs, currentHeads) {
Chris@157 648 if (cs->id() == id && !cs->isOnBranch(currentBranch)) {
Chris@157 649 if (cs->branch() == "" || cs->branch() == "default") {
Chris@157 650 mergeCommitComment = tr("Merge from the default branch");
Chris@157 651 } else {
Chris@157 652 mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
Chris@157 653 }
Chris@157 654 }
Chris@157 655 }
Chris@157 656
Chris@157 657 if (mergeCommitComment == "") {
Chris@157 658 mergeCommitComment = tr("Merge from %1").arg(id);
Chris@157 659 }
Chris@148 660 }
Chris@148 661
Chris@148 662
jtkorhonen@0 663 void MainWindow::hgCloneFromRemote()
jtkorhonen@0 664 {
Chris@109 665 QStringList params;
jtkorhonen@0 666
Chris@109 667 if (!QDir(workFolderPath).exists()) {
Chris@109 668 if (!QDir().mkpath(workFolderPath)) {
Chris@109 669 DEBUG << "hgCloneFromRemote: Failed to create target path "
Chris@109 670 << workFolderPath << endl;
Chris@109 671 //!!! report error
Chris@109 672 return;
Chris@104 673 }
Chris@109 674 }
Chris@104 675
Chris@109 676 params << "clone" << remoteRepoPath << workFolderPath;
Chris@109 677
Chris@109 678 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
Chris@113 679 hgTabs->updateWorkFolderFileList("");
jtkorhonen@0 680
Chris@109 681 runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, workFolderPath, params));
jtkorhonen@0 682 }
jtkorhonen@0 683
jtkorhonen@0 684 void MainWindow::hgInit()
jtkorhonen@0 685 {
Chris@109 686 QStringList params;
jtkorhonen@0 687
Chris@109 688 params << "init";
Chris@109 689 params << workFolderPath;
jtkorhonen@0 690
Chris@109 691 runner->requestAction(HgAction(ACT_INIT, workFolderPath, params));
jtkorhonen@0 692 }
jtkorhonen@0 693
jtkorhonen@0 694 void MainWindow::hgIncoming()
jtkorhonen@0 695 {
Chris@109 696 QStringList params;
jtkorhonen@0 697
Chris@109 698 params << "incoming" << "--newest-first" << remoteRepoPath;
Chris@125 699 params << "--template" << Changeset::getLogTemplate();
jtkorhonen@0 700
Chris@109 701 runner->requestAction(HgAction(ACT_INCOMING, workFolderPath, params));
jtkorhonen@0 702 }
jtkorhonen@0 703
jtkorhonen@0 704 void MainWindow::hgPull()
jtkorhonen@0 705 {
Chris@126 706 if (QMessageBox::question
Chris@126 707 (this, tr("Confirm pull"),
Chris@126 708 format3(tr("Confirm pull from remote repository"),
Chris@126 709 tr("You are about to pull from the following remote repository:"),
Chris@126 710 remoteRepoPath),
Chris@126 711 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
jtkorhonen@0 712
Chris@126 713 QStringList params;
Chris@126 714 params << "pull" << remoteRepoPath;
Chris@126 715 runner->requestAction(HgAction(ACT_PULL, workFolderPath, params));
Chris@126 716 }
jtkorhonen@0 717 }
jtkorhonen@0 718
jtkorhonen@0 719 void MainWindow::hgPush()
jtkorhonen@0 720 {
Chris@126 721 if (QMessageBox::question
Chris@126 722 (this, tr("Confirm push"),
Chris@126 723 format3(tr("Confirm push to remote repository"),
Chris@126 724 tr("You are about to push to the following remote repository:"),
Chris@126 725 remoteRepoPath),
Chris@126 726 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
jtkorhonen@0 727
Chris@126 728 QStringList params;
Chris@154 729 params << "push" << "--new-branch" << remoteRepoPath;
Chris@126 730 runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params));
Chris@126 731 }
jtkorhonen@0 732 }
jtkorhonen@0 733
jtkorhonen@28 734 QString MainWindow::listAllUpIpV4Addresses()
jtkorhonen@26 735 {
jtkorhonen@28 736 QString ret;
jtkorhonen@26 737 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
jtkorhonen@26 738
jtkorhonen@26 739 for (int i = 0; i < ifaces.count(); i++)
jtkorhonen@26 740 {
jtkorhonen@26 741 QNetworkInterface iface = ifaces.at(i);
jtkorhonen@26 742
jtkorhonen@26 743 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack))
jtkorhonen@26 744 {
jtkorhonen@26 745 for (int j=0; j<iface.addressEntries().count(); j++)
jtkorhonen@26 746 {
jtkorhonen@28 747 QHostAddress tmp = iface.addressEntries().at(j).ip();
jtkorhonen@28 748 if (QAbstractSocket::IPv4Protocol == tmp.protocol())
jtkorhonen@24 749 {
jtkorhonen@28 750 if (!ret.isEmpty())
jtkorhonen@28 751 {
jtkorhonen@28 752 ret += " ";
jtkorhonen@28 753 }
jtkorhonen@28 754 ret += tmp.toString();
jtkorhonen@24 755 }
jtkorhonen@24 756 }
jtkorhonen@22 757 }
jtkorhonen@17 758 }
jtkorhonen@28 759 return ret;
jtkorhonen@28 760 }
jtkorhonen@17 761
Chris@120 762 void MainWindow::clearState()
Chris@120 763 {
Chris@120 764 foreach (Changeset *cs, currentParents) delete cs;
Chris@120 765 currentParents.clear();
Chris@120 766 foreach (Changeset *cs, currentHeads) delete cs;
Chris@120 767 currentHeads.clear();
Chris@120 768 currentBranch = "";
Chris@163 769 lastStatOutput = "";
Chris@163 770 lastRevertedFiles.clear();
Chris@163 771 mergeTargetRevision = "";
Chris@163 772 mergeCommitComment = "";
Chris@173 773 stateUnknown = true;
Chris@120 774 needNewLog = true;
Chris@120 775 }
jtkorhonen@17 776
jtkorhonen@11 777 void MainWindow::hgServe()
jtkorhonen@11 778 {
Chris@109 779 QStringList params;
Chris@109 780 QString msg;
jtkorhonen@11 781
Chris@109 782 QString addrs = listAllUpIpV4Addresses();
Chris@109 783 QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000";
Chris@109 784 params << "serve";
jtkorhonen@11 785
Chris@109 786 runner->requestAction(HgAction(ACT_SERVE, workFolderPath, params));
Chris@109 787
Chris@109 788 QMessageBox::information(this, "Serve", msg, QMessageBox::Close);
Chris@109 789 //!!! runner -> killCurrentCommand();
jtkorhonen@11 790 }
jtkorhonen@11 791
Chris@64 792 void MainWindow::startupDialog()
Chris@64 793 {
Chris@64 794 StartupDialog *dlg = new StartupDialog(this);
Chris@65 795 if (dlg->exec()) firstStart = false;
Chris@64 796 }
jtkorhonen@11 797
Chris@69 798 void MainWindow::open()
Chris@69 799 {
Chris@86 800 bool done = false;
Chris@69 801
Chris@86 802 while (!done) {
Chris@69 803
Chris@86 804 MultiChoiceDialog *d = new MultiChoiceDialog
Chris@86 805 (tr("Open Repository"),
Chris@86 806 tr("<qt><big>What would you like to open?</big></qt>"),
Chris@86 807 this);
Chris@69 808
Chris@86 809 d->addChoice("remote",
Chris@86 810 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
Chris@86 811 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
Chris@86 812 MultiChoiceDialog::UrlToDirectoryArg);
Chris@69 813
Chris@86 814 d->addChoice("local",
Chris@86 815 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
Chris@86 816 tr("Open an existing local Mercurial repository."),
Chris@86 817 MultiChoiceDialog::DirectoryArg);
Chris@69 818
Chris@86 819 d->addChoice("init",
Chris@86 820 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
Chris@86 821 tr("Open a local folder, by creating a Mercurial repository in it."),
Chris@86 822 MultiChoiceDialog::DirectoryArg);
Chris@79 823
Chris@86 824 d->setCurrentChoice("local");
Chris@86 825
Chris@86 826 if (d->exec() == QDialog::Accepted) {
Chris@86 827
Chris@86 828 QString choice = d->getCurrentChoice();
Chris@86 829 QString arg = d->getArgument().trimmed();
Chris@86 830
Chris@86 831 bool result = false;
Chris@86 832
Chris@86 833 if (choice == "local") {
Chris@86 834 result = openLocal(arg);
Chris@86 835 } else if (choice == "remote") {
Chris@86 836 result = openRemote(arg, d->getAdditionalArgument().trimmed());
Chris@86 837 } else if (choice == "init") {
Chris@86 838 result = openInit(arg);
Chris@86 839 }
Chris@86 840
Chris@86 841 if (result) {
Chris@86 842 enableDisableActions();
Chris@120 843 clearState();
Chris@109 844 hgQueryPaths();
Chris@91 845 done = true;
Chris@91 846 }
Chris@86 847
Chris@86 848 } else {
Chris@86 849
Chris@86 850 // cancelled
Chris@86 851 done = true;
Chris@69 852 }
Chris@79 853
Chris@86 854 delete d;
Chris@69 855 }
Chris@69 856 }
Chris@69 857
Chris@145 858 void MainWindow::open(QString local)
Chris@145 859 {
Chris@145 860 if (openLocal(local)) {
Chris@145 861 enableDisableActions();
Chris@145 862 clearState();
Chris@145 863 hgQueryPaths();
Chris@145 864 }
Chris@145 865 }
Chris@145 866
Chris@79 867 bool MainWindow::complainAboutFilePath(QString arg)
Chris@79 868 {
Chris@79 869 QMessageBox::critical
Chris@79 870 (this, tr("File chosen"),
Chris@84 871 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 872 return false;
Chris@79 873 }
Chris@79 874
Chris@79 875 bool MainWindow::complainAboutUnknownFolder(QString arg)
Chris@79 876 {
Chris@79 877 QMessageBox::critical
Chris@79 878 (this, tr("Folder does not exist"),
Chris@84 879 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 880 return false;
Chris@84 881 }
Chris@84 882
Chris@84 883 bool MainWindow::complainAboutInitInRepo(QString arg)
Chris@84 884 {
Chris@84 885 QMessageBox::critical
Chris@84 886 (this, tr("Path is in existing repository"),
Chris@84 887 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 888 return false;
Chris@84 889 }
Chris@84 890
Chris@84 891 bool MainWindow::complainAboutInitFile(QString arg)
Chris@84 892 {
Chris@84 893 QMessageBox::critical
Chris@84 894 (this, tr("Path is a file"),
Chris@84 895 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 896 return false;
Chris@84 897 }
Chris@84 898
Chris@84 899 bool MainWindow::complainAboutCloneToExisting(QString arg)
Chris@84 900 {
Chris@84 901 QMessageBox::critical
Chris@84 902 (this, tr("Path is in existing repository"),
Chris@84 903 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 new folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@84 904 return false;
Chris@84 905 }
Chris@84 906
Chris@84 907 bool MainWindow::complainAboutCloneToFile(QString arg)
Chris@84 908 {
Chris@84 909 QMessageBox::critical
Chris@84 910 (this, tr("Path is a file"),
Chris@84 911 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 912 return false;
Chris@84 913 }
Chris@84 914
Chris@84 915 bool MainWindow::complainAboutCloneToExistingFolder(QString arg)
Chris@84 916 {
Chris@84 917 QMessageBox::critical
Chris@84 918 (this, tr("Folder exists"),
Chris@84 919 tr("<qt><b>Local folder already exists</b><br><br>You asked to open a remote repository by cloning it to the local path \"%1\".<br>This is the path of an existing folder.<br>Please provide a new folder name for the local repository.</qt>").arg(xmlEncode(arg)));
Chris@79 920 return false;
Chris@79 921 }
Chris@79 922
Chris@79 923 bool MainWindow::askToOpenParentRepo(QString arg, QString parent)
Chris@79 924 {
Chris@79 925 return (QMessageBox::question
Chris@84 926 (this, tr("Path is inside a repository"),
Chris@86 927 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 928 .arg(xmlEncode(arg)).arg(xmlEncode(parent)),
Chris@79 929 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 930 QMessageBox::Ok)
Chris@79 931 == QMessageBox::Ok);
Chris@79 932 }
Chris@79 933
Chris@79 934 bool MainWindow::askToInitExisting(QString arg)
Chris@79 935 {
Chris@79 936 return (QMessageBox::question
Chris@84 937 (this, tr("Folder has no repository"),
Chris@84 938 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 939 .arg(xmlEncode(arg)),
Chris@79 940 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 941 QMessageBox::Ok)
Chris@79 942 == QMessageBox::Ok);
Chris@79 943 }
Chris@79 944
Chris@79 945 bool MainWindow::askToInitNew(QString arg)
Chris@79 946 {
Chris@79 947 return (QMessageBox::question
Chris@84 948 (this, tr("Folder does not exist"),
Chris@84 949 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 950 .arg(xmlEncode(arg)),
Chris@84 951 QMessageBox::Ok | QMessageBox::Cancel,
Chris@84 952 QMessageBox::Ok)
Chris@84 953 == QMessageBox::Ok);
Chris@84 954 }
Chris@84 955
Chris@84 956 bool MainWindow::askToOpenInsteadOfInit(QString arg)
Chris@84 957 {
Chris@84 958 return (QMessageBox::question
Chris@84 959 (this, tr("Repository exists"),
Chris@84 960 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 961 .arg(xmlEncode(arg)),
Chris@79 962 QMessageBox::Ok | QMessageBox::Cancel,
Chris@79 963 QMessageBox::Ok)
Chris@79 964 == QMessageBox::Ok);
Chris@79 965 }
Chris@79 966
Chris@79 967 bool MainWindow::openLocal(QString local)
Chris@79 968 {
Chris@79 969 DEBUG << "open " << local << endl;
Chris@79 970
Chris@79 971 FolderStatus status = getFolderStatus(local);
Chris@79 972 QString containing = getContainingRepoFolder(local);
Chris@79 973
Chris@79 974 switch (status) {
Chris@79 975
Chris@79 976 case FolderHasRepo:
Chris@79 977 // fine
Chris@79 978 break;
Chris@79 979
Chris@79 980 case FolderExists:
Chris@79 981 if (containing != "") {
Chris@79 982 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 983 local = containing;
Chris@79 984 } else {
Chris@86 985 //!!! No -- this is likely to happen far more by accident
Chris@86 986 // than because the user actually wanted to init something.
Chris@86 987 // Don't ask, just politely reject.
Chris@79 988 if (!askToInitExisting(local)) return false;
Chris@79 989 return openInit(local);
Chris@79 990 }
Chris@79 991 break;
Chris@79 992
Chris@79 993 case FolderParentExists:
Chris@79 994 if (containing != "") {
Chris@79 995 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 996 local = containing;
Chris@79 997 } else {
Chris@79 998 if (!askToInitNew(local)) return false;
Chris@79 999 return openInit(local);
Chris@79 1000 }
Chris@79 1001 break;
Chris@79 1002
Chris@79 1003 case FolderUnknown:
Chris@84 1004 if (containing != "") {
Chris@84 1005 if (!askToOpenParentRepo(local, containing)) return false;
Chris@84 1006 local = containing;
Chris@84 1007 } else {
Chris@84 1008 return complainAboutUnknownFolder(local);
Chris@84 1009 }
Chris@84 1010 break;
Chris@79 1011
Chris@79 1012 case FolderIsFile:
Chris@79 1013 return complainAboutFilePath(local);
Chris@79 1014 }
Chris@79 1015
Chris@79 1016 workFolderPath = local;
Chris@79 1017 remoteRepoPath = "";
Chris@79 1018 return true;
Chris@79 1019 }
Chris@79 1020
Chris@79 1021 bool MainWindow::openRemote(QString remote, QString local)
Chris@79 1022 {
Chris@79 1023 DEBUG << "clone " << remote << " to " << local << endl;
Chris@84 1024
Chris@84 1025 FolderStatus status = getFolderStatus(local);
Chris@84 1026 QString containing = getContainingRepoFolder(local);
Chris@84 1027
Chris@84 1028 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 1029
Chris@84 1030 if (status == FolderHasRepo || containing != "") {
Chris@84 1031 return complainAboutCloneToExisting(local);
Chris@84 1032 }
Chris@84 1033
Chris@84 1034 if (status == FolderIsFile) {
Chris@84 1035 return complainAboutCloneToFile(local);
Chris@84 1036 }
Chris@84 1037
Chris@84 1038 if (status == FolderUnknown) {
Chris@84 1039 return complainAboutUnknownFolder(local);
Chris@84 1040 }
Chris@84 1041
Chris@84 1042 if (status == FolderExists) {
Chris@84 1043 //!!! we can do better than this surely?
Chris@84 1044 return complainAboutCloneToExistingFolder(local);
Chris@84 1045 }
Chris@84 1046
Chris@84 1047 workFolderPath = local;
Chris@84 1048 remoteRepoPath = remote;
Chris@84 1049 hgCloneFromRemote();
Chris@84 1050
Chris@79 1051 return true;
Chris@79 1052 }
Chris@79 1053
Chris@84 1054 bool MainWindow::openInit(QString local)
Chris@79 1055 {
Chris@84 1056 DEBUG << "openInit " << local << endl;
Chris@84 1057
Chris@84 1058 FolderStatus status = getFolderStatus(local);
Chris@84 1059 QString containing = getContainingRepoFolder(local);
Chris@84 1060
Chris@84 1061 DEBUG << "status = " << status << ", containing = " << containing << endl;
Chris@84 1062
Chris@84 1063 if (status == FolderHasRepo) {
Chris@84 1064 if (!askToOpenInsteadOfInit(local)) return false;
Chris@84 1065 }
Chris@84 1066
Chris@84 1067 if (containing != "") {
Chris@84 1068 return complainAboutInitInRepo(local);
Chris@84 1069 }
Chris@84 1070
Chris@84 1071 if (status == FolderIsFile) {
Chris@84 1072 return complainAboutInitFile(local);
Chris@84 1073 }
Chris@84 1074
Chris@84 1075 if (status == FolderUnknown) {
Chris@84 1076 return complainAboutUnknownFolder(local);
Chris@84 1077 }
Chris@84 1078
Chris@84 1079 workFolderPath = local;
Chris@84 1080 remoteRepoPath = "";
Chris@84 1081 hgInit();
Chris@79 1082 return true;
Chris@79 1083 }
Chris@79 1084
jtkorhonen@0 1085 void MainWindow::settings()
jtkorhonen@0 1086 {
Chris@69 1087 /*!!!
jtkorhonen@0 1088 SettingsDialog *settingsDlg = new SettingsDialog(this);
jtkorhonen@0 1089 settingsDlg->setModal(true);
jtkorhonen@0 1090 settingsDlg->exec();
Chris@98 1091 hgTabs -> clearLists();
jtkorhonen@0 1092 enableDisableActions();
jtkorhonen@0 1093 hgStat();
Chris@69 1094 */
jtkorhonen@0 1095 }
jtkorhonen@0 1096
jtkorhonen@2 1097 #define STDOUT_NEEDS_BIG_WINDOW 512
jtkorhonen@2 1098 #define SMALL_WND_W 500
jtkorhonen@2 1099 #define SMALL_WND_H 300
jtkorhonen@2 1100
jtkorhonen@2 1101 #define BIG_WND_W 1024
jtkorhonen@2 1102 #define BIG_WND_H 768
jtkorhonen@2 1103
jtkorhonen@2 1104
jtkorhonen@2 1105 void MainWindow::presentLongStdoutToUser(QString stdo)
jtkorhonen@0 1106 {
jtkorhonen@2 1107 if (!stdo.isEmpty())
jtkorhonen@2 1108 {
jtkorhonen@2 1109 QDialog dlg;
jtkorhonen@0 1110
jtkorhonen@2 1111 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
jtkorhonen@2 1112 {
jtkorhonen@2 1113 dlg.setMinimumWidth(BIG_WND_W);
jtkorhonen@2 1114 dlg.setMinimumHeight(BIG_WND_H);
jtkorhonen@2 1115 }
jtkorhonen@2 1116 else
jtkorhonen@2 1117 {
jtkorhonen@2 1118 dlg.setMinimumWidth(SMALL_WND_W);
jtkorhonen@2 1119 dlg.setMinimumHeight(SMALL_WND_H);
jtkorhonen@2 1120 }
jtkorhonen@0 1121
jtkorhonen@2 1122 QVBoxLayout *box = new QVBoxLayout;
jtkorhonen@2 1123 QListWidget *list = new QListWidget;
jtkorhonen@2 1124 list-> addItems(stdo.split("\n"));
jtkorhonen@2 1125 QPushButton *btn = new QPushButton(tr("Ok"));
jtkorhonen@2 1126 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
jtkorhonen@0 1127
jtkorhonen@2 1128 box -> addWidget(list);
jtkorhonen@2 1129 box -> addWidget(btn);
jtkorhonen@2 1130 dlg.setLayout(box);
jtkorhonen@2 1131
jtkorhonen@2 1132 dlg.exec();
jtkorhonen@2 1133 }
jtkorhonen@2 1134 else
jtkorhonen@2 1135 {
Chris@98 1136 QMessageBox::information(this, tr("EasyMercurial"), tr("Mercurial command did not return any output."));
jtkorhonen@2 1137 }
jtkorhonen@0 1138 }
jtkorhonen@0 1139
Chris@90 1140 void MainWindow::updateFileSystemWatcher()
Chris@90 1141 {
Chris@90 1142 delete fsWatcher;
Chris@90 1143 fsWatcher = new QFileSystemWatcher();
Chris@90 1144 std::deque<QString> pending;
Chris@90 1145 pending.push_back(workFolderPath);
Chris@90 1146 while (!pending.empty()) {
Chris@90 1147 QString path = pending.front();
Chris@90 1148 pending.pop_front();
Chris@90 1149 fsWatcher->addPath(path);
Chris@90 1150 DEBUG << "Added to file system watcher: " << path << endl;
Chris@90 1151 QDir d(path);
Chris@90 1152 if (d.exists()) {
Chris@115 1153 d.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable);
Chris@90 1154 foreach (QString entry, d.entryList()) {
Chris@90 1155 if (entry == ".hg") continue;
Chris@90 1156 QString entryPath = d.absoluteFilePath(entry);
Chris@90 1157 pending.push_back(entryPath);
Chris@90 1158 }
Chris@90 1159 }
Chris@90 1160 }
Chris@90 1161 connect(fsWatcher, SIGNAL(directoryChanged(QString)),
Chris@90 1162 this, SLOT(fsDirectoryChanged(QString)));
Chris@90 1163 connect(fsWatcher, SIGNAL(fileChanged(QString)),
Chris@90 1164 this, SLOT(fsFileChanged(QString)));
Chris@90 1165 }
Chris@90 1166
Chris@122 1167 void MainWindow::fsDirectoryChanged(QString d)
Chris@90 1168 {
Chris@122 1169 DEBUG << "MainWindow::fsDirectoryChanged " << d << endl;
Chris@90 1170 hgStat();
Chris@90 1171 }
Chris@90 1172
Chris@122 1173 void MainWindow::fsFileChanged(QString f)
Chris@90 1174 {
Chris@122 1175 DEBUG << "MainWindow::fsFileChanged " << f << endl;
Chris@90 1176 hgStat();
Chris@90 1177 }
Chris@90 1178
Chris@125 1179 QString MainWindow::format3(QString head, QString intro, QString code)
Chris@125 1180 {
Chris@168 1181 code = xmlEncode(code).replace("\n", "<br>").replace(" ", "&nbsp;");
Chris@125 1182 if (intro == "") {
Chris@168 1183 return QString("<qt><h3>%1</h3><p><code>%2</code></p>")
Chris@168 1184 .arg(head).arg(code);
Chris@126 1185 } else if (code == "") {
Chris@126 1186 return QString("<qt><h3>%1</h3><p>%2</p>")
Chris@126 1187 .arg(head).arg(intro);
Chris@125 1188 } else {
Chris@168 1189 return QString("<qt><h3>%1</h3><p>%2</p><p><code>%3</code></p>")
Chris@168 1190 .arg(head).arg(intro).arg(code);
Chris@125 1191 }
Chris@125 1192 }
Chris@125 1193
Chris@120 1194 void MainWindow::showIncoming(QString output)
Chris@120 1195 {
Chris@120 1196 runner->hide();
Chris@125 1197 IncomingDialog *d = new IncomingDialog(this, output);
Chris@125 1198 d->exec();
Chris@125 1199 delete d;
Chris@125 1200 }
Chris@125 1201
Chris@125 1202 int MainWindow::extractChangeCount(QString text)
Chris@125 1203 {
Chris@125 1204 QRegExp re("added (\\d+) ch\\w+ with (\\d+) ch\\w+ to (\\d+) f\\w+");
Chris@125 1205 if (re.indexIn(text) >= 0) {
Chris@125 1206 return re.cap(1).toInt();
Chris@125 1207 } else if (text.contains("no changes")) {
Chris@125 1208 return 0;
Chris@125 1209 } else {
Chris@125 1210 return -1; // unknown
Chris@125 1211 }
Chris@120 1212 }
Chris@120 1213
Chris@120 1214 void MainWindow::showPushResult(QString output)
Chris@120 1215 {
Chris@125 1216 QString report;
Chris@125 1217 int n = extractChangeCount(output);
Chris@125 1218 if (n > 0) {
Chris@125 1219 report = tr("Pushed %n changeset(s)", "", n);
Chris@125 1220 } else if (n == 0) {
Chris@125 1221 report = tr("No changes to push");
Chris@125 1222 } else {
Chris@125 1223 report = tr("Push complete");
Chris@125 1224 }
Chris@125 1225 report = format3(report, tr("The push command output was:"), output);
Chris@120 1226 runner->hide();
Chris@125 1227 QMessageBox::information(this, "Push complete", report);
Chris@120 1228 }
Chris@120 1229
Chris@120 1230 void MainWindow::showPullResult(QString output)
Chris@120 1231 {
Chris@125 1232 QString report;
Chris@125 1233 int n = extractChangeCount(output);
Chris@125 1234 if (n > 0) {
Chris@125 1235 report = tr("Pulled %n changeset(s)", "", n);
Chris@125 1236 } else if (n == 0) {
Chris@125 1237 report = tr("No changes to pull");
Chris@125 1238 } else {
Chris@125 1239 report = tr("Pull complete");
Chris@125 1240 }
Chris@125 1241 report = format3(report, tr("The pull command output was:"), output);
Chris@120 1242 runner->hide();
Chris@125 1243
Chris@125 1244 //!!! and something about updating
Chris@125 1245
Chris@125 1246 QMessageBox::information(this, "Pull complete", report);
Chris@120 1247 }
Chris@120 1248
Chris@143 1249 void MainWindow::commandFailed(HgAction action, QString output)
Chris@62 1250 {
Chris@62 1251 DEBUG << "MainWindow::commandFailed" << endl;
Chris@74 1252
Chris@113 1253 // Some commands we just have to ignore bad return values from:
Chris@113 1254
Chris@113 1255 switch(action.action) {
Chris@113 1256 case ACT_NONE:
Chris@113 1257 // uh huh
Chris@113 1258 return;
Chris@113 1259 case ACT_INCOMING:
Chris@113 1260 // returns non-zero code if the check was successful but there
Chris@113 1261 // are no changes pending
Chris@143 1262 if (output.trimmed() == "") showIncoming("");
Chris@113 1263 return;
Chris@162 1264 case ACT_QUERY_HEADS:
Chris@162 1265 // fails if repo is empty; we don't care (if there's a genuine
Chris@162 1266 // problem, something else will fail too). Need to do this,
Chris@162 1267 // otherwise empty repo state will not be reflected properly
Chris@162 1268 // (since heads/log procedure never completes for empty repo)
Chris@162 1269 enableDisableActions();
Chris@162 1270 return;
Chris@113 1271 case ACT_FOLDERDIFF:
Chris@113 1272 case ACT_CHGSETDIFF:
Chris@113 1273 // external program, unlikely to be anything useful in stderr
Chris@113 1274 // and some return with failure codes when something as basic
Chris@113 1275 // as the user closing the window via the wm happens
Chris@113 1276 return;
Chris@113 1277
Chris@113 1278 default:
Chris@114 1279 break;
Chris@113 1280 }
Chris@113 1281
Chris@113 1282 QString command = action.executable;
Chris@113 1283 if (command == "") command = "hg";
Chris@113 1284 foreach (QString arg, action.params) {
Chris@113 1285 command += " " + arg;
Chris@113 1286 }
Chris@113 1287
Chris@113 1288 QString message = tr("<qt><h3>Command failed</h3>"
Chris@113 1289 "<p>The following command failed:</p>"
Chris@113 1290 "<code>%1</code>"
Chris@113 1291 "%2</qt>")
Chris@113 1292 .arg(command)
Chris@143 1293 .arg((output.trimmed() != "") ?
Chris@113 1294 tr("<p>Its output said:</p><code>%1</code>")
Chris@143 1295 .arg(xmlEncode(output.left(800))
Chris@113 1296 .replace("\n", "<br>"))
Chris@113 1297 : "");
Chris@113 1298
Chris@113 1299 QMessageBox::warning(this, tr("Command failed"), message);
Chris@62 1300 }
Chris@62 1301
Chris@109 1302 void MainWindow::commandCompleted(HgAction completedAction, QString output)
jtkorhonen@0 1303 {
Chris@109 1304 HGACTIONS action = completedAction.action;
Chris@109 1305
Chris@109 1306 if (action == ACT_NONE) return;
Chris@109 1307
Chris@150 1308 bool headsChanged = false;
Chris@150 1309 QStringList oldHeadIds;
Chris@150 1310
Chris@150 1311 switch (action) {
Chris@109 1312
Chris@109 1313 case ACT_QUERY_PATHS:
jtkorhonen@0 1314 {
Chris@109 1315 DEBUG << "stdout is " << output << endl;
Chris@109 1316 LogParser lp(output, "=");
Chris@109 1317 LogList ll = lp.parse();
Chris@109 1318 DEBUG << ll.size() << " results" << endl;
Chris@109 1319 if (!ll.empty()) {
Chris@109 1320 remoteRepoPath = lp.parse()[0]["default"].trimmed();
Chris@109 1321 DEBUG << "Set remote path to " << remoteRepoPath << endl;
Chris@109 1322 }
Chris@109 1323 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1324 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@109 1325 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
Chris@109 1326 break;
Chris@109 1327 }
jtkorhonen@0 1328
Chris@109 1329 case ACT_QUERY_BRANCH:
Chris@109 1330 currentBranch = output.trimmed();
Chris@109 1331 break;
jtkorhonen@0 1332
Chris@109 1333 case ACT_STAT:
Chris@153 1334 if (fsWatcher) fsWatcher->blockSignals(false);
Chris@163 1335 lastStatOutput = output;
Chris@109 1336 updateFileSystemWatcher();
Chris@109 1337 break;
Chris@163 1338
Chris@163 1339 case ACT_RESOLVE_LIST:
Chris@163 1340 if (output != "") {
Chris@163 1341 // Remove lines beginning with R (they are resolved,
Chris@163 1342 // and the file stat parser treats R as removed)
Chris@163 1343 QStringList outList = output.split('\n');
Chris@163 1344 QStringList winnowed;
Chris@163 1345 foreach (QString line, outList) {
Chris@163 1346 if (!line.startsWith("R ")) winnowed.push_back(line);
Chris@163 1347 }
Chris@163 1348 output = winnowed.join("\n");
Chris@163 1349 }
Chris@163 1350 DEBUG << "lastStatOutput = " << lastStatOutput << endl;
Chris@163 1351 DEBUG << "output = " << output << endl;
Chris@163 1352 hgTabs->updateWorkFolderFileList(lastStatOutput + output);
Chris@163 1353 break;
Chris@163 1354
Chris@163 1355 case ACT_RESOLVE_MARK:
Chris@163 1356 shouldHgStat = true;
Chris@163 1357 break;
Chris@109 1358
Chris@109 1359 case ACT_INCOMING:
Chris@120 1360 showIncoming(output);
Chris@120 1361 break;
Chris@120 1362
Chris@109 1363 case ACT_ANNOTATE:
Chris@109 1364 presentLongStdoutToUser(output);
Chris@109 1365 shouldHgStat = true;
Chris@109 1366 break;
Chris@109 1367
Chris@109 1368 case ACT_PULL:
Chris@120 1369 showPullResult(output);
Chris@109 1370 shouldHgStat = true;
Chris@109 1371 break;
Chris@109 1372
Chris@109 1373 case ACT_PUSH:
Chris@120 1374 showPushResult(output);
Chris@109 1375 break;
Chris@109 1376
Chris@109 1377 case ACT_INIT:
Chris@109 1378 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
Chris@109 1379 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1380 enableDisableActions();
Chris@109 1381 shouldHgStat = true;
Chris@109 1382 break;
Chris@109 1383
Chris@109 1384 case ACT_CLONEFROMREMOTE:
Chris@109 1385 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
Chris@109 1386 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
Chris@109 1387 MultiChoiceDialog::addRecentArgument("remote", workFolderPath, true);
Chris@109 1388 QMessageBox::information(this, "Clone", output);
Chris@109 1389 enableDisableActions();
Chris@109 1390 shouldHgStat = true;
Chris@109 1391 break;
Chris@109 1392
Chris@109 1393 case ACT_LOG:
Chris@120 1394 hgTabs->setNewLog(output);
Chris@120 1395 needNewLog = false;
Chris@120 1396 break;
Chris@120 1397
Chris@120 1398 case ACT_LOG_INCREMENTAL:
Chris@120 1399 hgTabs->addIncrementalLog(output);
Chris@109 1400 break;
Chris@109 1401
Chris@109 1402 case ACT_QUERY_PARENTS:
Chris@152 1403 {
Chris@109 1404 foreach (Changeset *cs, currentParents) delete cs;
Chris@109 1405 currentParents = Changeset::parseChangesets(output);
Chris@152 1406 QStringList parentIds = Changeset::getIds(currentParents);
Chris@153 1407 hgTabs->setCurrent(parentIds, currentBranch);
Chris@152 1408 }
Chris@109 1409 break;
Chris@109 1410
Chris@109 1411 case ACT_QUERY_HEADS:
Chris@150 1412 {
Chris@150 1413 oldHeadIds = Changeset::getIds(currentHeads);
Chris@150 1414 Changesets newHeads = Changeset::parseChangesets(output);
Chris@150 1415 QStringList newHeadIds = Changeset::getIds(newHeads);
Chris@150 1416 if (oldHeadIds != newHeadIds) {
Chris@150 1417 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl;
Chris@150 1418 headsChanged = true;
Chris@150 1419 foreach (Changeset *cs, currentHeads) delete cs;
Chris@150 1420 currentHeads = newHeads;
Chris@150 1421 }
Chris@150 1422 }
Chris@109 1423 break;
Chris@130 1424
Chris@130 1425 case ACT_COMMIT:
Chris@130 1426 hgTabs->clearSelections();
Chris@163 1427 justMerged = false;
Chris@130 1428 shouldHgStat = true;
Chris@130 1429 break;
Chris@163 1430
Chris@163 1431 case ACT_REVERT:
Chris@163 1432 hgMarkResolved(lastRevertedFiles);
Chris@163 1433 justMerged = false;
Chris@163 1434 break;
Chris@109 1435
Chris@109 1436 case ACT_REMOVE:
Chris@109 1437 case ACT_ADD:
Chris@116 1438 hgTabs->clearSelections();
Chris@116 1439 shouldHgStat = true;
Chris@116 1440 break;
Chris@116 1441
Chris@164 1442 case ACT_TAG:
Chris@164 1443 needNewLog = true;
Chris@164 1444 shouldHgStat = true;
Chris@164 1445 break;
Chris@164 1446
Chris@168 1447 case ACT_DIFF_SUMMARY:
Chris@168 1448 QMessageBox::information(this, tr("Change summary"),
Chris@168 1449 format3(tr("Summary of uncommitted changes"),
Chris@168 1450 "",
Chris@168 1451 output));
Chris@168 1452 break;
Chris@168 1453
Chris@109 1454 case ACT_FOLDERDIFF:
Chris@109 1455 case ACT_CHGSETDIFF:
Chris@109 1456 case ACT_SERVE:
Chris@109 1457 case ACT_HG_IGNORE:
Chris@109 1458 shouldHgStat = true;
Chris@109 1459 break;
Chris@109 1460
Chris@109 1461 case ACT_UPDATE:
Chris@162 1462 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output)));
Chris@109 1463 shouldHgStat = true;
Chris@109 1464 break;
Chris@109 1465
Chris@109 1466 case ACT_MERGE:
Chris@162 1467 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Merge successful</h3><p>%1</p>").arg(xmlEncode(output)));
Chris@109 1468 shouldHgStat = true;
Chris@109 1469 justMerged = true;
Chris@109 1470 break;
Chris@109 1471
Chris@109 1472 case ACT_RETRY_MERGE:
Chris@163 1473 QMessageBox::information(this, tr("Resolved"),
Chris@163 1474 tr("<qt><h3>Merge resolved</h3><p>Merge resolved successfully.</p>"));
Chris@109 1475 shouldHgStat = true;
Chris@109 1476 justMerged = true;
Chris@109 1477 break;
Chris@109 1478
Chris@109 1479 default:
Chris@109 1480 break;
Chris@109 1481 }
Chris@108 1482
Chris@121 1483 // Sequence when no full log required:
Chris@163 1484 // paths -> branch -> stat -> resolve-list -> heads ->
Chris@150 1485 // incremental-log (only if heads changed) -> parents
Chris@150 1486 //
Chris@121 1487 // Sequence when full log required:
Chris@163 1488 // paths -> branch -> stat -> resolve-list -> heads -> parents -> log
Chris@150 1489 //
Chris@150 1490 // Note we want to call enableDisableActions only once, at the end
Chris@150 1491 // of whichever sequence is in use.
Chris@150 1492
Chris@156 1493 bool noMore = false;
Chris@156 1494
Chris@150 1495 switch (action) {
Chris@150 1496
Chris@150 1497 case ACT_QUERY_PATHS:
Chris@109 1498 hgQueryBranch();
Chris@150 1499 break;
Chris@150 1500
Chris@150 1501 case ACT_QUERY_BRANCH:
Chris@109 1502 hgStat();
Chris@150 1503 break;
Chris@150 1504
Chris@150 1505 case ACT_STAT:
Chris@163 1506 hgResolveList();
Chris@163 1507 break;
Chris@163 1508
Chris@163 1509 case ACT_RESOLVE_LIST:
Chris@150 1510 hgQueryHeads();
Chris@150 1511 break;
Chris@150 1512
Chris@150 1513 case ACT_QUERY_HEADS:
Chris@150 1514 if (headsChanged && !needNewLog) {
Chris@150 1515 hgLogIncremental(oldHeadIds);
Chris@121 1516 } else {
Chris@150 1517 hgQueryParents();
Chris@121 1518 }
Chris@150 1519 break;
Chris@150 1520
Chris@150 1521 case ACT_LOG_INCREMENTAL:
Chris@109 1522 hgQueryParents();
Chris@150 1523 break;
Chris@150 1524
Chris@150 1525 case ACT_QUERY_PARENTS:
Chris@120 1526 if (needNewLog) {
Chris@120 1527 hgLog();
Chris@150 1528 } else {
Chris@150 1529 // we're done
Chris@156 1530 noMore = true;
Chris@120 1531 }
Chris@150 1532 break;
Chris@150 1533
Chris@150 1534 case ACT_LOG:
Chris@150 1535 // we're done
Chris@156 1536 noMore = true;
Chris@150 1537
Chris@150 1538 default:
Chris@109 1539 if (shouldHgStat) {
Chris@163 1540 shouldHgStat = false;
Chris@109 1541 hgQueryPaths();
Chris@150 1542 } else {
Chris@156 1543 noMore = true;
jtkorhonen@0 1544 }
Chris@150 1545 break;
Chris@150 1546 }
Chris@156 1547
Chris@156 1548 if (noMore) {
Chris@173 1549 stateUnknown = false;
Chris@156 1550 enableDisableActions();
Chris@156 1551 hgTabs->updateHistory();
Chris@156 1552 }
jtkorhonen@0 1553 }
jtkorhonen@0 1554
jtkorhonen@0 1555 void MainWindow::connectActions()
jtkorhonen@0 1556 {
jtkorhonen@0 1557 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
jtkorhonen@0 1558 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
jtkorhonen@0 1559
Chris@120 1560 connect(hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
jtkorhonen@0 1561 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
jtkorhonen@0 1562 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
jtkorhonen@0 1563 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
jtkorhonen@0 1564 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
jtkorhonen@0 1565 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
jtkorhonen@0 1566 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
jtkorhonen@0 1567 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
jtkorhonen@34 1568 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
jtkorhonen@0 1569
jtkorhonen@0 1570 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
Chris@69 1571 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
jtkorhonen@0 1572
jtkorhonen@0 1573 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
jtkorhonen@0 1574 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
jtkorhonen@0 1575 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
jtkorhonen@0 1576
jtkorhonen@0 1577 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
jtkorhonen@11 1578 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
Chris@94 1579 connect(clearSelectionsAct, SIGNAL(triggered()), this, SLOT(clearSelections()));
jtkorhonen@0 1580 }
Chris@141 1581
Chris@141 1582 void MainWindow::connectTabsSignals()
Chris@141 1583 {
Chris@141 1584 connect(hgTabs, SIGNAL(commit()),
Chris@141 1585 this, SLOT(hgCommit()));
Chris@141 1586
Chris@141 1587 connect(hgTabs, SIGNAL(revert()),
Chris@141 1588 this, SLOT(hgRevert()));
Chris@141 1589
Chris@141 1590 connect(hgTabs, SIGNAL(diffWorkingFolder()),
Chris@141 1591 this, SLOT(hgFolderDiff()));
Chris@168 1592
Chris@168 1593 connect(hgTabs, SIGNAL(showSummary()),
Chris@168 1594 this, SLOT(hgShowSummary()));
Chris@148 1595
Chris@141 1596 connect(hgTabs, SIGNAL(updateTo(QString)),
Chris@148 1597 this, SLOT(hgUpdateToRev(QString)));
Chris@141 1598
Chris@141 1599 connect(hgTabs, SIGNAL(diffToCurrent(QString)),
Chris@148 1600 this, SLOT(hgDiffToCurrent(QString)));
Chris@141 1601
Chris@148 1602 connect(hgTabs, SIGNAL(diffToParent(QString, QString)),
Chris@148 1603 this, SLOT(hgDiffToParent(QString, QString)));
Chris@141 1604
Chris@141 1605 connect(hgTabs, SIGNAL(mergeFrom(QString)),
Chris@148 1606 this, SLOT(hgMergeFrom(QString)));
Chris@164 1607
Chris@141 1608 connect(hgTabs, SIGNAL(tag(QString)),
Chris@148 1609 this, SLOT(hgTag(QString)));
Chris@141 1610 }
Chris@141 1611
jtkorhonen@0 1612 void MainWindow::enableDisableActions()
jtkorhonen@0 1613 {
Chris@90 1614 DEBUG << "MainWindow::enableDisableActions" << endl;
Chris@90 1615
Chris@115 1616 //!!! should also do things like set the status texts for the
Chris@115 1617 //!!! actions appropriately by context
Chris@115 1618
jtkorhonen@0 1619 QDir localRepoDir;
jtkorhonen@0 1620 QDir workFolderDir;
Chris@145 1621 bool workFolderExist = true;
Chris@145 1622 bool localRepoExist = true;
jtkorhonen@0 1623
jtkorhonen@0 1624 remoteRepoActionsEnabled = true;
Chris@90 1625 if (remoteRepoPath.isEmpty()) {
jtkorhonen@0 1626 remoteRepoActionsEnabled = false;
jtkorhonen@0 1627 }
jtkorhonen@0 1628
jtkorhonen@0 1629 localRepoActionsEnabled = true;
Chris@90 1630 if (workFolderPath.isEmpty()) {
jtkorhonen@0 1631 localRepoActionsEnabled = false;
jtkorhonen@0 1632 workFolderExist = false;
jtkorhonen@0 1633 }
jtkorhonen@0 1634
Chris@90 1635 if (!workFolderDir.exists(workFolderPath)) {
jtkorhonen@0 1636 localRepoActionsEnabled = false;
jtkorhonen@0 1637 workFolderExist = false;
Chris@90 1638 } else {
jtkorhonen@0 1639 workFolderExist = true;
jtkorhonen@0 1640 }
jtkorhonen@0 1641
Chris@112 1642 if (!localRepoDir.exists(workFolderPath + "/.hg")) {
jtkorhonen@0 1643 localRepoActionsEnabled = false;
jtkorhonen@0 1644 localRepoExist = false;
jtkorhonen@0 1645 }
jtkorhonen@0 1646
jtkorhonen@0 1647 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
jtkorhonen@0 1648 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
jtkorhonen@0 1649 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
Chris@169 1650
Chris@112 1651 bool haveDiff = (diffBinaryName != "");
Chris@112 1652
Chris@120 1653 hgRefreshAct -> setEnabled(localRepoActionsEnabled);
Chris@112 1654 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
jtkorhonen@0 1655 hgRevertAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1656 hgAddAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1657 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1658 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1659 hgCommitAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1660 hgMergeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@2 1661 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@11 1662 hgServeAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@34 1663 hgIgnoreAct -> setEnabled(localRepoActionsEnabled);
jtkorhonen@0 1664
Chris@90 1665 DEBUG << "localRepoActionsEnabled = " << localRepoActionsEnabled << endl;
Chris@98 1666 DEBUG << "canCommit = " << hgTabs->canCommit() << endl;
Chris@90 1667
Chris@98 1668 hgAddAct->setEnabled(localRepoActionsEnabled && hgTabs->canAdd());
Chris@98 1669 hgRemoveAct->setEnabled(localRepoActionsEnabled && hgTabs->canRemove());
Chris@98 1670 hgCommitAct->setEnabled(localRepoActionsEnabled && hgTabs->canCommit());
Chris@163 1671 hgRevertAct->setEnabled(localRepoActionsEnabled && hgTabs->canRevert());
Chris@163 1672 hgFolderDiffAct->setEnabled(localRepoActionsEnabled && hgTabs->canDiff());
Chris@90 1673
Chris@108 1674 // A default merge makes sense if:
Chris@108 1675 // * there is only one parent (if there are two, we have an uncommitted merge) and
Chris@108 1676 // * there are exactly two heads that have the same branch as the current branch and
Chris@108 1677 // * our parent is one of those heads
Chris@108 1678 //
Chris@108 1679 // A default update makes sense if:
Chris@108 1680 // * there is only one parent and
Chris@108 1681 // * the parent is not one of the current heads
Chris@156 1682
Chris@108 1683 bool canMerge = false;
Chris@108 1684 bool canUpdate = false;
Chris@156 1685 bool haveMerge = false;
Chris@162 1686 bool emptyRepo = false;
Chris@156 1687 int currentBranchHeads = 0;
Chris@156 1688
Chris@108 1689 if (currentParents.size() == 1) {
Chris@156 1690 bool parentIsHead = false;
Chris@108 1691 Changeset *parent = currentParents[0];
Chris@108 1692 foreach (Changeset *head, currentHeads) {
Chris@108 1693 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl;
Chris@108 1694 if (head->isOnBranch(currentBranch)) {
Chris@108 1695 ++currentBranchHeads;
Chris@108 1696 if (parent->id() == head->id()) {
Chris@108 1697 parentIsHead = true;
Chris@108 1698 }
Chris@108 1699 }
Chris@108 1700 }
Chris@108 1701 if (currentBranchHeads == 2 && parentIsHead) {
Chris@108 1702 canMerge = true;
Chris@108 1703 }
Chris@108 1704 if (!parentIsHead) {
Chris@108 1705 canUpdate = true;
Chris@108 1706 DEBUG << "parent id = " << parent->id() << endl;
Chris@108 1707 DEBUG << " head ids "<<endl;
Chris@108 1708 foreach (Changeset *h, currentHeads) {
Chris@108 1709 DEBUG << "head id = " << h->id() << endl;
Chris@108 1710 }
Chris@108 1711 }
Chris@162 1712 } else if (currentParents.size() == 0) {
Chris@162 1713 emptyRepo = true;
Chris@156 1714 } else {
Chris@156 1715 haveMerge = true;
Chris@163 1716 justMerged = true;
Chris@108 1717 }
Chris@156 1718
Chris@163 1719 hgMergeAct->setEnabled(localRepoActionsEnabled &&
Chris@163 1720 (canMerge || hgTabs->canResolve()));
Chris@163 1721 hgUpdateAct->setEnabled(localRepoActionsEnabled &&
Chris@172 1722 (canUpdate && !hgTabs->haveChangesToCommit()));
Chris@115 1723
Chris@115 1724 // Set the state field on the file status widget
Chris@115 1725
Chris@115 1726 QString branchText;
Chris@115 1727 if (currentBranch == "" || currentBranch == "default") {
Chris@115 1728 branchText = tr("the default branch");
Chris@115 1729 } else {
Chris@115 1730 branchText = tr("branch \"%1\"").arg(currentBranch);
Chris@115 1731 }
Chris@156 1732
Chris@173 1733 if (stateUnknown) {
Chris@173 1734 hgTabs->setState(tr("(Examining repository)"));
Chris@173 1735 } else if (emptyRepo) {
Chris@162 1736 hgTabs->setState(tr("Nothing committed to this repository yet"));
Chris@162 1737 } else if (canMerge) {
Chris@156 1738 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
Chris@163 1739 } else if (!hgTabs->getAllUnresolvedFiles().empty()) {
Chris@163 1740 hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText));
Chris@156 1741 } else if (haveMerge) {
Chris@157 1742 hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
Chris@156 1743 } else if (canUpdate) {
Chris@172 1744 if (hgTabs->haveChangesToCommit()) {
Chris@163 1745 // have uncommitted changes
Chris@163 1746 hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText));
Chris@163 1747 } else {
Chris@163 1748 // no uncommitted changes
Chris@163 1749 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
Chris@163 1750 }
Chris@156 1751 } else if (currentBranchHeads > 1) {
Chris@156 1752 hgTabs->setState(tr("At one of %n heads of %1", "", currentBranchHeads).arg(branchText));
Chris@115 1753 } else {
Chris@115 1754 hgTabs->setState(tr("At the head of %1").arg(branchText));
Chris@115 1755 }
jtkorhonen@0 1756 }
jtkorhonen@0 1757
jtkorhonen@0 1758 void MainWindow::createActions()
jtkorhonen@0 1759 {
jtkorhonen@0 1760 //File actions
Chris@69 1761 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
Chris@169 1762 openAct -> setStatusTip(tr("Open a repository"));
Chris@69 1763
jtkorhonen@0 1764 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
jtkorhonen@0 1765 settingsAct -> setStatusTip(tr("View and change application settings"));
jtkorhonen@0 1766
Chris@169 1767 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Quit"), this);
jtkorhonen@0 1768 exitAct->setShortcuts(QKeySequence::Quit);
Chris@169 1769 exitAct->setStatusTip(tr("Quit EasyMercurial"));
jtkorhonen@0 1770
jtkorhonen@0 1771 //Repository actions
Chris@120 1772 hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
Chris@169 1773 hgRefreshAct->setStatusTip(tr("Update the window to show the current state of the working folder"));
Chris@61 1774
Chris@61 1775 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
Chris@169 1776 hgIncomingAct -> setStatusTip(tr("See what changes are available in the remote repository waiting to be pulled"));
jtkorhonen@0 1777
Chris@61 1778 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
Chris@169 1779 hgPullAct -> setStatusTip(tr("Pull changes from the remote repository to the local repository"));
jtkorhonen@0 1780
Chris@61 1781 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push"), this);
Chris@169 1782 hgPushAct->setStatusTip(tr("Push changes from the local repository to the remote repository"));
jtkorhonen@0 1783
jtkorhonen@0 1784 //Workfolder actions
Chris@99 1785 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("Diff"), this);
Chris@169 1786 hgFolderDiffAct->setStatusTip(tr("See what has changed in the working folder compared with the last committed state"));
jtkorhonen@0 1787
Chris@61 1788 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Revert"), this);
Chris@169 1789 hgRevertAct->setStatusTip(tr("Throw away your changes and return to the last committed state"));
jtkorhonen@0 1790
Chris@61 1791 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add"), this);
Chris@169 1792 hgAddAct -> setStatusTip(tr("Mark the selected file(s) to be added on the next commit"));
jtkorhonen@0 1793
Chris@169 1794 //!!! needs to be modified for number
Chris@61 1795 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove"), this);
Chris@169 1796 hgRemoveAct -> setStatusTip(tr("Mark the selected file(s) to be removed from version control on the next commit"));
jtkorhonen@0 1797
Chris@61 1798 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update"), this);
Chris@169 1799 hgUpdateAct->setStatusTip(tr("Update the working folder to the head of the current repository branch"));
jtkorhonen@0 1800
Chris@169 1801 //!!! needs to be modified when files selected
Chris@61 1802 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit"), this);
Chris@169 1803 hgCommitAct->setStatusTip(tr("Commit your changes to the local repository"));
jtkorhonen@0 1804
jtkorhonen@0 1805 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
Chris@169 1806 hgMergeAct->setStatusTip(tr("Merge the two independent sets of changes in the local repository into the working folder"));
jtkorhonen@0 1807
jtkorhonen@0 1808 //Advanced actions
Chris@169 1809 //!!! needs to be modified for number
jtkorhonen@0 1810 hgAnnotateAct = new QAction(tr("Annotate"), this);
jtkorhonen@0 1811 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
jtkorhonen@0 1812
jtkorhonen@34 1813 hgIgnoreAct = new QAction(tr("Edit .hgignore"), this);
Chris@169 1814 hgIgnoreAct -> setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial"));
jtkorhonen@34 1815
jtkorhonen@11 1816 hgServeAct = new QAction(tr("Serve (via http)"), this);
jtkorhonen@11 1817 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
jtkorhonen@11 1818
jtkorhonen@0 1819 //Help actions
jtkorhonen@0 1820 aboutAct = new QAction(tr("About"), this);
Chris@94 1821
Chris@94 1822 // Miscellaneous
Chris@94 1823 clearSelectionsAct = new QAction(tr("Clear selections"), this);
Chris@94 1824 clearSelectionsAct->setShortcut(Qt::Key_Escape);
jtkorhonen@0 1825 }
jtkorhonen@0 1826
jtkorhonen@0 1827 void MainWindow::createMenus()
jtkorhonen@0 1828 {
jtkorhonen@0 1829 fileMenu = menuBar()->addMenu(tr("File"));
Chris@169 1830
Chris@69 1831 fileMenu -> addAction(openAct);
jtkorhonen@0 1832 fileMenu -> addAction(settingsAct);
jtkorhonen@0 1833 fileMenu -> addSeparator();
jtkorhonen@0 1834 fileMenu -> addAction(exitAct);
jtkorhonen@0 1835
jtkorhonen@0 1836 advancedMenu = menuBar()->addMenu(tr("Advanced"));
Chris@169 1837
jtkorhonen@34 1838 advancedMenu -> addAction(hgIgnoreAct);
jtkorhonen@34 1839 advancedMenu -> addSeparator();
jtkorhonen@11 1840 advancedMenu -> addAction(hgServeAct);
jtkorhonen@0 1841
jtkorhonen@0 1842 helpMenu = menuBar()->addMenu(tr("Help"));
jtkorhonen@0 1843 helpMenu->addAction(aboutAct);
jtkorhonen@0 1844 }
jtkorhonen@0 1845
jtkorhonen@0 1846 void MainWindow::createToolBars()
jtkorhonen@0 1847 {
jtkorhonen@0 1848 fileToolBar = addToolBar(tr("File"));
jtkorhonen@0 1849 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@69 1850 fileToolBar -> addAction(openAct);
Chris@120 1851 fileToolBar -> addAction(hgRefreshAct);
jtkorhonen@0 1852 fileToolBar -> addSeparator();
jtkorhonen@0 1853 fileToolBar -> setMovable(false);
jtkorhonen@0 1854
jtkorhonen@0 1855 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
jtkorhonen@0 1856 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
jtkorhonen@0 1857 repoToolBar->addAction(hgIncomingAct);
jtkorhonen@0 1858 repoToolBar->addAction(hgPullAct);
jtkorhonen@0 1859 repoToolBar->addAction(hgPushAct);
jtkorhonen@0 1860 repoToolBar -> setMovable(false);
jtkorhonen@0 1861
jtkorhonen@0 1862 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
jtkorhonen@0 1863 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
jtkorhonen@0 1864 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
Chris@95 1865 workFolderToolBar->addAction(hgFolderDiffAct);
jtkorhonen@0 1866 workFolderToolBar->addSeparator();
jtkorhonen@0 1867 workFolderToolBar->addAction(hgRevertAct);
jtkorhonen@0 1868 workFolderToolBar->addAction(hgUpdateAct);
jtkorhonen@0 1869 workFolderToolBar->addAction(hgCommitAct);
jtkorhonen@0 1870 workFolderToolBar->addAction(hgMergeAct);
jtkorhonen@0 1871 workFolderToolBar->addSeparator();
jtkorhonen@0 1872 workFolderToolBar->addAction(hgAddAct);
jtkorhonen@0 1873 workFolderToolBar->addAction(hgRemoveAct);
jtkorhonen@0 1874 workFolderToolBar -> setMovable(false);
Chris@61 1875
Chris@61 1876 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
Chris@61 1877 tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
Chris@61 1878 }
jtkorhonen@0 1879 }
jtkorhonen@0 1880
jtkorhonen@0 1881
jtkorhonen@0 1882 void MainWindow::createStatusBar()
jtkorhonen@0 1883 {
jtkorhonen@0 1884 statusBar()->showMessage(tr("Ready"));
jtkorhonen@0 1885 }
jtkorhonen@0 1886
Chris@69 1887
Chris@69 1888 //!!! review these:
Chris@69 1889
jtkorhonen@0 1890 void MainWindow::readSettings()
jtkorhonen@0 1891 {
jtkorhonen@0 1892 QDir workFolder;
jtkorhonen@0 1893
Chris@61 1894 QSettings settings;
jtkorhonen@0 1895
jtkorhonen@30 1896 remoteRepoPath = settings.value("remoterepopath", "").toString();
jtkorhonen@0 1897 workFolderPath = settings.value("workfolderpath", "").toString();
jtkorhonen@0 1898 if (!workFolder.exists(workFolderPath))
jtkorhonen@0 1899 {
jtkorhonen@0 1900 workFolderPath = "";
jtkorhonen@0 1901 }
jtkorhonen@0 1902
jtkorhonen@0 1903 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
jtkorhonen@0 1904 QSize size = settings.value("size", QSize(400, 400)).toSize();
jtkorhonen@0 1905 firstStart = settings.value("firststart", QVariant(true)).toBool();
jtkorhonen@0 1906
Chris@109 1907 //!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
jtkorhonen@0 1908 resize(size);
jtkorhonen@0 1909 move(pos);
jtkorhonen@0 1910 }
jtkorhonen@0 1911
jtkorhonen@17 1912
jtkorhonen@0 1913 void MainWindow::writeSettings()
jtkorhonen@0 1914 {
Chris@61 1915 QSettings settings;
jtkorhonen@0 1916 settings.setValue("pos", pos());
jtkorhonen@0 1917 settings.setValue("size", size());
jtkorhonen@0 1918 settings.setValue("remoterepopath", remoteRepoPath);
jtkorhonen@0 1919 settings.setValue("workfolderpath", workFolderPath);
jtkorhonen@0 1920 settings.setValue("firststart", firstStart);
Chris@98 1921 //!!!settings.setValue("viewFileTypes", hgTabs -> getFileTypesBits());
jtkorhonen@0 1922 }
jtkorhonen@0 1923
jtkorhonen@0 1924
jtkorhonen@0 1925
jtkorhonen@0 1926