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