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