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