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