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