annotate hgaction.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
children 0f039d3cc38e
rev   line source
Chris@109 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@109 2
Chris@109 3 /*
Chris@109 4 EasyMercurial
Chris@109 5
Chris@109 6 Based on HgExplorer by Jari Korhonen
Chris@109 7 Copyright (c) 2010 Jari Korhonen
Chris@109 8 Copyright (c) 2010 Chris Cannam
Chris@109 9 Copyright (c) 2010 Queen Mary, University of London
Chris@109 10
Chris@109 11 This program is free software; you can redistribute it and/or
Chris@109 12 modify it under the terms of the GNU General Public License as
Chris@109 13 published by the Free Software Foundation; either version 2 of the
Chris@109 14 License, or (at your option) any later version. See the file
Chris@109 15 COPYING included with this distribution for more information.
Chris@109 16 */
Chris@109 17
Chris@109 18 #ifndef HGACTION_H
Chris@109 19 #define HGACTION_H
Chris@109 20
Chris@109 21 #include <QString>
Chris@109 22 #include <QStringList>
Chris@109 23
Chris@109 24 enum HGACTIONS
Chris@109 25 {
Chris@109 26 ACT_NONE,
Chris@109 27 ACT_QUERY_PATHS,
Chris@109 28 ACT_QUERY_BRANCH,
Chris@109 29 ACT_STAT,
Chris@109 30 ACT_QUERY_HEADS,
Chris@109 31 ACT_QUERY_PARENTS,
Chris@109 32 ACT_LOG,
Chris@109 33 ACT_REMOVE,
Chris@109 34 ACT_ADD,
Chris@109 35 ACT_INCOMING,
Chris@109 36 ACT_PUSH,
Chris@109 37 ACT_PULL,
Chris@109 38 ACT_CLONEFROMREMOTE,
Chris@109 39 ACT_INIT,
Chris@109 40 ACT_COMMIT,
Chris@109 41 ACT_ANNOTATE,
Chris@109 42 ACT_FILEDIFF,
Chris@109 43 ACT_FOLDERDIFF,
Chris@109 44 ACT_CHGSETDIFF,
Chris@109 45 ACT_UPDATE,
Chris@109 46 ACT_REVERT,
Chris@109 47 ACT_MERGE,
Chris@109 48 ACT_RESOLVE_LIST,
Chris@109 49 ACT_SERVE,
Chris@109 50 ACT_RESOLVE_MARK,
Chris@109 51 ACT_RETRY_MERGE,
Chris@109 52 ACT_TAG,
Chris@109 53 ACT_HG_IGNORE,
Chris@109 54 };
Chris@109 55
Chris@109 56 struct HgAction
Chris@109 57 {
Chris@109 58 HGACTIONS action;
Chris@109 59 QString workingDir;
Chris@109 60 QStringList params;
Chris@109 61
Chris@109 62 QString executable; // empty for normal Hg
Chris@109 63
Chris@109 64 HgAction() : action(ACT_NONE) { }
Chris@109 65
Chris@109 66 HgAction(HGACTIONS _action, QString _wd, QStringList _params) :
Chris@109 67 action(_action), workingDir(_wd), params(_params) { }
Chris@109 68 /*
Chris@109 69 HgAction(const HgAction &a) :
Chris@109 70 action(a.action), workingDir(a.workingDir),
Chris@109 71 params(a.params), executable(a.executable) { }
Chris@109 72
Chris@109 73 HgAction &operator=(const HgAction &a) {
Chris@109 74 if (&a != this) {
Chris@109 75 action = a.action;
Chris@109 76 workingDir = a.workingDir;
Chris@109 77 params = a.params;
Chris@109 78 executable = a.executable;
Chris@109 79 }
Chris@109 80 return *this;
Chris@109 81 }
Chris@109 82 */
Chris@109 83 bool operator==(const HgAction &a) {
Chris@109 84 return (a.action == action && a.workingDir == workingDir &&
Chris@109 85 a.params == params && a.executable == executable);
Chris@109 86 }
Chris@109 87
Chris@109 88 bool mayBeInteractive() const {
Chris@109 89 switch (action) {
Chris@109 90 case ACT_INCOMING:
Chris@109 91 case ACT_PUSH:
Chris@109 92 case ACT_PULL:
Chris@109 93 case ACT_CLONEFROMREMOTE:
Chris@109 94 return true;
Chris@109 95 default:
Chris@109 96 return false;
Chris@109 97 }
Chris@109 98 }
Chris@109 99 };
Chris@109 100
Chris@109 101 #endif