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@57
|
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>
|
jtkorhonen@0
|
32
|
Chris@53
|
33 #include "mainwindow.h"
|
Chris@53
|
34 #include "settingsdialog.h"
|
Chris@69
|
35 #include "multichoicedialog.h"
|
Chris@64
|
36 #include "startupdialog.h"
|
Chris@53
|
37 #include "colourset.h"
|
Chris@62
|
38 #include "debug.h"
|
Chris@74
|
39 #include "logparser.h"
|
Chris@53
|
40
|
jtkorhonen@0
|
41
|
jtkorhonen@0
|
42 MainWindow::MainWindow()
|
jtkorhonen@0
|
43 {
|
jtkorhonen@0
|
44 QString wndTitle;
|
jtkorhonen@0
|
45
|
Chris@90
|
46 fsWatcher = 0;
|
Chris@90
|
47
|
jtkorhonen@0
|
48 createActions();
|
jtkorhonen@0
|
49 createMenus();
|
jtkorhonen@0
|
50 createToolBars();
|
jtkorhonen@0
|
51 createStatusBar();
|
jtkorhonen@0
|
52
|
jtkorhonen@0
|
53 runner = new HgRunner(this);
|
Chris@62
|
54 connect(runner, SIGNAL(commandCompleted()),
|
Chris@62
|
55 this, SLOT(commandCompleted()));
|
Chris@62
|
56 connect(runner, SIGNAL(commandFailed()),
|
Chris@62
|
57 this, SLOT(commandFailed()));
|
jtkorhonen@0
|
58 runningAction = ACT_NONE;
|
jtkorhonen@0
|
59 statusBar()->addPermanentWidget(runner);
|
jtkorhonen@0
|
60
|
Chris@61
|
61 setWindowTitle(tr("EasyMercurial"));
|
jtkorhonen@0
|
62
|
jtkorhonen@0
|
63 remoteRepoPath = "";
|
jtkorhonen@0
|
64 workFolderPath = "";
|
jtkorhonen@0
|
65
|
jtkorhonen@0
|
66 readSettings();
|
jtkorhonen@0
|
67
|
jtkorhonen@0
|
68 tabPage = 0;
|
jtkorhonen@33
|
69 justMerged = false;
|
jtkorhonen@0
|
70 hgExp = new HgExpWidget((QWidget *) this, remoteRepoPath, workFolderPath, initialFileTypesBits);
|
jtkorhonen@0
|
71 setCentralWidget(hgExp);
|
jtkorhonen@0
|
72
|
jtkorhonen@0
|
73 setUnifiedTitleAndToolBarOnMac(true);
|
jtkorhonen@0
|
74 connectActions();
|
jtkorhonen@0
|
75 enableDisableActions();
|
jtkorhonen@0
|
76
|
Chris@64
|
77 if (firstStart) {
|
Chris@64
|
78 startupDialog();
|
jtkorhonen@0
|
79 }
|
jtkorhonen@0
|
80
|
Chris@64
|
81 ColourSet *cs = ColourSet::instance();
|
Chris@64
|
82 cs->clearDefaultNames();
|
Chris@64
|
83 cs->addDefaultName("");
|
Chris@64
|
84 cs->addDefaultName(getUserInfo());
|
Chris@62
|
85
|
Chris@72
|
86 if (workFolderPath == "") {
|
Chris@72
|
87 open();
|
Chris@72
|
88 }
|
Chris@72
|
89
|
Chris@74
|
90 hgPaths();
|
jtkorhonen@0
|
91 }
|
jtkorhonen@0
|
92
|
jtkorhonen@0
|
93
|
jtkorhonen@0
|
94 void MainWindow::closeEvent(QCloseEvent *)
|
jtkorhonen@0
|
95 {
|
jtkorhonen@0
|
96 writeSettings();
|
Chris@90
|
97 delete fsWatcher;
|
jtkorhonen@0
|
98 }
|
jtkorhonen@0
|
99
|
jtkorhonen@0
|
100
|
Chris@64
|
101 QString MainWindow::getUserInfo() const
|
Chris@64
|
102 {
|
Chris@64
|
103 QSettings settings;
|
Chris@64
|
104 settings.beginGroup("User Information");
|
Chris@64
|
105 QString name = settings.value("name", getUserRealName()).toString();
|
Chris@64
|
106 QString email = settings.value("email", "").toString();
|
Chris@64
|
107
|
Chris@64
|
108 QString identifier;
|
Chris@64
|
109
|
Chris@64
|
110 if (email != "") {
|
Chris@64
|
111 identifier = QString("%1 <%2>").arg(name).arg(email);
|
Chris@64
|
112 } else {
|
Chris@64
|
113 identifier = name;
|
Chris@64
|
114 }
|
Chris@64
|
115
|
Chris@64
|
116 return identifier;
|
Chris@64
|
117 }
|
Chris@64
|
118
|
jtkorhonen@0
|
119 void MainWindow::about()
|
jtkorhonen@0
|
120 {
|
jtkorhonen@0
|
121 QMessageBox::about(this, tr("About HgExplorer"),
|
jtkorhonen@0
|
122 tr("<b>HgExplorer</b> tries to be Mercurial's <b>VSS Explorer:</b> ;-)<br><br>"
|
jtkorhonen@0
|
123 "-Hides command line in normal use<br>"
|
jtkorhonen@0
|
124 "-Makes common operations easier<br><br>"
|
jtkorhonen@0
|
125 "(c) 2010 (lgpl), Jari Korhonen (jtkorhonen@gmail.com)<br><br>"
|
jtkorhonen@0
|
126 "-Needs Mercurial ;-) (thanks Matt Mackall, Bryan O'Sullivan and others !)<br>"
|
jtkorhonen@0
|
127 "-Uses excellent Nuvola icons (c) David Vignoni (Thanks, David !)<br>"
|
jtkorhonen@29
|
128 "-Needs Qt4, mingw (in windows), python, kdiff3 (Thanks to all of you !)<br>"
|
jtkorhonen@29
|
129 "-Windows standalone install uses hg / python / kdiff3 from TortoiseHg (BIG Thanks !)<br>"
|
jtkorhonen@29
|
130 "-Windows standalone install uses InstallJammer setup tool (Thanks, great tool !)<br>"));
|
jtkorhonen@0
|
131 }
|
jtkorhonen@0
|
132
|
jtkorhonen@0
|
133
|
jtkorhonen@0
|
134 void MainWindow::hgStat()
|
jtkorhonen@0
|
135 {
|
Chris@73
|
136 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
137 {
|
Chris@73
|
138 QStringList params;
|
Chris@73
|
139
|
Chris@91
|
140 params << "stat" << "-ardum";
|
Chris@73
|
141
|
Chris@73
|
142 runner -> startHgCommand(workFolderPath, params);
|
Chris@73
|
143 runningAction = ACT_STAT;
|
jtkorhonen@0
|
144 }
|
jtkorhonen@0
|
145 }
|
jtkorhonen@0
|
146
|
Chris@74
|
147 void MainWindow::hgPaths()
|
Chris@74
|
148 {
|
Chris@74
|
149 if (runningAction == ACT_NONE)
|
Chris@74
|
150 {
|
Chris@74
|
151 QStringList params;
|
Chris@74
|
152 params << "paths";
|
Chris@74
|
153 runner -> startHgCommand(workFolderPath, params);
|
Chris@74
|
154 runningAction = ACT_PATHS;
|
Chris@74
|
155 }
|
Chris@74
|
156 }
|
Chris@74
|
157
|
jtkorhonen@0
|
158 void MainWindow::hgHeads()
|
jtkorhonen@0
|
159 {
|
jtkorhonen@0
|
160 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
161 {
|
jtkorhonen@0
|
162 QStringList params;
|
jtkorhonen@0
|
163 params << "heads";
|
jtkorhonen@0
|
164
|
jtkorhonen@0
|
165 //on empty repos, "hg heads" will fail, don't care of that.
|
Chris@62
|
166 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
167 runningAction = ACT_HEADS;
|
jtkorhonen@0
|
168 }
|
jtkorhonen@0
|
169 }
|
jtkorhonen@0
|
170
|
jtkorhonen@0
|
171 void MainWindow::hgLog()
|
jtkorhonen@0
|
172 {
|
Chris@90
|
173 //!!! This needs to be incremental, except when we pull or set new repo
|
jtkorhonen@0
|
174 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
175 {
|
jtkorhonen@0
|
176 QStringList params;
|
Chris@43
|
177 params << "log";
|
Chris@43
|
178 params << "--template";
|
Chris@52
|
179 params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
|
jtkorhonen@0
|
180
|
Chris@62
|
181 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
182 runningAction = ACT_LOG;
|
jtkorhonen@0
|
183 }
|
jtkorhonen@0
|
184 }
|
jtkorhonen@0
|
185
|
jtkorhonen@0
|
186
|
jtkorhonen@0
|
187 void MainWindow::hgParents()
|
jtkorhonen@0
|
188 {
|
jtkorhonen@0
|
189 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
190 {
|
jtkorhonen@0
|
191 QStringList params;
|
jtkorhonen@0
|
192 params << "parents";
|
jtkorhonen@0
|
193
|
Chris@62
|
194 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
195 runningAction = ACT_PARENTS;
|
jtkorhonen@0
|
196 }
|
jtkorhonen@0
|
197 }
|
jtkorhonen@0
|
198
|
jtkorhonen@0
|
199
|
jtkorhonen@0
|
200
|
jtkorhonen@0
|
201 void MainWindow::hgRemove()
|
jtkorhonen@0
|
202 {
|
jtkorhonen@0
|
203 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
204 {
|
jtkorhonen@0
|
205 QStringList params;
|
Chris@91
|
206 QString currentFile;//!!! = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
207
|
jtkorhonen@0
|
208 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
209 {
|
jtkorhonen@6
|
210 if (QMessageBox::Ok == QMessageBox::warning(this, "Remove file", "Really remove file " + currentFile.mid(2) + "?",
|
jtkorhonen@6
|
211 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
|
jtkorhonen@6
|
212 {
|
mg@41
|
213 params << "remove" << "--after" << "--force" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
214
|
Chris@62
|
215 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@6
|
216 runningAction = ACT_REMOVE;
|
jtkorhonen@6
|
217 }
|
jtkorhonen@0
|
218 }
|
jtkorhonen@0
|
219 }
|
jtkorhonen@0
|
220 }
|
jtkorhonen@0
|
221
|
jtkorhonen@0
|
222 void MainWindow::hgAnnotate()
|
jtkorhonen@0
|
223 {
|
jtkorhonen@0
|
224 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
225 {
|
jtkorhonen@0
|
226 QStringList params;
|
Chris@91
|
227 QString currentFile;//!!! = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
228
|
jtkorhonen@0
|
229 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
230 {
|
mg@41
|
231 params << "annotate" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
232
|
Chris@62
|
233 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
234 runningAction = ACT_ANNOTATE;
|
jtkorhonen@0
|
235 }
|
jtkorhonen@0
|
236 }
|
jtkorhonen@0
|
237 }
|
jtkorhonen@0
|
238
|
jtkorhonen@0
|
239
|
jtkorhonen@0
|
240 void MainWindow::hgResolveMark()
|
jtkorhonen@0
|
241 {
|
jtkorhonen@0
|
242 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
243 {
|
jtkorhonen@0
|
244 QStringList params;
|
Chris@91
|
245 QString currentFile;//!!! = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
246
|
jtkorhonen@0
|
247 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
248 {
|
mg@41
|
249 params << "resolve" << "--mark" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
250
|
Chris@62
|
251 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
252 runningAction = ACT_RESOLVE_MARK;
|
jtkorhonen@0
|
253 }
|
jtkorhonen@0
|
254 }
|
jtkorhonen@0
|
255 }
|
jtkorhonen@0
|
256
|
jtkorhonen@0
|
257
|
jtkorhonen@0
|
258
|
jtkorhonen@0
|
259 void MainWindow::hgResolveList()
|
jtkorhonen@0
|
260 {
|
jtkorhonen@0
|
261 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
262 {
|
jtkorhonen@0
|
263 QStringList params;
|
jtkorhonen@0
|
264
|
jtkorhonen@0
|
265 params << "resolve" << "--list";
|
Chris@62
|
266 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
267 runningAction = ACT_RESOLVE_LIST;
|
jtkorhonen@0
|
268 }
|
jtkorhonen@0
|
269 }
|
jtkorhonen@0
|
270
|
jtkorhonen@0
|
271
|
jtkorhonen@0
|
272
|
jtkorhonen@0
|
273 void MainWindow::hgAdd()
|
jtkorhonen@0
|
274 {
|
jtkorhonen@0
|
275 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
276 {
|
jtkorhonen@0
|
277 QStringList params;
|
jtkorhonen@0
|
278
|
Chris@91
|
279 QString currentFile;//!!! = hgExp -> getCurrentFileListLine();
|
Chris@91
|
280 /*!!!
|
jtkorhonen@17
|
281 if (areAllSelectedUntracked(hgExp -> workFolderFileList))
|
jtkorhonen@5
|
282 {
|
jtkorhonen@17
|
283 //User wants to add selected file(s)
|
jtkorhonen@42
|
284 params << "add" << "--";
|
jtkorhonen@17
|
285
|
jtkorhonen@17
|
286 QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
|
jtkorhonen@17
|
287
|
jtkorhonen@17
|
288 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
289 {
|
jtkorhonen@17
|
290 QString tmp = selList.at(i)->text();
|
jtkorhonen@17
|
291 params.append(tmp.mid(2));
|
jtkorhonen@17
|
292 }
|
jtkorhonen@5
|
293 }
|
jtkorhonen@5
|
294 else
|
jtkorhonen@5
|
295 {
|
jtkorhonen@5
|
296 //Add all untracked files
|
jtkorhonen@5
|
297 params << "add";
|
jtkorhonen@5
|
298 }
|
jtkorhonen@0
|
299
|
Chris@62
|
300 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
301 runningAction = ACT_ADD;
|
Chris@91
|
302 */
|
jtkorhonen@0
|
303 }
|
jtkorhonen@0
|
304 }
|
jtkorhonen@0
|
305
|
Chris@90
|
306 bool MainWindow::getCommentOrTag(QString& commentOrTag,
|
Chris@90
|
307 QString question,
|
Chris@90
|
308 QString dlgTitle)
|
jtkorhonen@0
|
309 {
|
Chris@90
|
310 bool ok = false;
|
Chris@90
|
311 QString text = QInputDialog::getText(this, dlgTitle, question, QLineEdit::Normal, commentOrTag, &ok);
|
Chris@90
|
312 commentOrTag = text;
|
Chris@90
|
313 return ok;
|
Chris@90
|
314
|
Chris@90
|
315 /*!!!
|
jtkorhonen@0
|
316 int ret;
|
jtkorhonen@0
|
317
|
jtkorhonen@0
|
318 QDialog dlg(this);
|
jtkorhonen@0
|
319
|
jtkorhonen@34
|
320 QLabel *commentLabel = new QLabel(question);
|
jtkorhonen@34
|
321 QLineEdit *commentOrTagEdit = new QLineEdit;
|
jtkorhonen@34
|
322 commentOrTagEdit -> setFixedWidth(400);
|
jtkorhonen@0
|
323 QHBoxLayout *commentLayout = new QHBoxLayout;
|
jtkorhonen@0
|
324 commentLayout -> addWidget(commentLabel);
|
jtkorhonen@34
|
325 commentLayout -> addWidget(commentOrTagEdit);
|
jtkorhonen@0
|
326
|
jtkorhonen@0
|
327 QPushButton *btnOk = new QPushButton(tr("Ok"));
|
jtkorhonen@0
|
328 QPushButton *btnCancel = new QPushButton(tr("Cancel"));
|
jtkorhonen@0
|
329 QHBoxLayout *btnLayout = new QHBoxLayout;
|
jtkorhonen@0
|
330 btnLayout -> addWidget(btnOk);
|
jtkorhonen@0
|
331 btnLayout -> addWidget(btnCancel);
|
jtkorhonen@0
|
332
|
jtkorhonen@0
|
333 QVBoxLayout *mainLayout = new QVBoxLayout;
|
jtkorhonen@0
|
334 mainLayout -> addLayout(commentLayout);
|
jtkorhonen@0
|
335 mainLayout -> addLayout(btnLayout);
|
jtkorhonen@0
|
336
|
jtkorhonen@0
|
337 dlg.setLayout(mainLayout);
|
jtkorhonen@0
|
338
|
jtkorhonen@34
|
339 dlg.setWindowTitle(dlgTitle);
|
jtkorhonen@0
|
340
|
jtkorhonen@0
|
341 connect(btnOk, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
342 connect(btnCancel, SIGNAL(clicked()), &dlg, SLOT(reject()));
|
jtkorhonen@0
|
343
|
jtkorhonen@0
|
344 ret = dlg.exec();
|
jtkorhonen@34
|
345 commentOrTag = commentOrTagEdit -> text();
|
jtkorhonen@0
|
346 return ret;
|
Chris@90
|
347 */
|
jtkorhonen@0
|
348 }
|
jtkorhonen@0
|
349
|
jtkorhonen@0
|
350 void MainWindow::hgCommit()
|
jtkorhonen@0
|
351 {
|
jtkorhonen@0
|
352 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
353 {
|
jtkorhonen@0
|
354 QStringList params;
|
jtkorhonen@0
|
355 QString comment;
|
jtkorhonen@0
|
356
|
Chris@90
|
357 if (getCommentOrTag(comment, tr("Comment:"), tr("Save (commit)")))
|
jtkorhonen@0
|
358 {
|
jtkorhonen@0
|
359 if (!comment.isEmpty())
|
jtkorhonen@0
|
360 {
|
Chris@91
|
361 /*!!!
|
jtkorhonen@33
|
362 if ((justMerged == false) && (areAllSelectedCommitable(hgExp -> workFolderFileList)))
|
jtkorhonen@11
|
363 {
|
jtkorhonen@33
|
364 //User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files)
|
Chris@64
|
365 params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--";
|
jtkorhonen@17
|
366
|
jtkorhonen@17
|
367 QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
|
jtkorhonen@17
|
368 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
369 {
|
jtkorhonen@17
|
370 QString tmp = selList.at(i)->text();
|
jtkorhonen@17
|
371 params.append(tmp.mid(2));
|
jtkorhonen@17
|
372 }
|
jtkorhonen@11
|
373 }
|
jtkorhonen@11
|
374 else
|
jtkorhonen@11
|
375 {
|
jtkorhonen@11
|
376 //Commit all changes
|
Chris@64
|
377 params << "commit" << "--message" << comment << "--user" << getUserInfo();
|
jtkorhonen@11
|
378 }
|
jtkorhonen@0
|
379
|
Chris@62
|
380 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
381 runningAction = ACT_COMMIT;
|
Chris@91
|
382 */
|
jtkorhonen@0
|
383 }
|
jtkorhonen@0
|
384 }
|
jtkorhonen@0
|
385 }
|
jtkorhonen@0
|
386 }
|
jtkorhonen@0
|
387
|
jtkorhonen@34
|
388 QString MainWindow::filterTag(QString tag)
|
jtkorhonen@34
|
389 {
|
jtkorhonen@34
|
390 for(int i = 0; i < tag.size(); i++)
|
jtkorhonen@34
|
391 {
|
jtkorhonen@34
|
392 if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
|
jtkorhonen@34
|
393 {
|
jtkorhonen@34
|
394 //ok
|
jtkorhonen@34
|
395 }
|
jtkorhonen@34
|
396 else
|
jtkorhonen@34
|
397 {
|
jtkorhonen@34
|
398 tag[i] = QChar('_');
|
jtkorhonen@34
|
399 }
|
jtkorhonen@34
|
400 }
|
jtkorhonen@34
|
401 return tag;
|
jtkorhonen@34
|
402 }
|
jtkorhonen@34
|
403
|
jtkorhonen@34
|
404
|
jtkorhonen@34
|
405 void MainWindow::hgTag()
|
jtkorhonen@34
|
406 {
|
jtkorhonen@34
|
407 if (runningAction == ACT_NONE)
|
jtkorhonen@34
|
408 {
|
jtkorhonen@34
|
409 QStringList params;
|
jtkorhonen@34
|
410 QString tag;
|
jtkorhonen@34
|
411
|
Chris@90
|
412 if (getCommentOrTag(tag, tr("Tag:"), tr("Tag")))
|
jtkorhonen@34
|
413 {
|
jtkorhonen@34
|
414 if (!tag.isEmpty())
|
jtkorhonen@34
|
415 {
|
Chris@64
|
416 params << "tag" << "--user" << getUserInfo() << filterTag(tag);
|
jtkorhonen@34
|
417
|
Chris@62
|
418 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@34
|
419 runningAction = ACT_TAG;
|
jtkorhonen@34
|
420 }
|
jtkorhonen@34
|
421 }
|
jtkorhonen@34
|
422 }
|
jtkorhonen@34
|
423 }
|
jtkorhonen@34
|
424
|
jtkorhonen@34
|
425
|
jtkorhonen@34
|
426 void MainWindow::hgIgnore()
|
jtkorhonen@34
|
427 {
|
jtkorhonen@34
|
428 if (runningAction == ACT_NONE)
|
jtkorhonen@34
|
429 {
|
jtkorhonen@34
|
430 QString hgIgnorePath;
|
jtkorhonen@36
|
431 QStringList params;
|
jtkorhonen@36
|
432 QString editorName;
|
jtkorhonen@34
|
433
|
jtkorhonen@36
|
434 hgIgnorePath = workFolderPath;
|
jtkorhonen@34
|
435 hgIgnorePath += ".hgignore";
|
jtkorhonen@34
|
436
|
jtkorhonen@36
|
437 params << hgIgnorePath;
|
jtkorhonen@36
|
438
|
jtkorhonen@36
|
439 if ((getSystem() == "Linux"))
|
jtkorhonen@36
|
440 {
|
jtkorhonen@36
|
441 editorName = "gedit";
|
jtkorhonen@36
|
442 }
|
jtkorhonen@36
|
443 else
|
jtkorhonen@36
|
444 {
|
jtkorhonen@36
|
445 editorName = """C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe""";
|
jtkorhonen@36
|
446 }
|
jtkorhonen@36
|
447
|
Chris@62
|
448 runner -> startCommand(editorName, workFolderPath, params);
|
jtkorhonen@36
|
449 runningAction = ACT_HG_IGNORE;
|
jtkorhonen@34
|
450 }
|
jtkorhonen@34
|
451 }
|
jtkorhonen@34
|
452
|
jtkorhonen@34
|
453
|
jtkorhonen@34
|
454
|
jtkorhonen@0
|
455 void MainWindow::hgFileDiff()
|
jtkorhonen@0
|
456 {
|
jtkorhonen@0
|
457 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
458 {
|
jtkorhonen@0
|
459 QStringList params;
|
Chris@91
|
460 /*!!!
|
jtkorhonen@0
|
461 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
462
|
jtkorhonen@0
|
463 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
464 {
|
jtkorhonen@0
|
465 //Diff parent file against working folder file
|
mg@41
|
466 params << "kdiff3" << "--" << currentFile.mid(2);
|
Chris@62
|
467 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
468 runningAction = ACT_FILEDIFF;
|
jtkorhonen@0
|
469 }
|
Chris@91
|
470 */
|
jtkorhonen@0
|
471 }
|
jtkorhonen@0
|
472 }
|
jtkorhonen@0
|
473
|
jtkorhonen@0
|
474
|
jtkorhonen@0
|
475 void MainWindow::hgFolderDiff()
|
jtkorhonen@0
|
476 {
|
jtkorhonen@0
|
477 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
478 {
|
jtkorhonen@0
|
479 QStringList params;
|
jtkorhonen@0
|
480
|
jtkorhonen@0
|
481 //Diff parent against working folder (folder diff)
|
jtkorhonen@0
|
482 params << "kdiff3";
|
Chris@62
|
483 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
484 runningAction = ACT_FOLDERDIFF;
|
jtkorhonen@0
|
485 }
|
jtkorhonen@0
|
486 }
|
jtkorhonen@0
|
487
|
jtkorhonen@0
|
488
|
jtkorhonen@0
|
489 void MainWindow::hgChgSetDiff()
|
jtkorhonen@0
|
490 {
|
jtkorhonen@0
|
491 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
492 {
|
jtkorhonen@0
|
493 QStringList params;
|
jtkorhonen@0
|
494
|
jtkorhonen@0
|
495 //Diff 2 history log versions against each other
|
jtkorhonen@0
|
496 QString revA;
|
jtkorhonen@0
|
497 QString revB;
|
Chris@91
|
498 /*!!!
|
jtkorhonen@0
|
499 hgExp -> getHistoryDiffRevisions(revA, revB);
|
jtkorhonen@0
|
500
|
jtkorhonen@0
|
501 if ((!revA.isEmpty()) && (!revB.isEmpty()))
|
jtkorhonen@0
|
502 {
|
jtkorhonen@0
|
503 params << "kdiff3" << "--rev" << revA << "--rev" << revB;
|
Chris@62
|
504 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
505 runningAction = ACT_CHGSETDIFF;
|
jtkorhonen@0
|
506 }
|
jtkorhonen@0
|
507 else
|
jtkorhonen@0
|
508 {
|
jtkorhonen@0
|
509 QMessageBox::information(this, tr("Changeset diff"), tr("Please select two changesets from history list or heads list first."));
|
jtkorhonen@0
|
510 }
|
Chris@91
|
511 */
|
jtkorhonen@0
|
512 }
|
jtkorhonen@0
|
513 }
|
jtkorhonen@0
|
514
|
jtkorhonen@0
|
515
|
jtkorhonen@0
|
516
|
jtkorhonen@0
|
517 void MainWindow::hgUpdate()
|
jtkorhonen@0
|
518 {
|
jtkorhonen@0
|
519 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
520 {
|
jtkorhonen@0
|
521 QStringList params;
|
jtkorhonen@0
|
522
|
jtkorhonen@0
|
523
|
jtkorhonen@0
|
524 params << "update";
|
jtkorhonen@0
|
525
|
jtkorhonen@0
|
526
|
Chris@62
|
527 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
528 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
529 }
|
jtkorhonen@0
|
530 }
|
jtkorhonen@0
|
531
|
jtkorhonen@0
|
532
|
jtkorhonen@0
|
533 void MainWindow::hgUpdateToRev()
|
jtkorhonen@0
|
534 {
|
jtkorhonen@0
|
535 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
536 {
|
jtkorhonen@0
|
537 QStringList params;
|
jtkorhonen@0
|
538 QString rev;
|
Chris@91
|
539 /*!!!
|
jtkorhonen@0
|
540 hgExp -> getUpdateToRevRevision(rev);
|
jtkorhonen@0
|
541
|
jtkorhonen@0
|
542 hgExp -> setCurrentIndex(WORKTAB);
|
jtkorhonen@0
|
543 enableDisableActions();
|
jtkorhonen@0
|
544
|
jtkorhonen@0
|
545 params << "update" << "--rev" << rev << "--clean";
|
jtkorhonen@0
|
546
|
Chris@62
|
547 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
548
|
jtkorhonen@0
|
549 runningAction = ACT_UPDATE;
|
Chris@91
|
550 */
|
jtkorhonen@0
|
551 }
|
jtkorhonen@0
|
552 }
|
jtkorhonen@0
|
553
|
jtkorhonen@0
|
554
|
jtkorhonen@0
|
555 void MainWindow::hgRevert()
|
jtkorhonen@0
|
556 {
|
jtkorhonen@0
|
557 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
558 {
|
Chris@91
|
559 /*!!!
|
jtkorhonen@0
|
560 QStringList params;
|
jtkorhonen@0
|
561 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
562
|
mg@41
|
563 params << "revert" << "--no-backup" << "--" << currentFile.mid(2);
|
jtkorhonen@0
|
564
|
Chris@62
|
565 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
566 runningAction = ACT_REVERT;
|
Chris@91
|
567 */
|
jtkorhonen@0
|
568 }
|
jtkorhonen@0
|
569 }
|
jtkorhonen@0
|
570
|
jtkorhonen@33
|
571 void MainWindow::hgRetryMerge()
|
jtkorhonen@33
|
572 {
|
jtkorhonen@33
|
573 if (runningAction == ACT_NONE)
|
jtkorhonen@33
|
574 {
|
jtkorhonen@33
|
575 QStringList params;
|
jtkorhonen@33
|
576
|
jtkorhonen@33
|
577 params << "resolve" << "--all";
|
Chris@62
|
578 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@33
|
579 runningAction = ACT_RETRY_MERGE;
|
jtkorhonen@33
|
580 }
|
jtkorhonen@33
|
581 }
|
jtkorhonen@33
|
582
|
jtkorhonen@33
|
583
|
jtkorhonen@0
|
584 void MainWindow::hgMerge()
|
jtkorhonen@0
|
585 {
|
jtkorhonen@0
|
586 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
587 {
|
jtkorhonen@0
|
588 QStringList params;
|
jtkorhonen@0
|
589
|
jtkorhonen@0
|
590 params << "merge";
|
jtkorhonen@0
|
591
|
Chris@62
|
592 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
593 runningAction = ACT_MERGE;
|
jtkorhonen@0
|
594 }
|
jtkorhonen@0
|
595 }
|
jtkorhonen@0
|
596
|
jtkorhonen@0
|
597
|
jtkorhonen@0
|
598 void MainWindow::hgCloneFromRemote()
|
jtkorhonen@0
|
599 {
|
jtkorhonen@0
|
600 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
601 {
|
jtkorhonen@0
|
602 QStringList params;
|
jtkorhonen@0
|
603
|
jtkorhonen@0
|
604 params << "clone" << remoteRepoPath << workFolderPath;
|
jtkorhonen@0
|
605
|
Chris@62
|
606 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
607 runningAction = ACT_CLONEFROMREMOTE;
|
jtkorhonen@0
|
608 }
|
jtkorhonen@0
|
609 }
|
jtkorhonen@0
|
610
|
jtkorhonen@0
|
611
|
jtkorhonen@0
|
612 void MainWindow::hgInit()
|
jtkorhonen@0
|
613 {
|
jtkorhonen@0
|
614 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
615 {
|
jtkorhonen@0
|
616 QStringList params;
|
jtkorhonen@0
|
617
|
jtkorhonen@0
|
618 params << "init";
|
Chris@84
|
619 params << workFolderPath;
|
jtkorhonen@0
|
620
|
Chris@62
|
621 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
622 runningAction = ACT_INIT;
|
jtkorhonen@0
|
623 }
|
jtkorhonen@0
|
624 }
|
jtkorhonen@0
|
625
|
jtkorhonen@0
|
626
|
jtkorhonen@0
|
627 void MainWindow::hgIncoming()
|
jtkorhonen@0
|
628 {
|
jtkorhonen@0
|
629 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
630 {
|
jtkorhonen@0
|
631 QStringList params;
|
jtkorhonen@0
|
632
|
jtkorhonen@0
|
633 params << "incoming" << "--newest-first" << remoteRepoPath;
|
jtkorhonen@0
|
634
|
Chris@62
|
635 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
636 runningAction = ACT_INCOMING;
|
jtkorhonen@0
|
637 }
|
jtkorhonen@0
|
638 }
|
jtkorhonen@0
|
639
|
jtkorhonen@0
|
640
|
jtkorhonen@0
|
641 void MainWindow::hgPull()
|
jtkorhonen@0
|
642 {
|
jtkorhonen@0
|
643 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
644 {
|
jtkorhonen@0
|
645 QStringList params;
|
jtkorhonen@0
|
646
|
jtkorhonen@0
|
647 params << "pull" << remoteRepoPath;
|
jtkorhonen@0
|
648
|
Chris@62
|
649 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
650 runningAction = ACT_PULL;
|
jtkorhonen@0
|
651 }
|
jtkorhonen@0
|
652 }
|
jtkorhonen@0
|
653
|
jtkorhonen@0
|
654
|
jtkorhonen@0
|
655 void MainWindow::hgPush()
|
jtkorhonen@0
|
656 {
|
jtkorhonen@0
|
657 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
658 {
|
jtkorhonen@0
|
659 QStringList params;
|
jtkorhonen@0
|
660
|
jtkorhonen@0
|
661 params << "push" << remoteRepoPath;
|
jtkorhonen@0
|
662
|
Chris@62
|
663 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@0
|
664 runningAction = ACT_PUSH;
|
jtkorhonen@0
|
665 }
|
jtkorhonen@0
|
666 }
|
jtkorhonen@0
|
667
|
jtkorhonen@0
|
668
|
jtkorhonen@28
|
669 QString MainWindow::listAllUpIpV4Addresses()
|
jtkorhonen@26
|
670 {
|
jtkorhonen@28
|
671 QString ret;
|
jtkorhonen@26
|
672 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
|
jtkorhonen@26
|
673
|
jtkorhonen@26
|
674 for (int i = 0; i < ifaces.count(); i++)
|
jtkorhonen@26
|
675 {
|
jtkorhonen@26
|
676 QNetworkInterface iface = ifaces.at(i);
|
jtkorhonen@26
|
677
|
jtkorhonen@26
|
678 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack))
|
jtkorhonen@26
|
679 {
|
jtkorhonen@26
|
680 for (int j=0; j<iface.addressEntries().count(); j++)
|
jtkorhonen@26
|
681 {
|
jtkorhonen@28
|
682 QHostAddress tmp = iface.addressEntries().at(j).ip();
|
jtkorhonen@28
|
683 if (QAbstractSocket::IPv4Protocol == tmp.protocol())
|
jtkorhonen@24
|
684 {
|
jtkorhonen@28
|
685 if (!ret.isEmpty())
|
jtkorhonen@28
|
686 {
|
jtkorhonen@28
|
687 ret += " ";
|
jtkorhonen@28
|
688 }
|
jtkorhonen@28
|
689 ret += tmp.toString();
|
jtkorhonen@24
|
690 }
|
jtkorhonen@24
|
691 }
|
jtkorhonen@22
|
692 }
|
jtkorhonen@17
|
693 }
|
jtkorhonen@28
|
694 return ret;
|
jtkorhonen@28
|
695 }
|
jtkorhonen@17
|
696
|
jtkorhonen@17
|
697
|
jtkorhonen@11
|
698 void MainWindow::hgServe()
|
jtkorhonen@11
|
699 {
|
jtkorhonen@11
|
700 if (runningAction == ACT_NONE)
|
jtkorhonen@11
|
701 {
|
jtkorhonen@11
|
702 QStringList params;
|
jtkorhonen@22
|
703 QString msg;
|
jtkorhonen@11
|
704
|
jtkorhonen@28
|
705 QString addrs = listAllUpIpV4Addresses();
|
jtkorhonen@28
|
706 QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000";
|
jtkorhonen@28
|
707 params << "serve";
|
jtkorhonen@11
|
708
|
Chris@62
|
709 runner -> startHgCommand(workFolderPath, params);
|
jtkorhonen@11
|
710 runningAction = ACT_SERVE;
|
jtkorhonen@11
|
711
|
jtkorhonen@17
|
712 QMessageBox::information(this, "Serve", msg, QMessageBox::Close);
|
Chris@62
|
713 runner -> killCurrentCommand();
|
jtkorhonen@11
|
714 }
|
jtkorhonen@11
|
715 }
|
jtkorhonen@11
|
716
|
jtkorhonen@11
|
717
|
Chris@64
|
718 void MainWindow::startupDialog()
|
Chris@64
|
719 {
|
Chris@64
|
720 StartupDialog *dlg = new StartupDialog(this);
|
Chris@65
|
721 if (dlg->exec()) firstStart = false;
|
Chris@64
|
722 }
|
Chris@64
|
723
|
jtkorhonen@11
|
724
|
Chris@69
|
725 void MainWindow::open()
|
Chris@69
|
726 {
|
Chris@86
|
727 bool done = false;
|
Chris@69
|
728
|
Chris@86
|
729 while (!done) {
|
Chris@69
|
730
|
Chris@86
|
731 MultiChoiceDialog *d = new MultiChoiceDialog
|
Chris@86
|
732 (tr("Open Repository"),
|
Chris@86
|
733 tr("<qt><big>What would you like to open?</big></qt>"),
|
Chris@86
|
734 this);
|
Chris@69
|
735
|
Chris@86
|
736 d->addChoice("remote",
|
Chris@86
|
737 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
|
Chris@86
|
738 tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
|
Chris@86
|
739 MultiChoiceDialog::UrlToDirectoryArg);
|
Chris@69
|
740
|
Chris@86
|
741 d->addChoice("local",
|
Chris@86
|
742 tr("<qt><center><img src=\":images/hglogo-64.png\"><br>Local repository</center></qt>"),
|
Chris@86
|
743 tr("Open an existing local Mercurial repository."),
|
Chris@86
|
744 MultiChoiceDialog::DirectoryArg);
|
Chris@69
|
745
|
Chris@86
|
746 d->addChoice("init",
|
Chris@86
|
747 tr("<qt><center><img src=\":images/hdd_unmount-64.png\"><br>File folder</center></qt>"),
|
Chris@86
|
748 tr("Open a local folder, by creating a Mercurial repository in it."),
|
Chris@86
|
749 MultiChoiceDialog::DirectoryArg);
|
Chris@79
|
750
|
Chris@86
|
751 d->setCurrentChoice("local");
|
Chris@86
|
752
|
Chris@86
|
753 if (d->exec() == QDialog::Accepted) {
|
Chris@86
|
754
|
Chris@86
|
755 QString choice = d->getCurrentChoice();
|
Chris@86
|
756 QString arg = d->getArgument().trimmed();
|
Chris@86
|
757
|
Chris@86
|
758 bool result = false;
|
Chris@86
|
759
|
Chris@86
|
760 if (choice == "local") {
|
Chris@86
|
761 result = openLocal(arg);
|
Chris@86
|
762 } else if (choice == "remote") {
|
Chris@86
|
763 result = openRemote(arg, d->getAdditionalArgument().trimmed());
|
Chris@86
|
764 } else if (choice == "init") {
|
Chris@86
|
765 result = openInit(arg);
|
Chris@86
|
766 }
|
Chris@86
|
767
|
Chris@86
|
768 if (result) {
|
Chris@86
|
769 enableDisableActions();
|
Chris@86
|
770 hgPaths();
|
Chris@91
|
771 done = true;
|
Chris@91
|
772 }
|
Chris@86
|
773
|
Chris@86
|
774 } else {
|
Chris@86
|
775
|
Chris@86
|
776 // cancelled
|
Chris@86
|
777 done = true;
|
Chris@69
|
778 }
|
Chris@79
|
779
|
Chris@86
|
780 delete d;
|
Chris@69
|
781 }
|
Chris@69
|
782 }
|
Chris@69
|
783
|
Chris@79
|
784 bool MainWindow::complainAboutFilePath(QString arg)
|
Chris@79
|
785 {
|
Chris@79
|
786 QMessageBox::critical
|
Chris@79
|
787 (this, tr("File chosen"),
|
Chris@84
|
788 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
|
789 return false;
|
Chris@79
|
790 }
|
Chris@79
|
791
|
Chris@79
|
792 bool MainWindow::complainAboutUnknownFolder(QString arg)
|
Chris@79
|
793 {
|
Chris@79
|
794 QMessageBox::critical
|
Chris@79
|
795 (this, tr("Folder does not exist"),
|
Chris@84
|
796 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
|
797 return false;
|
Chris@84
|
798 }
|
Chris@84
|
799
|
Chris@84
|
800 bool MainWindow::complainAboutInitInRepo(QString arg)
|
Chris@84
|
801 {
|
Chris@84
|
802 QMessageBox::critical
|
Chris@84
|
803 (this, tr("Path is in existing repository"),
|
Chris@84
|
804 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
|
805 return false;
|
Chris@84
|
806 }
|
Chris@84
|
807
|
Chris@84
|
808 bool MainWindow::complainAboutInitFile(QString arg)
|
Chris@84
|
809 {
|
Chris@84
|
810 QMessageBox::critical
|
Chris@84
|
811 (this, tr("Path is a file"),
|
Chris@84
|
812 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
|
813 return false;
|
Chris@84
|
814 }
|
Chris@84
|
815
|
Chris@84
|
816 bool MainWindow::complainAboutCloneToExisting(QString arg)
|
Chris@84
|
817 {
|
Chris@84
|
818 QMessageBox::critical
|
Chris@84
|
819 (this, tr("Path is in existing repository"),
|
Chris@84
|
820 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
|
821 return false;
|
Chris@84
|
822 }
|
Chris@84
|
823
|
Chris@84
|
824 bool MainWindow::complainAboutCloneToFile(QString arg)
|
Chris@84
|
825 {
|
Chris@84
|
826 QMessageBox::critical
|
Chris@84
|
827 (this, tr("Path is a file"),
|
Chris@84
|
828 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
|
829 return false;
|
Chris@84
|
830 }
|
Chris@84
|
831
|
Chris@84
|
832 bool MainWindow::complainAboutCloneToExistingFolder(QString arg)
|
Chris@84
|
833 {
|
Chris@84
|
834 QMessageBox::critical
|
Chris@84
|
835 (this, tr("Folder exists"),
|
Chris@84
|
836 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
|
837 return false;
|
Chris@79
|
838 }
|
Chris@79
|
839
|
Chris@79
|
840 bool MainWindow::askToOpenParentRepo(QString arg, QString parent)
|
Chris@79
|
841 {
|
Chris@79
|
842 return (QMessageBox::question
|
Chris@84
|
843 (this, tr("Path is inside a repository"),
|
Chris@86
|
844 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
|
845 .arg(xmlEncode(arg)).arg(xmlEncode(parent)),
|
Chris@79
|
846 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@79
|
847 QMessageBox::Ok)
|
Chris@79
|
848 == QMessageBox::Ok);
|
Chris@79
|
849 }
|
Chris@79
|
850
|
Chris@79
|
851 bool MainWindow::askToInitExisting(QString arg)
|
Chris@79
|
852 {
|
Chris@79
|
853 return (QMessageBox::question
|
Chris@84
|
854 (this, tr("Folder has no repository"),
|
Chris@84
|
855 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
|
856 .arg(xmlEncode(arg)),
|
Chris@79
|
857 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@79
|
858 QMessageBox::Ok)
|
Chris@79
|
859 == QMessageBox::Ok);
|
Chris@79
|
860 }
|
Chris@79
|
861
|
Chris@79
|
862 bool MainWindow::askToInitNew(QString arg)
|
Chris@79
|
863 {
|
Chris@79
|
864 return (QMessageBox::question
|
Chris@84
|
865 (this, tr("Folder does not exist"),
|
Chris@84
|
866 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
|
867 .arg(xmlEncode(arg)),
|
Chris@84
|
868 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@84
|
869 QMessageBox::Ok)
|
Chris@84
|
870 == QMessageBox::Ok);
|
Chris@84
|
871 }
|
Chris@84
|
872
|
Chris@84
|
873 bool MainWindow::askToOpenInsteadOfInit(QString arg)
|
Chris@84
|
874 {
|
Chris@84
|
875 return (QMessageBox::question
|
Chris@84
|
876 (this, tr("Repository exists"),
|
Chris@84
|
877 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
|
878 .arg(xmlEncode(arg)),
|
Chris@79
|
879 QMessageBox::Ok | QMessageBox::Cancel,
|
Chris@79
|
880 QMessageBox::Ok)
|
Chris@79
|
881 == QMessageBox::Ok);
|
Chris@79
|
882 }
|
Chris@79
|
883
|
Chris@79
|
884 bool MainWindow::openLocal(QString local)
|
Chris@79
|
885 {
|
Chris@79
|
886 DEBUG << "open " << local << endl;
|
Chris@79
|
887
|
Chris@79
|
888 FolderStatus status = getFolderStatus(local);
|
Chris@79
|
889 QString containing = getContainingRepoFolder(local);
|
Chris@79
|
890
|
Chris@79
|
891 switch (status) {
|
Chris@79
|
892
|
Chris@79
|
893 case FolderHasRepo:
|
Chris@79
|
894 // fine
|
Chris@79
|
895 break;
|
Chris@79
|
896
|
Chris@79
|
897 case FolderExists:
|
Chris@79
|
898 if (containing != "") {
|
Chris@79
|
899 if (!askToOpenParentRepo(local, containing)) return false;
|
Chris@84
|
900 local = containing;
|
Chris@79
|
901 } else {
|
Chris@86
|
902 //!!! No -- this is likely to happen far more by accident
|
Chris@86
|
903 // than because the user actually wanted to init something.
|
Chris@86
|
904 // Don't ask, just politely reject.
|
Chris@79
|
905 if (!askToInitExisting(local)) return false;
|
Chris@79
|
906 return openInit(local);
|
Chris@79
|
907 }
|
Chris@79
|
908 break;
|
Chris@79
|
909
|
Chris@79
|
910 case FolderParentExists:
|
Chris@79
|
911 if (containing != "") {
|
Chris@79
|
912 if (!askToOpenParentRepo(local, containing)) return false;
|
Chris@84
|
913 local = containing;
|
Chris@79
|
914 } else {
|
Chris@79
|
915 if (!askToInitNew(local)) return false;
|
Chris@79
|
916 return openInit(local);
|
Chris@79
|
917 }
|
Chris@79
|
918 break;
|
Chris@79
|
919
|
Chris@79
|
920 case FolderUnknown:
|
Chris@84
|
921 if (containing != "") {
|
Chris@84
|
922 if (!askToOpenParentRepo(local, containing)) return false;
|
Chris@84
|
923 local = containing;
|
Chris@84
|
924 } else {
|
Chris@84
|
925 return complainAboutUnknownFolder(local);
|
Chris@84
|
926 }
|
Chris@84
|
927 break;
|
Chris@79
|
928
|
Chris@79
|
929 case FolderIsFile:
|
Chris@79
|
930 return complainAboutFilePath(local);
|
Chris@79
|
931 }
|
Chris@79
|
932
|
Chris@79
|
933 workFolderPath = local;
|
Chris@79
|
934 remoteRepoPath = "";
|
Chris@79
|
935 return true;
|
Chris@79
|
936 }
|
Chris@79
|
937
|
Chris@79
|
938 bool MainWindow::openRemote(QString remote, QString local)
|
Chris@79
|
939 {
|
Chris@79
|
940 DEBUG << "clone " << remote << " to " << local << endl;
|
Chris@84
|
941
|
Chris@84
|
942 FolderStatus status = getFolderStatus(local);
|
Chris@84
|
943 QString containing = getContainingRepoFolder(local);
|
Chris@84
|
944
|
Chris@84
|
945 DEBUG << "status = " << status << ", containing = " << containing << endl;
|
Chris@84
|
946
|
Chris@84
|
947 if (status == FolderHasRepo || containing != "") {
|
Chris@84
|
948 return complainAboutCloneToExisting(local);
|
Chris@84
|
949 }
|
Chris@84
|
950
|
Chris@84
|
951 if (status == FolderIsFile) {
|
Chris@84
|
952 return complainAboutCloneToFile(local);
|
Chris@84
|
953 }
|
Chris@84
|
954
|
Chris@84
|
955 if (status == FolderUnknown) {
|
Chris@84
|
956 return complainAboutUnknownFolder(local);
|
Chris@84
|
957 }
|
Chris@84
|
958
|
Chris@84
|
959 if (status == FolderExists) {
|
Chris@84
|
960 //!!! we can do better than this surely?
|
Chris@84
|
961 return complainAboutCloneToExistingFolder(local);
|
Chris@84
|
962 }
|
Chris@84
|
963
|
Chris@84
|
964 workFolderPath = local;
|
Chris@84
|
965 remoteRepoPath = remote;
|
Chris@84
|
966 hgCloneFromRemote();
|
Chris@84
|
967
|
Chris@79
|
968 return true;
|
Chris@79
|
969 }
|
Chris@79
|
970
|
Chris@84
|
971 bool MainWindow::openInit(QString local)
|
Chris@79
|
972 {
|
Chris@84
|
973 DEBUG << "openInit " << local << endl;
|
Chris@84
|
974
|
Chris@84
|
975 FolderStatus status = getFolderStatus(local);
|
Chris@84
|
976 QString containing = getContainingRepoFolder(local);
|
Chris@84
|
977
|
Chris@84
|
978 DEBUG << "status = " << status << ", containing = " << containing << endl;
|
Chris@84
|
979
|
Chris@84
|
980 if (status == FolderHasRepo) {
|
Chris@84
|
981 if (!askToOpenInsteadOfInit(local)) return false;
|
Chris@84
|
982 }
|
Chris@84
|
983
|
Chris@84
|
984 if (containing != "") {
|
Chris@84
|
985 return complainAboutInitInRepo(local);
|
Chris@84
|
986 }
|
Chris@84
|
987
|
Chris@84
|
988 if (status == FolderIsFile) {
|
Chris@84
|
989 return complainAboutInitFile(local);
|
Chris@84
|
990 }
|
Chris@84
|
991
|
Chris@84
|
992 if (status == FolderUnknown) {
|
Chris@84
|
993 return complainAboutUnknownFolder(local);
|
Chris@84
|
994 }
|
Chris@84
|
995
|
Chris@84
|
996 workFolderPath = local;
|
Chris@84
|
997 remoteRepoPath = "";
|
Chris@84
|
998 hgInit();
|
Chris@79
|
999 return true;
|
Chris@79
|
1000 }
|
Chris@79
|
1001
|
jtkorhonen@0
|
1002 void MainWindow::settings()
|
jtkorhonen@0
|
1003 {
|
Chris@69
|
1004 /*!!!
|
jtkorhonen@0
|
1005 SettingsDialog *settingsDlg = new SettingsDialog(this);
|
jtkorhonen@0
|
1006 settingsDlg->setModal(true);
|
jtkorhonen@0
|
1007 settingsDlg->exec();
|
jtkorhonen@0
|
1008 hgExp -> clearLists();
|
jtkorhonen@0
|
1009 enableDisableActions();
|
jtkorhonen@0
|
1010 hgStat();
|
Chris@69
|
1011 */
|
jtkorhonen@0
|
1012 }
|
jtkorhonen@0
|
1013
|
jtkorhonen@2
|
1014 #define STDOUT_NEEDS_BIG_WINDOW 512
|
jtkorhonen@2
|
1015 #define SMALL_WND_W 500
|
jtkorhonen@2
|
1016 #define SMALL_WND_H 300
|
jtkorhonen@2
|
1017
|
jtkorhonen@2
|
1018 #define BIG_WND_W 1024
|
jtkorhonen@2
|
1019 #define BIG_WND_H 768
|
jtkorhonen@2
|
1020
|
jtkorhonen@2
|
1021
|
jtkorhonen@2
|
1022 void MainWindow::presentLongStdoutToUser(QString stdo)
|
jtkorhonen@0
|
1023 {
|
jtkorhonen@2
|
1024 if (!stdo.isEmpty())
|
jtkorhonen@2
|
1025 {
|
jtkorhonen@2
|
1026 QDialog dlg;
|
jtkorhonen@0
|
1027
|
jtkorhonen@2
|
1028 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
|
jtkorhonen@2
|
1029 {
|
jtkorhonen@2
|
1030 dlg.setMinimumWidth(BIG_WND_W);
|
jtkorhonen@2
|
1031 dlg.setMinimumHeight(BIG_WND_H);
|
jtkorhonen@2
|
1032 }
|
jtkorhonen@2
|
1033 else
|
jtkorhonen@2
|
1034 {
|
jtkorhonen@2
|
1035 dlg.setMinimumWidth(SMALL_WND_W);
|
jtkorhonen@2
|
1036 dlg.setMinimumHeight(SMALL_WND_H);
|
jtkorhonen@2
|
1037 }
|
jtkorhonen@0
|
1038
|
jtkorhonen@2
|
1039 QVBoxLayout *box = new QVBoxLayout;
|
jtkorhonen@2
|
1040 QListWidget *list = new QListWidget;
|
jtkorhonen@2
|
1041 list-> addItems(stdo.split("\n"));
|
jtkorhonen@2
|
1042 QPushButton *btn = new QPushButton(tr("Ok"));
|
jtkorhonen@2
|
1043 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
1044
|
jtkorhonen@2
|
1045 box -> addWidget(list);
|
jtkorhonen@2
|
1046 box -> addWidget(btn);
|
jtkorhonen@2
|
1047 dlg.setLayout(box);
|
jtkorhonen@2
|
1048
|
jtkorhonen@2
|
1049 dlg.exec();
|
jtkorhonen@2
|
1050 }
|
jtkorhonen@2
|
1051 else
|
jtkorhonen@2
|
1052 {
|
jtkorhonen@2
|
1053 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output."));
|
jtkorhonen@2
|
1054 }
|
jtkorhonen@0
|
1055 }
|
jtkorhonen@0
|
1056
|
jtkorhonen@0
|
1057
|
jtkorhonen@17
|
1058 bool MainWindow::areAllSelectedCommitable(QListWidget *workList)
|
jtkorhonen@11
|
1059 {
|
jtkorhonen@11
|
1060 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
1061 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@11
|
1062 {
|
jtkorhonen@17
|
1063 QString tmp = selList.at(i) -> text().mid(0, 1);
|
jtkorhonen@11
|
1064 if (tmp == "A")
|
jtkorhonen@11
|
1065 {
|
jtkorhonen@11
|
1066 //scheduled to be added, ok to commit
|
jtkorhonen@11
|
1067 }
|
jtkorhonen@11
|
1068 else if (tmp == "M")
|
jtkorhonen@11
|
1069 {
|
jtkorhonen@11
|
1070 //locally modified, ok to commit
|
jtkorhonen@17
|
1071 }
|
jtkorhonen@17
|
1072 else if (tmp == "R")
|
jtkorhonen@17
|
1073 {
|
jtkorhonen@17
|
1074 //user wants to remove from repo, ok to commit
|
jtkorhonen@17
|
1075 }
|
jtkorhonen@17
|
1076 else
|
jtkorhonen@17
|
1077 {
|
jtkorhonen@17
|
1078 return false;
|
jtkorhonen@11
|
1079 }
|
jtkorhonen@11
|
1080 }
|
jtkorhonen@17
|
1081 return true;
|
jtkorhonen@11
|
1082 }
|
jtkorhonen@11
|
1083
|
jtkorhonen@6
|
1084 bool MainWindow::isSelectedDeletable(QListWidget *workList)
|
jtkorhonen@0
|
1085 {
|
jtkorhonen@0
|
1086 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
1087 if (selList.count() == 1)
|
jtkorhonen@0
|
1088 {
|
jtkorhonen@6
|
1089 QString tmp = selList.at(0)->text().mid(0, 1);
|
jtkorhonen@6
|
1090 if (tmp == "A")
|
jtkorhonen@0
|
1091 {
|
jtkorhonen@6
|
1092 //scheduled to be added, ok to remove (won't go to repo)
|
jtkorhonen@6
|
1093 return true;
|
jtkorhonen@6
|
1094 }
|
jtkorhonen@6
|
1095 else if (tmp == "C")
|
jtkorhonen@6
|
1096 {
|
jtkorhonen@6
|
1097 //Tracked but unchanged, ok to remove
|
jtkorhonen@6
|
1098 return true;
|
jtkorhonen@6
|
1099 }
|
jtkorhonen@6
|
1100 else if (tmp == "M")
|
jtkorhonen@6
|
1101 {
|
jtkorhonen@6
|
1102 //locally modified, ok to remove from repo
|
jtkorhonen@6
|
1103 return true;
|
jtkorhonen@6
|
1104 }
|
jtkorhonen@6
|
1105 else if (tmp == "!")
|
jtkorhonen@6
|
1106 {
|
jtkorhonen@6
|
1107 //locally deleted, ok to remove from repo
|
jtkorhonen@0
|
1108 return true;
|
jtkorhonen@0
|
1109 }
|
jtkorhonen@0
|
1110 }
|
jtkorhonen@0
|
1111 return false;
|
jtkorhonen@0
|
1112 }
|
jtkorhonen@0
|
1113
|
jtkorhonen@0
|
1114
|
jtkorhonen@17
|
1115 bool MainWindow::areAllSelectedUntracked(QListWidget *workList)
|
jtkorhonen@0
|
1116 {
|
jtkorhonen@0
|
1117 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
1118 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@0
|
1119 {
|
jtkorhonen@17
|
1120 QString tmp = selList.at(i) -> text();
|
jtkorhonen@17
|
1121
|
jtkorhonen@17
|
1122 if (tmp.mid(0,1) != "?")
|
jtkorhonen@0
|
1123 {
|
jtkorhonen@17
|
1124 return false;
|
jtkorhonen@0
|
1125 }
|
jtkorhonen@0
|
1126 }
|
jtkorhonen@17
|
1127 return true;
|
jtkorhonen@0
|
1128 }
|
jtkorhonen@0
|
1129
|
jtkorhonen@0
|
1130
|
jtkorhonen@0
|
1131 bool MainWindow::isSelectedModified(QListWidget *workList)
|
jtkorhonen@0
|
1132 {
|
jtkorhonen@0
|
1133 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
1134 if (selList.count() == 1)
|
jtkorhonen@0
|
1135 {
|
jtkorhonen@0
|
1136 if (selList.at(0)->text().mid(0, 1) == "M")
|
jtkorhonen@0
|
1137 {
|
jtkorhonen@0
|
1138 return true;
|
jtkorhonen@0
|
1139 }
|
jtkorhonen@0
|
1140 }
|
jtkorhonen@0
|
1141 return false;
|
jtkorhonen@0
|
1142 }
|
jtkorhonen@0
|
1143
|
jtkorhonen@17
|
1144 void MainWindow::countModifications(QListWidget *workList, int& added, int& modified, int& removed, int& notTracked,
|
jtkorhonen@17
|
1145 int& selected,
|
jtkorhonen@17
|
1146 int& selectedAdded, int& selectedModified, int& selectedRemoved, int& selectedNotTracked)
|
jtkorhonen@0
|
1147 {
|
jtkorhonen@0
|
1148 int itemCount = workList -> count();
|
jtkorhonen@0
|
1149 if (itemCount > 0)
|
jtkorhonen@0
|
1150 {
|
jtkorhonen@0
|
1151 int A= 0;
|
jtkorhonen@0
|
1152 int M=0;
|
jtkorhonen@0
|
1153 int R=0;
|
jtkorhonen@5
|
1154 int N=0;
|
jtkorhonen@17
|
1155 int S=0;
|
jtkorhonen@17
|
1156 int SA=0;
|
jtkorhonen@17
|
1157 int SM=0;
|
jtkorhonen@17
|
1158 int SR=0;
|
jtkorhonen@17
|
1159 int SN=0;
|
jtkorhonen@17
|
1160
|
jtkorhonen@0
|
1161 for (int i = 0; i < workList -> count(); i++)
|
jtkorhonen@0
|
1162 {
|
jtkorhonen@0
|
1163 QListWidgetItem *currItem = workList -> item(i);
|
jtkorhonen@0
|
1164
|
jtkorhonen@0
|
1165 QString tmp = currItem->text().mid(0, 1);
|
jtkorhonen@0
|
1166 if (tmp == "M")
|
jtkorhonen@0
|
1167 {
|
jtkorhonen@0
|
1168 M++;
|
jtkorhonen@0
|
1169 }
|
jtkorhonen@0
|
1170 else if (tmp == "R")
|
jtkorhonen@0
|
1171 {
|
jtkorhonen@0
|
1172 R++;
|
jtkorhonen@0
|
1173 }
|
jtkorhonen@0
|
1174 else if (tmp == "A")
|
jtkorhonen@0
|
1175 {
|
jtkorhonen@0
|
1176 A++;
|
jtkorhonen@0
|
1177 }
|
jtkorhonen@5
|
1178 else if (tmp == "?")
|
jtkorhonen@5
|
1179 {
|
jtkorhonen@5
|
1180 N++;
|
jtkorhonen@5
|
1181 }
|
jtkorhonen@0
|
1182 }
|
jtkorhonen@0
|
1183
|
jtkorhonen@17
|
1184 added = A;
|
jtkorhonen@17
|
1185 modified = M;
|
jtkorhonen@17
|
1186 removed = R;
|
jtkorhonen@17
|
1187 notTracked = N;
|
jtkorhonen@17
|
1188
|
jtkorhonen@17
|
1189 QList <QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
1190
|
jtkorhonen@17
|
1191 S = selList.size();
|
jtkorhonen@17
|
1192 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
1193 {
|
jtkorhonen@17
|
1194 QString tmp = selList.at(i) -> text();
|
jtkorhonen@17
|
1195
|
jtkorhonen@17
|
1196 if (tmp.mid(0,1) == "A")
|
jtkorhonen@17
|
1197 {
|
jtkorhonen@17
|
1198 SA++;
|
jtkorhonen@17
|
1199 }
|
jtkorhonen@17
|
1200 else if (tmp.mid(0,1) == "M")
|
jtkorhonen@17
|
1201 {
|
jtkorhonen@17
|
1202 SM++;
|
jtkorhonen@17
|
1203 }
|
jtkorhonen@17
|
1204 else if (tmp.mid(0,1) == "R")
|
jtkorhonen@17
|
1205 {
|
jtkorhonen@17
|
1206 SR++;
|
jtkorhonen@17
|
1207 }
|
jtkorhonen@17
|
1208 else if (tmp.mid(0,1) == "?")
|
jtkorhonen@17
|
1209 {
|
jtkorhonen@17
|
1210 SN++;
|
jtkorhonen@17
|
1211 }
|
jtkorhonen@17
|
1212 }
|
jtkorhonen@17
|
1213
|
jtkorhonen@17
|
1214 selected = S;
|
jtkorhonen@17
|
1215 selectedAdded = SA;
|
jtkorhonen@17
|
1216 selectedModified = SM;
|
jtkorhonen@17
|
1217 selectedRemoved = SR;
|
jtkorhonen@17
|
1218 selectedNotTracked = SN;
|
jtkorhonen@0
|
1219 }
|
jtkorhonen@0
|
1220 else
|
jtkorhonen@0
|
1221 {
|
jtkorhonen@17
|
1222 added = 0;
|
jtkorhonen@17
|
1223 modified = 0;
|
jtkorhonen@17
|
1224 removed = 0;
|
jtkorhonen@17
|
1225 notTracked = 0;
|
jtkorhonen@17
|
1226 selected = 0;
|
jtkorhonen@17
|
1227 selectedAdded = 0;
|
jtkorhonen@17
|
1228 selectedModified = 0;
|
jtkorhonen@17
|
1229 selectedRemoved = 0;
|
jtkorhonen@17
|
1230 selectedNotTracked = 0;
|
jtkorhonen@0
|
1231 }
|
jtkorhonen@0
|
1232 }
|
jtkorhonen@0
|
1233
|
jtkorhonen@0
|
1234
|
Chris@90
|
1235 void MainWindow::updateFileSystemWatcher()
|
Chris@90
|
1236 {
|
Chris@90
|
1237 //!!! this needs to be incremental when something changes
|
Chris@90
|
1238
|
Chris@90
|
1239 delete fsWatcher;
|
Chris@90
|
1240 fsWatcher = new QFileSystemWatcher();
|
Chris@90
|
1241 std::deque<QString> pending;
|
Chris@90
|
1242 pending.push_back(workFolderPath);
|
Chris@90
|
1243 while (!pending.empty()) {
|
Chris@90
|
1244 QString path = pending.front();
|
Chris@90
|
1245 pending.pop_front();
|
Chris@90
|
1246 fsWatcher->addPath(path);
|
Chris@90
|
1247 DEBUG << "Added to file system watcher: " << path << endl;
|
Chris@90
|
1248 QDir d(path);
|
Chris@90
|
1249 if (d.exists()) {
|
Chris@90
|
1250 d.setFilter(QDir::Files | QDir::Dirs |
|
Chris@90
|
1251 QDir::NoDotAndDotDot | QDir::Readable);
|
Chris@90
|
1252 foreach (QString entry, d.entryList()) {
|
Chris@90
|
1253 if (entry == ".hg") continue;
|
Chris@90
|
1254 QString entryPath = d.absoluteFilePath(entry);
|
Chris@90
|
1255 pending.push_back(entryPath);
|
Chris@90
|
1256 }
|
Chris@90
|
1257 }
|
Chris@90
|
1258 }
|
Chris@90
|
1259 connect(fsWatcher, SIGNAL(directoryChanged(QString)),
|
Chris@90
|
1260 this, SLOT(fsDirectoryChanged(QString)));
|
Chris@90
|
1261 connect(fsWatcher, SIGNAL(fileChanged(QString)),
|
Chris@90
|
1262 this, SLOT(fsFileChanged(QString)));
|
Chris@90
|
1263 }
|
Chris@90
|
1264
|
Chris@90
|
1265 void MainWindow::fsDirectoryChanged(QString)
|
Chris@90
|
1266 {
|
Chris@90
|
1267 //!!! should just queue one of these!
|
Chris@90
|
1268 hgStat();
|
Chris@90
|
1269 }
|
Chris@90
|
1270
|
Chris@90
|
1271 void MainWindow::fsFileChanged(QString)
|
Chris@90
|
1272 {
|
Chris@90
|
1273 //!!! should just queue one of these!
|
Chris@90
|
1274 hgStat();
|
Chris@90
|
1275 }
|
Chris@90
|
1276
|
Chris@62
|
1277 void MainWindow::commandFailed()
|
Chris@62
|
1278 {
|
Chris@62
|
1279 DEBUG << "MainWindow::commandFailed" << endl;
|
Chris@74
|
1280 runningAction = ACT_NONE;
|
Chris@74
|
1281 runner -> hideProgBar();
|
Chris@74
|
1282
|
Chris@79
|
1283 //!!! N.B hg incoming returns 1 even if successful, if there were no changes
|
Chris@62
|
1284 }
|
Chris@62
|
1285
|
Chris@62
|
1286 void MainWindow::commandCompleted()
|
jtkorhonen@0
|
1287 {
|
jtkorhonen@0
|
1288 bool shouldHgStat = false;
|
jtkorhonen@0
|
1289
|
jtkorhonen@0
|
1290 if (runningAction != ACT_NONE)
|
jtkorhonen@0
|
1291 {
|
jtkorhonen@0
|
1292 //We are running some hg command...
|
Chris@62
|
1293 if (runner -> isCommandRunning() == false)
|
jtkorhonen@0
|
1294 {
|
jtkorhonen@0
|
1295 //Running has just ended.
|
jtkorhonen@0
|
1296 int exitCode = runner -> getExitCode();
|
jtkorhonen@0
|
1297
|
jtkorhonen@0
|
1298 runner -> hideProgBar();
|
jtkorhonen@0
|
1299
|
jtkorhonen@0
|
1300 //Clumsy...
|
jtkorhonen@0
|
1301 if ((EXITOK(exitCode)) || ((exitCode == 1) && (runningAction == ACT_INCOMING)))
|
jtkorhonen@0
|
1302 {
|
jtkorhonen@0
|
1303 //Successful running.
|
jtkorhonen@0
|
1304 switch(runningAction)
|
jtkorhonen@0
|
1305 {
|
Chris@74
|
1306 case ACT_PATHS:
|
Chris@74
|
1307 {
|
Chris@84
|
1308 QString sout = runner->getOutput();
|
Chris@76
|
1309 DEBUG << "stdout is " << sout << endl;
|
Chris@76
|
1310 LogParser lp(sout, "=");
|
Chris@74
|
1311 LogList ll = lp.parse();
|
Chris@74
|
1312 DEBUG << ll.size() << " results" << endl;
|
Chris@74
|
1313 if (!ll.empty()) {
|
Chris@74
|
1314 remoteRepoPath = lp.parse()[0]["default"].trimmed();
|
Chris@74
|
1315 DEBUG << "Set remote path to " << remoteRepoPath << endl;
|
Chris@74
|
1316 }
|
Chris@74
|
1317 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
|
Chris@74
|
1318 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
|
Chris@74
|
1319 enableDisableActions();
|
Chris@74
|
1320 break;
|
Chris@74
|
1321 }
|
Chris@74
|
1322
|
jtkorhonen@0
|
1323 case ACT_STAT:
|
Chris@84
|
1324 hgExp -> updateWorkFolderFileList(runner -> getOutput());
|
Chris@90
|
1325 updateFileSystemWatcher();
|
jtkorhonen@0
|
1326 break;
|
jtkorhonen@0
|
1327
|
jtkorhonen@0
|
1328 case ACT_INCOMING:
|
jtkorhonen@0
|
1329 case ACT_ANNOTATE:
|
jtkorhonen@0
|
1330 case ACT_RESOLVE_LIST:
|
jtkorhonen@0
|
1331 case ACT_RESOLVE_MARK:
|
Chris@84
|
1332 presentLongStdoutToUser(runner -> getOutput());
|
jtkorhonen@0
|
1333 shouldHgStat = true;
|
jtkorhonen@0
|
1334 break;
|
jtkorhonen@0
|
1335
|
jtkorhonen@0
|
1336 case ACT_PULL:
|
Chris@84
|
1337 QMessageBox::information(this, "Pull", runner -> getOutput());
|
jtkorhonen@0
|
1338 shouldHgStat = true;
|
jtkorhonen@0
|
1339 break;
|
jtkorhonen@0
|
1340
|
jtkorhonen@0
|
1341 case ACT_PUSH:
|
Chris@84
|
1342 QMessageBox::information(this, "Push", runner -> getOutput());
|
jtkorhonen@0
|
1343 shouldHgStat = true;
|
jtkorhonen@0
|
1344 break;
|
jtkorhonen@0
|
1345
|
jtkorhonen@0
|
1346 case ACT_INIT:
|
Chris@69
|
1347 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
|
Chris@69
|
1348 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
|
jtkorhonen@0
|
1349 enableDisableActions();
|
jtkorhonen@0
|
1350 shouldHgStat = true;
|
jtkorhonen@0
|
1351 break;
|
jtkorhonen@0
|
1352
|
jtkorhonen@0
|
1353 case ACT_CLONEFROMREMOTE:
|
Chris@69
|
1354 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
|
Chris@69
|
1355 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
|
Chris@72
|
1356 MultiChoiceDialog::addRecentArgument("remote", workFolderPath, true);
|
Chris@84
|
1357 QMessageBox::information(this, "Clone", runner -> getOutput());
|
jtkorhonen@0
|
1358 enableDisableActions();
|
jtkorhonen@0
|
1359 shouldHgStat = true;
|
jtkorhonen@0
|
1360 break;
|
jtkorhonen@0
|
1361
|
jtkorhonen@0
|
1362 case ACT_LOG:
|
Chris@91
|
1363 hgExp -> updateLocalRepoHgLogList(runner -> getOutput());
|
jtkorhonen@0
|
1364 break;
|
jtkorhonen@0
|
1365
|
jtkorhonen@0
|
1366 case ACT_PARENTS:
|
jtkorhonen@0
|
1367 {
|
Chris@91
|
1368 //!!! hgExp -> updateLocalRepoParentsList(runner -> getOutput());
|
jtkorhonen@0
|
1369 }
|
jtkorhonen@0
|
1370 break;
|
jtkorhonen@0
|
1371
|
jtkorhonen@0
|
1372 case ACT_HEADS:
|
jtkorhonen@0
|
1373 {
|
Chris@84
|
1374 QString stdOut = runner -> getOutput();
|
Chris@91
|
1375 //!!! hgExp -> updateLocalRepoHeadsList(stdOut);
|
jtkorhonen@0
|
1376 }
|
jtkorhonen@0
|
1377 break;
|
jtkorhonen@0
|
1378
|
jtkorhonen@0
|
1379 case ACT_REMOVE:
|
jtkorhonen@0
|
1380 case ACT_ADD:
|
jtkorhonen@0
|
1381 case ACT_COMMIT:
|
jtkorhonen@0
|
1382 case ACT_FILEDIFF:
|
jtkorhonen@0
|
1383 case ACT_FOLDERDIFF:
|
jtkorhonen@0
|
1384 case ACT_CHGSETDIFF:
|
jtkorhonen@0
|
1385 case ACT_REVERT:
|
jtkorhonen@11
|
1386 case ACT_SERVE:
|
jtkorhonen@34
|
1387 case ACT_TAG:
|
jtkorhonen@36
|
1388 case ACT_HG_IGNORE:
|
jtkorhonen@0
|
1389 shouldHgStat = true;
|
jtkorhonen@0
|
1390 break;
|
jtkorhonen@0
|
1391
|
jtkorhonen@0
|
1392 case ACT_UPDATE:
|
Chris@84
|
1393 QMessageBox::information(this, tr("Update"), runner -> getOutput());
|
jtkorhonen@0
|
1394 shouldHgStat = true;
|
jtkorhonen@0
|
1395 break;
|
jtkorhonen@0
|
1396
|
jtkorhonen@0
|
1397 case ACT_MERGE:
|
Chris@84
|
1398 QMessageBox::information(this, tr("Merge"), runner -> getOutput());
|
jtkorhonen@0
|
1399 shouldHgStat = true;
|
jtkorhonen@33
|
1400 justMerged = true;
|
jtkorhonen@33
|
1401 break;
|
jtkorhonen@33
|
1402
|
jtkorhonen@33
|
1403 case ACT_RETRY_MERGE:
|
jtkorhonen@38
|
1404 QMessageBox::information(this, tr("Merge retry"), tr("Merge retry successful."));
|
jtkorhonen@33
|
1405 shouldHgStat = true;
|
jtkorhonen@33
|
1406 justMerged = true;
|
jtkorhonen@0
|
1407 break;
|
jtkorhonen@0
|
1408
|
jtkorhonen@0
|
1409 default:
|
jtkorhonen@0
|
1410 break;
|
jtkorhonen@0
|
1411 }
|
jtkorhonen@0
|
1412 }
|
jtkorhonen@0
|
1413
|
jtkorhonen@37
|
1414
|
Chris@74
|
1415 //Typical sequence goes paths -> stat -> heads -> parents -> log
|
Chris@74
|
1416 if (runningAction == ACT_PATHS)
|
Chris@74
|
1417 {
|
Chris@74
|
1418 runningAction = ACT_NONE;
|
Chris@74
|
1419 hgStat();
|
Chris@74
|
1420 }
|
Chris@74
|
1421 else if (runningAction == ACT_STAT)
|
jtkorhonen@0
|
1422 {
|
jtkorhonen@0
|
1423 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1424 hgHeads();
|
jtkorhonen@0
|
1425 }
|
jtkorhonen@0
|
1426 else if (runningAction == ACT_HEADS)
|
jtkorhonen@0
|
1427 {
|
jtkorhonen@0
|
1428 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1429 hgParents();
|
jtkorhonen@0
|
1430 }
|
jtkorhonen@0
|
1431 else if (runningAction == ACT_PARENTS)
|
jtkorhonen@0
|
1432 {
|
jtkorhonen@0
|
1433 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1434 hgLog();
|
jtkorhonen@0
|
1435 }
|
jtkorhonen@37
|
1436 else if ((runningAction == ACT_MERGE) && (exitCode != 0))
|
jtkorhonen@37
|
1437 {
|
jtkorhonen@37
|
1438 //If we had a failed merge, offer to retry
|
jtkorhonen@37
|
1439 if (QMessageBox::Ok == QMessageBox::information(this, tr("Retry merge ?"), tr("Merge attempt failed. retry ?"), QMessageBox::Ok | QMessageBox::Cancel))
|
jtkorhonen@37
|
1440 {
|
jtkorhonen@37
|
1441 runningAction = ACT_NONE;
|
jtkorhonen@37
|
1442 hgRetryMerge();
|
jtkorhonen@37
|
1443 }
|
jtkorhonen@37
|
1444 else
|
jtkorhonen@37
|
1445 {
|
jtkorhonen@37
|
1446 runningAction = ACT_NONE;
|
jtkorhonen@37
|
1447 hgStat();
|
jtkorhonen@37
|
1448 }
|
jtkorhonen@37
|
1449 }
|
jtkorhonen@0
|
1450 else
|
jtkorhonen@0
|
1451 {
|
jtkorhonen@0
|
1452 runningAction = ACT_NONE;
|
jtkorhonen@0
|
1453 if (shouldHgStat)
|
jtkorhonen@0
|
1454 {
|
Chris@74
|
1455 hgPaths();
|
jtkorhonen@0
|
1456 }
|
jtkorhonen@0
|
1457 }
|
jtkorhonen@0
|
1458 }
|
jtkorhonen@0
|
1459 }
|
Chris@90
|
1460
|
Chris@90
|
1461 enableDisableActions();
|
jtkorhonen@0
|
1462 }
|
jtkorhonen@0
|
1463
|
jtkorhonen@0
|
1464 void MainWindow::connectActions()
|
jtkorhonen@0
|
1465 {
|
jtkorhonen@0
|
1466 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
jtkorhonen@0
|
1467 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
jtkorhonen@0
|
1468 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
jtkorhonen@0
|
1469
|
Chris@74
|
1470 connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgPaths()));
|
Chris@74
|
1471 connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgPaths()));
|
jtkorhonen@0
|
1472 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
|
jtkorhonen@0
|
1473 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
|
jtkorhonen@0
|
1474 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
|
jtkorhonen@0
|
1475 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
|
jtkorhonen@0
|
1476 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
|
jtkorhonen@0
|
1477 connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
|
jtkorhonen@0
|
1478 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
|
jtkorhonen@0
|
1479 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
|
jtkorhonen@0
|
1480 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
|
jtkorhonen@33
|
1481 connect(hgRetryMergeAct, SIGNAL(triggered()), this, SLOT(hgRetryMerge()));
|
jtkorhonen@34
|
1482 connect(hgTagAct, SIGNAL(triggered()), this, SLOT(hgTag()));
|
jtkorhonen@34
|
1483 connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore()));
|
jtkorhonen@0
|
1484
|
jtkorhonen@0
|
1485 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
|
Chris@69
|
1486 connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
jtkorhonen@0
|
1487
|
jtkorhonen@0
|
1488 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
|
jtkorhonen@0
|
1489 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
|
jtkorhonen@0
|
1490 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
|
jtkorhonen@0
|
1491 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
|
jtkorhonen@0
|
1492 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
|
jtkorhonen@0
|
1493
|
jtkorhonen@0
|
1494 connect(hgExp, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
jtkorhonen@0
|
1495
|
jtkorhonen@0
|
1496 connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
|
jtkorhonen@0
|
1497 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
|
jtkorhonen@0
|
1498 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
|
jtkorhonen@0
|
1499 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
|
jtkorhonen@11
|
1500 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
|
jtkorhonen@0
|
1501 }
|
jtkorhonen@0
|
1502
|
jtkorhonen@0
|
1503 void MainWindow::tabChanged(int currTab)
|
jtkorhonen@0
|
1504 {
|
jtkorhonen@0
|
1505 tabPage = currTab;
|
jtkorhonen@32
|
1506
|
jtkorhonen@0
|
1507 }
|
jtkorhonen@0
|
1508
|
jtkorhonen@0
|
1509 void MainWindow::enableDisableActions()
|
jtkorhonen@0
|
1510 {
|
Chris@90
|
1511 DEBUG << "MainWindow::enableDisableActions" << endl;
|
Chris@90
|
1512
|
jtkorhonen@0
|
1513 QDir localRepoDir;
|
jtkorhonen@0
|
1514 QDir workFolderDir;
|
jtkorhonen@0
|
1515 bool workFolderExist;
|
jtkorhonen@0
|
1516 bool localRepoExist;
|
jtkorhonen@0
|
1517
|
jtkorhonen@0
|
1518 remoteRepoActionsEnabled = true;
|
Chris@90
|
1519 if (remoteRepoPath.isEmpty()) {
|
jtkorhonen@0
|
1520 remoteRepoActionsEnabled = false;
|
jtkorhonen@0
|
1521 }
|
jtkorhonen@0
|
1522
|
jtkorhonen@0
|
1523 localRepoActionsEnabled = true;
|
Chris@90
|
1524 if (workFolderPath.isEmpty()) {
|
jtkorhonen@0
|
1525 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1526 workFolderExist = false;
|
jtkorhonen@0
|
1527 }
|
jtkorhonen@0
|
1528
|
Chris@90
|
1529 if (!workFolderDir.exists(workFolderPath)) {
|
jtkorhonen@0
|
1530 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1531 workFolderExist = false;
|
Chris@90
|
1532 } else {
|
jtkorhonen@0
|
1533 workFolderExist = true;
|
jtkorhonen@0
|
1534 }
|
jtkorhonen@0
|
1535
|
Chris@90
|
1536 if (!localRepoDir.exists(workFolderPath + "/" + getHgDirName())) {
|
jtkorhonen@0
|
1537 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1538 localRepoExist = false;
|
jtkorhonen@0
|
1539 }
|
jtkorhonen@0
|
1540
|
jtkorhonen@0
|
1541 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1542 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1543 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1544 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
Chris@73
|
1545 /*
|
jtkorhonen@0
|
1546 if (tabPage != WORKTAB)
|
jtkorhonen@0
|
1547 {
|
jtkorhonen@0
|
1548 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1549 }
|
Chris@73
|
1550 */
|
jtkorhonen@0
|
1551 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
|
jtkorhonen@0
|
1552 hgStatAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1553 hgFileDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1554 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1555 hgRevertAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1556 hgAddAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1557 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1558 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1559 hgCommitAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1560 hgMergeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@33
|
1561 hgRetryMergeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1562 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1563 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1564 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@11
|
1565 hgServeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@34
|
1566 hgTagAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@34
|
1567 hgIgnoreAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1568
|
Chris@91
|
1569 //!!!hgExp -> enableDisableOtherTabs(tabPage);
|
jtkorhonen@0
|
1570
|
Chris@90
|
1571 DEBUG << "localRepoActionsEnabled = " << localRepoActionsEnabled << endl;
|
Chris@90
|
1572 DEBUG << "canCommit = " << hgExp->canCommit() << endl;
|
Chris@90
|
1573
|
Chris@90
|
1574 //!!! new stuff:
|
Chris@90
|
1575 hgCommitAct->setEnabled(localRepoActionsEnabled && hgExp->canCommit());
|
Chris@90
|
1576 hgRevertAct->setEnabled(localRepoActionsEnabled && hgExp->canCommit());
|
Chris@90
|
1577
|
Chris@90
|
1578 /*!!!
|
jtkorhonen@17
|
1579 int added, modified, removed, notTracked, selected, selectedAdded, selectedModified, selectedRemoved, selectedNotTracked;
|
jtkorhonen@17
|
1580
|
jtkorhonen@17
|
1581 countModifications(hgExp -> workFolderFileList,
|
jtkorhonen@17
|
1582 added, modified, removed, notTracked,
|
jtkorhonen@17
|
1583 selected,
|
jtkorhonen@17
|
1584 selectedAdded, selectedModified, selectedRemoved, selectedNotTracked);
|
jtkorhonen@0
|
1585
|
jtkorhonen@0
|
1586 if (tabPage == WORKTAB)
|
jtkorhonen@0
|
1587 {
|
jtkorhonen@0
|
1588 //Enable / disable actions according to workFolderFileList selections / currentSelection / count
|
jtkorhonen@0
|
1589 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1590 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1591
|
jtkorhonen@0
|
1592 if (localRepoActionsEnabled)
|
jtkorhonen@0
|
1593 {
|
jtkorhonen@17
|
1594 if ((added == 0) && (modified == 0) && (removed == 0))
|
jtkorhonen@0
|
1595 {
|
jtkorhonen@0
|
1596 hgCommitAct -> setEnabled(false);
|
jtkorhonen@0
|
1597 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
1598 }
|
jtkorhonen@17
|
1599 else if (selected != 0)
|
jtkorhonen@17
|
1600 {
|
jtkorhonen@17
|
1601 if (selectedNotTracked != 0)
|
jtkorhonen@17
|
1602 {
|
jtkorhonen@17
|
1603 hgCommitAct -> setEnabled(false);
|
jtkorhonen@17
|
1604 }
|
jtkorhonen@17
|
1605 else if ((selectedAdded == 0) && (selectedModified == 0) && (selectedRemoved == 0))
|
jtkorhonen@17
|
1606 {
|
jtkorhonen@17
|
1607 hgCommitAct -> setEnabled(false);
|
jtkorhonen@17
|
1608 }
|
jtkorhonen@17
|
1609 }
|
jtkorhonen@0
|
1610
|
jtkorhonen@17
|
1611 if (modified == 0)
|
jtkorhonen@0
|
1612 {
|
jtkorhonen@0
|
1613 hgFolderDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1614 }
|
jtkorhonen@0
|
1615
|
jtkorhonen@0
|
1616 if (!isSelectedModified(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
1617 {
|
jtkorhonen@0
|
1618 hgFileDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1619 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
1620 }
|
jtkorhonen@0
|
1621
|
jtkorhonen@5
|
1622 //JK 14.5.2010: Fixed confusing add button. Now this is simple: If we have something to add (any non-tracked files), add is enabled.
|
jtkorhonen@17
|
1623 if (notTracked == 0)
|
jtkorhonen@0
|
1624 {
|
jtkorhonen@0
|
1625 hgAddAct -> setEnabled(false);
|
jtkorhonen@0
|
1626 }
|
jtkorhonen@0
|
1627
|
jtkorhonen@6
|
1628 if (!isSelectedDeletable(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
1629 {
|
jtkorhonen@0
|
1630 hgRemoveAct -> setEnabled(false);
|
jtkorhonen@0
|
1631 }
|
jtkorhonen@0
|
1632
|
jtkorhonen@2
|
1633 hgResolveListAct -> setEnabled(true);
|
jtkorhonen@2
|
1634
|
jtkorhonen@5
|
1635 if (hgExp -> localRepoHeadsList->count() < 2)
|
jtkorhonen@0
|
1636 {
|
jtkorhonen@0
|
1637 hgMergeAct -> setEnabled(false);
|
jtkorhonen@33
|
1638 hgRetryMergeAct -> setEnabled(false);
|
jtkorhonen@0
|
1639 }
|
jtkorhonen@0
|
1640
|
jtkorhonen@34
|
1641 if (hgExp -> localRepoHeadsList->count() < 1)
|
jtkorhonen@34
|
1642 {
|
jtkorhonen@34
|
1643 hgTagAct -> setEnabled(false);
|
jtkorhonen@34
|
1644 }
|
jtkorhonen@34
|
1645
|
jtkorhonen@2
|
1646 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@2
|
1647 if (!currentFile.isEmpty())
|
jtkorhonen@2
|
1648 {
|
jtkorhonen@2
|
1649 hgAnnotateAct -> setEnabled(true);
|
jtkorhonen@2
|
1650 hgResolveMarkAct -> setEnabled(true);
|
jtkorhonen@2
|
1651 }
|
jtkorhonen@2
|
1652 else
|
jtkorhonen@2
|
1653 {
|
jtkorhonen@2
|
1654 hgAnnotateAct -> setEnabled(false);
|
jtkorhonen@2
|
1655 hgResolveMarkAct -> setEnabled(false);
|
jtkorhonen@2
|
1656 }
|
jtkorhonen@0
|
1657 }
|
jtkorhonen@0
|
1658 }
|
jtkorhonen@0
|
1659 else
|
jtkorhonen@0
|
1660 {
|
jtkorhonen@0
|
1661 QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems();
|
jtkorhonen@0
|
1662 QList <QListWidgetItem *> historySelList = hgExp -> localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
1663
|
jtkorhonen@0
|
1664 if ((historySelList.count() == 2) || (headSelList.count() == 2))
|
jtkorhonen@0
|
1665 {
|
jtkorhonen@0
|
1666 hgChgSetDiffAct -> setEnabled(true);
|
jtkorhonen@0
|
1667 }
|
jtkorhonen@0
|
1668 else
|
jtkorhonen@0
|
1669 {
|
jtkorhonen@0
|
1670 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1671 }
|
jtkorhonen@0
|
1672
|
jtkorhonen@30
|
1673 if (historySelList.count() == 1)
|
jtkorhonen@0
|
1674 {
|
jtkorhonen@30
|
1675 hgUpdateToRevAct -> setEnabled(true);
|
jtkorhonen@0
|
1676 }
|
jtkorhonen@0
|
1677 else
|
jtkorhonen@0
|
1678 {
|
jtkorhonen@0
|
1679 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1680 }
|
jtkorhonen@0
|
1681 }
|
Chris@90
|
1682 */
|
jtkorhonen@0
|
1683 }
|
jtkorhonen@0
|
1684
|
jtkorhonen@0
|
1685 void MainWindow::createActions()
|
jtkorhonen@0
|
1686 {
|
jtkorhonen@0
|
1687 //File actions
|
jtkorhonen@0
|
1688 hgInitAct = new QAction(tr("Init local repository"), this);
|
jtkorhonen@0
|
1689 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
|
jtkorhonen@0
|
1690
|
jtkorhonen@0
|
1691 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
|
jtkorhonen@0
|
1692 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
|
jtkorhonen@0
|
1693
|
Chris@69
|
1694 openAct = new QAction(QIcon(":/images/fileopen.png"), tr("Open..."), this);
|
Chris@69
|
1695 openAct -> setStatusTip(tr("Open repository"));
|
Chris@69
|
1696 openAct -> setIconVisibleInMenu(true);
|
Chris@69
|
1697
|
jtkorhonen@0
|
1698 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
|
jtkorhonen@0
|
1699 settingsAct -> setStatusTip(tr("View and change application settings"));
|
jtkorhonen@0
|
1700 settingsAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1701
|
jtkorhonen@0
|
1702 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
|
jtkorhonen@0
|
1703 exitAct->setShortcuts(QKeySequence::Quit);
|
jtkorhonen@0
|
1704 exitAct->setStatusTip(tr("Exit application"));
|
jtkorhonen@0
|
1705 exitAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1706
|
jtkorhonen@0
|
1707 //Repository actions
|
Chris@61
|
1708 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
|
Chris@61
|
1709 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
|
Chris@61
|
1710
|
Chris@61
|
1711 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
|
jtkorhonen@0
|
1712 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
|
jtkorhonen@0
|
1713
|
Chris@61
|
1714 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
|
jtkorhonen@0
|
1715 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
|
jtkorhonen@0
|
1716
|
Chris@61
|
1717 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push"), this);
|
jtkorhonen@0
|
1718 hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
|
jtkorhonen@0
|
1719
|
jtkorhonen@0
|
1720 //Workfolder actions
|
Chris@61
|
1721 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("Diff"), this);
|
jtkorhonen@0
|
1722 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
|
jtkorhonen@0
|
1723
|
jtkorhonen@0
|
1724 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this);
|
jtkorhonen@0
|
1725 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
|
jtkorhonen@0
|
1726
|
jtkorhonen@0
|
1727 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
|
jtkorhonen@0
|
1728 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
|
jtkorhonen@0
|
1729
|
Chris@61
|
1730 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Revert"), this);
|
jtkorhonen@0
|
1731 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
|
jtkorhonen@0
|
1732
|
Chris@61
|
1733 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add"), this);
|
jtkorhonen@17
|
1734 hgAddAct -> setStatusTip(tr("Add working folder file(s) (selected or all yet untracked) to local repository (on next commit)"));
|
jtkorhonen@0
|
1735
|
Chris@61
|
1736 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove"), this);
|
jtkorhonen@0
|
1737 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
|
jtkorhonen@0
|
1738
|
Chris@61
|
1739 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update"), this);
|
jtkorhonen@0
|
1740 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
|
jtkorhonen@0
|
1741
|
Chris@61
|
1742 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit"), this);
|
jtkorhonen@20
|
1743 hgCommitAct->setStatusTip(tr("Save selected file(s) or all changed files in working folder (and all subfolders) to local repository"));
|
jtkorhonen@0
|
1744
|
jtkorhonen@0
|
1745 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
|
jtkorhonen@0
|
1746 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
|
jtkorhonen@0
|
1747
|
jtkorhonen@0
|
1748 //Advanced actions
|
jtkorhonen@0
|
1749 hgUpdateToRevAct = new QAction(tr("Update to revision"), this);
|
jtkorhonen@0
|
1750 hgUpdateToRevAct -> setStatusTip(tr("Update working folder to version selected from history list"));
|
jtkorhonen@0
|
1751
|
jtkorhonen@0
|
1752 hgAnnotateAct = new QAction(tr("Annotate"), this);
|
jtkorhonen@0
|
1753 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
|
jtkorhonen@0
|
1754
|
jtkorhonen@0
|
1755 hgResolveListAct = new QAction(tr("Resolve (list)"), this);
|
jtkorhonen@0
|
1756 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
|
jtkorhonen@0
|
1757
|
jtkorhonen@0
|
1758 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
|
jtkorhonen@0
|
1759 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
|
jtkorhonen@0
|
1760
|
jtkorhonen@33
|
1761 hgRetryMergeAct = new QAction(tr("Retry merge"), this);
|
jtkorhonen@33
|
1762 hgRetryMergeAct -> setStatusTip(tr("Retry merge after failed merge attempt."));
|
jtkorhonen@33
|
1763
|
jtkorhonen@34
|
1764 hgTagAct = new QAction(tr("Tag revision"), this);
|
jtkorhonen@34
|
1765 hgTagAct -> setStatusTip(tr("Give decsriptive name (tag) to current workfolder parent revision."));
|
jtkorhonen@34
|
1766
|
jtkorhonen@34
|
1767 hgIgnoreAct = new QAction(tr("Edit .hgignore"), this);
|
jtkorhonen@34
|
1768 hgIgnoreAct -> setStatusTip(tr("Edit .hgignore file (file contains names of files that should be ignored by mercurial)"));
|
jtkorhonen@34
|
1769
|
jtkorhonen@11
|
1770 hgServeAct = new QAction(tr("Serve (via http)"), this);
|
jtkorhonen@11
|
1771 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
|
jtkorhonen@11
|
1772
|
jtkorhonen@0
|
1773 //Help actions
|
jtkorhonen@0
|
1774 aboutAct = new QAction(tr("About"), this);
|
jtkorhonen@0
|
1775 aboutAct->setStatusTip(tr("Show the application's About box"));
|
jtkorhonen@0
|
1776
|
jtkorhonen@0
|
1777 aboutQtAct = new QAction(tr("About Qt"), this);
|
jtkorhonen@0
|
1778 aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
jtkorhonen@0
|
1779 }
|
jtkorhonen@0
|
1780
|
jtkorhonen@0
|
1781 void MainWindow::createMenus()
|
jtkorhonen@0
|
1782 {
|
jtkorhonen@0
|
1783 fileMenu = menuBar()->addMenu(tr("File"));
|
jtkorhonen@0
|
1784 fileMenu -> addAction(hgInitAct);
|
jtkorhonen@0
|
1785 fileMenu -> addAction(hgCloneFromRemoteAct);
|
jtkorhonen@0
|
1786 fileMenu -> addSeparator();
|
Chris@69
|
1787 fileMenu -> addAction(openAct);
|
jtkorhonen@0
|
1788 fileMenu -> addAction(settingsAct);
|
jtkorhonen@0
|
1789 fileMenu -> addSeparator();
|
jtkorhonen@0
|
1790 fileMenu -> addAction(exitAct);
|
jtkorhonen@0
|
1791
|
jtkorhonen@0
|
1792 advancedMenu = menuBar()->addMenu(tr("Advanced"));
|
jtkorhonen@0
|
1793 advancedMenu -> addAction(hgUpdateToRevAct);
|
jtkorhonen@0
|
1794 advancedMenu -> addSeparator();
|
jtkorhonen@0
|
1795 advancedMenu -> addAction(hgAnnotateAct);
|
jtkorhonen@0
|
1796 advancedMenu -> addSeparator();
|
jtkorhonen@33
|
1797 advancedMenu -> addAction(hgRetryMergeAct);
|
jtkorhonen@0
|
1798 advancedMenu -> addAction(hgResolveListAct);
|
jtkorhonen@0
|
1799 advancedMenu -> addAction(hgResolveMarkAct);
|
jtkorhonen@11
|
1800 advancedMenu -> addSeparator();
|
jtkorhonen@34
|
1801 advancedMenu -> addAction(hgTagAct);
|
jtkorhonen@34
|
1802 advancedMenu -> addSeparator();
|
jtkorhonen@34
|
1803 advancedMenu -> addAction(hgIgnoreAct);
|
jtkorhonen@34
|
1804 advancedMenu -> addSeparator();
|
jtkorhonen@11
|
1805 advancedMenu -> addAction(hgServeAct);
|
jtkorhonen@0
|
1806
|
jtkorhonen@0
|
1807 helpMenu = menuBar()->addMenu(tr("Help"));
|
jtkorhonen@0
|
1808 helpMenu->addAction(aboutAct);
|
jtkorhonen@0
|
1809 helpMenu->addAction(aboutQtAct);
|
jtkorhonen@0
|
1810 }
|
jtkorhonen@0
|
1811
|
jtkorhonen@0
|
1812 void MainWindow::createToolBars()
|
jtkorhonen@0
|
1813 {
|
jtkorhonen@0
|
1814 fileToolBar = addToolBar(tr("File"));
|
jtkorhonen@0
|
1815 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
Chris@69
|
1816 fileToolBar -> addAction(openAct);
|
Chris@43
|
1817 fileToolBar -> addAction(hgStatAct);
|
jtkorhonen@0
|
1818 fileToolBar -> addSeparator();
|
Chris@61
|
1819 // fileToolBar -> addAction(hgChgSetDiffAct);
|
jtkorhonen@0
|
1820 fileToolBar -> setMovable(false);
|
jtkorhonen@0
|
1821
|
jtkorhonen@0
|
1822 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
|
jtkorhonen@0
|
1823 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1824 repoToolBar->addAction(hgIncomingAct);
|
jtkorhonen@0
|
1825 repoToolBar->addAction(hgPullAct);
|
jtkorhonen@0
|
1826 repoToolBar->addAction(hgPushAct);
|
jtkorhonen@0
|
1827 repoToolBar -> setMovable(false);
|
jtkorhonen@0
|
1828
|
jtkorhonen@0
|
1829 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
|
jtkorhonen@0
|
1830 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
|
jtkorhonen@0
|
1831 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
Chris@61
|
1832 // workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1833 workFolderToolBar->addAction(hgFileDiffAct);
|
Chris@61
|
1834 // workFolderToolBar->addAction(hgFolderDiffAct);
|
jtkorhonen@0
|
1835 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1836 workFolderToolBar->addAction(hgRevertAct);
|
jtkorhonen@0
|
1837 workFolderToolBar->addAction(hgUpdateAct);
|
jtkorhonen@0
|
1838 workFolderToolBar->addAction(hgCommitAct);
|
jtkorhonen@0
|
1839 workFolderToolBar->addAction(hgMergeAct);
|
jtkorhonen@0
|
1840 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1841 workFolderToolBar->addAction(hgAddAct);
|
jtkorhonen@0
|
1842 workFolderToolBar->addAction(hgRemoveAct);
|
jtkorhonen@0
|
1843 workFolderToolBar -> setMovable(false);
|
Chris@61
|
1844
|
Chris@61
|
1845 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
|
Chris@61
|
1846 tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
Chris@61
|
1847 }
|
jtkorhonen@0
|
1848 }
|
jtkorhonen@0
|
1849
|
jtkorhonen@0
|
1850
|
jtkorhonen@0
|
1851 void MainWindow::createStatusBar()
|
jtkorhonen@0
|
1852 {
|
jtkorhonen@0
|
1853 statusBar()->showMessage(tr("Ready"));
|
jtkorhonen@0
|
1854 }
|
jtkorhonen@0
|
1855
|
Chris@69
|
1856
|
Chris@69
|
1857 //!!! review these:
|
Chris@69
|
1858
|
jtkorhonen@0
|
1859 void MainWindow::readSettings()
|
jtkorhonen@0
|
1860 {
|
jtkorhonen@0
|
1861 QDir workFolder;
|
jtkorhonen@0
|
1862
|
Chris@61
|
1863 QSettings settings;
|
jtkorhonen@0
|
1864
|
jtkorhonen@30
|
1865 remoteRepoPath = settings.value("remoterepopath", "").toString();
|
jtkorhonen@0
|
1866 workFolderPath = settings.value("workfolderpath", "").toString();
|
jtkorhonen@0
|
1867 if (!workFolder.exists(workFolderPath))
|
jtkorhonen@0
|
1868 {
|
jtkorhonen@0
|
1869 workFolderPath = "";
|
jtkorhonen@0
|
1870 }
|
jtkorhonen@0
|
1871
|
jtkorhonen@0
|
1872 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
jtkorhonen@0
|
1873 QSize size = settings.value("size", QSize(400, 400)).toSize();
|
jtkorhonen@0
|
1874 firstStart = settings.value("firststart", QVariant(true)).toBool();
|
jtkorhonen@0
|
1875
|
jtkorhonen@0
|
1876 initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
|
jtkorhonen@0
|
1877 resize(size);
|
jtkorhonen@0
|
1878 move(pos);
|
jtkorhonen@0
|
1879 }
|
jtkorhonen@0
|
1880
|
jtkorhonen@17
|
1881
|
jtkorhonen@0
|
1882 void MainWindow::writeSettings()
|
jtkorhonen@0
|
1883 {
|
Chris@61
|
1884 QSettings settings;
|
jtkorhonen@0
|
1885 settings.setValue("pos", pos());
|
jtkorhonen@0
|
1886 settings.setValue("size", size());
|
jtkorhonen@0
|
1887 settings.setValue("remoterepopath", remoteRepoPath);
|
jtkorhonen@0
|
1888 settings.setValue("workfolderpath", workFolderPath);
|
jtkorhonen@0
|
1889 settings.setValue("firststart", firstStart);
|
Chris@91
|
1890 //!!!settings.setValue("viewFileTypes", hgExp -> getFileTypesBits());
|
jtkorhonen@0
|
1891 }
|
jtkorhonen@0
|
1892
|
jtkorhonen@0
|
1893
|
jtkorhonen@0
|
1894
|
jtkorhonen@0
|
1895
|