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