Mercurial > hg > easyhg
comparison hgrunner.h @ 109:1721c580c10e
* Add a queueing mechanism for Hg actions, instead of refusing to start an action if something else is already happening. This is essential now that actions can be prompted by asynchronous events (e.g. filesystem watcher).
* Make Revert behave sensibly
author | Chris Cannam |
---|---|
date | Fri, 26 Nov 2010 12:48:29 +0000 |
parents | fdca34c989c0 |
children | 0f039d3cc38e |
comparison
equal
deleted
inserted
replaced
108:8ae3b44c0073 | 109:1721c580c10e |
---|---|
16 */ | 16 */ |
17 | 17 |
18 #ifndef HGRUNNER_H | 18 #ifndef HGRUNNER_H |
19 #define HGRUNNER_H | 19 #define HGRUNNER_H |
20 | 20 |
21 #include "hgaction.h" | |
22 | |
21 #include <QProgressBar> | 23 #include <QProgressBar> |
22 #include <QProcess> | 24 #include <QProcess> |
23 #include <QByteArray> | 25 #include <QByteArray> |
24 #include <QRect> | 26 #include <QRect> |
25 #include <QFile> | 27 #include <QFile> |
28 | |
29 #include <deque> | |
26 | 30 |
27 class HgRunner : public QProgressBar | 31 class HgRunner : public QProgressBar |
28 { | 32 { |
29 Q_OBJECT | 33 Q_OBJECT |
30 | 34 |
31 public: | 35 public: |
32 HgRunner(QWidget * parent = 0); | 36 HgRunner(QWidget * parent = 0); |
33 ~HgRunner(); | 37 ~HgRunner(); |
34 | 38 |
35 void startHgCommand(QString workingDir, QStringList params, bool interactive = false); | 39 void requestAction(HgAction action); |
36 void startCommand(QString command, QString workingDir, QStringList params, bool interactive = false); | 40 /* |
37 | |
38 bool isCommandRunning(); | 41 bool isCommandRunning(); |
39 void killCurrentCommand(); | 42 void killCurrentCommand(); |
40 | 43 |
41 int getExitCode(); | 44 void hideProgBar(); |
42 QProcess::ExitStatus getExitStatus(); | 45 */ |
46 signals: | |
47 void commandCompleted(HgAction action, QString stdout); | |
48 void commandFailed(HgAction action, QString stderr); | |
43 | 49 |
44 void hideProgBar(); | 50 private slots: |
45 | 51 void started(); |
46 QString getOutput(); | 52 void finished(int procExitCode, QProcess::ExitStatus procExitStatus); |
47 | 53 void dataReady(); |
48 signals: | |
49 void commandCompleted(); | |
50 void commandFailed(); | |
51 | 54 |
52 private: | 55 private: |
53 void setProcExitInfo(int procExitCode, QProcess::ExitStatus procExitStatus); | 56 void checkQueue(); |
54 QString getLastCommandLine(); | 57 void startCommand(HgAction action); |
55 void presentErrorToUser(); | |
56 QString getHgBinaryName(); | 58 QString getHgBinaryName(); |
57 void closeProcInput(); | 59 void closeProcInput(); |
60 void killCurrentCommand(); | |
58 | 61 |
59 void noteUsername(QString); | 62 void noteUsername(QString); |
60 void noteRealm(QString); | 63 void noteRealm(QString); |
61 void getUsername(); | 64 void getUsername(); |
62 void getPassword(); | 65 void getPassword(); |
68 QFile *m_procInput; | 71 QFile *m_procInput; |
69 | 72 |
70 bool m_isRunning; | 73 bool m_isRunning; |
71 QProcess *m_proc; | 74 QProcess *m_proc; |
72 QString m_output; | 75 QString m_output; |
73 int m_exitCode; | |
74 QProcess::ExitStatus m_exitStatus; | |
75 QString m_lastHgCommand; | |
76 QString m_lastParams; | |
77 | 76 |
78 QString m_userName; | 77 QString m_userName; |
79 QString m_realm; | 78 QString m_realm; |
80 | 79 |
81 private slots: | 80 typedef std::deque<HgAction> ActionQueue; |
82 void started(); | 81 ActionQueue m_queue; |
83 void finished(int procExitCode, QProcess::ExitStatus procExitStatus); | 82 HgAction m_currentAction; |
84 void dataReady(); | |
85 }; | 83 }; |
86 | 84 |
87 #endif // HGRUNNER_H | 85 #endif // HGRUNNER_H |