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