Chris@585
|
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@560
|
8 Copyright (c) 2012 Chris Cannam
|
Chris@560
|
9 Copyright (c) 2012 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@359
|
32 #include <QWidgetAction>
|
Chris@125
|
33 #include <QRegExp>
|
Chris@199
|
34 #include <QShortcut>
|
Chris@237
|
35 #include <QUrl>
|
Chris@476
|
36 #include <QDialogButtonBox>
|
Chris@238
|
37 #include <QTimer>
|
Chris@494
|
38 #include <QTextBrowser>
|
jtkorhonen@0
|
39
|
Chris@53
|
40 #include "mainwindow.h"
|
Chris@69
|
41 #include "multichoicedialog.h"
|
Chris@64
|
42 #include "startupdialog.h"
|
Chris@53
|
43 #include "colourset.h"
|
Chris@62
|
44 #include "debug.h"
|
Chris@74
|
45 #include "logparser.h"
|
Chris@103
|
46 #include "confirmcommentdialog.h"
|
Chris@125
|
47 #include "incomingdialog.h"
|
Chris@175
|
48 #include "settingsdialog.h"
|
Chris@275
|
49 #include "moreinformationdialog.h"
|
Chris@331
|
50 #include "annotatedialog.h"
|
Chris@229
|
51 #include "version.h"
|
Chris@287
|
52 #include "workstatuswidget.h"
|
Chris@414
|
53 #include "hgignoredialog.h"
|
Chris@491
|
54 #include "versiontester.h"
|
Chris@540
|
55 #include "fswatcher.h"
|
Chris@53
|
56
|
jtkorhonen@0
|
57
|
Chris@172
|
58 MainWindow::MainWindow(QString myDirPath) :
|
Chris@238
|
59 m_myDirPath(myDirPath),
|
Chris@540
|
60 m_helpDialog(0)
|
jtkorhonen@0
|
61 {
|
Chris@197
|
62 setWindowIcon(QIcon(":images/easyhg-icon.png"));
|
Chris@197
|
63
|
jtkorhonen@0
|
64 QString wndTitle;
|
jtkorhonen@0
|
65
|
Chris@284
|
66 m_showAllFiles = false;
|
Chris@273
|
67
|
Chris@540
|
68 m_fsWatcher = new FsWatcher();
|
Chris@540
|
69 m_fsWatcherToken = m_fsWatcher->getNewToken();
|
Chris@540
|
70 m_commandSequenceInProgress = false;
|
Chris@541
|
71 connect(m_fsWatcher, SIGNAL(changed()), this, SLOT(checkFilesystem()));
|
Chris@540
|
72
|
Chris@284
|
73 m_commitsSincePush = 0;
|
Chris@284
|
74 m_shouldHgStat = true;
|
Chris@90
|
75
|
jtkorhonen@0
|
76 createActions();
|
jtkorhonen@0
|
77 createMenus();
|
jtkorhonen@0
|
78 createToolBars();
|
jtkorhonen@0
|
79 createStatusBar();
|
jtkorhonen@0
|
80
|
Chris@284
|
81 m_runner = new HgRunner(m_myDirPath, this);
|
Chris@284
|
82 connect(m_runner, SIGNAL(commandStarting(HgAction)),
|
Chris@241
|
83 this, SLOT(commandStarting(HgAction)));
|
Chris@284
|
84 connect(m_runner, SIGNAL(commandCompleted(HgAction, QString)),
|
Chris@109
|
85 this, SLOT(commandCompleted(HgAction, QString)));
|
Chris@537
|
86 connect(m_runner, SIGNAL(commandFailed(HgAction, QString, QString)),
|
Chris@537
|
87 this, SLOT(commandFailed(HgAction, QString, QString)));
|
Chris@564
|
88 connect(m_runner, SIGNAL(commandCancelled(HgAction)),
|
Chris@564
|
89 this, SLOT(commandCancelled(HgAction)));
|
Chris@284
|
90 statusBar()->addPermanentWidget(m_runner);
|
jtkorhonen@0
|
91
|
Chris@61
|
92 setWindowTitle(tr("EasyMercurial"));
|
jtkorhonen@0
|
93
|
Chris@284
|
94 m_remoteRepoPath = "";
|
Chris@284
|
95 m_workFolderPath = "";
|
jtkorhonen@0
|
96
|
jtkorhonen@0
|
97 readSettings();
|
jtkorhonen@0
|
98
|
Chris@284
|
99 m_justMerged = false;
|
Chris@210
|
100
|
Chris@210
|
101 QWidget *central = new QWidget(this);
|
Chris@210
|
102 setCentralWidget(central);
|
Chris@210
|
103
|
Chris@210
|
104 QGridLayout *cl = new QGridLayout(central);
|
Chris@287
|
105 int row = 0;
|
Chris@210
|
106
|
Chris@210
|
107 #ifndef Q_OS_MAC
|
Chris@210
|
108 cl->setMargin(0);
|
Chris@210
|
109 #endif
|
jtkorhonen@0
|
110
|
Chris@287
|
111 m_workStatus = new WorkStatusWidget(this);
|
Chris@558
|
112 cl->addWidget(m_workStatus, row++, 0);
|
Chris@287
|
113
|
Chris@287
|
114 m_hgTabs = new HgTabWidget(central, m_workFolderPath);
|
Chris@287
|
115 connectTabsSignals();
|
Chris@287
|
116
|
Chris@554
|
117 cl->addWidget(m_hgTabs, row++, 0, 1, 2);
|
Chris@287
|
118
|
Chris@284
|
119 connect(m_hgTabs, SIGNAL(selectionChanged()),
|
Chris@95
|
120 this, SLOT(enableDisableActions()));
|
Chris@484
|
121 connect(m_hgTabs, SIGNAL(showAllChanged()),
|
Chris@484
|
122 this, SLOT(showAllChanged()));
|
Chris@95
|
123
|
jtkorhonen@0
|
124 setUnifiedTitleAndToolBarOnMac(true);
|
jtkorhonen@0
|
125 connectActions();
|
Chris@120
|
126 clearState();
|
jtkorhonen@0
|
127 enableDisableActions();
|
jtkorhonen@0
|
128
|
Chris@284
|
129 if (m_firstStart) {
|
Chris@64
|
130 startupDialog();
|
jtkorhonen@0
|
131 }
|
jtkorhonen@0
|
132
|
Chris@239
|
133 SettingsDialog::findDefaultLocations(m_myDirPath);
|
Chris@112
|
134
|
Chris@64
|
135 ColourSet *cs = ColourSet::instance();
|
Chris@64
|
136 cs->clearDefaultNames();
|
Chris@64
|
137 cs->addDefaultName("");
|
Chris@153
|
138 cs->addDefaultName("default");
|
Chris@64
|
139 cs->addDefaultName(getUserInfo());
|
Chris@62
|
140
|
Chris@491
|
141 VersionTester *vt = new VersionTester
|
Chris@507
|
142 ("easyhg.org", "/latest-version.txt", EASYHG_VERSION);
|
Chris@491
|
143 connect(vt, SIGNAL(newerVersionAvailable(QString)),
|
Chris@491
|
144 this, SLOT(newerVersionAvailable(QString)));
|
Chris@491
|
145
|
Chris@175
|
146 hgTest();
|
Chris@359
|
147 updateRecentMenu();
|
jtkorhonen@0
|
148 }
|
jtkorhonen@0
|
149
|
jtkorhonen@0
|
150
|
jtkorhonen@0
|
151 void MainWindow::closeEvent(QCloseEvent *)
|
jtkorhonen@0
|
152 {
|
jtkorhonen@0
|
153 writeSettings();
|
Chris@284
|
154 delete m_fsWatcher;
|
jtkorhonen@0
|
155 }
|
jtkorhonen@0
|
156
|
jtkorhonen@0
|
157
|
Chris@554
|
158 void MainWindow::resizeEvent(QResizeEvent *)
|
Chris@554
|
159 {
|
Chris@554
|
160 }
|
Chris@554
|
161
|
Chris@554
|
162
|
Chris@64
|
163 QString MainWindow::getUserInfo() const
|
Chris@64
|
164 {
|
Chris@64
|
165 QSettings settings;
|
Chris@64
|
166 settings.beginGroup("User Information");
|
Chris@64
|
167 QString name = settings.value("name", getUserRealName()).toString();
|
Chris@64
|
168 QString email = settings.value("email", "").toString();
|
Chris@64
|
169
|
Chris@64
|
170 QString identifier;
|
Chris@64
|
171
|
Chris@64
|
172 if (email != "") {
|
Chris@64
|
173 identifier = QString("%1 <%2>").arg(name).arg(email);
|
Chris@64
|
174 } else {
|
Chris@64
|
175 identifier = name;
|
Chris@64
|
176 }
|
Chris@64
|
177
|
Chris@64
|
178 return identifier;
|
Chris@64
|
179 }
|
Chris@64
|
180
|
jtkorhonen@0
|
181 void MainWindow::about()
|
jtkorhonen@0
|
182 {
|
Chris@97
|
183 QMessageBox::about(this, tr("About EasyMercurial"),
|
Chris@229
|
184 tr("<qt><h2>EasyMercurial v%1</h2>"
|
Chris@228
|
185 #ifdef Q_OS_MAC
|
Chris@228
|
186 "<font size=-1>"
|
Chris@228
|
187 #endif
|
Chris@97
|
188 "<p>EasyMercurial is a simple user interface for the "
|
Chris@186
|
189 "Mercurial</a> version control system.</p>"
|
Chris@186
|
190 "<h4>Credits and Copyright</h4>"
|
Chris@186
|
191 "<p>Development carried out by Chris Cannam for "
|
Chris@186
|
192 "SoundSoftware.ac.uk at the Centre for Digital Music, "
|
Chris@186
|
193 "Queen Mary, University of London.</p>"
|
Chris@186
|
194 "<p>EasyMercurial is based on HgExplorer by "
|
Chris@186
|
195 "Jari Korhonen, with thanks.</p>"
|
Chris@186
|
196 "<p style=\"margin-left: 2em;\">"
|
Chris@560
|
197 "Copyright © 2012 Queen Mary, University of London.<br>"
|
Chris@186
|
198 "Copyright © 2010 Jari Korhonen.<br>"
|
Chris@560
|
199 "Copyright © 2012 Chris Cannam."
|
Chris@186
|
200 "</p>"
|
Chris@186
|
201 "<p style=\"margin-left: 2em;\">"
|
Chris@186
|
202 "This program requires Mercurial, by Matt Mackall and others.<br>"
|
Chris@186
|
203 "This program uses Qt by Nokia.<br>"
|
Chris@186
|
204 "This program uses Nuvola icons by David Vignoni.<br>"
|
Chris@186
|
205 "This program may use KDiff3 by Joachim Eibl.<br>"
|
Chris@186
|
206 "This program may use PyQt by River Bank Computing.<br>"
|
Chris@186
|
207 "Packaging for Mercurial and other dependencies on Windows is derived from TortoiseHg by Steve Borho and others."
|
Chris@186
|
208 "</p>"
|
Chris@186
|
209 "<h4>License</h4>"
|
Chris@186
|
210 "<p>This program is free software; you can redistribute it and/or "
|
Chris@97
|
211 "modify it under the terms of the GNU General Public License as "
|
Chris@97
|
212 "published by the Free Software Foundation; either version 2 of the "
|
Chris@97
|
213 "License, or (at your option) any later version. See the file "
|
Chris@223
|
214 "COPYING included with this distribution for more information.</p>"
|
Chris@228
|
215 #ifdef Q_OS_MAC
|
Chris@228
|
216 "</font>"
|
Chris@228
|
217 #endif
|
Chris@229
|
218 ).arg(EASYHG_VERSION));
|
jtkorhonen@0
|
219 }
|
jtkorhonen@0
|
220
|
Chris@94
|
221 void MainWindow::clearSelections()
|
Chris@94
|
222 {
|
Chris@284
|
223 m_hgTabs->clearSelections();
|
Chris@94
|
224 }
|
jtkorhonen@0
|
225
|
Chris@484
|
226 void MainWindow::showAllChanged()
|
Chris@199
|
227 {
|
Chris@199
|
228 hgQueryPaths();
|
Chris@199
|
229 }
|
Chris@199
|
230
|
Chris@120
|
231 void MainWindow::hgRefresh()
|
Chris@120
|
232 {
|
Chris@120
|
233 clearState();
|
Chris@120
|
234 hgQueryPaths();
|
Chris@120
|
235 }
|
Chris@120
|
236
|
Chris@175
|
237 void MainWindow::hgTest()
|
Chris@175
|
238 {
|
Chris@175
|
239 QStringList params;
|
Chris@175
|
240 params << "--version";
|
Chris@382
|
241 // The path is not necessarily set here, but we need something for
|
Chris@382
|
242 // this test or else HgRunner will (cautiously) refuse to run
|
Chris@382
|
243 QString path = m_myDirPath;
|
Chris@382
|
244 if (path == "") path = QDir::homePath();
|
Chris@382
|
245 m_runner->requestAction(HgAction(ACT_TEST_HG, path, params));
|
Chris@175
|
246 }
|
Chris@175
|
247
|
Chris@200
|
248 void MainWindow::hgTestExtension()
|
Chris@200
|
249 {
|
Chris@200
|
250 QStringList params;
|
Chris@200
|
251 params << "--version";
|
Chris@382
|
252 // The path is not necessarily set here, but we need something for
|
Chris@382
|
253 // this test or else HgRunner will (cautiously) refuse to run
|
Chris@382
|
254 QString path = m_myDirPath;
|
Chris@382
|
255 if (path == "") path = QDir::homePath();
|
Chris@382
|
256 m_runner->requestAction(HgAction(ACT_TEST_HG_EXT, path, params));
|
Chris@200
|
257 }
|
Chris@200
|
258
|
jtkorhonen@0
|
259 void MainWindow::hgStat()
|
jtkorhonen@0
|
260 {
|
Chris@109
|
261 QStringList params;
|
Chris@199
|
262
|
Chris@542
|
263 // We always stat all files, regardless of whether we're showing
|
Chris@542
|
264 // them all, because we need them for the filesystem monitor
|
Chris@542
|
265 params << "stat" << "-A";
|
Chris@153
|
266
|
Chris@284
|
267 m_lastStatOutput = "";
|
Chris@273
|
268
|
Chris@541
|
269 // We're about to do a stat, so we can silently bring ourselves
|
Chris@541
|
270 // up-to-date on any file changes to this point
|
Chris@541
|
271 (void)m_fsWatcher->getChangedPaths(m_fsWatcherToken);
|
Chris@541
|
272
|
Chris@284
|
273 m_runner->requestAction(HgAction(ACT_STAT, m_workFolderPath, params));
|
jtkorhonen@0
|
274 }
|
jtkorhonen@0
|
275
|
Chris@109
|
276 void MainWindow::hgQueryPaths()
|
Chris@74
|
277 {
|
Chris@484
|
278 m_showAllFiles = m_hgTabs->shouldShowAll();
|
Chris@484
|
279
|
Chris@210
|
280 // Quickest is to just read the file
|
Chris@198
|
281
|
Chris@284
|
282 QFileInfo hgrc(m_workFolderPath + "/.hg/hgrc");
|
Chris@198
|
283
|
Chris@210
|
284 QString path;
|
Chris@210
|
285
|
Chris@198
|
286 if (hgrc.exists()) {
|
Chris@198
|
287 QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat);
|
Chris@198
|
288 s.beginGroup("paths");
|
Chris@210
|
289 path = s.value("default").toString();
|
Chris@210
|
290 }
|
Chris@198
|
291
|
Chris@565
|
292 // std::cerr << "hgQueryPaths: setting m_remoteRepoPath to " << m_remoteRepoPath << " from file " << hgrc.absoluteFilePath() << std::endl;
|
Chris@553
|
293
|
Chris@284
|
294 m_remoteRepoPath = path;
|
Chris@198
|
295
|
Chris@210
|
296 // We have to do this here, because commandCompleted won't be called
|
Chris@284
|
297 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
|
Chris@284
|
298 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
|
Chris@287
|
299 updateWorkFolderAndRepoNames();
|
Chris@210
|
300
|
Chris@210
|
301 hgQueryBranch();
|
Chris@210
|
302 return;
|
Chris@210
|
303
|
Chris@210
|
304 /* The classic method!
|
Chris@198
|
305
|
Chris@109
|
306 QStringList params;
|
Chris@109
|
307 params << "paths";
|
Chris@284
|
308 m_runner->requestAction(HgAction(ACT_QUERY_PATHS, m_workFolderPath, params));
|
Chris@210
|
309 */
|
Chris@74
|
310 }
|
Chris@74
|
311
|
Chris@109
|
312 void MainWindow::hgQueryBranch()
|
Chris@106
|
313 {
|
Chris@210
|
314 // Quickest is to just read the file
|
Chris@198
|
315
|
Chris@284
|
316 QFile hgbr(m_workFolderPath + "/.hg/branch");
|
Chris@198
|
317
|
Chris@210
|
318 QString br = "default";
|
Chris@210
|
319
|
Chris@198
|
320 if (hgbr.exists() && hgbr.open(QFile::ReadOnly)) {
|
Chris@210
|
321 QByteArray ba = hgbr.readLine();
|
Chris@210
|
322 br = QString::fromUtf8(ba).trimmed();
|
Chris@210
|
323 }
|
Chris@210
|
324
|
Chris@284
|
325 m_currentBranch = br;
|
Chris@210
|
326
|
Chris@210
|
327 // We have to do this here, because commandCompleted won't be called
|
Chris@210
|
328 hgStat();
|
Chris@210
|
329 return;
|
Chris@198
|
330
|
Chris@210
|
331 /* The classic method!
|
Chris@198
|
332
|
Chris@109
|
333 QStringList params;
|
Chris@109
|
334 params << "branch";
|
Chris@284
|
335 m_runner->requestAction(HgAction(ACT_QUERY_BRANCH, m_workFolderPath, params));
|
Chris@210
|
336 */
|
Chris@106
|
337 }
|
Chris@106
|
338
|
Chris@506
|
339 void MainWindow::hgQueryHeadsActive()
|
Chris@506
|
340 {
|
Chris@506
|
341 QStringList params;
|
Chris@514
|
342 params << "heads";
|
Chris@506
|
343 m_runner->requestAction(HgAction(ACT_QUERY_HEADS_ACTIVE, m_workFolderPath, params));
|
Chris@506
|
344 }
|
Chris@506
|
345
|
Chris@109
|
346 void MainWindow::hgQueryHeads()
|
jtkorhonen@0
|
347 {
|
Chris@109
|
348 QStringList params;
|
Chris@137
|
349 // On empty repos, "hg heads" will fail -- we don't care about
|
Chris@137
|
350 // that. Use --closed option so as to include closed branches;
|
Chris@137
|
351 // otherwise we'll be stuck if the user updates into one, and our
|
Chris@137
|
352 // incremental log will end up with spurious stuff in it because
|
Chris@137
|
353 // we won't be pruning at the ends of closed branches
|
Chris@137
|
354 params << "heads" << "--closed";
|
Chris@284
|
355 m_runner->requestAction(HgAction(ACT_QUERY_HEADS, m_workFolderPath, params));
|
jtkorhonen@0
|
356 }
|
jtkorhonen@0
|
357
|
jtkorhonen@0
|
358 void MainWindow::hgLog()
|
jtkorhonen@0
|
359 {
|
mikel@617
|
360 QSettings settings;
|
mikel@617
|
361 settings.beginGroup("Presentation");
|
mikel@617
|
362
|
Chris@109
|
363 QStringList params;
|
Chris@109
|
364 params << "log";
|
mikel@617
|
365 params << "--date";
|
mikel@617
|
366 params << settings.value("datefrom", QDate(2000, 1, 1)).toDate().toString("yyyy-MM-dd") + " to " + QDate::currentDate().toString("yyyy-MM-dd");
|
Chris@109
|
367 params << "--template";
|
Chris@125
|
368 params << Changeset::getLogTemplate();
|
Chris@109
|
369
|
Chris@284
|
370 m_runner->requestAction(HgAction(ACT_LOG, m_workFolderPath, params));
|
Chris@109
|
371 }
|
Chris@109
|
372
|
Chris@150
|
373 void MainWindow::hgLogIncremental(QStringList prune)
|
Chris@120
|
374 {
|
Chris@305
|
375 // Sometimes we can be called with prune empty -- it represents
|
Chris@305
|
376 // the current heads, but if we have none already and for some
|
Chris@305
|
377 // reason are being prompted for an incremental update, we may run
|
Chris@305
|
378 // into trouble. In that case, make this a full log instead
|
Chris@305
|
379
|
Chris@305
|
380 if (prune.empty()) {
|
Chris@305
|
381 hgLog();
|
Chris@305
|
382 return;
|
Chris@305
|
383 }
|
Chris@305
|
384
|
Chris@120
|
385 QStringList params;
|
Chris@120
|
386 params << "log";
|
Chris@120
|
387
|
Chris@150
|
388 foreach (QString p, prune) {
|
Chris@153
|
389 params << "--prune" << Changeset::hashOf(p);
|
Chris@120
|
390 }
|
Chris@120
|
391
|
Chris@120
|
392 params << "--template";
|
Chris@125
|
393 params << Changeset::getLogTemplate();
|
Chris@120
|
394
|
Chris@284
|
395 m_runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, m_workFolderPath, params));
|
Chris@120
|
396 }
|
Chris@109
|
397
|
Chris@109
|
398 void MainWindow::hgQueryParents()
|
Chris@109
|
399 {
|
Chris@109
|
400 QStringList params;
|
Chris@109
|
401 params << "parents";
|
Chris@284
|
402 m_runner->requestAction(HgAction(ACT_QUERY_PARENTS, m_workFolderPath, params));
|
Chris@109
|
403 }
|
Chris@109
|
404
|
Chris@326
|
405 void MainWindow::hgAnnotateFiles(QStringList files)
|
Chris@326
|
406 {
|
Chris@326
|
407 QStringList params;
|
Chris@326
|
408
|
Chris@326
|
409 if (!files.isEmpty()) {
|
Chris@332
|
410 params << "annotate" << "-udqc" << "--" << files;
|
Chris@326
|
411 m_runner->requestAction(HgAction(ACT_ANNOTATE, m_workFolderPath, params));
|
Chris@326
|
412 }
|
Chris@326
|
413 }
|
Chris@326
|
414
|
Chris@109
|
415 void MainWindow::hgResolveList()
|
Chris@109
|
416 {
|
Chris@109
|
417 QStringList params;
|
jtkorhonen@0
|
418
|
Chris@109
|
419 params << "resolve" << "--list";
|
Chris@284
|
420 m_runner->requestAction(HgAction(ACT_RESOLVE_LIST, m_workFolderPath, params));
|
Chris@109
|
421 }
|
Chris@109
|
422
|
Chris@109
|
423 void MainWindow::hgAdd()
|
jtkorhonen@0
|
424 {
|
Chris@109
|
425 // hgExplorer permitted adding "all" files -- I'm not sure
|
Chris@109
|
426 // that one is a good idea, let's require the user to select
|
jtkorhonen@0
|
427
|
Chris@326
|
428 hgAddFiles(m_hgTabs->getSelectedAddableFiles());
|
Chris@326
|
429 }
|
Chris@326
|
430
|
Chris@326
|
431 void MainWindow::hgAddFiles(QStringList files)
|
Chris@326
|
432 {
|
Chris@326
|
433 QStringList params;
|
Chris@109
|
434
|
Chris@109
|
435 if (!files.empty()) {
|
Chris@109
|
436 params << "add" << "--" << files;
|
Chris@284
|
437 m_runner->requestAction(HgAction(ACT_ADD, m_workFolderPath, params));
|
jtkorhonen@0
|
438 }
|
jtkorhonen@0
|
439 }
|
jtkorhonen@0
|
440
|
Chris@98
|
441 void MainWindow::hgRemove()
|
Chris@98
|
442 {
|
Chris@326
|
443 hgRemoveFiles(m_hgTabs->getSelectedRemovableFiles());
|
Chris@326
|
444 }
|
Chris@326
|
445
|
Chris@326
|
446 void MainWindow::hgRemoveFiles(QStringList files)
|
Chris@326
|
447 {
|
Chris@109
|
448 QStringList params;
|
Chris@98
|
449
|
Chris@109
|
450 if (!files.empty()) {
|
Chris@109
|
451 params << "remove" << "--after" << "--force" << "--" << files;
|
Chris@284
|
452 m_runner->requestAction(HgAction(ACT_REMOVE, m_workFolderPath, params));
|
Chris@109
|
453 }
|
jtkorhonen@0
|
454 }
|
jtkorhonen@0
|
455
|
jtkorhonen@0
|
456 void MainWindow::hgCommit()
|
jtkorhonen@0
|
457 {
|
Chris@326
|
458 hgCommitFiles(QStringList());
|
Chris@326
|
459 }
|
Chris@326
|
460
|
Chris@326
|
461 void MainWindow::hgCommitFiles(QStringList files)
|
Chris@326
|
462 {
|
Chris@109
|
463 QStringList params;
|
Chris@109
|
464 QString comment;
|
Chris@94
|
465
|
Chris@284
|
466 if (m_justMerged) {
|
Chris@284
|
467 comment = m_mergeCommitComment;
|
Chris@157
|
468 }
|
Chris@157
|
469
|
Chris@284
|
470 QStringList allFiles = m_hgTabs->getAllCommittableFiles();
|
Chris@127
|
471 QStringList reportFiles = files;
|
Chris@237
|
472 if (reportFiles.empty()) {
|
Chris@237
|
473 reportFiles = allFiles;
|
Chris@237
|
474 }
|
Chris@103
|
475
|
Chris@237
|
476 QString subsetNote;
|
Chris@237
|
477 if (reportFiles != allFiles) {
|
Chris@237
|
478 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
|
479 }
|
Chris@237
|
480
|
Chris@155
|
481 QString cf(tr("Commit files"));
|
Chris@155
|
482
|
Chris@311
|
483 QString branchText;
|
Chris@311
|
484 if (m_currentBranch == "" || m_currentBranch == "default") {
|
Chris@311
|
485 branchText = tr("the default branch");
|
Chris@311
|
486 } else {
|
Chris@311
|
487 branchText = tr("branch \"%1\"").arg(m_currentBranch);
|
Chris@311
|
488 }
|
Chris@311
|
489
|
Chris@109
|
490 if (ConfirmCommentDialog::confirmAndGetLongComment
|
Chris@109
|
491 (this,
|
Chris@155
|
492 cf,
|
Chris@237
|
493 tr("<h3>%1</h3><p>%2%3").arg(cf)
|
Chris@473
|
494 .arg(tr("You are about to commit changes to the following files in %1:").arg(branchText))
|
Chris@237
|
495 .arg(subsetNote),
|
Chris@237
|
496 tr("<h3>%1</h3><p>%2%3").arg(cf)
|
Chris@473
|
497 .arg(tr("You are about to commit changes to %n file(s) in %1.", "", reportFiles.size()).arg(branchText))
|
Chris@237
|
498 .arg(subsetNote),
|
Chris@127
|
499 reportFiles,
|
Chris@193
|
500 comment,
|
Chris@365
|
501 tr("Co&mmit"))) {
|
Chris@103
|
502
|
Chris@284
|
503 if (!m_justMerged && !files.empty()) {
|
Chris@157
|
504 // User wants to commit selected file(s) (and this is not
|
Chris@157
|
505 // merge commit, which would fail if we selected files)
|
Chris@157
|
506 params << "commit" << "--message" << comment
|
Chris@157
|
507 << "--user" << getUserInfo() << "--" << files;
|
Chris@109
|
508 } else {
|
Chris@109
|
509 // Commit all changes
|
Chris@157
|
510 params << "commit" << "--message" << comment
|
Chris@157
|
511 << "--user" << getUserInfo();
|
jtkorhonen@0
|
512 }
|
Chris@109
|
513
|
Chris@284
|
514 m_runner->requestAction(HgAction(ACT_COMMIT, m_workFolderPath, params));
|
Chris@284
|
515 m_mergeCommitComment = "";
|
jtkorhonen@0
|
516 }
|
jtkorhonen@0
|
517 }
|
jtkorhonen@0
|
518
|
jtkorhonen@34
|
519 QString MainWindow::filterTag(QString tag)
|
jtkorhonen@34
|
520 {
|
Chris@278
|
521 for(int i = 0; i < tag.size(); i++) {
|
Chris@278
|
522 if (tag[i].isLower() || tag[i].isUpper() ||
|
Chris@278
|
523 tag[i].isDigit() || (tag[i] == QChar('.'))) {
|
jtkorhonen@34
|
524 //ok
|
Chris@278
|
525 } else {
|
jtkorhonen@34
|
526 tag[i] = QChar('_');
|
jtkorhonen@34
|
527 }
|
jtkorhonen@34
|
528 }
|
jtkorhonen@34
|
529 return tag;
|
jtkorhonen@34
|
530 }
|
jtkorhonen@34
|
531
|
jtkorhonen@34
|
532
|
Chris@311
|
533 void MainWindow::hgNewBranch()
|
Chris@278
|
534 {
|
Chris@278
|
535 QStringList params;
|
Chris@278
|
536 QString branch;
|
Chris@278
|
537
|
Chris@278
|
538 if (ConfirmCommentDialog::confirmAndGetShortComment
|
Chris@278
|
539 (this,
|
Chris@278
|
540 tr("New Branch"),
|
Chris@278
|
541 tr("Enter new branch name:"),
|
Chris@278
|
542 branch,
|
Chris@365
|
543 tr("Start &Branch"))) {
|
Chris@278
|
544 if (!branch.isEmpty()) {//!!! do something better if it is empty
|
Chris@278
|
545
|
Chris@278
|
546 params << "branch" << filterTag(branch);
|
Chris@307
|
547 m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params));
|
Chris@278
|
548 }
|
Chris@278
|
549 }
|
Chris@278
|
550 }
|
Chris@278
|
551
|
Chris@311
|
552 void MainWindow::hgNoBranch()
|
Chris@311
|
553 {
|
Chris@311
|
554 if (m_currentParents.empty()) return;
|
Chris@311
|
555
|
Chris@311
|
556 QString parentBranch = m_currentParents[0]->branch();
|
Chris@311
|
557 if (parentBranch == "") parentBranch = "default";
|
Chris@311
|
558
|
Chris@311
|
559 QStringList params;
|
Chris@311
|
560 params << "branch" << parentBranch;
|
Chris@311
|
561 m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params));
|
Chris@311
|
562 }
|
Chris@311
|
563
|
Chris@514
|
564 void MainWindow::hgCloseBranch()
|
Chris@514
|
565 {
|
Chris@514
|
566 QStringList params;
|
Chris@514
|
567
|
Chris@514
|
568 //!!! how to ensure this doesn't happen when uncommitted changes present?
|
Chris@514
|
569
|
Chris@514
|
570 QString cf(tr("Close branch"));
|
Chris@514
|
571 QString comment;
|
Chris@514
|
572
|
Chris@514
|
573 QString defaultWarning;
|
Chris@514
|
574
|
Chris@514
|
575 QString branchText;
|
Chris@514
|
576 if (m_currentBranch == "" || m_currentBranch == "default") {
|
Chris@514
|
577 branchText = tr("the default branch");
|
Chris@514
|
578 defaultWarning = tr("<p><b>Warning:</b> you are asking to close the default branch. This is not usually a good idea!</p>");
|
Chris@514
|
579 } else {
|
Chris@514
|
580 branchText = tr("branch \"%1\"").arg(m_currentBranch);
|
Chris@514
|
581 }
|
Chris@514
|
582
|
Chris@514
|
583 if (ConfirmCommentDialog::confirmAndGetLongComment
|
Chris@514
|
584 (this,
|
Chris@514
|
585 cf,
|
Chris@514
|
586 tr("<h3>%1</h3><p>%2%3").arg(cf)
|
Chris@518
|
587 .arg(tr("You are about to close %1.<p>This branch will be marked as closed and hidden from the history view.<p>You will still be able to see if it you select \"Show closed branches\" in the history view, and it will be reopened if you commit to it.<p>Please enter your comment for the commit log:").arg(branchText))
|
Chris@514
|
588 .arg(defaultWarning),
|
Chris@514
|
589 comment,
|
Chris@514
|
590 tr("C&lose branch"))) {
|
Chris@514
|
591
|
Chris@514
|
592 params << "commit" << "--message" << comment
|
Chris@514
|
593 << "--user" << getUserInfo() << "--close-branch";
|
Chris@514
|
594
|
Chris@514
|
595 m_runner->requestAction(HgAction(ACT_CLOSE_BRANCH, m_workFolderPath, params));
|
Chris@514
|
596 }
|
Chris@514
|
597 }
|
Chris@514
|
598
|
Chris@164
|
599 void MainWindow::hgTag(QString id)
|
jtkorhonen@34
|
600 {
|
Chris@109
|
601 QStringList params;
|
Chris@109
|
602 QString tag;
|
jtkorhonen@34
|
603
|
Chris@109
|
604 if (ConfirmCommentDialog::confirmAndGetShortComment
|
Chris@109
|
605 (this,
|
Chris@109
|
606 tr("Tag"),
|
Chris@109
|
607 tr("Enter tag:"),
|
Chris@193
|
608 tag,
|
Chris@365
|
609 tr("Add &Tag"))) {
|
Chris@164
|
610 if (!tag.isEmpty()) {//!!! do something better if it is empty
|
Chris@164
|
611
|
Chris@164
|
612 params << "tag" << "--user" << getUserInfo();
|
Chris@164
|
613 params << "--rev" << Changeset::hashOf(id) << filterTag(tag);
|
Chris@109
|
614
|
Chris@284
|
615 m_runner->requestAction(HgAction(ACT_TAG, m_workFolderPath, params));
|
jtkorhonen@34
|
616 }
|
jtkorhonen@34
|
617 }
|
jtkorhonen@34
|
618 }
|
jtkorhonen@34
|
619
|
Chris@417
|
620 void MainWindow::initHgIgnore()
|
jtkorhonen@34
|
621 {
|
Chris@284
|
622 if (!QDir(m_workFolderPath).exists()) return;
|
Chris@417
|
623 QString hgIgnorePath = m_workFolderPath + "/.hgignore";
|
Chris@417
|
624
|
Chris@249
|
625 QFile f(hgIgnorePath);
|
Chris@249
|
626 if (!f.exists()) {
|
Chris@249
|
627 f.open(QFile::WriteOnly);
|
Chris@249
|
628 QTextStream *ts = new QTextStream(&f);
|
Chris@249
|
629 *ts << "syntax: glob\n";
|
Chris@249
|
630 delete ts;
|
Chris@249
|
631 f.close();
|
Chris@249
|
632 }
|
Chris@417
|
633 }
|
Chris@417
|
634
|
Chris@425
|
635 void MainWindow::hgIgnore()
|
Chris@425
|
636 {
|
Chris@425
|
637 // hgExplorer permitted adding "all" files -- I'm not sure
|
Chris@425
|
638 // that one is a good idea, let's require the user to select
|
Chris@425
|
639
|
Chris@425
|
640 hgIgnoreFiles(m_hgTabs->getSelectedAddableFiles());
|
Chris@425
|
641 }
|
Chris@425
|
642
|
Chris@417
|
643 void MainWindow::hgEditIgnore()
|
Chris@417
|
644 {
|
Chris@417
|
645 if (!QDir(m_workFolderPath).exists()) return;
|
Chris@417
|
646
|
Chris@417
|
647 initHgIgnore();
|
Chris@417
|
648
|
Chris@417
|
649 QString hgIgnorePath = m_workFolderPath + "/.hgignore";
|
Chris@476
|
650
|
Chris@476
|
651 QFile f(hgIgnorePath);
|
Chris@476
|
652 if (!f.exists()) return; // shouldn't happen (after initHgIgnore called)
|
Chris@476
|
653
|
Chris@476
|
654 if (!f.open(QFile::ReadOnly)) return;
|
Chris@476
|
655 QTextStream sin(&f);
|
Chris@476
|
656 QString all = sin.readAll();
|
Chris@476
|
657 f.close();
|
Chris@476
|
658
|
Chris@476
|
659 QDialog d;
|
Chris@476
|
660 QGridLayout layout;
|
Chris@476
|
661 d.setLayout(&layout);
|
Chris@476
|
662
|
Chris@476
|
663 int row = 0;
|
Chris@476
|
664 layout.addWidget(new QLabel(tr("<qt><h3>Ignored File Patterns</h3></qt>")), row++, 0);//!!! todo: link to Hg docs?
|
Chris@476
|
665
|
Chris@476
|
666 QTextEdit ed;
|
Chris@476
|
667 ed.setAcceptRichText(false);
|
Chris@476
|
668 ed.setLineWrapMode(QTextEdit::NoWrap);
|
Chris@476
|
669 layout.setRowStretch(row, 10);
|
Chris@476
|
670 layout.addWidget(&ed, row++, 0);
|
Chris@179
|
671
|
Chris@476
|
672 QDialogButtonBox bb(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
|
Chris@476
|
673 connect(bb.button(QDialogButtonBox::Save), SIGNAL(clicked()),
|
Chris@476
|
674 &d, SLOT(accept()));
|
Chris@476
|
675 connect(bb.button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
|
Chris@476
|
676 &d, SLOT(reject()));
|
Chris@476
|
677 layout.addWidget(&bb, row++, 0);
|
Chris@476
|
678
|
Chris@476
|
679 ed.document()->setPlainText(all);
|
Chris@476
|
680
|
Chris@476
|
681 d.resize(QSize(300, 400));
|
Chris@476
|
682
|
Chris@476
|
683 if (d.exec() == QDialog::Accepted) {
|
Chris@476
|
684 if (!f.open(QFile::WriteOnly | QFile::Truncate)) {
|
Chris@476
|
685 QMessageBox::critical(this, tr("Write failed"),
|
Chris@476
|
686 tr("Failed to open file %1 for writing")
|
Chris@476
|
687 .arg(f.fileName()));
|
Chris@476
|
688 return;
|
Chris@476
|
689 }
|
Chris@476
|
690 QTextStream sout(&f);
|
Chris@476
|
691 sout << ed.document()->toPlainText();
|
Chris@476
|
692 f.close();
|
Chris@179
|
693 }
|
Chris@179
|
694 }
|
Chris@179
|
695
|
Chris@421
|
696 static QString regexEscape(QString filename)
|
Chris@421
|
697 {
|
Chris@421
|
698 return filename
|
Chris@421
|
699 .replace(".", "\\.")
|
Chris@421
|
700 .replace("[", "\\[")
|
Chris@421
|
701 .replace("]", "\\]")
|
Chris@421
|
702 .replace("(", "\\(")
|
Chris@421
|
703 .replace(")", "\\)")
|
Chris@421
|
704 .replace("?", "\\?");
|
Chris@421
|
705 }
|
Chris@421
|
706
|
Chris@326
|
707 void MainWindow::hgIgnoreFiles(QStringList files)
|
Chris@326
|
708 {
|
Chris@417
|
709 if (!QDir(m_workFolderPath).exists() || files.empty()) return;
|
Chris@413
|
710
|
Chris@413
|
711 // we should:
|
Chris@413
|
712 //
|
Chris@413
|
713 // * show the user the list of file names selected
|
Chris@413
|
714 //
|
Chris@413
|
715 // * offer a choice (depending on the files selected?)
|
Chris@413
|
716 //
|
Chris@413
|
717 // - ignore only these files
|
Chris@413
|
718 //
|
Chris@413
|
719 // - ignore files with these names, in any subdirectories?
|
Chris@413
|
720 //
|
Chris@413
|
721 // - ignore all files with this extension (if they have a common
|
Chris@413
|
722 // extension)?
|
Chris@413
|
723 //
|
Chris@413
|
724 // - ignore all files with these extensions (if they have any
|
Chris@413
|
725 // extensions?)
|
Chris@413
|
726
|
Chris@414
|
727 DEBUG << "MainWindow::hgIgnoreFiles: File names are:" << endl;
|
Chris@414
|
728 foreach (QString file, files) DEBUG << file << endl;
|
Chris@414
|
729
|
Chris@414
|
730 QSet<QString> suffixes;
|
Chris@414
|
731 foreach (QString file, files) {
|
Chris@414
|
732 QString s = QFileInfo(file).suffix();
|
Chris@414
|
733 if (s != "") suffixes.insert(s);
|
Chris@414
|
734 }
|
Chris@414
|
735
|
Chris@419
|
736 QString directory;
|
Chris@429
|
737 int dirCount = 0;
|
Chris@419
|
738 foreach (QString file, files) {
|
Chris@419
|
739 QString d = QFileInfo(file).path();
|
Chris@419
|
740 if (d != directory) {
|
Chris@419
|
741 ++dirCount;
|
Chris@419
|
742 directory = d;
|
Chris@419
|
743 }
|
Chris@419
|
744 }
|
Chris@421
|
745 if (dirCount != 1 || directory == ".") directory = "";
|
Chris@419
|
746
|
Chris@414
|
747 HgIgnoreDialog::IgnoreType itype =
|
Chris@415
|
748 HgIgnoreDialog::confirmIgnore
|
Chris@419
|
749 (this, files, QStringList::fromSet(suffixes), directory);
|
Chris@414
|
750
|
Chris@416
|
751 DEBUG << "hgIgnoreFiles: Ignore type is " << itype << endl;
|
Chris@417
|
752
|
Chris@421
|
753 if (itype == HgIgnoreDialog::IgnoreNothing) return;
|
Chris@421
|
754
|
Chris@417
|
755 // Now, .hgignore can be switched from regex to glob syntax
|
Chris@417
|
756 // part-way through -- and glob is much simpler for us, so we
|
Chris@417
|
757 // should do that if it's in regex mode at the end of the file.
|
Chris@417
|
758
|
Chris@417
|
759 initHgIgnore();
|
Chris@417
|
760
|
Chris@417
|
761 QString hgIgnorePath = m_workFolderPath + "/.hgignore";
|
Chris@417
|
762
|
Chris@417
|
763 // hgignore file should now exist (initHgIgnore should have
|
Chris@417
|
764 // created it if it didn't). Check for glob status first
|
Chris@417
|
765
|
Chris@417
|
766 QFile f(hgIgnorePath);
|
Chris@417
|
767 if (!f.exists()) {
|
Chris@417
|
768 std::cerr << "MainWindow::ignoreFiles: Internal error: .hgignore file not found (even though we were supposed to have created it)" << std::endl;
|
Chris@417
|
769 return;
|
Chris@417
|
770 }
|
Chris@417
|
771
|
Chris@417
|
772 f.open(QFile::ReadOnly);
|
Chris@417
|
773 bool glob = false;
|
Chris@606
|
774 bool cr = false; // whether the last line examined ended with a CR
|
Chris@417
|
775 while (!f.atEnd()) {
|
Chris@417
|
776 QByteArray ba = f.readLine();
|
Chris@606
|
777 QString s = QString::fromLocal8Bit(ba);
|
Chris@606
|
778 cr = (s.endsWith('\n') || s.endsWith('\r'));
|
Chris@606
|
779 s = s.trimmed();
|
Chris@417
|
780 if (s.startsWith("syntax:")) {
|
Chris@417
|
781 if (s.endsWith("glob")) {
|
Chris@417
|
782 glob = true;
|
Chris@417
|
783 } else {
|
Chris@417
|
784 glob = false;
|
Chris@417
|
785 }
|
Chris@417
|
786 }
|
Chris@417
|
787 }
|
Chris@417
|
788 f.close();
|
Chris@417
|
789
|
Chris@417
|
790 f.open(QFile::Append);
|
Chris@417
|
791 QTextStream out(&f);
|
Chris@417
|
792
|
Chris@606
|
793 if (!cr) {
|
Chris@606
|
794 out << endl;
|
Chris@606
|
795 }
|
Chris@606
|
796
|
Chris@417
|
797 if (!glob) {
|
Chris@417
|
798 out << "syntax: glob" << endl;
|
Chris@417
|
799 }
|
Chris@417
|
800
|
Chris@421
|
801 QString info = "<qt><h3>" + tr("Ignored files") + "</h3><p>";
|
Chris@421
|
802 info += tr("The following lines have been added to the .hgignore file for this working copy:");
|
Chris@421
|
803 info += "</p><code>";
|
Chris@421
|
804
|
Chris@421
|
805 QStringList args;
|
Chris@417
|
806 if (itype == HgIgnoreDialog::IgnoreAllFilesOfGivenSuffixes) {
|
Chris@421
|
807 args = QStringList::fromSet(suffixes);
|
Chris@421
|
808 } else if (itype == HgIgnoreDialog::IgnoreGivenFilesOnly) {
|
Chris@421
|
809 args = files;
|
Chris@421
|
810 } else if (itype == HgIgnoreDialog::IgnoreAllFilesOfGivenNames) {
|
Chris@421
|
811 QSet<QString> names;
|
Chris@421
|
812 foreach (QString f, files) {
|
Chris@421
|
813 names << QFileInfo(f).fileName();
|
Chris@417
|
814 }
|
Chris@421
|
815 args = QStringList::fromSet(names);
|
Chris@421
|
816 } else if (itype == HgIgnoreDialog::IgnoreWholeDirectory) {
|
Chris@421
|
817 args << directory;
|
Chris@421
|
818 }
|
Chris@421
|
819
|
Chris@421
|
820 bool first = true;
|
Chris@421
|
821
|
Chris@421
|
822 foreach (QString a, args) {
|
Chris@421
|
823 QString line;
|
Chris@421
|
824 if (itype == HgIgnoreDialog::IgnoreAllFilesOfGivenSuffixes) {
|
Chris@421
|
825 line = "*." + a;
|
Chris@421
|
826 } else if (itype == HgIgnoreDialog::IgnoreGivenFilesOnly) {
|
Chris@421
|
827 // Doesn't seem to be possible to do this with a glob,
|
Chris@421
|
828 // because the glob is always unanchored and there is no
|
Chris@421
|
829 // equivalent of ^ to anchor it
|
chris@423
|
830 line = "re:^" + regexEscape(a) + "$";
|
Chris@421
|
831 } else if (itype == HgIgnoreDialog::IgnoreAllFilesOfGivenNames) {
|
Chris@421
|
832 line = a;
|
Chris@421
|
833 } else if (itype == HgIgnoreDialog::IgnoreWholeDirectory) {
|
Chris@421
|
834 line = "re:^" + regexEscape(a) + "/";
|
Chris@418
|
835 }
|
Chris@421
|
836 if (line != "") {
|
Chris@421
|
837 out << line << endl;
|
Chris@421
|
838 if (!first) info += "<br>";
|
Chris@421
|
839 first = false;
|
Chris@421
|
840 info += xmlEncode(line);
|
Chris@417
|
841 }
|
Chris@417
|
842 }
|
Chris@417
|
843
|
Chris@419
|
844 f.close();
|
Chris@419
|
845
|
Chris@421
|
846 info += "</code></qt>";
|
Chris@421
|
847
|
Chris@421
|
848 QMessageBox::information(this, tr("Ignored files"),
|
Chris@421
|
849 info);
|
Chris@421
|
850
|
Chris@417
|
851 hgRefresh();
|
Chris@326
|
852 }
|
Chris@326
|
853
|
Chris@326
|
854 void MainWindow::hgUnIgnoreFiles(QStringList files)
|
Chris@326
|
855 {
|
Chris@421
|
856 // Not implemented: edit the .hgignore instead
|
Chris@421
|
857 hgEditIgnore();
|
Chris@326
|
858 }
|
Chris@326
|
859
|
Chris@239
|
860 QString MainWindow::getDiffBinaryName()
|
Chris@179
|
861 {
|
Chris@179
|
862 QSettings settings;
|
Chris@179
|
863 settings.beginGroup("Locations");
|
Chris@239
|
864 return settings.value("extdiffbinary", "").toString();
|
Chris@179
|
865 }
|
Chris@179
|
866
|
Chris@239
|
867 QString MainWindow::getMergeBinaryName()
|
Chris@179
|
868 {
|
Chris@179
|
869 QSettings settings;
|
Chris@179
|
870 settings.beginGroup("Locations");
|
Chris@239
|
871 return settings.value("mergebinary", "").toString();
|
Chris@179
|
872 }
|
Chris@179
|
873
|
Chris@168
|
874 void MainWindow::hgShowSummary()
|
Chris@168
|
875 {
|
Chris@168
|
876 QStringList params;
|
Chris@168
|
877
|
Chris@168
|
878 params << "diff" << "--stat";
|
Chris@168
|
879
|
Chris@288
|
880 m_runner->requestAction(HgAction(ACT_UNCOMMITTED_SUMMARY, m_workFolderPath, params));
|
Chris@168
|
881 }
|
Chris@168
|
882
|
jtkorhonen@0
|
883 void MainWindow::hgFolderDiff()
|
jtkorhonen@0
|
884 {
|
Chris@326
|
885 hgDiffFiles(QStringList());
|
Chris@326
|
886 }
|
Chris@326
|
887
|
Chris@326
|
888 void MainWindow::hgDiffFiles(QStringList files)
|
Chris@326
|
889 {
|
Chris@239
|
890 QString diff = getDiffBinaryName();
|
Chris@179
|
891 if (diff == "") return;
|
Chris@112
|
892
|
Chris@109
|
893 QStringList params;
|
jtkorhonen@0
|
894
|
Chris@112
|
895 // Diff parent against working folder (folder diff)
|
Chris@112
|
896
|
Chris@148
|
897 params << "--config" << "extensions.extdiff=" << "extdiff";
|
Chris@179
|
898 params << "--program" << diff;
|
Chris@109
|
899
|
Chris@331
|
900 params << "--" << files; // may be none: whole dir
|
Chris@273
|
901
|
Chris@284
|
902 m_runner->requestAction(HgAction(ACT_FOLDERDIFF, m_workFolderPath, params));
|
jtkorhonen@0
|
903 }
|
jtkorhonen@0
|
904
|
Chris@148
|
905 void MainWindow::hgDiffToCurrent(QString id)
|
jtkorhonen@0
|
906 {
|
Chris@239
|
907 QString diff = getDiffBinaryName();
|
Chris@179
|
908 if (diff == "") return;
|
Chris@163
|
909
|
Chris@148
|
910 QStringList params;
|
jtkorhonen@0
|
911
|
Chris@148
|
912 // Diff given revision against working folder
|
jtkorhonen@0
|
913
|
Chris@148
|
914 params << "--config" << "extensions.extdiff=" << "extdiff";
|
Chris@179
|
915 params << "--program" << diff;
|
Chris@153
|
916 params << "--rev" << Changeset::hashOf(id);
|
Chris@148
|
917
|
Chris@284
|
918 m_runner->requestAction(HgAction(ACT_FOLDERDIFF, m_workFolderPath, params));
|
jtkorhonen@0
|
919 }
|
jtkorhonen@0
|
920
|
Chris@148
|
921 void MainWindow::hgDiffToParent(QString child, QString parent)
|
Chris@148
|
922 {
|
Chris@239
|
923 QString diff = getDiffBinaryName();
|
Chris@179
|
924 if (diff == "") return;
|
Chris@163
|
925
|
Chris@148
|
926 QStringList params;
|
Chris@148
|
927
|
Chris@281
|
928 // Diff given revision against parent revision
|
Chris@148
|
929
|
Chris@148
|
930 params << "--config" << "extensions.extdiff=" << "extdiff";
|
Chris@179
|
931 params << "--program" << diff;
|
Chris@153
|
932 params << "--rev" << Changeset::hashOf(parent)
|
Chris@153
|
933 << "--rev" << Changeset::hashOf(child);
|
Chris@148
|
934
|
Chris@284
|
935 m_runner->requestAction(HgAction(ACT_CHGSETDIFF, m_workFolderPath, params));
|
Chris@273
|
936 }
|
Chris@326
|
937
|
Chris@273
|
938
|
Chris@289
|
939 void MainWindow::hgShowSummaryFor(Changeset *cs)
|
Chris@288
|
940 {
|
Chris@288
|
941 QStringList params;
|
Chris@288
|
942
|
Chris@289
|
943 // This will pick a default parent if there is more than one
|
Chris@289
|
944 // (whereas with diff we need to supply one). But it does need a
|
Chris@289
|
945 // bit more parsing
|
Chris@289
|
946 params << "log" << "--stat" << "--rev" << Changeset::hashOf(cs->id());
|
Chris@289
|
947
|
Chris@289
|
948 m_runner->requestAction(HgAction(ACT_DIFF_SUMMARY, m_workFolderPath,
|
Chris@289
|
949 params, cs));
|
Chris@148
|
950 }
|
Chris@148
|
951
|
jtkorhonen@0
|
952
|
jtkorhonen@0
|
953 void MainWindow::hgUpdate()
|
jtkorhonen@0
|
954 {
|
Chris@109
|
955 QStringList params;
|
jtkorhonen@0
|
956
|
Chris@109
|
957 params << "update";
|
Chris@109
|
958
|
Chris@284
|
959 m_runner->requestAction(HgAction(ACT_UPDATE, m_workFolderPath, params));
|
jtkorhonen@0
|
960 }
|
jtkorhonen@0
|
961
|
jtkorhonen@0
|
962
|
Chris@148
|
963 void MainWindow::hgUpdateToRev(QString id)
|
jtkorhonen@0
|
964 {
|
Chris@148
|
965 QStringList params;
|
jtkorhonen@0
|
966
|
Chris@153
|
967 params << "update" << "--rev" << Changeset::hashOf(id) << "--check";
|
jtkorhonen@0
|
968
|
Chris@284
|
969 m_runner->requestAction(HgAction(ACT_UPDATE, m_workFolderPath, params));
|
jtkorhonen@0
|
970 }
|
jtkorhonen@0
|
971
|
jtkorhonen@0
|
972
|
jtkorhonen@0
|
973 void MainWindow::hgRevert()
|
jtkorhonen@0
|
974 {
|
Chris@326
|
975 hgRevertFiles(QStringList());
|
Chris@326
|
976 }
|
Chris@326
|
977
|
Chris@326
|
978 void MainWindow::hgRevertFiles(QStringList files)
|
Chris@326
|
979 {
|
Chris@109
|
980 QStringList params;
|
Chris@109
|
981 QString comment;
|
Chris@237
|
982 bool all = false;
|
Chris@98
|
983
|
Chris@284
|
984 QStringList allFiles = m_hgTabs->getAllRevertableFiles();
|
Chris@237
|
985 if (files.empty() || files == allFiles) {
|
Chris@237
|
986 files = allFiles;
|
Chris@237
|
987 all = true;
|
Chris@237
|
988 }
|
Chris@237
|
989
|
Chris@237
|
990 QString subsetNote;
|
Chris@237
|
991 if (!all) {
|
Chris@237
|
992 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
|
993 }
|
Chris@155
|
994
|
Chris@155
|
995 QString rf(tr("Revert files"));
|
Chris@237
|
996
|
Chris@237
|
997 // Set up params before asking for confirmation, because there is
|
Chris@237
|
998 // a failure case here that we would need to report on early
|
Chris@237
|
999
|
Chris@284
|
1000 DEBUG << "hgRevert: m_justMerged = " << m_justMerged << ", m_mergeTargetRevision = " << m_mergeTargetRevision << endl;
|
Chris@273
|
1001
|
Chris@284
|
1002 if (m_justMerged) {
|
Chris@237
|
1003
|
Chris@237
|
1004 // This is a little fiddly. The proper way to "revert" the
|
Chris@237
|
1005 // whole of an uncommitted merge is with "hg update --clean ."
|
Chris@237
|
1006 // But if the user has selected only some files, we're sort of
|
Chris@237
|
1007 // promising to revert only those, which means we need to
|
Chris@237
|
1008 // specify which parent to revert to. We can only do that if
|
Chris@237
|
1009 // we have a record of it, which we do if you just did the
|
Chris@237
|
1010 // merge from within easyhg but don't if you've exited and
|
Chris@237
|
1011 // restarted, or changed repository, since then. Hmmm.
|
Chris@237
|
1012
|
Chris@237
|
1013 if (all) {
|
Chris@237
|
1014 params << "update" << "--clean" << ".";
|
Chris@237
|
1015 } else {
|
Chris@284
|
1016 if (m_mergeTargetRevision != "") {
|
Chris@237
|
1017 params << "revert" << "--rev"
|
Chris@284
|
1018 << Changeset::hashOf(m_mergeTargetRevision)
|
Chris@237
|
1019 << "--" << files;
|
Chris@237
|
1020 } else {
|
Chris@237
|
1021 QMessageBox::information
|
Chris@237
|
1022 (this, tr("Unable to revert"),
|
Chris@237
|
1023 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
|
1024 return;
|
Chris@237
|
1025 }
|
Chris@237
|
1026 }
|
Chris@237
|
1027 } else {
|
Chris@237
|
1028 params << "revert" << "--" << files;
|
Chris@237
|
1029 }
|
Chris@237
|
1030
|
Chris@109
|
1031 if (ConfirmCommentDialog::confirmDangerousFilesAction
|
Chris@109
|
1032 (this,
|
Chris@155
|
1033 rf,
|
Chris@237
|
1034 tr("<h3>%1</h3><p>%2%3").arg(rf)
|
Chris@237
|
1035 .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
|
1036 .arg(subsetNote),
|
Chris@237
|
1037 tr("<h3>%1</h3><p>%2%3").arg(rf)
|
Chris@237
|
1038 .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
|
1039 .arg(subsetNote),
|
Chris@193
|
1040 files,
|
Chris@365
|
1041 tr("Re&vert"))) {
|
Chris@163
|
1042
|
Chris@284
|
1043 m_lastRevertedFiles = files;
|
Chris@109
|
1044
|
Chris@284
|
1045 m_runner->requestAction(HgAction(ACT_REVERT, m_workFolderPath, params));
|
jtkorhonen@0
|
1046 }
|
jtkorhonen@0
|
1047 }
|
jtkorhonen@0
|
1048
|
Chris@163
|
1049
|
Chris@361
|
1050 void MainWindow::hgRenameFiles(QStringList files)
|
Chris@361
|
1051 {
|
Chris@361
|
1052 QString renameTo;
|
Chris@361
|
1053
|
Chris@361
|
1054 QString file;
|
Chris@361
|
1055 if (files.empty()) return;
|
Chris@361
|
1056 file = files[0];
|
Chris@361
|
1057
|
Chris@361
|
1058 if (ConfirmCommentDialog::confirmAndGetShortComment
|
Chris@361
|
1059 (this,
|
Chris@361
|
1060 tr("Rename"),
|
Chris@361
|
1061 tr("Rename <code>%1</code> to:").arg(xmlEncode(file)),
|
Chris@361
|
1062 renameTo,
|
Chris@365
|
1063 tr("Re&name"))) {
|
Chris@361
|
1064
|
Chris@361
|
1065 if (renameTo != "" && renameTo != file) {
|
Chris@361
|
1066
|
Chris@361
|
1067 QStringList params;
|
Chris@361
|
1068
|
Chris@361
|
1069 params << "rename" << "--" << file << renameTo;
|
Chris@361
|
1070
|
Chris@361
|
1071 m_runner->requestAction(HgAction(ACT_RENAME_FILE, m_workFolderPath, params));
|
Chris@361
|
1072 }
|
Chris@361
|
1073 }
|
Chris@361
|
1074 }
|
Chris@361
|
1075
|
Chris@361
|
1076
|
Chris@361
|
1077 void MainWindow::hgCopyFiles(QStringList files)
|
Chris@361
|
1078 {
|
Chris@361
|
1079 QString copyTo;
|
Chris@361
|
1080
|
Chris@361
|
1081 QString file;
|
Chris@361
|
1082 if (files.empty()) return;
|
Chris@361
|
1083 file = files[0];
|
Chris@361
|
1084
|
Chris@361
|
1085 if (ConfirmCommentDialog::confirmAndGetShortComment
|
Chris@361
|
1086 (this,
|
Chris@361
|
1087 tr("Copy"),
|
Chris@361
|
1088 tr("Copy <code>%1</code> to:").arg(xmlEncode(file)),
|
Chris@361
|
1089 copyTo,
|
Chris@365
|
1090 tr("Co&py"))) {
|
Chris@361
|
1091
|
Chris@361
|
1092 if (copyTo != "" && copyTo != file) {
|
Chris@361
|
1093
|
Chris@361
|
1094 QStringList params;
|
Chris@361
|
1095
|
Chris@361
|
1096 params << "copy" << "--" << file << copyTo;
|
Chris@361
|
1097
|
Chris@361
|
1098 m_runner->requestAction(HgAction(ACT_COPY_FILE, m_workFolderPath, params));
|
Chris@361
|
1099 }
|
Chris@361
|
1100 }
|
Chris@361
|
1101 }
|
Chris@361
|
1102
|
Chris@361
|
1103
|
Chris@326
|
1104 void MainWindow::hgMarkFilesResolved(QStringList files)
|
Chris@163
|
1105 {
|
Chris@163
|
1106 QStringList params;
|
Chris@163
|
1107
|
Chris@163
|
1108 params << "resolve" << "--mark";
|
Chris@163
|
1109
|
Chris@163
|
1110 if (files.empty()) {
|
Chris@163
|
1111 params << "--all";
|
Chris@163
|
1112 } else {
|
Chris@164
|
1113 params << "--" << files;
|
Chris@163
|
1114 }
|
Chris@163
|
1115
|
Chris@284
|
1116 m_runner->requestAction(HgAction(ACT_RESOLVE_MARK, m_workFolderPath, params));
|
Chris@163
|
1117 }
|
Chris@163
|
1118
|
Chris@163
|
1119
|
Chris@326
|
1120 void MainWindow::hgRedoMerge()
|
Chris@326
|
1121 {
|
Chris@326
|
1122 hgRedoFileMerges(QStringList());
|
Chris@326
|
1123 }
|
Chris@326
|
1124
|
Chris@326
|
1125
|
Chris@326
|
1126 void MainWindow::hgRedoFileMerges(QStringList files)
|
jtkorhonen@33
|
1127 {
|
Chris@109
|
1128 QStringList params;
|
jtkorhonen@33
|
1129
|
Chris@163
|
1130 params << "resolve";
|
Chris@163
|
1131
|
Chris@239
|
1132 QString merge = getMergeBinaryName();
|
Chris@179
|
1133 if (merge != "") {
|
Chris@179
|
1134 params << "--tool" << merge;
|
Chris@163
|
1135 }
|
Chris@163
|
1136
|
Chris@163
|
1137 if (files.empty()) {
|
Chris@163
|
1138 params << "--all";
|
Chris@163
|
1139 } else {
|
Chris@164
|
1140 params << "--" << files;
|
Chris@163
|
1141 }
|
Chris@163
|
1142
|
Chris@284
|
1143 if (m_currentParents.size() == 1) {
|
Chris@284
|
1144 m_mergeTargetRevision = m_currentParents[0]->id();
|
Chris@237
|
1145 }
|
Chris@237
|
1146
|
Chris@284
|
1147 m_runner->requestAction(HgAction(ACT_RETRY_MERGE, m_workFolderPath, params));
|
Chris@273
|
1148
|
Chris@284
|
1149 m_mergeCommitComment = tr("Merge");
|
jtkorhonen@33
|
1150 }
|
Chris@326
|
1151
|
jtkorhonen@33
|
1152
|
jtkorhonen@0
|
1153 void MainWindow::hgMerge()
|
jtkorhonen@0
|
1154 {
|
Chris@284
|
1155 if (m_hgTabs->canResolve()) {
|
Chris@326
|
1156 hgRedoMerge();
|
Chris@163
|
1157 return;
|
Chris@163
|
1158 }
|
Chris@163
|
1159
|
Chris@109
|
1160 QStringList params;
|
jtkorhonen@0
|
1161
|
Chris@109
|
1162 params << "merge";
|
Chris@163
|
1163
|
Chris@239
|
1164 QString merge = getMergeBinaryName();
|
Chris@179
|
1165 if (merge != "") {
|
Chris@179
|
1166 params << "--tool" << merge;
|
Chris@163
|
1167 }
|
Chris@163
|
1168
|
Chris@284
|
1169 if (m_currentParents.size() == 1) {
|
Chris@284
|
1170 m_mergeTargetRevision = m_currentParents[0]->id();
|
Chris@163
|
1171 }
|
Chris@163
|
1172
|
Chris@284
|
1173 m_runner->requestAction(HgAction(ACT_MERGE, m_workFolderPath, params));
|
Chris@273
|
1174
|
Chris@284
|
1175 m_mergeCommitComment = tr("Merge");
|
jtkorhonen@0
|
1176 }
|
jtkorhonen@0
|
1177
|
jtkorhonen@0
|
1178
|
Chris@148
|
1179 void MainWindow::hgMergeFrom(QString id)
|
Chris@148
|
1180 {
|
Chris@148
|
1181 QStringList params;
|
Chris@148
|
1182
|
Chris@148
|
1183 params << "merge";
|
Chris@153
|
1184 params << "--rev" << Changeset::hashOf(id);
|
Chris@163
|
1185
|
Chris@239
|
1186 QString merge = getMergeBinaryName();
|
Chris@179
|
1187 if (merge != "") {
|
Chris@179
|
1188 params << "--tool" << merge;
|
Chris@163
|
1189 }
|
Chris@148
|
1190
|
Chris@284
|
1191 if (m_currentParents.size() == 1) {
|
Chris@284
|
1192 m_mergeTargetRevision = m_currentParents[0]->id();
|
Chris@237
|
1193 }
|
Chris@237
|
1194
|
Chris@284
|
1195 m_runner->requestAction(HgAction(ACT_MERGE, m_workFolderPath, params));
|
Chris@273
|
1196
|
Chris@284
|
1197 m_mergeCommitComment = "";
|
Chris@273
|
1198
|
Chris@284
|
1199 foreach (Changeset *cs, m_currentHeads) {
|
Chris@284
|
1200 if (cs->id() == id && !cs->isOnBranch(m_currentBranch)) {
|
Chris@157
|
1201 if (cs->branch() == "" || cs->branch() == "default") {
|
Chris@284
|
1202 m_mergeCommitComment = tr("Merge from the default branch");
|
Chris@157
|
1203 } else {
|
Chris@284
|
1204 m_mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
|
Chris@157
|
1205 }
|
Chris@157
|
1206 }
|
Chris@157
|
1207 }
|
Chris@157
|
1208
|
Chris@284
|
1209 if (m_mergeCommitComment == "") {
|
Chris@284
|
1210 m_mergeCommitComment = tr("Merge from %1").arg(id);
|
Chris@157
|
1211 }
|
Chris@148
|
1212 }
|
Chris@148
|
1213
|
Chris@148
|
1214
|
jtkorhonen@0
|
1215 void MainWindow::hgCloneFromRemote()
|
jtkorhonen@0
|
1216 {
|
Chris@109
|
1217 QStringList params;
|
jtkorhonen@0
|
1218
|
Chris@284
|
1219 if (!QDir(m_workFolderPath).exists()) {
|
Chris@284
|
1220 if (!QDir().mkpath(m_workFolderPath)) {
|
Chris@109
|
1221 DEBUG << "hgCloneFromRemote: Failed to create target path "
|
Chris@284
|
1222 << m_workFolderPath << endl;
|
Chris@607
|
1223 QMessageBox::critical
|
Chris@607
|
1224 (this, tr("Could not create target folder"),
|
Chris@607
|
1225 tr("<qt><b>Could not create target folder</b><br><br>The local target folder \"%1\" does not exist<br>and could not be created.</qt>").arg(xmlEncode(m_workFolderPath)));
|
Chris@608
|
1226 m_workFolderPath = "";
|
Chris@109
|
1227 return;
|
Chris@104
|
1228 }
|
Chris@109
|
1229 }
|
Chris@104
|
1230
|
Chris@284
|
1231 params << "clone" << m_remoteRepoPath << m_workFolderPath;
|
Chris@109
|
1232
|
Chris@287
|
1233 updateWorkFolderAndRepoNames();
|
Chris@284
|
1234 m_hgTabs->updateWorkFolderFileList("");
|
Chris@608
|
1235 m_hgTabs->clearAll();
|
Chris@273
|
1236
|
Chris@284
|
1237 m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params));
|
jtkorhonen@0
|
1238 }
|
jtkorhonen@0
|
1239
|
jtkorhonen@0
|
1240 void MainWindow::hgInit()
|
jtkorhonen@0
|
1241 {
|
Chris@109
|
1242 QStringList params;
|
jtkorhonen@0
|
1243
|
Chris@109
|
1244 params << "init";
|
Chris@284
|
1245 params << m_workFolderPath;
|
Chris@273
|
1246
|
Chris@284
|
1247 m_runner->requestAction(HgAction(ACT_INIT, m_workFolderPath, params));
|
jtkorhonen@0
|
1248 }
|
jtkorhonen@0
|
1249
|
jtkorhonen@0
|
1250 void MainWindow::hgIncoming()
|
jtkorhonen@0
|
1251 {
|
Chris@109
|
1252 QStringList params;
|
jtkorhonen@0
|
1253
|
Chris@284
|
1254 params << "incoming" << "--newest-first" << m_remoteRepoPath;
|
Chris@125
|
1255 params << "--template" << Changeset::getLogTemplate();
|
jtkorhonen@0
|
1256
|
Chris@284
|
1257 m_runner->requestAction(HgAction(ACT_INCOMING, m_workFolderPath, params));
|
jtkorhonen@0
|
1258 }
|
jtkorhonen@0
|
1259
|
jtkorhonen@0
|
1260 void MainWindow::hgPull()
|
jtkorhonen@0
|
1261 {
|
Chris@193
|
1262 if (ConfirmCommentDialog::confirm
|
Chris@126
|
1263 (this, tr("Confirm pull"),
|
Chris@299
|
1264 tr("<qt><h3>Pull from remote repository?</h3></qt>"),
|
Chris@299
|
1265 tr("<qt><p>You are about to pull changes from the remote repository at <code>%1</code>.</p></qt>").arg(xmlEncode(m_remoteRepoPath)),
|
Chris@365
|
1266 tr("&Pull"))) {
|
jtkorhonen@0
|
1267
|
Chris@126
|
1268 QStringList params;
|
Chris@284
|
1269 params << "pull" << m_remoteRepoPath;
|
Chris@284
|
1270 m_runner->requestAction(HgAction(ACT_PULL, m_workFolderPath, params));
|
Chris@126
|
1271 }
|
jtkorhonen@0
|
1272 }
|
jtkorhonen@0
|
1273
|
jtkorhonen@0
|
1274 void MainWindow::hgPush()
|
jtkorhonen@0
|
1275 {
|
Chris@363
|
1276 if (m_remoteRepoPath.isEmpty()) {
|
Chris@363
|
1277 changeRemoteRepo(true);
|
Chris@363
|
1278 if (m_remoteRepoPath.isEmpty()) return;
|
Chris@363
|
1279 }
|
Chris@363
|
1280
|
Chris@356
|
1281 QString uncommittedNote;
|
Chris@356
|
1282 if (m_hgTabs->canCommit()) {
|
Chris@356
|
1283 uncommittedNote = tr("<p><b>Note:</b> You have uncommitted changes. If you want to push these changes to the remote repository, you need to commit them first.");
|
Chris@356
|
1284 }
|
Chris@356
|
1285
|
Chris@193
|
1286 if (ConfirmCommentDialog::confirm
|
Chris@126
|
1287 (this, tr("Confirm push"),
|
Chris@299
|
1288 tr("<qt><h3>Push to remote repository?</h3></qt>"),
|
Chris@356
|
1289 tr("<qt><p>You are about to push your commits to the remote repository at <code>%1</code>.</p>%2</qt>").arg(xmlEncode(m_remoteRepoPath)).arg(uncommittedNote),
|
Chris@365
|
1290 tr("&Push"))) {
|
jtkorhonen@0
|
1291
|
Chris@126
|
1292 QStringList params;
|
Chris@284
|
1293 params << "push" << "--new-branch" << m_remoteRepoPath;
|
Chris@284
|
1294 m_runner->requestAction(HgAction(ACT_PUSH, m_workFolderPath, params));
|
Chris@126
|
1295 }
|
jtkorhonen@0
|
1296 }
|
jtkorhonen@0
|
1297
|
Chris@182
|
1298 QStringList MainWindow::listAllUpIpV4Addresses()
|
jtkorhonen@26
|
1299 {
|
Chris@182
|
1300 QStringList ret;
|
jtkorhonen@26
|
1301 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
|
jtkorhonen@26
|
1302
|
Chris@182
|
1303 for (int i = 0; i < ifaces.count(); i++) {
|
jtkorhonen@26
|
1304 QNetworkInterface iface = ifaces.at(i);
|
Chris@182
|
1305 if (iface.flags().testFlag(QNetworkInterface::IsUp)
|
Chris@182
|
1306 && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
|
Chris@182
|
1307 for (int j=0; j<iface.addressEntries().count(); j++) {
|
jtkorhonen@28
|
1308 QHostAddress tmp = iface.addressEntries().at(j).ip();
|
Chris@182
|
1309 if (QAbstractSocket::IPv4Protocol == tmp.protocol()) {
|
Chris@182
|
1310 ret.push_back(tmp.toString());
|
jtkorhonen@24
|
1311 }
|
jtkorhonen@24
|
1312 }
|
jtkorhonen@22
|
1313 }
|
jtkorhonen@17
|
1314 }
|
jtkorhonen@28
|
1315 return ret;
|
jtkorhonen@28
|
1316 }
|
jtkorhonen@17
|
1317
|
Chris@120
|
1318 void MainWindow::clearState()
|
Chris@120
|
1319 {
|
Chris@305
|
1320 DEBUG << "MainWindow::clearState" << endl;
|
Chris@284
|
1321 foreach (Changeset *cs, m_currentParents) delete cs;
|
Chris@284
|
1322 m_currentParents.clear();
|
Chris@284
|
1323 foreach (Changeset *cs, m_currentHeads) delete cs;
|
Chris@284
|
1324 m_currentHeads.clear();
|
Chris@506
|
1325 m_closedHeadIds.clear();
|
Chris@284
|
1326 m_currentBranch = "";
|
Chris@284
|
1327 m_lastStatOutput = "";
|
Chris@284
|
1328 m_lastRevertedFiles.clear();
|
Chris@284
|
1329 m_mergeTargetRevision = "";
|
Chris@284
|
1330 m_mergeCommitComment = "";
|
Chris@284
|
1331 m_stateUnknown = true;
|
Chris@284
|
1332 m_needNewLog = true;
|
Chris@120
|
1333 }
|
jtkorhonen@17
|
1334
|
jtkorhonen@11
|
1335 void MainWindow::hgServe()
|
jtkorhonen@11
|
1336 {
|
Chris@109
|
1337 QStringList params;
|
Chris@109
|
1338 QString msg;
|
jtkorhonen@11
|
1339
|
Chris@182
|
1340 QStringList addrs = listAllUpIpV4Addresses();
|
Chris@182
|
1341
|
Chris@182
|
1342 if (addrs.empty()) {
|
Chris@182
|
1343 QMessageBox::critical
|
Chris@182
|
1344 (this, tr("Serve"), tr("Failed to identify an active IPv4 address"));
|
Chris@182
|
1345 return;
|
Chris@182
|
1346 }
|
Chris@182
|
1347
|
Chris@526
|
1348 // See #202. We really want to display the port that the server
|
Chris@526
|
1349 // ends up using -- but we don't get that information until after
|
Chris@526
|
1350 // it has exited! However, we can improve the likelihood of
|
Chris@526
|
1351 // showing the right port by at least checking whether a port is
|
Chris@526
|
1352 // defined in the hgrc file.
|
Chris@526
|
1353
|
Chris@526
|
1354 QFileInfo hgrc(QDir::homePath() + "/.hgrc");
|
Chris@526
|
1355 QString path;
|
Chris@526
|
1356 int port = 8000; // the default
|
Chris@526
|
1357 if (hgrc.exists()) {
|
Chris@526
|
1358 QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat);
|
Chris@526
|
1359 s.beginGroup("web");
|
Chris@527
|
1360 int p = s.value("port").toInt();
|
Chris@527
|
1361 if (p) port = p;
|
Chris@526
|
1362 }
|
Chris@182
|
1363
|
Chris@182
|
1364 QTextStream ts(&msg);
|
Chris@429
|
1365 ts << QString("<qt><h3>%1</h3><p>%2</p>")
|
Chris@425
|
1366 .arg(tr("Sharing Repository"))
|
Chris@429
|
1367 .arg(tr("Your local repository is now being made temporarily available via HTTP for workgroup access."));
|
Chris@429
|
1368 if (addrs.size() > 1) {
|
Chris@429
|
1369 ts << QString("<p>%3</p>")
|
Chris@429
|
1370 .arg(tr("Users who have network access to your computer can now clone your repository, by using one of the following URLs as a remote location:"));
|
Chris@429
|
1371 } else {
|
Chris@429
|
1372 ts << QString("<p>%3</p>")
|
Chris@429
|
1373 .arg(tr("Users who have network access to your computer can now clone your repository, by using the following URL as a remote location:"));
|
Chris@429
|
1374 }
|
Chris@182
|
1375 foreach (QString addr, addrs) {
|
Chris@526
|
1376 ts << QString("<pre> http://%1:%2</pre>").arg(xmlEncode(addr)).arg(port);
|
Chris@182
|
1377 }
|
Chris@425
|
1378 ts << tr("<p>Press Close to terminate this server, end remote access, and return.</p>");
|
Chris@182
|
1379 ts.flush();
|
Chris@182
|
1380
|
Chris@109
|
1381 params << "serve";
|
jtkorhonen@11
|
1382
|
Chris@284
|
1383 m_runner->requestAction(HgAction(ACT_SERVE, m_workFolderPath, params));
|
Chris@109
|
1384
|
Chris@425
|
1385 QMessageBox::information(this, tr("Share Repository"), msg, QMessageBox::Close);
|
Chris@182
|
1386
|
Chris@284
|
1387 m_runner->killCurrentActions();
|
jtkorhonen@11
|
1388 }
|
jtkorhonen@11
|
1389
|
Chris@64
|
1390 void MainWindow::startupDialog()
|
Chris@64
|
1391 {
|
Chris@64
|
1392 StartupDialog *dlg = new StartupDialog(this);
|
Chris@284
|
1393 if (dlg->exec()) m_firstStart = false;
|
Chris@344
|
1394 else exit(0);
|
Chris@64
|
1395 }
|
jtkorhonen@11
|
1396
|
Chris@69
|
1397 void MainWindow::open()
|
Chris@69
|
1398 {
|
Chris@86
|
1399 bool done = false;
|
Chris@69
|
1400
|
Chris@86
|
1401 while (!done) {
|
Chris@69
|
1402
|
Chris@86
|
1403 MultiChoiceDialog *d = new MultiChoiceDialog
|
Chris@86
|
1404 (tr("Open Repository"),
|
Chris@86
|
1405 tr("<qt><big>What would you like to open?</big></qt>"),
|
Chris@86
|
1406 this);
|
Chris@69
|
1407
|
Chris@345
|
1408 d->addChoice("remote",
|
Chris@345
|
1409 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
|
Chris@345
|
1410 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
|
Chris@345
|
1411 MultiChoiceDialog::UrlToDirectoryArg);
|
Chris@345
|
1412
|
Chris@339
|
1413 d->addChoice("local",
|
Chris@339
|
1414 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
|
Chris@339
|
1415 tr("Open an existing local Mercurial repository."),
|
Chris@339
|
1416 MultiChoiceDialog::DirectoryArg);
|
Chris@339
|
1417
|
Chris@339
|
1418 d->addChoice("init",
|
Chris@339
|
1419 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
|
Chris@339
|
1420 tr("Open a local folder, by creating a Mercurial repository in it."),
|
Chris@339
|
1421 MultiChoiceDialog::DirectoryArg);
|
Chris@339
|
1422
|
Chris@248
|
1423 QSettings settings;
|
Chris@484
|
1424 settings.beginGroup("");
|
Chris@359
|
1425 QString lastChoice = settings.value("lastopentype", "remote").toString();
|
Chris@248
|
1426 if (lastChoice != "local" &&
|
Chris@248
|
1427 lastChoice != "remote" &&
|
Chris@248
|
1428 lastChoice != "init") {
|
Chris@359
|
1429 lastChoice = "remote";
|
Chris@248
|
1430 }
|
Chris@248
|
1431
|
Chris@248
|
1432 d->setCurrentChoice(lastChoice);
|
Chris@86
|
1433
|
Chris@86
|
1434 if (d->exec() == QDialog::Accepted) {
|
Chris@86
|
1435
|
Chris@86
|
1436 QString choice = d->getCurrentChoice();
|
Chris@248
|
1437 settings.setValue("lastopentype", choice);
|
Chris@248
|
1438
|
Chris@86
|
1439 QString arg = d->getArgument().trimmed();
|
Chris@86
|
1440
|
Chris@86
|
1441 bool result = false;
|
Chris@86
|
1442
|
Chris@86
|
1443 if (choice == "local") {
|
Chris@86
|
1444 result = openLocal(arg);
|
Chris@86
|
1445 } else if (choice == "remote") {
|
Chris@86
|
1446 result = openRemote(arg, d->getAdditionalArgument().trimmed());
|
Chris@86
|
1447 } else if (choice == "init") {
|
Chris@86
|
1448 result = openInit(arg);
|
Chris@86
|
1449 }
|
Chris@86
|
1450
|
Chris@86
|
1451 if (result) {
|
Chris@86
|
1452 enableDisableActions();
|
Chris@120
|
1453 clearState();
|
Chris@109
|
1454 hgQueryPaths();
|
Chris@91
|
1455 done = true;
|
Chris@91
|
1456 }
|
Chris@86
|
1457
|
Chris@86
|
1458 } else {
|
Chris@86
|
1459
|
Chris@86
|
1460 // cancelled
|
Chris@86
|
1461 done = true;
|
Chris@69
|
1462 }
|
Chris@79
|
1463
|
Chris@86
|
1464 delete d;
|
Chris@69
|
1465 }
|
Chris@69
|
1466 }
|
Chris@69
|
1467
|
Chris@359
|
1468 void MainWindow::recentMenuActivated()
|
Chris@359
|
1469 {
|
Chris@359
|
1470 QAction *a = qobject_cast<QAction *>(sender());
|
Chris@359
|
1471 if (!a) return;
|
Chris@359
|
1472 QString local = a->text();
|
Chris@359
|
1473 open(local);
|
Chris@359
|
1474 }
|
Chris@359
|
1475
|
Chris@182
|
1476 void MainWindow::changeRemoteRepo()
|
Chris@182
|
1477 {
|
Chris@363
|
1478 changeRemoteRepo(false);
|
Chris@363
|
1479 }
|
Chris@363
|
1480
|
Chris@363
|
1481 void MainWindow::changeRemoteRepo(bool initial)
|
Chris@363
|
1482 {
|
Chris@183
|
1483 // This will involve rewriting the local .hgrc
|
Chris@183
|
1484
|
Chris@284
|
1485 QDir hgDir(m_workFolderPath + "/.hg");
|
Chris@184
|
1486 if (!hgDir.exists()) {
|
Chris@184
|
1487 //!!! visible error!
|
Chris@184
|
1488 return;
|
Chris@184
|
1489 }
|
Chris@184
|
1490
|
Chris@284
|
1491 QFileInfo hgrc(m_workFolderPath + "/.hg/hgrc");
|
Chris@184
|
1492 if (hgrc.exists() && !hgrc.isWritable()) {
|
Chris@183
|
1493 //!!! visible error!
|
Chris@183
|
1494 return;
|
Chris@183
|
1495 }
|
Chris@183
|
1496
|
Chris@183
|
1497 MultiChoiceDialog *d = new MultiChoiceDialog
|
Chris@363
|
1498 (tr("Set Remote Location"),
|
Chris@363
|
1499 tr("<qt><big>Set the remote location</big></qt>"),
|
Chris@183
|
1500 this);
|
Chris@183
|
1501
|
Chris@363
|
1502 QString explanation;
|
Chris@363
|
1503 if (initial) {
|
Chris@609
|
1504 explanation = tr("Provide a remote URL to use when pushing from, or pulling to, the local<br>repository <code>%1</code>.<br>This will be the default for subsequent pushes and pulls.<br>You can change it using “Set Remote Location” on the File menu.").arg(m_workFolderPath);
|
Chris@363
|
1505 } else {
|
Chris@609
|
1506 explanation = tr("Provide a new remote URL to use when pushing from, or pulling to, the local<br>repository <code>%1</code>.").arg(m_workFolderPath);
|
Chris@363
|
1507 }
|
Chris@363
|
1508
|
Chris@183
|
1509 d->addChoice("remote",
|
Chris@183
|
1510 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
|
Chris@363
|
1511 explanation,
|
Chris@553
|
1512 MultiChoiceDialog::UrlArg,
|
Chris@553
|
1513 true); // default empty
|
Chris@183
|
1514
|
Chris@183
|
1515 if (d->exec() == QDialog::Accepted) {
|
Chris@210
|
1516
|
Chris@210
|
1517 // New block to ensure QSettings is deleted before
|
Chris@210
|
1518 // hgQueryPaths called. NB use of absoluteFilePath instead of
|
Chris@210
|
1519 // canonicalFilePath, which would fail if the file did not yet
|
Chris@210
|
1520 // exist
|
Chris@210
|
1521
|
Chris@210
|
1522 {
|
Chris@210
|
1523 QSettings s(hgrc.absoluteFilePath(), QSettings::IniFormat);
|
Chris@210
|
1524 s.beginGroup("paths");
|
Chris@210
|
1525 s.setValue("default", d->getArgument());
|
Chris@210
|
1526 }
|
Chris@210
|
1527
|
Chris@284
|
1528 m_stateUnknown = true;
|
Chris@183
|
1529 hgQueryPaths();
|
Chris@183
|
1530 }
|
Chris@183
|
1531
|
Chris@183
|
1532 delete d;
|
Chris@182
|
1533 }
|
Chris@182
|
1534
|
Chris@145
|
1535 void MainWindow::open(QString local)
|
Chris@145
|
1536 {
|
Chris@145
|
1537 if (openLocal(local)) {
|
Chris@145
|
1538 enableDisableActions();
|
Chris@145
|
1539 clearState();
|
Chris@145
|
1540 hgQueryPaths();
|
Chris@145
|
1541 }
|
Chris@145
|
1542 }
|
Chris@145
|
1543
|
Chris@79
|
1544 bool MainWindow::complainAboutFilePath(QString arg)
|
Chris@79
|
1545 {
|
Chris@79
|
1546 QMessageBox::critical
|
Chris@79
|
1547 (this, tr("File chosen"),
|
Chris@84
|
1548 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
|
1549 return false;
|
Chris@79
|
1550 }
|
Chris@79
|
1551
|
Chris@248
|
1552 bool MainWindow::askAboutUnknownFolder(QString arg)
|
Chris@248
|
1553 {
|
Chris@248
|
1554 bool result = (QMessageBox::question
|
Chris@248
|
1555 (this, tr("Path does not exist"),
|
Chris@248
|
1556 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
|
1557 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@248
|
1558 QMessageBox::Cancel)
|
Chris@248
|
1559 == QMessageBox::Ok);
|
Chris@248
|
1560 if (result) {
|
Chris@248
|
1561 QDir dir(arg);
|
Chris@248
|
1562 dir.cdUp();
|
Chris@248
|
1563 if (!dir.mkpath(dir.absolutePath())) {
|
Chris@248
|
1564 QMessageBox::critical
|
Chris@248
|
1565 (this, tr("Failed to create folder"),
|
Chris@248
|
1566 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
|
1567 return false;
|
Chris@248
|
1568 }
|
Chris@248
|
1569 return true;
|
Chris@248
|
1570 }
|
Chris@248
|
1571 return false;
|
Chris@248
|
1572 }
|
Chris@248
|
1573
|
Chris@79
|
1574 bool MainWindow::complainAboutUnknownFolder(QString arg)
|
Chris@79
|
1575 {
|
Chris@79
|
1576 QMessageBox::critical
|
Chris@79
|
1577 (this, tr("Folder does not exist"),
|
Chris@84
|
1578 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
|
1579 return false;
|
Chris@84
|
1580 }
|
Chris@84
|
1581
|
Chris@84
|
1582 bool MainWindow::complainAboutInitInRepo(QString arg)
|
Chris@84
|
1583 {
|
Chris@84
|
1584 QMessageBox::critical
|
Chris@84
|
1585 (this, tr("Path is in existing repository"),
|
Chris@84
|
1586 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
|
1587 return false;
|
Chris@84
|
1588 }
|
Chris@84
|
1589
|
Chris@84
|
1590 bool MainWindow::complainAboutInitFile(QString arg)
|
Chris@84
|
1591 {
|
Chris@84
|
1592 QMessageBox::critical
|
Chris@84
|
1593 (this, tr("Path is a file"),
|
Chris@84
|
1594 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
|
1595 return false;
|
Chris@84
|
1596 }
|
Chris@84
|
1597
|
Chris@84
|
1598 bool MainWindow::complainAboutCloneToExisting(QString arg)
|
Chris@84
|
1599 {
|
Chris@84
|
1600 QMessageBox::critical
|
Chris@84
|
1601 (this, tr("Path is in existing repository"),
|
Chris@237
|
1602 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
|
1603 return false;
|
Chris@84
|
1604 }
|
Chris@84
|
1605
|
Chris@84
|
1606 bool MainWindow::complainAboutCloneToFile(QString arg)
|
Chris@84
|
1607 {
|
Chris@84
|
1608 QMessageBox::critical
|
Chris@84
|
1609 (this, tr("Path is a file"),
|
Chris@84
|
1610 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
|
1611 return false;
|
Chris@84
|
1612 }
|
Chris@84
|
1613
|
Chris@237
|
1614 QString MainWindow::complainAboutCloneToExistingFolder(QString arg, QString remote)
|
Chris@84
|
1615 {
|
Chris@348
|
1616 // If the directory "arg" exists but is empty, then we accept it.
|
Chris@348
|
1617
|
Chris@348
|
1618 // If the directory "arg" exists and is non-empty, but "arg" plus
|
Chris@348
|
1619 // the last path component of "remote" does not exist, then offer
|
Chris@348
|
1620 // the latter as an alternative path.
|
Chris@237
|
1621
|
Chris@237
|
1622 QString offer;
|
Chris@237
|
1623
|
Chris@237
|
1624 QDir d(arg);
|
Chris@348
|
1625
|
Chris@237
|
1626 if (d.exists()) {
|
Chris@348
|
1627
|
Chris@348
|
1628 if (d.entryList(QDir::Dirs | QDir::Files |
|
Chris@348
|
1629 QDir::NoDotAndDotDot |
|
Chris@348
|
1630 QDir::Hidden | QDir::System).empty()) {
|
Chris@348
|
1631 // directory is empty; accept it
|
Chris@348
|
1632 return arg;
|
Chris@348
|
1633 }
|
Chris@348
|
1634
|
Chris@237
|
1635 if (QRegExp("^\\w+://").indexIn(remote) >= 0) {
|
Chris@237
|
1636 QString rpath = QUrl(remote).path();
|
Chris@237
|
1637 if (rpath != "") {
|
Chris@237
|
1638 rpath = QDir(rpath).dirName();
|
Chris@237
|
1639 if (rpath != "" && !d.exists(rpath)) {
|
Chris@237
|
1640 offer = d.filePath(rpath);
|
Chris@237
|
1641 }
|
Chris@237
|
1642 }
|
Chris@237
|
1643 }
|
Chris@237
|
1644 }
|
Chris@237
|
1645
|
Chris@237
|
1646 if (offer != "") {
|
Chris@237
|
1647 bool result = (QMessageBox::question
|
Chris@237
|
1648 (this, tr("Folder exists"),
|
Chris@237
|
1649 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
|
1650 .arg(xmlEncode(arg)).arg(xmlEncode(offer)),
|
Chris@237
|
1651 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@237
|
1652 QMessageBox::Cancel)
|
Chris@237
|
1653 == QMessageBox::Ok);
|
Chris@237
|
1654 if (result) return offer;
|
Chris@237
|
1655 else return "";
|
Chris@237
|
1656 }
|
Chris@237
|
1657
|
Chris@84
|
1658 QMessageBox::critical
|
Chris@84
|
1659 (this, tr("Folder exists"),
|
Chris@237
|
1660 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
|
1661 return "";
|
Chris@79
|
1662 }
|
Chris@79
|
1663
|
Chris@79
|
1664 bool MainWindow::askToOpenParentRepo(QString arg, QString parent)
|
Chris@79
|
1665 {
|
Chris@79
|
1666 return (QMessageBox::question
|
Chris@84
|
1667 (this, tr("Path is inside a repository"),
|
Chris@86
|
1668 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
|
1669 .arg(xmlEncode(arg)).arg(xmlEncode(parent)),
|
Chris@79
|
1670 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@79
|
1671 QMessageBox::Ok)
|
Chris@79
|
1672 == QMessageBox::Ok);
|
Chris@79
|
1673 }
|
Chris@79
|
1674
|
Chris@79
|
1675 bool MainWindow::askToInitExisting(QString arg)
|
Chris@79
|
1676 {
|
Chris@79
|
1677 return (QMessageBox::question
|
Chris@84
|
1678 (this, tr("Folder has no repository"),
|
Chris@359
|
1679 tr("<qt><b>Initialise a repository here?</b><br><br>You asked to open \"%1\".<br>This folder is not a Mercurial working copy.<br><br>Would you like to initialise a repository here?</qt>")
|
Chris@79
|
1680 .arg(xmlEncode(arg)),
|
Chris@79
|
1681 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@79
|
1682 QMessageBox::Ok)
|
Chris@79
|
1683 == QMessageBox::Ok);
|
Chris@79
|
1684 }
|
Chris@79
|
1685
|
Chris@79
|
1686 bool MainWindow::askToInitNew(QString arg)
|
Chris@79
|
1687 {
|
Chris@79
|
1688 return (QMessageBox::question
|
Chris@84
|
1689 (this, tr("Folder does not exist"),
|
Chris@84
|
1690 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
|
1691 .arg(xmlEncode(arg)),
|
Chris@84
|
1692 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@84
|
1693 QMessageBox::Ok)
|
Chris@84
|
1694 == QMessageBox::Ok);
|
Chris@84
|
1695 }
|
Chris@84
|
1696
|
Chris@84
|
1697 bool MainWindow::askToOpenInsteadOfInit(QString arg)
|
Chris@84
|
1698 {
|
Chris@84
|
1699 return (QMessageBox::question
|
Chris@84
|
1700 (this, tr("Repository exists"),
|
Chris@84
|
1701 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
|
1702 .arg(xmlEncode(arg)),
|
Chris@79
|
1703 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@79
|
1704 QMessageBox::Ok)
|
Chris@79
|
1705 == QMessageBox::Ok);
|
Chris@79
|
1706 }
|
Chris@79
|
1707
|
Chris@79
|
1708 bool MainWindow::openLocal(QString local)
|
Chris@79
|
1709 {
|
Chris@79
|
1710 DEBUG << "open " << local << endl;
|
Chris@79
|
1711
|
Chris@79
|
1712 FolderStatus status = getFolderStatus(local);
|
Chris@79
|
1713 QString containing = getContainingRepoFolder(local);
|
Chris@79
|
1714
|
Chris@79
|
1715 switch (status) {
|
Chris@79
|
1716
|
Chris@79
|
1717 case FolderHasRepo:
|
Chris@79
|
1718 // fine
|
Chris@79
|
1719 break;
|
Chris@79
|
1720
|
Chris@79
|
1721 case FolderExists:
|
Chris@79
|
1722 if (containing != "") {
|
Chris@79
|
1723 if (!askToOpenParentRepo(local, containing)) return false;
|
Chris@84
|
1724 local = containing;
|
Chris@79
|
1725 } else {
|
Chris@86
|
1726 //!!! No -- this is likely to happen far more by accident
|
Chris@86
|
1727 // than because the user actually wanted to init something.
|
Chris@86
|
1728 // Don't ask, just politely reject.
|
Chris@79
|
1729 if (!askToInitExisting(local)) return false;
|
Chris@79
|
1730 return openInit(local);
|
Chris@79
|
1731 }
|
Chris@79
|
1732 break;
|
Chris@79
|
1733
|
Chris@79
|
1734 case FolderParentExists:
|
Chris@79
|
1735 if (containing != "") {
|
Chris@79
|
1736 if (!askToOpenParentRepo(local, containing)) return false;
|
Chris@84
|
1737 local = containing;
|
Chris@79
|
1738 } else {
|
Chris@79
|
1739 if (!askToInitNew(local)) return false;
|
Chris@79
|
1740 return openInit(local);
|
Chris@79
|
1741 }
|
Chris@79
|
1742 break;
|
Chris@79
|
1743
|
Chris@79
|
1744 case FolderUnknown:
|
Chris@84
|
1745 if (containing != "") {
|
Chris@84
|
1746 if (!askToOpenParentRepo(local, containing)) return false;
|
Chris@84
|
1747 local = containing;
|
Chris@84
|
1748 } else {
|
Chris@84
|
1749 return complainAboutUnknownFolder(local);
|
Chris@84
|
1750 }
|
Chris@84
|
1751 break;
|
Chris@79
|
1752
|
Chris@79
|
1753 case FolderIsFile:
|
Chris@79
|
1754 return complainAboutFilePath(local);
|
Chris@79
|
1755 }
|
Chris@79
|
1756
|
Chris@284
|
1757 m_workFolderPath = local;
|
Chris@284
|
1758 m_remoteRepoPath = "";
|
Chris@79
|
1759 return true;
|
Chris@79
|
1760 }
|
Chris@79
|
1761
|
Chris@79
|
1762 bool MainWindow::openRemote(QString remote, QString local)
|
Chris@79
|
1763 {
|
Chris@79
|
1764 DEBUG << "clone " << remote << " to " << local << endl;
|
Chris@84
|
1765
|
Chris@84
|
1766 FolderStatus status = getFolderStatus(local);
|
Chris@84
|
1767 QString containing = getContainingRepoFolder(local);
|
Chris@84
|
1768
|
Chris@84
|
1769 DEBUG << "status = " << status << ", containing = " << containing << endl;
|
Chris@84
|
1770
|
Chris@84
|
1771 if (status == FolderHasRepo || containing != "") {
|
Chris@84
|
1772 return complainAboutCloneToExisting(local);
|
Chris@84
|
1773 }
|
Chris@84
|
1774
|
Chris@84
|
1775 if (status == FolderIsFile) {
|
Chris@84
|
1776 return complainAboutCloneToFile(local);
|
Chris@84
|
1777 }
|
Chris@84
|
1778
|
Chris@84
|
1779 if (status == FolderUnknown) {
|
Chris@248
|
1780 if (!askAboutUnknownFolder(local)) {
|
Chris@248
|
1781 return false;
|
Chris@248
|
1782 }
|
Chris@84
|
1783 }
|
Chris@84
|
1784
|
Chris@84
|
1785 if (status == FolderExists) {
|
Chris@237
|
1786 local = complainAboutCloneToExistingFolder(local, remote);
|
Chris@237
|
1787 if (local == "") return false;
|
Chris@84
|
1788 }
|
Chris@84
|
1789
|
Chris@284
|
1790 m_workFolderPath = local;
|
Chris@284
|
1791 m_remoteRepoPath = remote;
|
Chris@84
|
1792 hgCloneFromRemote();
|
Chris@84
|
1793
|
Chris@79
|
1794 return true;
|
Chris@79
|
1795 }
|
Chris@79
|
1796
|
Chris@84
|
1797 bool MainWindow::openInit(QString local)
|
Chris@79
|
1798 {
|
Chris@84
|
1799 DEBUG << "openInit " << local << endl;
|
Chris@84
|
1800
|
Chris@84
|
1801 FolderStatus status = getFolderStatus(local);
|
Chris@84
|
1802 QString containing = getContainingRepoFolder(local);
|
Chris@84
|
1803
|
Chris@84
|
1804 DEBUG << "status = " << status << ", containing = " << containing << endl;
|
Chris@84
|
1805
|
Chris@84
|
1806 if (status == FolderHasRepo) {
|
Chris@84
|
1807 if (!askToOpenInsteadOfInit(local)) return false;
|
Chris@552
|
1808 return openLocal(local);
|
Chris@84
|
1809 }
|
Chris@84
|
1810
|
Chris@84
|
1811 if (containing != "") {
|
Chris@84
|
1812 return complainAboutInitInRepo(local);
|
Chris@84
|
1813 }
|
Chris@84
|
1814
|
Chris@84
|
1815 if (status == FolderIsFile) {
|
Chris@84
|
1816 return complainAboutInitFile(local);
|
Chris@84
|
1817 }
|
Chris@84
|
1818
|
Chris@84
|
1819 if (status == FolderUnknown) {
|
Chris@84
|
1820 return complainAboutUnknownFolder(local);
|
Chris@84
|
1821 }
|
Chris@84
|
1822
|
Chris@284
|
1823 m_workFolderPath = local;
|
Chris@284
|
1824 m_remoteRepoPath = "";
|
Chris@84
|
1825 hgInit();
|
Chris@79
|
1826 return true;
|
Chris@79
|
1827 }
|
Chris@79
|
1828
|
jtkorhonen@0
|
1829 void MainWindow::settings()
|
jtkorhonen@0
|
1830 {
|
Chris@472
|
1831 settings(SettingsDialog::PersonalDetailsTab);
|
Chris@472
|
1832 }
|
Chris@472
|
1833
|
Chris@472
|
1834 void MainWindow::settings(SettingsDialog::Tab tab)
|
Chris@472
|
1835 {
|
jtkorhonen@0
|
1836 SettingsDialog *settingsDlg = new SettingsDialog(this);
|
Chris@472
|
1837 settingsDlg->setCurrentTab(tab);
|
jtkorhonen@0
|
1838 settingsDlg->exec();
|
Chris@230
|
1839
|
Chris@230
|
1840 if (settingsDlg->presentationChanged()) {
|
Chris@284
|
1841 m_hgTabs->updateFileStates();
|
Chris@230
|
1842 updateToolBarStyle();
|
Chris@273
|
1843 hgRefresh();
|
Chris@230
|
1844 }
|
jtkorhonen@0
|
1845 }
|
jtkorhonen@0
|
1846
|
Chris@541
|
1847 void MainWindow::updateFsWatcher()
|
Chris@541
|
1848 {
|
Chris@541
|
1849 m_fsWatcher->setWorkDirPath(m_workFolderPath);
|
Chris@541
|
1850 m_fsWatcher->setTrackedFilePaths(m_hgTabs->getFileStates().trackedFiles());
|
Chris@541
|
1851 }
|
Chris@541
|
1852
|
Chris@238
|
1853 void MainWindow::checkFilesystem()
|
Chris@238
|
1854 {
|
Chris@238
|
1855 DEBUG << "MainWindow::checkFilesystem" << endl;
|
Chris@541
|
1856 if (!m_commandSequenceInProgress) {
|
Chris@541
|
1857 if (!m_fsWatcher->getChangedPaths(m_fsWatcherToken).empty()) {
|
Chris@541
|
1858 hgRefresh();
|
Chris@541
|
1859 return;
|
Chris@541
|
1860 }
|
Chris@549
|
1861 updateFsWatcher();
|
Chris@541
|
1862 }
|
Chris@90
|
1863 }
|
Chris@90
|
1864
|
Chris@275
|
1865 QString MainWindow::format1(QString head)
|
Chris@275
|
1866 {
|
Chris@275
|
1867 return QString("<qt><h3>%1</h3></qt>").arg(head);
|
Chris@275
|
1868 }
|
Chris@275
|
1869
|
Chris@125
|
1870 QString MainWindow::format3(QString head, QString intro, QString code)
|
Chris@125
|
1871 {
|
Chris@196
|
1872 code = xmlEncode(code).replace("\n", "<br>")
|
Chris@196
|
1873 #ifndef Q_OS_WIN32
|
Chris@196
|
1874 // The hard hyphen comes out funny on Windows
|
Chris@196
|
1875 .replace("-", "‑")
|
Chris@196
|
1876 #endif
|
Chris@196
|
1877 .replace(" ", " ");
|
Chris@125
|
1878 if (intro == "") {
|
Chris@168
|
1879 return QString("<qt><h3>%1</h3><p><code>%2</code></p>")
|
Chris@168
|
1880 .arg(head).arg(code);
|
Chris@126
|
1881 } else if (code == "") {
|
Chris@126
|
1882 return QString("<qt><h3>%1</h3><p>%2</p>")
|
Chris@126
|
1883 .arg(head).arg(intro);
|
Chris@125
|
1884 } else {
|
Chris@168
|
1885 return QString("<qt><h3>%1</h3><p>%2</p><p><code>%3</code></p>")
|
Chris@168
|
1886 .arg(head).arg(intro).arg(code);
|
Chris@125
|
1887 }
|
Chris@125
|
1888 }
|
Chris@125
|
1889
|
Chris@120
|
1890 void MainWindow::showIncoming(QString output)
|
Chris@120
|
1891 {
|
Chris@284
|
1892 m_runner->hide();
|
Chris@125
|
1893 IncomingDialog *d = new IncomingDialog(this, output);
|
Chris@125
|
1894 d->exec();
|
Chris@125
|
1895 delete d;
|
Chris@125
|
1896 }
|
Chris@125
|
1897
|
Chris@125
|
1898 int MainWindow::extractChangeCount(QString text)
|
Chris@125
|
1899 {
|
Chris@125
|
1900 QRegExp re("added (\\d+) ch\\w+ with (\\d+) ch\\w+ to (\\d+) f\\w+");
|
Chris@125
|
1901 if (re.indexIn(text) >= 0) {
|
Chris@125
|
1902 return re.cap(1).toInt();
|
Chris@125
|
1903 } else if (text.contains("no changes")) {
|
Chris@125
|
1904 return 0;
|
Chris@125
|
1905 } else {
|
Chris@125
|
1906 return -1; // unknown
|
Chris@125
|
1907 }
|
Chris@120
|
1908 }
|
Chris@120
|
1909
|
Chris@120
|
1910 void MainWindow::showPushResult(QString output)
|
Chris@120
|
1911 {
|
Chris@291
|
1912 QString head;
|
Chris@125
|
1913 QString report;
|
Chris@125
|
1914 int n = extractChangeCount(output);
|
Chris@125
|
1915 if (n > 0) {
|
Chris@291
|
1916 head = tr("Pushed %n changeset(s)", "", n);
|
Chris@300
|
1917 report = tr("<qt>Successfully pushed to the remote repository at <code>%1</code>.</qt>").arg(xmlEncode(m_remoteRepoPath));
|
Chris@125
|
1918 } else if (n == 0) {
|
Chris@291
|
1919 head = tr("No changes to push");
|
Chris@291
|
1920 report = tr("The remote repository already contains all changes that have been committed locally.");
|
Chris@294
|
1921 if (m_hgTabs->canCommit()) {
|
Chris@291
|
1922 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
|
1923 }
|
Chris@125
|
1924 } else {
|
Chris@291
|
1925 head = tr("Push complete");
|
Chris@125
|
1926 }
|
Chris@284
|
1927 m_runner->hide();
|
Chris@291
|
1928
|
Chris@291
|
1929 MoreInformationDialog::information(this, tr("Push complete"),
|
Chris@291
|
1930 head, report, output);
|
Chris@120
|
1931 }
|
Chris@120
|
1932
|
Chris@120
|
1933 void MainWindow::showPullResult(QString output)
|
Chris@120
|
1934 {
|
Chris@291
|
1935 QString head;
|
Chris@125
|
1936 QString report;
|
Chris@125
|
1937 int n = extractChangeCount(output);
|
Chris@125
|
1938 if (n > 0) {
|
Chris@291
|
1939 head = tr("Pulled %n changeset(s)", "", n);
|
Chris@322
|
1940 report = tr("New changes will be highlighted in yellow in the history.");
|
Chris@125
|
1941 } else if (n == 0) {
|
Chris@291
|
1942 head = tr("No changes to pull");
|
Chris@291
|
1943 report = tr("Your local repository already contains all changes found in the remote repository.");
|
Chris@125
|
1944 } else {
|
Chris@291
|
1945 head = tr("Pull complete");
|
Chris@125
|
1946 }
|
Chris@284
|
1947 m_runner->hide();
|
Chris@275
|
1948
|
Chris@275
|
1949 MoreInformationDialog::information(this, tr("Pull complete"),
|
Chris@291
|
1950 head, report, output);
|
Chris@120
|
1951 }
|
Chris@120
|
1952
|
Chris@174
|
1953 void MainWindow::reportNewRemoteHeads(QString output)
|
Chris@174
|
1954 {
|
Chris@174
|
1955 bool headsAreLocal = false;
|
Chris@174
|
1956
|
Chris@284
|
1957 if (m_currentParents.size() == 1) {
|
Chris@506
|
1958 int currentBranchActiveHeads = 0;
|
Chris@174
|
1959 bool parentIsHead = false;
|
Chris@284
|
1960 Changeset *parent = m_currentParents[0];
|
Chris@506
|
1961 foreach (Changeset *head, m_activeHeads) {
|
Chris@284
|
1962 if (head->isOnBranch(m_currentBranch)) {
|
Chris@506
|
1963 ++currentBranchActiveHeads;
|
Chris@174
|
1964 }
|
Chris@174
|
1965 if (parent->id() == head->id()) {
|
Chris@174
|
1966 parentIsHead = true;
|
Chris@174
|
1967 }
|
Chris@174
|
1968 }
|
Chris@506
|
1969 if (currentBranchActiveHeads == 2 && parentIsHead) {
|
Chris@174
|
1970 headsAreLocal = true;
|
Chris@174
|
1971 }
|
Chris@174
|
1972 }
|
Chris@174
|
1973
|
Chris@174
|
1974 if (headsAreLocal) {
|
Chris@291
|
1975 MoreInformationDialog::warning
|
Chris@291
|
1976 (this,
|
Chris@291
|
1977 tr("Push failed"),
|
Chris@291
|
1978 tr("Push failed"),
|
Chris@291
|
1979 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
|
1980 output);
|
Chris@318
|
1981 } else if (m_hgTabs->canCommit() && m_currentParents.size() > 1) {
|
Chris@318
|
1982 MoreInformationDialog::warning
|
Chris@318
|
1983 (this,
|
Chris@318
|
1984 tr("Push failed"),
|
Chris@318
|
1985 tr("Push failed"),
|
Chris@318
|
1986 tr("Your local repository could not be pushed to the remote repository.<br><br>You have an uncommitted merge in your local folder. You probably need to commit it before you push."),
|
Chris@318
|
1987 output);
|
Chris@174
|
1988 } else {
|
Chris@291
|
1989 MoreInformationDialog::warning
|
Chris@291
|
1990 (this,
|
Chris@291
|
1991 tr("Push failed"),
|
Chris@291
|
1992 tr("Push failed"),
|
Chris@291
|
1993 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
|
1994 output);
|
Chris@174
|
1995 }
|
Chris@174
|
1996 }
|
Chris@174
|
1997
|
Chris@353
|
1998 void MainWindow::reportAuthFailed(QString output)
|
Chris@353
|
1999 {
|
Chris@353
|
2000 MoreInformationDialog::warning
|
Chris@353
|
2001 (this,
|
Chris@353
|
2002 tr("Authorization failed"),
|
Chris@353
|
2003 tr("Authorization failed"),
|
Chris@353
|
2004 tr("You may have entered an incorrect user name or password, or the remote URL may be wrong.<br><br>Or you may lack the necessary permissions on the remote repository.<br><br>Check with the administrator of your remote repository if necessary."),
|
Chris@353
|
2005 output);
|
Chris@353
|
2006 }
|
Chris@353
|
2007
|
Chris@238
|
2008 void MainWindow::commandStarting(HgAction action)
|
Chris@238
|
2009 {
|
Chris@540
|
2010 m_commandSequenceInProgress = true;
|
Chris@238
|
2011 }
|
Chris@238
|
2012
|
Chris@546
|
2013 void MainWindow::commandFailed(HgAction action, QString stdErr, QString stdOut)
|
Chris@62
|
2014 {
|
Chris@62
|
2015 DEBUG << "MainWindow::commandFailed" << endl;
|
Chris@540
|
2016
|
Chris@540
|
2017 m_commandSequenceInProgress = false;
|
Chris@74
|
2018
|
Chris@210
|
2019 QString setstr;
|
Chris@210
|
2020 #ifdef Q_OS_MAC
|
Chris@210
|
2021 setstr = tr("Preferences");
|
Chris@210
|
2022 #else
|
Chris@210
|
2023 setstr = tr("Settings");
|
Chris@210
|
2024 #endif
|
Chris@210
|
2025
|
Chris@353
|
2026 // Some commands we just have to ignore bad return values from,
|
Chris@353
|
2027 // and some output gets special treatment.
|
Chris@353
|
2028
|
Chris@353
|
2029 // Note our fallback case should always be to report a
|
Chris@353
|
2030 // non-specific error and show the text -- in case output scraping
|
Chris@353
|
2031 // fails (as it surely will). Note also that we must force the
|
Chris@353
|
2032 // locale in order to ensure the output is scrapable; this happens
|
Chris@353
|
2033 // in HgRunner and may break some system encodings.
|
Chris@113
|
2034
|
Chris@113
|
2035 switch(action.action) {
|
Chris@113
|
2036 case ACT_NONE:
|
Chris@113
|
2037 // uh huh
|
Chris@113
|
2038 return;
|
Chris@175
|
2039 case ACT_TEST_HG:
|
Chris@291
|
2040 MoreInformationDialog::warning
|
Chris@291
|
2041 (this,
|
Chris@291
|
2042 tr("Failed to run Mercurial"),
|
Chris@291
|
2043 tr("Failed to run Mercurial"),
|
Chris@483
|
2044 tr("The Mercurial program either could not be found or failed to run.<br><br>Check that the Mercurial program path is correct in %1.").arg(setstr),
|
Chris@545
|
2045 stdErr);
|
Chris@472
|
2046 settings(SettingsDialog::PathsTab);
|
Chris@200
|
2047 return;
|
Chris@200
|
2048 case ACT_TEST_HG_EXT:
|
Chris@309
|
2049 MoreInformationDialog::warning
|
Chris@291
|
2050 (this,
|
Chris@291
|
2051 tr("Failed to run Mercurial"),
|
Chris@291
|
2052 tr("Failed to run Mercurial with extension enabled"),
|
Chris@310
|
2053 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem.<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 might not work if you do this.").arg(setstr),
|
Chris@545
|
2054 stdErr);
|
Chris@472
|
2055 settings(SettingsDialog::PathsTab);
|
Chris@175
|
2056 return;
|
Chris@252
|
2057 case ACT_CLONEFROMREMOTE:
|
Chris@252
|
2058 // if clone fails, we have no repo
|
Chris@284
|
2059 m_workFolderPath = "";
|
Chris@252
|
2060 enableDisableActions();
|
Chris@330
|
2061 break; // go on to default report
|
Chris@113
|
2062 case ACT_INCOMING:
|
Chris@545
|
2063 if (stdErr.contains("authorization failed")) {
|
Chris@545
|
2064 reportAuthFailed(stdErr);
|
Chris@353
|
2065 return;
|
Chris@545
|
2066 } else if (stdErr.contains("entry cancelled")) {
|
Chris@358
|
2067 // ignore this, user cancelled username or password dialog
|
Chris@358
|
2068 return;
|
Chris@353
|
2069 } else {
|
Chris@545
|
2070 // Incoming returns non-zero code and no stdErr if the
|
Chris@353
|
2071 // check was successful but there are no changes
|
Chris@353
|
2072 // pending. This is the only case where we need to remove
|
Chris@353
|
2073 // warning messages, because it's the only case where a
|
Chris@353
|
2074 // non-zero code can be returned even though the command
|
Chris@353
|
2075 // has for our purposes succeeded
|
Chris@545
|
2076 QString replaced = stdErr;
|
Chris@352
|
2077 while (1) {
|
Chris@352
|
2078 QString r1 = replaced;
|
Chris@352
|
2079 r1.replace(QRegExp("warning: [^\\n]*"), "");
|
Chris@352
|
2080 if (r1 == replaced) break;
|
Chris@352
|
2081 replaced = r1.trimmed();
|
Chris@352
|
2082 }
|
Chris@352
|
2083 if (replaced == "") {
|
Chris@352
|
2084 showIncoming("");
|
Chris@352
|
2085 return;
|
Chris@352
|
2086 }
|
Chris@211
|
2087 }
|
Chris@330
|
2088 break; // go on to default report
|
Chris@353
|
2089 case ACT_PULL:
|
Chris@545
|
2090 if (stdErr.contains("authorization failed")) {
|
Chris@545
|
2091 reportAuthFailed(stdErr);
|
Chris@353
|
2092 return;
|
Chris@545
|
2093 } else if (stdErr.contains("entry cancelled")) {
|
Chris@358
|
2094 // ignore this, user cancelled username or password dialog
|
Chris@358
|
2095 return;
|
Chris@546
|
2096 } else if (stdErr.contains("no changes found") || stdOut.contains("no changes found")) {
|
Chris@537
|
2097 // success: hg 2.1 starts returning failure code for empty pull/push
|
Chris@540
|
2098 m_commandSequenceInProgress = true; // there may be further commands
|
Chris@546
|
2099 commandCompleted(action, stdOut);
|
Chris@537
|
2100 return;
|
Chris@353
|
2101 }
|
Chris@353
|
2102 break; // go on to default report
|
Chris@353
|
2103 case ACT_PUSH:
|
Chris@545
|
2104 if (stdErr.contains("creates new remote head")) {
|
Chris@545
|
2105 reportNewRemoteHeads(stdErr);
|
Chris@353
|
2106 return;
|
Chris@545
|
2107 } else if (stdErr.contains("authorization failed")) {
|
Chris@545
|
2108 reportAuthFailed(stdErr);
|
Chris@353
|
2109 return;
|
Chris@545
|
2110 } else if (stdErr.contains("entry cancelled")) {
|
Chris@358
|
2111 // ignore this, user cancelled username or password dialog
|
Chris@358
|
2112 return;
|
Chris@546
|
2113 } else if (stdErr.contains("no changes found") || stdOut.contains("no changes found")) {
|
Chris@537
|
2114 // success: hg 2.1 starts returning failure code for empty pull/push
|
Chris@540
|
2115 m_commandSequenceInProgress = true; // there may be further commands
|
Chris@546
|
2116 commandCompleted(action, stdOut);
|
Chris@537
|
2117 return;
|
Chris@353
|
2118 }
|
Chris@353
|
2119 break; // go on to default report
|
Chris@506
|
2120 case ACT_QUERY_HEADS_ACTIVE:
|
Chris@162
|
2121 case ACT_QUERY_HEADS:
|
Chris@162
|
2122 // fails if repo is empty; we don't care (if there's a genuine
|
Chris@202
|
2123 // problem, something else will fail too). Pretend it
|
Chris@202
|
2124 // succeeded, so that any further actions that are contingent
|
Chris@202
|
2125 // on the success of the heads query get carried out properly.
|
Chris@540
|
2126 m_commandSequenceInProgress = true; // there may be further commands
|
Chris@202
|
2127 commandCompleted(action, "");
|
Chris@162
|
2128 return;
|
Chris@113
|
2129 case ACT_FOLDERDIFF:
|
Chris@113
|
2130 case ACT_CHGSETDIFF:
|
Chris@545
|
2131 // external program, unlikely to be anything useful in stdErr
|
Chris@113
|
2132 // and some return with failure codes when something as basic
|
Chris@113
|
2133 // as the user closing the window via the wm happens
|
Chris@113
|
2134 return;
|
Chris@328
|
2135 case ACT_MERGE:
|
Chris@545
|
2136 if (stdErr.contains("working directory ancestor")) {
|
Chris@530
|
2137 // arguably we should prevent this upfront, but that's
|
Chris@530
|
2138 // trickier!
|
Chris@530
|
2139 MoreInformationDialog::information
|
Chris@530
|
2140 (this, tr("Merge"), tr("Merge has no effect"),
|
Chris@530
|
2141 tr("You asked to merge a revision with one of its ancestors.<p>This has no effect, because the ancestor's changes already exist in both revisions."),
|
Chris@545
|
2142 stdErr);
|
Chris@530
|
2143 return;
|
Chris@530
|
2144 }
|
Chris@530
|
2145 // else fall through
|
Chris@328
|
2146 case ACT_RETRY_MERGE:
|
Chris@328
|
2147 MoreInformationDialog::information
|
Chris@328
|
2148 (this, tr("Merge"), tr("Merge failed"),
|
Chris@328
|
2149 tr("Some files were not merged successfully.<p>You can Merge again to repeat the interactive merge; use Revert to abandon the merge entirely; or edit the files that are in conflict in an editor and, when you are happy with them, choose Mark Resolved in each file's right-button menu."),
|
Chris@545
|
2150 stdErr);
|
Chris@378
|
2151 m_mergeCommitComment = "";
|
Chris@603
|
2152 hgQueryPaths();
|
Chris@328
|
2153 return;
|
Chris@199
|
2154 case ACT_STAT:
|
Chris@330
|
2155 break; // go on to default report
|
Chris@113
|
2156 default:
|
Chris@114
|
2157 break;
|
Chris@113
|
2158 }
|
Chris@113
|
2159
|
Chris@113
|
2160 QString command = action.executable;
|
Chris@113
|
2161 if (command == "") command = "hg";
|
Chris@113
|
2162 foreach (QString arg, action.params) {
|
Chris@113
|
2163 command += " " + arg;
|
Chris@113
|
2164 }
|
Chris@113
|
2165
|
Chris@309
|
2166 MoreInformationDialog::warning
|
Chris@309
|
2167 (this,
|
Chris@309
|
2168 tr("Command failed"),
|
Chris@309
|
2169 tr("Command failed"),
|
Chris@545
|
2170 (stdErr == "" ?
|
Chris@483
|
2171 tr("A Mercurial command failed to run correctly. This may indicate an installation problem or some other problem with EasyMercurial.") :
|
Chris@483
|
2172 tr("A Mercurial command failed to run correctly. This may indicate an installation problem or some other problem with EasyMercurial.<br><br>See “More Details” for the command output.")),
|
Chris@545
|
2173 stdErr);
|
Chris@62
|
2174 }
|
Chris@62
|
2175
|
Chris@109
|
2176 void MainWindow::commandCompleted(HgAction completedAction, QString output)
|
jtkorhonen@0
|
2177 {
|
Chris@521
|
2178 // std::cerr << "commandCompleted: " << completedAction.action << std::endl;
|
Chris@519
|
2179
|
Chris@109
|
2180 HGACTIONS action = completedAction.action;
|
Chris@109
|
2181
|
Chris@109
|
2182 if (action == ACT_NONE) return;
|
Chris@109
|
2183
|
Chris@519
|
2184 output.replace("\r\n", "\n");
|
Chris@519
|
2185
|
Chris@150
|
2186 bool headsChanged = false;
|
Chris@150
|
2187 QStringList oldHeadIds;
|
Chris@150
|
2188
|
Chris@150
|
2189 switch (action) {
|
Chris@109
|
2190
|
Chris@175
|
2191 case ACT_TEST_HG:
|
Chris@377
|
2192 {
|
Chris@377
|
2193 QRegExp versionRE("^Mercurial.*version ([\\d+])\\.([\\d+])");
|
Chris@377
|
2194 int pos = versionRE.indexIn(output);
|
Chris@377
|
2195 if (pos >= 0) {
|
Chris@377
|
2196 int major = versionRE.cap(1).toInt();
|
Chris@377
|
2197 int minor = versionRE.cap(2).toInt();
|
Chris@377
|
2198 // We need v1.7 or newer
|
Chris@377
|
2199 if (major < 1 || (major == 1 && minor < 7)) {
|
Chris@377
|
2200 MoreInformationDialog::warning
|
Chris@377
|
2201 (this,
|
Chris@377
|
2202 tr("Newer Mercurial version required"),
|
Chris@377
|
2203 tr("Newer Mercurial version required"),
|
Chris@377
|
2204 tr("To use EasyMercurial, you should have at least Mercurial v1.7 installed.<br><br>The version found on this system (v%1.%2) does not support all of the features required by EasyMercurial.").arg(major).arg(minor),
|
Chris@377
|
2205 output);
|
Chris@377
|
2206 }
|
Chris@377
|
2207 }
|
Chris@175
|
2208 break;
|
Chris@377
|
2209 }
|
Chris@175
|
2210
|
Chris@200
|
2211 case ACT_TEST_HG_EXT:
|
Chris@200
|
2212 break;
|
Chris@200
|
2213
|
Chris@109
|
2214 case ACT_QUERY_PATHS:
|
jtkorhonen@0
|
2215 {
|
Chris@109
|
2216 DEBUG << "stdout is " << output << endl;
|
Chris@109
|
2217 LogParser lp(output, "=");
|
Chris@109
|
2218 LogList ll = lp.parse();
|
Chris@109
|
2219 DEBUG << ll.size() << " results" << endl;
|
Chris@109
|
2220 if (!ll.empty()) {
|
Chris@284
|
2221 m_remoteRepoPath = lp.parse()[0]["default"].trimmed();
|
Chris@284
|
2222 DEBUG << "Set remote path to " << m_remoteRepoPath << endl;
|
Chris@210
|
2223 } else {
|
Chris@284
|
2224 m_remoteRepoPath = "";
|
Chris@109
|
2225 }
|
Chris@284
|
2226 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
|
Chris@284
|
2227 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
|
Chris@287
|
2228 updateWorkFolderAndRepoNames();
|
Chris@109
|
2229 break;
|
Chris@109
|
2230 }
|
jtkorhonen@0
|
2231
|
Chris@109
|
2232 case ACT_QUERY_BRANCH:
|
Chris@284
|
2233 m_currentBranch = output.trimmed();
|
Chris@109
|
2234 break;
|
jtkorhonen@0
|
2235
|
Chris@109
|
2236 case ACT_STAT:
|
Chris@284
|
2237 m_lastStatOutput = output;
|
Chris@109
|
2238 break;
|
Chris@163
|
2239
|
Chris@163
|
2240 case ACT_RESOLVE_LIST:
|
Chris@505
|
2241 // This happens on every update, after the stat (above)
|
Chris@163
|
2242 if (output != "") {
|
Chris@163
|
2243 // Remove lines beginning with R (they are resolved,
|
Chris@163
|
2244 // and the file stat parser treats R as removed)
|
Chris@163
|
2245 QStringList outList = output.split('\n');
|
Chris@163
|
2246 QStringList winnowed;
|
Chris@163
|
2247 foreach (QString line, outList) {
|
Chris@163
|
2248 if (!line.startsWith("R ")) winnowed.push_back(line);
|
Chris@163
|
2249 }
|
Chris@163
|
2250 output = winnowed.join("\n");
|
Chris@163
|
2251 }
|
Chris@284
|
2252 DEBUG << "m_lastStatOutput = " << m_lastStatOutput << endl;
|
Chris@199
|
2253 DEBUG << "resolve output = " << output << endl;
|
Chris@284
|
2254 m_hgTabs->updateWorkFolderFileList(m_lastStatOutput + output);
|
Chris@163
|
2255 break;
|
Chris@163
|
2256
|
Chris@163
|
2257 case ACT_RESOLVE_MARK:
|
Chris@284
|
2258 m_shouldHgStat = true;
|
Chris@163
|
2259 break;
|
Chris@109
|
2260
|
Chris@109
|
2261 case ACT_INCOMING:
|
Chris@120
|
2262 showIncoming(output);
|
Chris@120
|
2263 break;
|
Chris@120
|
2264
|
Chris@109
|
2265 case ACT_ANNOTATE:
|
Chris@331
|
2266 {
|
Chris@331
|
2267 AnnotateDialog dialog(this, output);
|
Chris@331
|
2268 dialog.exec();
|
Chris@284
|
2269 m_shouldHgStat = true;
|
Chris@109
|
2270 break;
|
Chris@331
|
2271 }
|
Chris@109
|
2272
|
Chris@109
|
2273 case ACT_PULL:
|
Chris@120
|
2274 showPullResult(output);
|
Chris@284
|
2275 m_shouldHgStat = true;
|
Chris@109
|
2276 break;
|
Chris@109
|
2277
|
Chris@109
|
2278 case ACT_PUSH:
|
Chris@120
|
2279 showPushResult(output);
|
Chris@109
|
2280 break;
|
Chris@109
|
2281
|
Chris@109
|
2282 case ACT_INIT:
|
Chris@284
|
2283 MultiChoiceDialog::addRecentArgument("init", m_workFolderPath);
|
Chris@284
|
2284 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
|
Chris@109
|
2285 enableDisableActions();
|
Chris@284
|
2286 m_shouldHgStat = true;
|
Chris@109
|
2287 break;
|
Chris@109
|
2288
|
Chris@109
|
2289 case ACT_CLONEFROMREMOTE:
|
Chris@284
|
2290 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
|
Chris@284
|
2291 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
|
Chris@284
|
2292 MultiChoiceDialog::addRecentArgument("remote", m_workFolderPath, true);
|
Chris@291
|
2293 MoreInformationDialog::information
|
Chris@291
|
2294 (this,
|
Chris@291
|
2295 tr("Clone"),
|
Chris@384
|
2296 tr("Open successful"),
|
Chris@295
|
2297 tr("The remote repository was successfully cloned to the local folder <code>%1</code>.").arg(xmlEncode(m_workFolderPath)),
|
Chris@291
|
2298 output);
|
Chris@109
|
2299 enableDisableActions();
|
Chris@284
|
2300 m_shouldHgStat = true;
|
Chris@109
|
2301 break;
|
Chris@109
|
2302
|
Chris@109
|
2303 case ACT_LOG:
|
Chris@284
|
2304 m_hgTabs->setNewLog(output);
|
Chris@284
|
2305 m_needNewLog = false;
|
Chris@120
|
2306 break;
|
Chris@120
|
2307
|
Chris@120
|
2308 case ACT_LOG_INCREMENTAL:
|
Chris@284
|
2309 m_hgTabs->addIncrementalLog(output);
|
Chris@109
|
2310 break;
|
Chris@109
|
2311
|
Chris@109
|
2312 case ACT_QUERY_PARENTS:
|
Chris@152
|
2313 {
|
Chris@284
|
2314 foreach (Changeset *cs, m_currentParents) delete cs;
|
Chris@284
|
2315 m_currentParents = Changeset::parseChangesets(output);
|
Chris@284
|
2316 QStringList parentIds = Changeset::getIds(m_currentParents);
|
Chris@284
|
2317 m_hgTabs->setCurrent(parentIds, m_currentBranch);
|
Chris@152
|
2318 }
|
Chris@109
|
2319 break;
|
Chris@109
|
2320
|
Chris@506
|
2321 case ACT_QUERY_HEADS_ACTIVE:
|
Chris@506
|
2322 foreach (Changeset *cs, m_activeHeads) delete cs;
|
Chris@506
|
2323 m_activeHeads = Changeset::parseChangesets(output);
|
Chris@506
|
2324 break;
|
Chris@506
|
2325
|
Chris@109
|
2326 case ACT_QUERY_HEADS:
|
Chris@150
|
2327 {
|
Chris@284
|
2328 oldHeadIds = Changeset::getIds(m_currentHeads);
|
Chris@150
|
2329 Changesets newHeads = Changeset::parseChangesets(output);
|
Chris@150
|
2330 QStringList newHeadIds = Changeset::getIds(newHeads);
|
Chris@150
|
2331 if (oldHeadIds != newHeadIds) {
|
Chris@150
|
2332 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl;
|
Chris@305
|
2333 DEBUG << "Old heads: " << oldHeadIds.join(",") << endl;
|
Chris@305
|
2334 DEBUG << "New heads: " << newHeadIds.join(",") << endl;
|
Chris@150
|
2335 headsChanged = true;
|
Chris@284
|
2336 foreach (Changeset *cs, m_currentHeads) delete cs;
|
Chris@284
|
2337 m_currentHeads = newHeads;
|
Chris@506
|
2338 updateClosedHeads();
|
Chris@150
|
2339 }
|
Chris@150
|
2340 }
|
Chris@109
|
2341 break;
|
Chris@130
|
2342
|
Chris@130
|
2343 case ACT_COMMIT:
|
Chris@347
|
2344 if (m_currentParents.empty()) {
|
Chris@347
|
2345 // first commit to empty repo
|
Chris@347
|
2346 m_needNewLog = true;
|
Chris@347
|
2347 }
|
Chris@284
|
2348 m_hgTabs->clearSelections();
|
Chris@284
|
2349 m_justMerged = false;
|
Chris@284
|
2350 m_shouldHgStat = true;
|
Chris@130
|
2351 break;
|
Chris@163
|
2352
|
Chris@514
|
2353 case ACT_CLOSE_BRANCH:
|
Chris@514
|
2354 m_hgTabs->clearSelections();
|
Chris@514
|
2355 m_justMerged = false;
|
Chris@514
|
2356 m_shouldHgStat = true;
|
Chris@514
|
2357 break;
|
Chris@514
|
2358
|
Chris@163
|
2359 case ACT_REVERT:
|
Chris@326
|
2360 hgMarkFilesResolved(m_lastRevertedFiles);
|
Chris@284
|
2361 m_justMerged = false;
|
Chris@163
|
2362 break;
|
Chris@109
|
2363
|
Chris@109
|
2364 case ACT_REMOVE:
|
Chris@109
|
2365 case ACT_ADD:
|
Chris@284
|
2366 m_hgTabs->clearSelections();
|
Chris@284
|
2367 m_shouldHgStat = true;
|
Chris@116
|
2368 break;
|
Chris@116
|
2369
|
Chris@164
|
2370 case ACT_TAG:
|
Chris@284
|
2371 m_needNewLog = true;
|
Chris@284
|
2372 m_shouldHgStat = true;
|
Chris@164
|
2373 break;
|
Chris@164
|
2374
|
Chris@278
|
2375 case ACT_NEW_BRANCH:
|
Chris@307
|
2376 m_shouldHgStat = true;
|
Chris@278
|
2377 break;
|
Chris@278
|
2378
|
Chris@288
|
2379 case ACT_UNCOMMITTED_SUMMARY:
|
Chris@168
|
2380 QMessageBox::information(this, tr("Change summary"),
|
Chris@168
|
2381 format3(tr("Summary of uncommitted changes"),
|
Chris@168
|
2382 "",
|
Chris@168
|
2383 output));
|
Chris@168
|
2384 break;
|
Chris@168
|
2385
|
Chris@288
|
2386 case ACT_DIFF_SUMMARY:
|
Chris@289
|
2387 {
|
Chris@289
|
2388 // Output has log info first, diff following after a blank line
|
Chris@289
|
2389 QStringList olist = output.split("\n\n", QString::SkipEmptyParts);
|
Chris@289
|
2390 if (olist.size() > 1) output = olist[1];
|
Chris@289
|
2391
|
Chris@289
|
2392 Changeset *cs = (Changeset *)completedAction.extraData;
|
Chris@289
|
2393 if (cs) {
|
Chris@289
|
2394 QMessageBox::information
|
Chris@289
|
2395 (this, tr("Change summary"),
|
Chris@289
|
2396 format3(tr("Summary of changes"),
|
Chris@289
|
2397 cs->formatHtml(),
|
Chris@289
|
2398 output));
|
Chris@289
|
2399 } else if (output == "") {
|
Chris@289
|
2400 // Can happen, for a merge commit (depending on parent)
|
Chris@288
|
2401 QMessageBox::information(this, tr("Change summary"),
|
Chris@288
|
2402 format3(tr("Summary of changes"),
|
Chris@288
|
2403 tr("No changes"),
|
Chris@288
|
2404 output));
|
Chris@288
|
2405 } else {
|
Chris@288
|
2406 QMessageBox::information(this, tr("Change summary"),
|
Chris@288
|
2407 format3(tr("Summary of changes"),
|
Chris@288
|
2408 "",
|
Chris@288
|
2409 output));
|
Chris@288
|
2410 }
|
Chris@288
|
2411 break;
|
Chris@289
|
2412 }
|
Chris@288
|
2413
|
Chris@109
|
2414 case ACT_FOLDERDIFF:
|
Chris@109
|
2415 case ACT_CHGSETDIFF:
|
Chris@109
|
2416 case ACT_SERVE:
|
Chris@109
|
2417 case ACT_HG_IGNORE:
|
Chris@284
|
2418 m_shouldHgStat = true;
|
Chris@109
|
2419 break;
|
Chris@109
|
2420
|
Chris@109
|
2421 case ACT_UPDATE:
|
Chris@162
|
2422 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output)));
|
Chris@284
|
2423 m_shouldHgStat = true;
|
Chris@109
|
2424 break;
|
Chris@109
|
2425
|
Chris@109
|
2426 case ACT_MERGE:
|
Chris@294
|
2427 MoreInformationDialog::information
|
Chris@294
|
2428 (this, tr("Merge"), tr("Merge successful"),
|
Chris@302
|
2429 tr("Remember to test and commit the result before making any further changes."),
|
Chris@294
|
2430 output);
|
Chris@284
|
2431 m_shouldHgStat = true;
|
Chris@284
|
2432 m_justMerged = true;
|
Chris@109
|
2433 break;
|
Chris@109
|
2434
|
Chris@109
|
2435 case ACT_RETRY_MERGE:
|
Chris@163
|
2436 QMessageBox::information(this, tr("Resolved"),
|
Chris@302
|
2437 tr("<qt><h3>Merge resolved</h3><p>Merge resolved successfully.<br>Remember to test and commit the result before making any further changes.</p>"));
|
Chris@284
|
2438 m_shouldHgStat = true;
|
Chris@284
|
2439 m_justMerged = true;
|
Chris@109
|
2440 break;
|
Chris@109
|
2441
|
Chris@109
|
2442 default:
|
Chris@109
|
2443 break;
|
Chris@109
|
2444 }
|
Chris@108
|
2445
|
Chris@121
|
2446 // Sequence when no full log required:
|
Chris@520
|
2447 // paths -> branch -> stat -> resolve-list -> heads ->
|
Chris@150
|
2448 // incremental-log (only if heads changed) -> parents
|
Chris@150
|
2449 //
|
Chris@121
|
2450 // Sequence when full log required:
|
Chris@520
|
2451 // paths -> branch -> stat -> resolve-list -> heads ->
|
Chris@519
|
2452 // parents -> log
|
Chris@150
|
2453 //
|
Chris@150
|
2454 // Note we want to call enableDisableActions only once, at the end
|
Chris@150
|
2455 // of whichever sequence is in use.
|
Chris@150
|
2456
|
Chris@156
|
2457 bool noMore = false;
|
Chris@156
|
2458
|
Chris@150
|
2459 switch (action) {
|
Chris@175
|
2460
|
Chris@175
|
2461 case ACT_TEST_HG:
|
Chris@248
|
2462 {
|
Chris@248
|
2463 QSettings settings;
|
Chris@248
|
2464 if (settings.value("useextension", true).toBool()) {
|
Chris@248
|
2465 hgTestExtension();
|
Chris@284
|
2466 } else if (m_workFolderPath == "") {
|
Chris@248
|
2467 open();
|
Chris@248
|
2468 } else {
|
Chris@248
|
2469 hgQueryPaths();
|
Chris@248
|
2470 }
|
Chris@200
|
2471 break;
|
Chris@248
|
2472 }
|
Chris@200
|
2473
|
Chris@200
|
2474 case ACT_TEST_HG_EXT:
|
Chris@284
|
2475 if (m_workFolderPath == "") {
|
Chris@248
|
2476 open();
|
Chris@248
|
2477 } else{
|
Chris@248
|
2478 hgQueryPaths();
|
Chris@248
|
2479 }
|
Chris@175
|
2480 break;
|
Chris@150
|
2481
|
Chris@150
|
2482 case ACT_QUERY_PATHS:
|
Chris@519
|
2483 // NB this call is duplicated in hgQueryPaths
|
Chris@109
|
2484 hgQueryBranch();
|
Chris@150
|
2485 break;
|
Chris@150
|
2486
|
Chris@150
|
2487 case ACT_QUERY_BRANCH:
|
Chris@519
|
2488 // NB this call is duplicated in hgQueryBranch
|
Chris@109
|
2489 hgStat();
|
Chris@150
|
2490 break;
|
Chris@150
|
2491
|
Chris@150
|
2492 case ACT_STAT:
|
Chris@163
|
2493 hgResolveList();
|
Chris@163
|
2494 break;
|
Chris@519
|
2495
|
Chris@163
|
2496 case ACT_RESOLVE_LIST:
|
Chris@506
|
2497 hgQueryHeadsActive();
|
Chris@506
|
2498 break;
|
Chris@506
|
2499
|
Chris@506
|
2500 case ACT_QUERY_HEADS_ACTIVE:
|
Chris@150
|
2501 hgQueryHeads();
|
Chris@150
|
2502 break;
|
Chris@150
|
2503
|
Chris@150
|
2504 case ACT_QUERY_HEADS:
|
Chris@284
|
2505 if (headsChanged && !m_needNewLog) {
|
Chris@150
|
2506 hgLogIncremental(oldHeadIds);
|
Chris@121
|
2507 } else {
|
Chris@150
|
2508 hgQueryParents();
|
Chris@121
|
2509 }
|
Chris@150
|
2510 break;
|
Chris@150
|
2511
|
Chris@150
|
2512 case ACT_LOG_INCREMENTAL:
|
Chris@109
|
2513 hgQueryParents();
|
Chris@150
|
2514 break;
|
Chris@150
|
2515
|
Chris@150
|
2516 case ACT_QUERY_PARENTS:
|
Chris@284
|
2517 if (m_needNewLog) {
|
Chris@120
|
2518 hgLog();
|
Chris@150
|
2519 } else {
|
Chris@150
|
2520 // we're done
|
Chris@156
|
2521 noMore = true;
|
Chris@120
|
2522 }
|
Chris@150
|
2523 break;
|
Chris@150
|
2524
|
Chris@150
|
2525 case ACT_LOG:
|
Chris@150
|
2526 // we're done
|
Chris@156
|
2527 noMore = true;
|
Chris@198
|
2528 break;
|
Chris@150
|
2529
|
Chris@150
|
2530 default:
|
Chris@284
|
2531 if (m_shouldHgStat) {
|
Chris@284
|
2532 m_shouldHgStat = false;
|
Chris@109
|
2533 hgQueryPaths();
|
Chris@150
|
2534 } else {
|
Chris@156
|
2535 noMore = true;
|
jtkorhonen@0
|
2536 }
|
Chris@150
|
2537 break;
|
Chris@150
|
2538 }
|
Chris@156
|
2539
|
Chris@156
|
2540 if (noMore) {
|
Chris@540
|
2541 m_commandSequenceInProgress = false;
|
Chris@284
|
2542 m_stateUnknown = false;
|
Chris@156
|
2543 enableDisableActions();
|
Chris@284
|
2544 m_hgTabs->updateHistory();
|
Chris@359
|
2545 updateRecentMenu();
|
Chris@541
|
2546 checkFilesystem();
|
Chris@156
|
2547 }
|
jtkorhonen@0
|
2548 }
|
jtkorhonen@0
|
2549
|
Chris@564
|
2550 void MainWindow::commandCancelled(HgAction cancelledAction)
|
Chris@564
|
2551 {
|
Chris@564
|
2552 // Originally I had this checking whether the cancelled action was
|
Chris@564
|
2553 // a network one and, if so, calling hgQueryPaths to update the
|
Chris@564
|
2554 // local view in case it had changed anything. But that doesn't
|
Chris@564
|
2555 // work properly -- because at this point, although the command
|
Chris@564
|
2556 // has been cancelled and a kill signal sent, it hasn't actually
|
Chris@564
|
2557 // exited yet. If we request another command now, it will go on
|
Chris@564
|
2558 // the stack and be associated with the failed exit forthcoming
|
Chris@564
|
2559 // from the cancelled command -- giving the user a disturbing
|
Chris@564
|
2560 // command-failed dialog
|
Chris@564
|
2561 }
|
Chris@564
|
2562
|
jtkorhonen@0
|
2563 void MainWindow::connectActions()
|
jtkorhonen@0
|
2564 {
|
Chris@284
|
2565 connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
Chris@284
|
2566 connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
Chris@494
|
2567 connect(m_helpAct, SIGNAL(triggered()), this, SLOT(help()));
|
Chris@273
|
2568
|
Chris@284
|
2569 connect(m_hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
|
Chris@284
|
2570 connect(m_hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
|
Chris@284
|
2571 connect(m_hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
|
Chris@284
|
2572 connect(m_hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
|
Chris@425
|
2573 connect(m_hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
|
Chris@425
|
2574 connect(m_hgEditIgnoreAct, SIGNAL(triggered()), this, SLOT(hgEditIgnore()));
|
Chris@284
|
2575 connect(m_hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
|
Chris@284
|
2576 connect(m_hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
|
Chris@284
|
2577 connect(m_hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
|
Chris@284
|
2578 connect(m_hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
|
Chris@273
|
2579
|
Chris@284
|
2580 connect(m_settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
|
Chris@284
|
2581 connect(m_openAct, SIGNAL(triggered()), this, SLOT(open()));
|
Chris@284
|
2582 connect(m_changeRemoteRepoAct, SIGNAL(triggered()), this, SLOT(changeRemoteRepo()));
|
Chris@273
|
2583
|
Chris@284
|
2584 connect(m_hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
|
Chris@284
|
2585 connect(m_hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
|
Chris@284
|
2586 connect(m_hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
|
Chris@273
|
2587
|
Chris@284
|
2588 connect(m_hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
|
jtkorhonen@0
|
2589 }
|
Chris@141
|
2590
|
Chris@141
|
2591 void MainWindow::connectTabsSignals()
|
Chris@141
|
2592 {
|
Chris@327
|
2593 connect(m_hgTabs, SIGNAL(currentChanged(int)),
|
Chris@327
|
2594 this, SLOT(enableDisableActions()));
|
Chris@327
|
2595
|
Chris@284
|
2596 connect(m_hgTabs, SIGNAL(commit()),
|
Chris@141
|
2597 this, SLOT(hgCommit()));
|
Chris@141
|
2598
|
Chris@284
|
2599 connect(m_hgTabs, SIGNAL(revert()),
|
Chris@141
|
2600 this, SLOT(hgRevert()));
|
Chris@141
|
2601
|
Chris@284
|
2602 connect(m_hgTabs, SIGNAL(diffWorkingFolder()),
|
Chris@141
|
2603 this, SLOT(hgFolderDiff()));
|
Chris@168
|
2604
|
Chris@284
|
2605 connect(m_hgTabs, SIGNAL(showSummary()),
|
Chris@168
|
2606 this, SLOT(hgShowSummary()));
|
Chris@311
|
2607
|
Chris@311
|
2608 connect(m_hgTabs, SIGNAL(newBranch()),
|
Chris@311
|
2609 this, SLOT(hgNewBranch()));
|
Chris@311
|
2610
|
Chris@311
|
2611 connect(m_hgTabs, SIGNAL(noBranch()),
|
Chris@311
|
2612 this, SLOT(hgNoBranch()));
|
Chris@148
|
2613
|
Chris@284
|
2614 connect(m_hgTabs, SIGNAL(updateTo(QString)),
|
Chris@148
|
2615 this, SLOT(hgUpdateToRev(QString)));
|
Chris@141
|
2616
|
Chris@284
|
2617 connect(m_hgTabs, SIGNAL(diffToCurrent(QString)),
|
Chris@148
|
2618 this, SLOT(hgDiffToCurrent(QString)));
|
Chris@141
|
2619
|
Chris@284
|
2620 connect(m_hgTabs, SIGNAL(diffToParent(QString, QString)),
|
Chris@148
|
2621 this, SLOT(hgDiffToParent(QString, QString)));
|
Chris@141
|
2622
|
Chris@289
|
2623 connect(m_hgTabs, SIGNAL(showSummary(Changeset *)),
|
Chris@289
|
2624 this, SLOT(hgShowSummaryFor(Changeset *)));
|
Chris@288
|
2625
|
Chris@284
|
2626 connect(m_hgTabs, SIGNAL(mergeFrom(QString)),
|
Chris@148
|
2627 this, SLOT(hgMergeFrom(QString)));
|
Chris@164
|
2628
|
Chris@307
|
2629 connect(m_hgTabs, SIGNAL(newBranch(QString)),
|
Chris@311
|
2630 this, SLOT(hgNewBranch()));
|
Chris@278
|
2631
|
Chris@514
|
2632 connect(m_hgTabs, SIGNAL(closeBranch(QString)),
|
Chris@514
|
2633 this, SLOT(hgCloseBranch()));
|
Chris@514
|
2634
|
Chris@284
|
2635 connect(m_hgTabs, SIGNAL(tag(QString)),
|
Chris@148
|
2636 this, SLOT(hgTag(QString)));
|
Chris@326
|
2637
|
Chris@326
|
2638 connect(m_hgTabs, SIGNAL(annotateFiles(QStringList)),
|
Chris@326
|
2639 this, SLOT(hgAnnotateFiles(QStringList)));
|
Chris@326
|
2640
|
Chris@326
|
2641 connect(m_hgTabs, SIGNAL(diffFiles(QStringList)),
|
Chris@326
|
2642 this, SLOT(hgDiffFiles(QStringList)));
|
Chris@326
|
2643
|
Chris@326
|
2644 connect(m_hgTabs, SIGNAL(commitFiles(QStringList)),
|
Chris@326
|
2645 this, SLOT(hgCommitFiles(QStringList)));
|
Chris@326
|
2646
|
Chris@326
|
2647 connect(m_hgTabs, SIGNAL(revertFiles(QStringList)),
|
Chris@326
|
2648 this, SLOT(hgRevertFiles(QStringList)));
|
Chris@326
|
2649
|
Chris@361
|
2650 connect(m_hgTabs, SIGNAL(renameFiles(QStringList)),
|
Chris@361
|
2651 this, SLOT(hgRenameFiles(QStringList)));
|
Chris@361
|
2652
|
Chris@361
|
2653 connect(m_hgTabs, SIGNAL(copyFiles(QStringList)),
|
Chris@361
|
2654 this, SLOT(hgCopyFiles(QStringList)));
|
Chris@361
|
2655
|
Chris@326
|
2656 connect(m_hgTabs, SIGNAL(addFiles(QStringList)),
|
Chris@326
|
2657 this, SLOT(hgAddFiles(QStringList)));
|
Chris@326
|
2658
|
Chris@326
|
2659 connect(m_hgTabs, SIGNAL(removeFiles(QStringList)),
|
Chris@326
|
2660 this, SLOT(hgRemoveFiles(QStringList)));
|
Chris@326
|
2661
|
Chris@326
|
2662 connect(m_hgTabs, SIGNAL(redoFileMerges(QStringList)),
|
Chris@326
|
2663 this, SLOT(hgRedoFileMerges(QStringList)));
|
Chris@326
|
2664
|
Chris@326
|
2665 connect(m_hgTabs, SIGNAL(markFilesResolved(QStringList)),
|
Chris@326
|
2666 this, SLOT(hgMarkFilesResolved(QStringList)));
|
Chris@326
|
2667
|
Chris@326
|
2668 connect(m_hgTabs, SIGNAL(ignoreFiles(QStringList)),
|
Chris@326
|
2669 this, SLOT(hgIgnoreFiles(QStringList)));
|
Chris@326
|
2670
|
Chris@326
|
2671 connect(m_hgTabs, SIGNAL(unIgnoreFiles(QStringList)),
|
Chris@326
|
2672 this, SLOT(hgUnIgnoreFiles(QStringList)));
|
Chris@141
|
2673 }
|
Chris@141
|
2674
|
jtkorhonen@0
|
2675 void MainWindow::enableDisableActions()
|
jtkorhonen@0
|
2676 {
|
Chris@90
|
2677 DEBUG << "MainWindow::enableDisableActions" << endl;
|
Chris@90
|
2678
|
Chris@284
|
2679 QString dirname = QDir(m_workFolderPath).dirName();
|
Chris@340
|
2680
|
Chris@340
|
2681 if (m_workFolderPath != "") { // dirname of "" is ".", so test path instead
|
Chris@202
|
2682 setWindowTitle(tr("EasyMercurial: %1").arg(dirname));
|
Chris@202
|
2683 } else {
|
Chris@202
|
2684 setWindowTitle(tr("EasyMercurial"));
|
Chris@202
|
2685 }
|
Chris@202
|
2686
|
Chris@115
|
2687 //!!! should also do things like set the status texts for the
|
Chris@115
|
2688 //!!! actions appropriately by context
|
Chris@115
|
2689
|
jtkorhonen@0
|
2690 QDir localRepoDir;
|
jtkorhonen@0
|
2691 QDir workFolderDir;
|
jtkorhonen@0
|
2692
|
Chris@284
|
2693 m_remoteRepoActionsEnabled = true;
|
Chris@284
|
2694 if (m_remoteRepoPath.isEmpty()) {
|
Chris@284
|
2695 m_remoteRepoActionsEnabled = false;
|
jtkorhonen@0
|
2696 }
|
jtkorhonen@0
|
2697
|
Chris@284
|
2698 m_localRepoActionsEnabled = true;
|
Chris@284
|
2699 if (m_workFolderPath.isEmpty()) {
|
Chris@284
|
2700 m_localRepoActionsEnabled = false;
|
jtkorhonen@0
|
2701 }
|
jtkorhonen@0
|
2702
|
Chris@284
|
2703 if (m_workFolderPath == "" || !workFolderDir.exists(m_workFolderPath)) {
|
Chris@284
|
2704 m_localRepoActionsEnabled = false;
|
jtkorhonen@0
|
2705 }
|
jtkorhonen@0
|
2706
|
Chris@284
|
2707 if (!localRepoDir.exists(m_workFolderPath + "/.hg")) {
|
Chris@284
|
2708 m_localRepoActionsEnabled = false;
|
jtkorhonen@0
|
2709 }
|
jtkorhonen@0
|
2710
|
Chris@179
|
2711 bool haveDiff = false;
|
Chris@179
|
2712 QSettings settings;
|
Chris@179
|
2713 settings.beginGroup("Locations");
|
Chris@179
|
2714 if (settings.value("extdiffbinary", "").toString() != "") {
|
Chris@179
|
2715 haveDiff = true;
|
Chris@179
|
2716 }
|
Chris@179
|
2717 settings.endGroup();
|
Chris@112
|
2718
|
Chris@505
|
2719 m_hgTabs->setHaveMerge(m_currentParents.size() == 2);
|
Chris@505
|
2720
|
Chris@365
|
2721 m_hgRefreshAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2722 m_hgFolderDiffAct->setEnabled(m_localRepoActionsEnabled && haveDiff);
|
Chris@365
|
2723 m_hgRevertAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2724 m_hgAddAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2725 m_hgRemoveAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@425
|
2726 m_hgIgnoreAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2727 m_hgUpdateAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2728 m_hgCommitAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2729 m_hgMergeAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@365
|
2730 m_hgServeAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@413
|
2731 m_hgEditIgnoreAct->setEnabled(m_localRepoActionsEnabled);
|
Chris@273
|
2732
|
Chris@284
|
2733 DEBUG << "m_localRepoActionsEnabled = " << m_localRepoActionsEnabled << endl;
|
Chris@284
|
2734 DEBUG << "canCommit = " << m_hgTabs->canCommit() << endl;
|
Chris@273
|
2735
|
Chris@284
|
2736 m_hgAddAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canAdd());
|
Chris@284
|
2737 m_hgRemoveAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canRemove());
|
Chris@284
|
2738 m_hgCommitAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canCommit());
|
Chris@284
|
2739 m_hgRevertAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canRevert());
|
Chris@284
|
2740 m_hgFolderDiffAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canDiff());
|
Chris@425
|
2741 m_hgIgnoreAct->setEnabled(m_localRepoActionsEnabled && m_hgTabs->canIgnore());
|
Chris@90
|
2742
|
Chris@108
|
2743 // A default merge makes sense if:
|
Chris@108
|
2744 // * there is only one parent (if there are two, we have an uncommitted merge) and
|
Chris@108
|
2745 // * there are exactly two heads that have the same branch as the current branch and
|
Chris@108
|
2746 // * our parent is one of those heads
|
Chris@108
|
2747 //
|
Chris@108
|
2748 // A default update makes sense if:
|
Chris@108
|
2749 // * there is only one parent and
|
Chris@108
|
2750 // * the parent is not one of the current heads
|
Chris@156
|
2751
|
Chris@108
|
2752 bool canMerge = false;
|
Chris@108
|
2753 bool canUpdate = false;
|
Chris@156
|
2754 bool haveMerge = false;
|
Chris@162
|
2755 bool emptyRepo = false;
|
Chris@225
|
2756 bool noWorkingCopy = false;
|
Chris@235
|
2757 bool newBranch = false;
|
Chris@506
|
2758 bool closedBranch = false;
|
Chris@506
|
2759 int currentBranchActiveHeads = 0;
|
Chris@273
|
2760
|
Chris@284
|
2761 if (m_currentParents.size() == 1) {
|
Chris@156
|
2762 bool parentIsHead = false;
|
Chris@506
|
2763 bool parentIsActiveHead = false;
|
Chris@284
|
2764 Changeset *parent = m_currentParents[0];
|
Chris@506
|
2765 foreach (Changeset *head, m_activeHeads) {
|
Chris@284
|
2766 if (head->isOnBranch(m_currentBranch)) {
|
Chris@506
|
2767 ++currentBranchActiveHeads;
|
Chris@235
|
2768 }
|
Chris@235
|
2769 if (parent->id() == head->id()) {
|
Chris@506
|
2770 parentIsActiveHead = parentIsHead = true;
|
Chris@108
|
2771 }
|
Chris@108
|
2772 }
|
Chris@506
|
2773 if (!parentIsActiveHead) {
|
Chris@506
|
2774 foreach (Changeset *head, m_currentHeads) {
|
Chris@506
|
2775 if (parent->id() == head->id()) {
|
Chris@506
|
2776 parentIsHead = true;
|
Chris@506
|
2777 }
|
Chris@506
|
2778 }
|
Chris@506
|
2779 }
|
Chris@506
|
2780 if (currentBranchActiveHeads == 2 && parentIsActiveHead) {
|
Chris@108
|
2781 canMerge = true;
|
Chris@108
|
2782 }
|
Chris@506
|
2783 if (currentBranchActiveHeads == 0 && parentIsActiveHead) {
|
Chris@235
|
2784 // Just created a new branch
|
Chris@235
|
2785 newBranch = true;
|
Chris@235
|
2786 }
|
Chris@108
|
2787 if (!parentIsHead) {
|
Chris@108
|
2788 canUpdate = true;
|
Chris@108
|
2789 DEBUG << "parent id = " << parent->id() << endl;
|
Chris@108
|
2790 DEBUG << " head ids "<<endl;
|
Chris@284
|
2791 foreach (Changeset *h, m_currentHeads) {
|
Chris@108
|
2792 DEBUG << "head id = " << h->id() << endl;
|
Chris@108
|
2793 }
|
Chris@506
|
2794 } else if (!parentIsActiveHead) {
|
Chris@506
|
2795 closedBranch = true;
|
Chris@108
|
2796 }
|
Chris@284
|
2797 m_justMerged = false;
|
Chris@284
|
2798 } else if (m_currentParents.size() == 0) {
|
Chris@284
|
2799 if (m_currentHeads.size() == 0) {
|
Chris@225
|
2800 // No heads -> empty repo
|
Chris@225
|
2801 emptyRepo = true;
|
Chris@225
|
2802 } else {
|
Chris@225
|
2803 // Heads, but no parents -> no working copy, e.g. we have
|
Chris@225
|
2804 // just converted this repo but haven't updated in it yet.
|
Chris@225
|
2805 // Uncommon but confusing; probably merits a special case
|
Chris@225
|
2806 noWorkingCopy = true;
|
Chris@225
|
2807 canUpdate = true;
|
Chris@225
|
2808 }
|
Chris@284
|
2809 m_justMerged = false;
|
Chris@156
|
2810 } else {
|
Chris@156
|
2811 haveMerge = true;
|
Chris@284
|
2812 m_justMerged = true;
|
Chris@108
|
2813 }
|
Chris@505
|
2814
|
Chris@363
|
2815 m_hgIncomingAct->setEnabled(m_remoteRepoActionsEnabled);
|
Chris@363
|
2816 m_hgPullAct->setEnabled(m_remoteRepoActionsEnabled);
|
Chris@363
|
2817 // permit push even if no remote yet; we'll ask for one
|
Chris@363
|
2818 m_hgPushAct->setEnabled(m_localRepoActionsEnabled && !emptyRepo);
|
Chris@363
|
2819
|
Chris@284
|
2820 m_hgMergeAct->setEnabled(m_localRepoActionsEnabled &&
|
Chris@506
|
2821 (canMerge || m_hgTabs->canResolve()));
|
Chris@284
|
2822 m_hgUpdateAct->setEnabled(m_localRepoActionsEnabled &&
|
Chris@506
|
2823 (canUpdate && !m_hgTabs->haveChangesToCommit()));
|
Chris@115
|
2824
|
Chris@115
|
2825 // Set the state field on the file status widget
|
Chris@115
|
2826
|
Chris@115
|
2827 QString branchText;
|
Chris@284
|
2828 if (m_currentBranch == "" || m_currentBranch == "default") {
|
Chris@115
|
2829 branchText = tr("the default branch");
|
Chris@115
|
2830 } else {
|
Chris@284
|
2831 branchText = tr("branch \"%1\"").arg(m_currentBranch);
|
Chris@115
|
2832 }
|
Chris@156
|
2833
|
Chris@284
|
2834 if (m_stateUnknown) {
|
Chris@284
|
2835 if (m_workFolderPath == "") {
|
Chris@287
|
2836 m_workStatus->setState(tr("No repository open"));
|
Chris@248
|
2837 } else {
|
Chris@287
|
2838 m_workStatus->setState(tr("(Examining repository)"));
|
Chris@248
|
2839 }
|
Chris@173
|
2840 } else if (emptyRepo) {
|
Chris@287
|
2841 m_workStatus->setState(tr("Nothing committed to this repository yet"));
|
Chris@225
|
2842 } else if (noWorkingCopy) {
|
Chris@287
|
2843 m_workStatus->setState(tr("No working copy yet: consider updating"));
|
Chris@162
|
2844 } else if (canMerge) {
|
Chris@287
|
2845 m_workStatus->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
|
Chris@284
|
2846 } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) {
|
Chris@287
|
2847 m_workStatus->setState(tr("Have unresolved files following merge on %1").arg(branchText));
|
Chris@156
|
2848 } else if (haveMerge) {
|
Chris@287
|
2849 m_workStatus->setState(tr("Have merged but not yet committed on %1").arg(branchText));
|
Chris@235
|
2850 } else if (newBranch) {
|
Chris@287
|
2851 m_workStatus->setState(tr("On %1. New branch: has not yet been committed").arg(branchText));
|
Chris@506
|
2852 } else if (closedBranch) {
|
Chris@506
|
2853 if (canUpdate) {
|
Chris@506
|
2854 m_workStatus->setState(tr("On a closed branch. Not at the head of the branch"));
|
Chris@506
|
2855 } else {
|
Chris@506
|
2856 m_workStatus->setState(tr("At the head of a closed branch"));
|
Chris@506
|
2857 }
|
Chris@156
|
2858 } else if (canUpdate) {
|
Chris@284
|
2859 if (m_hgTabs->haveChangesToCommit()) {
|
Chris@163
|
2860 // have uncommitted changes
|
Chris@287
|
2861 m_workStatus->setState(tr("On %1. Not at the head of the branch").arg(branchText));
|
Chris@163
|
2862 } else {
|
Chris@163
|
2863 // no uncommitted changes
|
Chris@287
|
2864 m_workStatus->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
|
Chris@163
|
2865 }
|
Chris@506
|
2866 } else if (currentBranchActiveHeads > 1) {
|
Chris@506
|
2867 m_workStatus->setState(tr("At one of %n heads of %1", "", currentBranchActiveHeads).arg(branchText));
|
Chris@115
|
2868 } else {
|
Chris@287
|
2869 m_workStatus->setState(tr("At the head of %1").arg(branchText));
|
Chris@115
|
2870 }
|
jtkorhonen@0
|
2871 }
|
jtkorhonen@0
|
2872
|
Chris@359
|
2873
|
Chris@506
|
2874 void MainWindow::updateClosedHeads()
|
Chris@506
|
2875 {
|
Chris@506
|
2876 m_closedHeadIds.clear();
|
Chris@506
|
2877 QSet<QString> activeIds;
|
Chris@506
|
2878 foreach (Changeset *cs, m_activeHeads) {
|
Chris@506
|
2879 activeIds.insert(cs->id());
|
Chris@506
|
2880 }
|
Chris@506
|
2881 foreach (Changeset *cs, m_currentHeads) {
|
Chris@506
|
2882 if (!activeIds.contains(cs->id())) {
|
Chris@506
|
2883 m_closedHeadIds.insert(cs->id());
|
Chris@506
|
2884 }
|
Chris@506
|
2885 }
|
Chris@506
|
2886 m_hgTabs->setClosedHeadIds(m_closedHeadIds);
|
Chris@506
|
2887 }
|
Chris@506
|
2888
|
Chris@359
|
2889 void MainWindow::updateRecentMenu()
|
Chris@359
|
2890 {
|
Chris@359
|
2891 m_recentMenu->clear();
|
Chris@359
|
2892 RecentFiles rf("Recent-local");
|
Chris@359
|
2893 QStringList recent = rf.getRecent();
|
Chris@359
|
2894 if (recent.empty()) {
|
Chris@359
|
2895 QLabel *label = new QLabel(tr("No recent local repositories"));
|
Chris@359
|
2896 QWidgetAction *wa = new QWidgetAction(m_recentMenu);
|
Chris@359
|
2897 wa->setDefaultWidget(label);
|
Chris@359
|
2898 return;
|
Chris@359
|
2899 }
|
Chris@359
|
2900 foreach (QString r, recent) {
|
Chris@359
|
2901 QAction *a = m_recentMenu->addAction(r);
|
Chris@611
|
2902 connect(a, SIGNAL(triggered()), this, SLOT(recentMenuActivated()));
|
Chris@359
|
2903 }
|
Chris@359
|
2904 }
|
Chris@359
|
2905
|
jtkorhonen@0
|
2906 void MainWindow::createActions()
|
jtkorhonen@0
|
2907 {
|
jtkorhonen@0
|
2908 //File actions
|
Chris@365
|
2909 m_openAct = new QAction(QIcon(":/images/fileopen.png"), tr("&Open..."), this);
|
Chris@609
|
2910 m_openAct->setStatusTip(tr("Open a remote repository or an existing local folder"));
|
Chris@365
|
2911 m_openAct->setShortcut(tr("Ctrl+O"));
|
Chris@365
|
2912
|
Chris@609
|
2913 m_changeRemoteRepoAct = new QAction(tr("Set Push and Pull &Location..."), this);
|
Chris@609
|
2914 m_changeRemoteRepoAct->setStatusTip(tr("Set or change the default URL for pull and push actions from this repository"));
|
Chris@273
|
2915
|
Chris@365
|
2916 m_settingsAct = new QAction(QIcon(":/images/settings.png"), tr("&Settings..."), this);
|
Chris@365
|
2917 m_settingsAct->setStatusTip(tr("View and change application settings"));
|
Chris@273
|
2918
|
Chris@343
|
2919 #ifdef Q_OS_WIN32
|
Chris@365
|
2920 m_exitAct = new QAction(QIcon(":/images/exit.png"), tr("E&xit"), this);
|
Chris@343
|
2921 #else
|
Chris@365
|
2922 m_exitAct = new QAction(QIcon(":/images/exit.png"), tr("&Quit"), this);
|
Chris@343
|
2923 #endif
|
Chris@284
|
2924 m_exitAct->setShortcuts(QKeySequence::Quit);
|
Chris@365
|
2925 m_exitAct->setStatusTip(tr("Exit EasyMercurial"));
|
jtkorhonen@0
|
2926
|
jtkorhonen@0
|
2927 //Repository actions
|
Chris@544
|
2928 m_hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("&Re-Read Working Folder"), this);
|
Chris@365
|
2929 m_hgRefreshAct->setShortcut(tr("Ctrl+R"));
|
Chris@284
|
2930 m_hgRefreshAct->setStatusTip(tr("Refresh the window to show the current state of the working folder"));
|
Chris@273
|
2931
|
Chris@365
|
2932 m_hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Pre&view Incoming Changes"), this);
|
Chris@365
|
2933 m_hgIncomingAct->setIconText(tr("Preview"));
|
Chris@365
|
2934 m_hgIncomingAct->setStatusTip(tr("See what changes are available in the remote repository waiting to be pulled"));
|
Chris@365
|
2935
|
Chris@365
|
2936 m_hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pu&ll from Remote Repository"), this);
|
Chris@365
|
2937 m_hgPullAct->setIconText(tr("Pull"));
|
Chris@365
|
2938 m_hgPullAct->setShortcut(tr("Ctrl+L"));
|
Chris@365
|
2939 m_hgPullAct->setStatusTip(tr("Pull changes from the remote repository to the local repository"));
|
Chris@365
|
2940
|
Chris@365
|
2941 m_hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Pus&h to Remote Repository"), this);
|
Chris@365
|
2942 m_hgPushAct->setIconText(tr("Push"));
|
Chris@365
|
2943 m_hgPushAct->setShortcut(tr("Ctrl+H"));
|
Chris@284
|
2944 m_hgPushAct->setStatusTip(tr("Push changes from the local repository to the remote repository"));
|
jtkorhonen@0
|
2945
|
jtkorhonen@0
|
2946 //Workfolder actions
|
Chris@365
|
2947 m_hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("&Diff"), this);
|
Chris@365
|
2948 m_hgFolderDiffAct->setIconText(tr("Diff"));
|
Chris@365
|
2949 m_hgFolderDiffAct->setShortcut(tr("Ctrl+D"));
|
Chris@284
|
2950 m_hgFolderDiffAct->setStatusTip(tr("See what has changed in the working folder compared with the last committed state"));
|
Chris@273
|
2951
|
Chris@365
|
2952 m_hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Re&vert"), this);
|
Chris@284
|
2953 m_hgRevertAct->setStatusTip(tr("Throw away your changes and return to the last committed state"));
|
Chris@273
|
2954
|
Chris@365
|
2955 m_hgAddAct = new QAction(QIcon(":/images/add.png"), tr("&Add Files"), this);
|
Chris@365
|
2956 m_hgAddAct->setIconText(tr("Add"));
|
Chris@365
|
2957 m_hgAddAct->setShortcut(tr("+"));
|
Chris@365
|
2958 m_hgAddAct->setStatusTip(tr("Mark the selected files to be added on the next commit"));
|
Chris@365
|
2959
|
Chris@365
|
2960 m_hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("&Remove Files"), this);
|
Chris@365
|
2961 m_hgRemoveAct->setIconText(tr("Remove"));
|
Chris@365
|
2962 m_hgRemoveAct->setShortcut(tr("Del"));
|
Chris@365
|
2963 m_hgRemoveAct->setStatusTip(tr("Mark the selected files to be removed from version control on the next commit"));
|
Chris@365
|
2964
|
Chris@425
|
2965 m_hgIgnoreAct = new QAction(tr("&Ignore Files..."), this);
|
Chris@425
|
2966 m_hgIgnoreAct->setStatusTip(tr("Add the selected filenames to the ignored list, of files that should never be tracked in this repository"));
|
Chris@425
|
2967
|
Chris@425
|
2968 m_hgEditIgnoreAct = new QAction(tr("Edit Ignored List"), this);
|
Chris@425
|
2969 m_hgEditIgnoreAct->setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial"));
|
Chris@425
|
2970
|
Chris@365
|
2971 m_hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("&Update to Branch Head"), this);
|
Chris@365
|
2972 m_hgUpdateAct->setIconText(tr("Update"));
|
Chris@365
|
2973 m_hgUpdateAct->setShortcut(tr("Ctrl+U"));
|
Chris@284
|
2974 m_hgUpdateAct->setStatusTip(tr("Update the working folder to the head of the current repository branch"));
|
jtkorhonen@0
|
2975
|
Chris@365
|
2976 m_hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("&Commit..."), this);
|
Chris@365
|
2977 m_hgCommitAct->setShortcut(tr("Ctrl+Return"));
|
Chris@284
|
2978 m_hgCommitAct->setStatusTip(tr("Commit your changes to the local repository"));
|
Chris@273
|
2979
|
Chris@365
|
2980 m_hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("&Merge"), this);
|
Chris@365
|
2981 m_hgMergeAct->setShortcut(tr("Ctrl+M"));
|
Chris@284
|
2982 m_hgMergeAct->setStatusTip(tr("Merge the two independent sets of changes in the local repository into the working folder"));
|
jtkorhonen@0
|
2983
|
Chris@425
|
2984 m_hgServeAct = new QAction(tr("Share Repository"), this);
|
Chris@425
|
2985 m_hgServeAct->setStatusTip(tr("Serve local repository temporarily via HTTP for workgroup access"));
|
jtkorhonen@11
|
2986
|
jtkorhonen@0
|
2987 //Help actions
|
Chris@494
|
2988 #ifdef Q_OS_MAC
|
Chris@494
|
2989 m_helpAct = new QAction(tr("EasyMercurial Help"), this);
|
Chris@494
|
2990 #else
|
Chris@494
|
2991 m_helpAct = new QAction(tr("Help Topics"), this);
|
Chris@494
|
2992 #endif
|
Chris@494
|
2993 m_helpAct->setShortcuts(QKeySequence::HelpContents);
|
Chris@284
|
2994 m_aboutAct = new QAction(tr("About EasyMercurial"), this);
|
Chris@94
|
2995
|
Chris@94
|
2996 // Miscellaneous
|
Chris@199
|
2997 QShortcut *clearSelectionsShortcut = new QShortcut(Qt::Key_Escape, this);
|
Chris@199
|
2998 connect(clearSelectionsShortcut, SIGNAL(activated()),
|
Chris@199
|
2999 this, SLOT(clearSelections()));
|
jtkorhonen@0
|
3000 }
|
jtkorhonen@0
|
3001
|
jtkorhonen@0
|
3002 void MainWindow::createMenus()
|
jtkorhonen@0
|
3003 {
|
Chris@365
|
3004 m_fileMenu = menuBar()->addMenu(tr("&File"));
|
Chris@365
|
3005
|
Chris@365
|
3006 m_fileMenu->addAction(m_openAct);
|
Chris@365
|
3007 m_recentMenu = m_fileMenu->addMenu(tr("Open Re¢"));
|
Chris@365
|
3008 m_fileMenu->addAction(m_hgRefreshAct);
|
Chris@365
|
3009 m_fileMenu->addSeparator();
|
Chris@425
|
3010 m_fileMenu->addAction(m_hgServeAct);
|
Chris@425
|
3011 m_fileMenu->addSeparator();
|
Chris@365
|
3012 m_fileMenu->addAction(m_settingsAct);
|
Chris@365
|
3013 m_fileMenu->addSeparator();
|
Chris@365
|
3014 m_fileMenu->addAction(m_exitAct);
|
Chris@365
|
3015
|
Chris@365
|
3016 QMenu *workMenu;
|
Chris@365
|
3017 workMenu = menuBar()->addMenu(tr("&Work"));
|
Chris@365
|
3018 workMenu->addAction(m_hgFolderDiffAct);
|
Chris@365
|
3019 workMenu->addSeparator();
|
Chris@365
|
3020 workMenu->addAction(m_hgUpdateAct);
|
Chris@365
|
3021 workMenu->addAction(m_hgCommitAct);
|
Chris@365
|
3022 workMenu->addAction(m_hgMergeAct);
|
Chris@365
|
3023 workMenu->addSeparator();
|
Chris@365
|
3024 workMenu->addAction(m_hgAddAct);
|
Chris@365
|
3025 workMenu->addAction(m_hgRemoveAct);
|
Chris@365
|
3026 workMenu->addSeparator();
|
Chris@425
|
3027 workMenu->addAction(m_hgIgnoreAct);
|
Chris@425
|
3028 workMenu->addAction(m_hgEditIgnoreAct);
|
Chris@425
|
3029 workMenu->addSeparator();
|
Chris@365
|
3030 workMenu->addAction(m_hgRevertAct);
|
Chris@365
|
3031
|
Chris@365
|
3032 QMenu *remoteMenu;
|
Chris@365
|
3033 remoteMenu = menuBar()->addMenu(tr("&Remote"));
|
Chris@365
|
3034 remoteMenu->addAction(m_hgIncomingAct);
|
Chris@365
|
3035 remoteMenu->addSeparator();
|
Chris@609
|
3036 remoteMenu->addAction(m_changeRemoteRepoAct);
|
Chris@365
|
3037 remoteMenu->addAction(m_hgPullAct);
|
Chris@365
|
3038 remoteMenu->addAction(m_hgPushAct);
|
Chris@273
|
3039
|
Chris@378
|
3040 m_helpMenu = menuBar()->addMenu(tr("&Help"));
|
Chris@494
|
3041 m_helpMenu->addAction(m_helpAct);
|
Chris@284
|
3042 m_helpMenu->addAction(m_aboutAct);
|
jtkorhonen@0
|
3043 }
|
jtkorhonen@0
|
3044
|
jtkorhonen@0
|
3045 void MainWindow::createToolBars()
|
jtkorhonen@0
|
3046 {
|
Chris@442
|
3047 int sz = 32;
|
Chris@442
|
3048
|
Chris@543
|
3049 bool spacingReqd = false;
|
chris@550
|
3050 QString spacer = "";
|
Chris@543
|
3051 #ifndef Q_OS_MAC
|
Chris@543
|
3052 spacingReqd = true;
|
chris@550
|
3053 spacer = " ";
|
chris@550
|
3054 #ifdef Q_OS_WIN32
|
chris@550
|
3055 spacer = " ";
|
chris@550
|
3056 #endif
|
Chris@543
|
3057 #endif
|
Chris@273
|
3058
|
Chris@594
|
3059 m_workFolderToolBar = new QToolBar(tr("Work"));
|
Chris@284
|
3060 addToolBar(Qt::LeftToolBarArea, m_workFolderToolBar);
|
Chris@442
|
3061 m_workFolderToolBar->setIconSize(QSize(sz, sz));
|
Chris@543
|
3062 if (spacingReqd) {
|
Chris@543
|
3063 QWidget *w = new QWidget;
|
Chris@543
|
3064 w->setFixedHeight(6);
|
Chris@543
|
3065 m_workFolderToolBar->addWidget(w);
|
Chris@543
|
3066 }
|
Chris@284
|
3067 m_workFolderToolBar->addAction(m_hgFolderDiffAct);
|
Chris@284
|
3068 m_workFolderToolBar->addSeparator();
|
Chris@284
|
3069 m_workFolderToolBar->addAction(m_hgRevertAct);
|
Chris@284
|
3070 m_workFolderToolBar->addAction(m_hgUpdateAct);
|
Chris@284
|
3071 m_workFolderToolBar->addAction(m_hgCommitAct);
|
Chris@284
|
3072 m_workFolderToolBar->addAction(m_hgMergeAct);
|
Chris@284
|
3073 m_workFolderToolBar->addSeparator();
|
Chris@284
|
3074 m_workFolderToolBar->addAction(m_hgAddAct);
|
Chris@284
|
3075 m_workFolderToolBar->addAction(m_hgRemoveAct);
|
Chris@365
|
3076 m_workFolderToolBar->setMovable(false);
|
Chris@61
|
3077
|
Chris@543
|
3078 m_repoToolBar = addToolBar(tr("Remote"));
|
Chris@543
|
3079 m_repoToolBar->setIconSize(QSize(sz, sz));
|
Chris@572
|
3080 if (spacingReqd) {
|
Chris@572
|
3081 m_repoToolBar->addWidget(new QLabel(spacer));
|
Chris@572
|
3082 }
|
Chris@543
|
3083 m_repoToolBar->addAction(m_openAct);
|
Chris@572
|
3084 if (spacingReqd) {
|
Chris@572
|
3085 m_repoToolBar->addWidget(new QLabel(spacer));
|
Chris@572
|
3086 }
|
Chris@543
|
3087 m_repoToolBar->addSeparator();
|
Chris@543
|
3088 m_repoToolBar->addAction(m_hgIncomingAct);
|
Chris@543
|
3089 m_repoToolBar->addAction(m_hgPullAct);
|
Chris@543
|
3090 m_repoToolBar->addAction(m_hgPushAct);
|
Chris@543
|
3091 m_repoToolBar->setMovable(false);
|
Chris@543
|
3092
|
Chris@230
|
3093 updateToolBarStyle();
|
jtkorhonen@0
|
3094 }
|
jtkorhonen@0
|
3095
|
Chris@230
|
3096 void MainWindow::updateToolBarStyle()
|
Chris@230
|
3097 {
|
Chris@230
|
3098 QSettings settings;
|
Chris@230
|
3099 settings.beginGroup("Presentation");
|
Chris@230
|
3100 bool showText = settings.value("showiconlabels", true).toBool();
|
Chris@230
|
3101 settings.endGroup();
|
Chris@230
|
3102
|
Chris@230
|
3103 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
|
Chris@230
|
3104 tb->setToolButtonStyle(showText ?
|
Chris@230
|
3105 Qt::ToolButtonTextUnderIcon :
|
Chris@230
|
3106 Qt::ToolButtonIconOnly);
|
Chris@230
|
3107 }
|
Chris@230
|
3108 }
|
jtkorhonen@0
|
3109
|
Chris@287
|
3110 void MainWindow::updateWorkFolderAndRepoNames()
|
Chris@287
|
3111 {
|
Chris@287
|
3112 m_hgTabs->setLocalPath(m_workFolderPath);
|
Chris@287
|
3113
|
Chris@287
|
3114 m_workStatus->setLocalPath(m_workFolderPath);
|
Chris@287
|
3115 m_workStatus->setRemoteURL(m_remoteRepoPath);
|
Chris@287
|
3116 }
|
Chris@287
|
3117
|
jtkorhonen@0
|
3118 void MainWindow::createStatusBar()
|
jtkorhonen@0
|
3119 {
|
jtkorhonen@0
|
3120 statusBar()->showMessage(tr("Ready"));
|
jtkorhonen@0
|
3121 }
|
jtkorhonen@0
|
3122
|
jtkorhonen@0
|
3123 void MainWindow::readSettings()
|
jtkorhonen@0
|
3124 {
|
jtkorhonen@0
|
3125 QDir workFolder;
|
jtkorhonen@0
|
3126
|
Chris@61
|
3127 QSettings settings;
|
jtkorhonen@0
|
3128
|
Chris@284
|
3129 m_workFolderPath = settings.value("workfolderpath", "").toString();
|
Chris@553
|
3130 if (!workFolder.exists(m_workFolderPath)) {
|
Chris@284
|
3131 m_workFolderPath = "";
|
jtkorhonen@0
|
3132 }
|
jtkorhonen@0
|
3133
|
jtkorhonen@0
|
3134 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
Chris@340
|
3135 QSize size = settings.value("size", QSize(550, 550)).toSize();
|
Chris@284
|
3136 m_firstStart = settings.value("firststart", QVariant(true)).toBool();
|
jtkorhonen@0
|
3137
|
jtkorhonen@0
|
3138 resize(size);
|
jtkorhonen@0
|
3139 move(pos);
|
jtkorhonen@0
|
3140 }
|
jtkorhonen@0
|
3141
|
jtkorhonen@0
|
3142 void MainWindow::writeSettings()
|
jtkorhonen@0
|
3143 {
|
Chris@61
|
3144 QSettings settings;
|
jtkorhonen@0
|
3145 settings.setValue("pos", pos());
|
jtkorhonen@0
|
3146 settings.setValue("size", size());
|
Chris@284
|
3147 settings.setValue("remoterepopath", m_remoteRepoPath);
|
Chris@284
|
3148 settings.setValue("workfolderpath", m_workFolderPath);
|
Chris@284
|
3149 settings.setValue("firststart", m_firstStart);
|
jtkorhonen@0
|
3150 }
|
jtkorhonen@0
|
3151
|
Chris@491
|
3152 void MainWindow::newerVersionAvailable(QString version)
|
Chris@491
|
3153 {
|
Chris@491
|
3154 QSettings settings;
|
Chris@491
|
3155 settings.beginGroup("NewerVersionWarning");
|
Chris@491
|
3156 QString tag = QString("version-%1-available-show").arg(version);
|
Chris@491
|
3157 if (settings.value(tag, true).toBool()) {
|
Chris@491
|
3158 QString title(tr("Newer version available"));
|
Chris@491
|
3159 QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of EasyMercurial, but version %3 is now available.</p><p>Please see the <a href=\"http://easymercurial.org/\">EasyMercurial website</a> for more information.</p>").arg(EASYHG_VERSION).arg(version));
|
Chris@491
|
3160 QMessageBox::information(this, title, text);
|
Chris@491
|
3161 settings.setValue(tag, false);
|
Chris@491
|
3162 }
|
Chris@491
|
3163 settings.endGroup();
|
Chris@491
|
3164 }
|
Chris@491
|
3165
|
Chris@494
|
3166 void MainWindow::help()
|
Chris@494
|
3167 {
|
Chris@494
|
3168 if (!m_helpDialog) {
|
Chris@494
|
3169 m_helpDialog = new QDialog;
|
Chris@494
|
3170 QGridLayout *layout = new QGridLayout;
|
Chris@494
|
3171 m_helpDialog->setLayout(layout);
|
Chris@498
|
3172 QPushButton *home = new QPushButton;
|
Chris@498
|
3173 home->setIcon(QIcon(":images/home.png"));
|
Chris@498
|
3174 layout->addWidget(home, 0, 0);
|
Chris@498
|
3175 QPushButton *back = new QPushButton;
|
Chris@498
|
3176 back->setIcon(QIcon(":images/back.png"));
|
Chris@498
|
3177 layout->addWidget(back, 0, 1);
|
Chris@498
|
3178 QPushButton *fwd = new QPushButton;
|
Chris@498
|
3179 fwd->setIcon(QIcon(":images/forward.png"));
|
Chris@498
|
3180 layout->addWidget(fwd, 0, 2);
|
Chris@494
|
3181 QTextBrowser *text = new QTextBrowser;
|
Chris@494
|
3182 text->setOpenExternalLinks(true);
|
Chris@498
|
3183 layout->addWidget(text, 1, 0, 1, 4);
|
Chris@494
|
3184 text->setSource(QUrl("qrc:help/topics.html"));
|
Chris@494
|
3185 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
|
Chris@494
|
3186 connect(bb, SIGNAL(rejected()), m_helpDialog, SLOT(hide()));
|
Chris@498
|
3187 connect(text, SIGNAL(backwardAvailable(bool)),
|
Chris@498
|
3188 back, SLOT(setEnabled(bool)));
|
Chris@498
|
3189 connect(text, SIGNAL(forwardAvailable(bool)),
|
Chris@498
|
3190 fwd, SLOT(setEnabled(bool)));
|
Chris@498
|
3191 connect(home, SIGNAL(clicked()), text, SLOT(home()));
|
Chris@498
|
3192 connect(back, SIGNAL(clicked()), text, SLOT(backward()));
|
Chris@498
|
3193 connect(fwd, SIGNAL(clicked()), text, SLOT(forward()));
|
Chris@498
|
3194 back->setEnabled(false);
|
Chris@498
|
3195 fwd->setEnabled(false);
|
Chris@498
|
3196 layout->addWidget(bb, 2, 0, 1, 4);
|
Chris@498
|
3197 layout->setColumnStretch(3, 20);
|
Chris@494
|
3198 m_helpDialog->resize(450, 500);
|
Chris@494
|
3199 }
|
Chris@494
|
3200 QTextBrowser *tb = m_helpDialog->findChild<QTextBrowser *>();
|
Chris@494
|
3201 if (tb) tb->home();
|
Chris@494
|
3202 m_helpDialog->show();
|
Chris@494
|
3203 m_helpDialog->raise();
|
Chris@494
|
3204 }
|
Chris@494
|
3205
|