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