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