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