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