annotate mainwindow.cpp @ 169:c7fa56707ae9

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