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