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