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