diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgaction.h	Fri Nov 26 12:48:29 2010 +0000
@@ -0,0 +1,101 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    EasyMercurial
+
+    Based on HgExplorer by Jari Korhonen
+    Copyright (c) 2010 Jari Korhonen
+    Copyright (c) 2010 Chris Cannam
+    Copyright (c) 2010 Queen Mary, University of London
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef HGACTION_H
+#define HGACTION_H
+
+#include <QString>
+#include <QStringList>
+
+enum HGACTIONS
+{
+    ACT_NONE,
+    ACT_QUERY_PATHS,
+    ACT_QUERY_BRANCH,
+    ACT_STAT,
+    ACT_QUERY_HEADS,
+    ACT_QUERY_PARENTS,
+    ACT_LOG,
+    ACT_REMOVE,
+    ACT_ADD,
+    ACT_INCOMING,
+    ACT_PUSH,
+    ACT_PULL,
+    ACT_CLONEFROMREMOTE,
+    ACT_INIT,
+    ACT_COMMIT,
+    ACT_ANNOTATE,
+    ACT_FILEDIFF,
+    ACT_FOLDERDIFF,
+    ACT_CHGSETDIFF,
+    ACT_UPDATE,
+    ACT_REVERT,
+    ACT_MERGE,
+    ACT_RESOLVE_LIST,
+    ACT_SERVE,
+    ACT_RESOLVE_MARK,
+    ACT_RETRY_MERGE,
+    ACT_TAG,
+    ACT_HG_IGNORE,
+};
+
+struct HgAction
+{
+    HGACTIONS action;
+    QString workingDir;
+    QStringList params;
+
+    QString executable; // empty for normal Hg
+
+    HgAction() : action(ACT_NONE) { }
+
+    HgAction(HGACTIONS _action, QString _wd, QStringList _params) :
+        action(_action), workingDir(_wd), params(_params) { }
+/*
+    HgAction(const HgAction &a) :
+        action(a.action), workingDir(a.workingDir),
+        params(a.params), executable(a.executable) { }
+
+    HgAction &operator=(const HgAction &a) {
+        if (&a != this) {
+            action = a.action;
+            workingDir = a.workingDir;
+            params = a.params;
+            executable = a.executable;
+        }
+        return *this;
+    }
+*/
+    bool operator==(const HgAction &a) {
+        return (a.action == action && a.workingDir == workingDir &&
+                a.params == params && a.executable == executable);
+    }
+
+    bool mayBeInteractive() const {
+	switch (action) {
+	case ACT_INCOMING:
+	case ACT_PUSH:
+	case ACT_PULL:
+	case ACT_CLONEFROMREMOTE:
+	    return true;
+	default:
+	    return false;
+	}
+    }
+};
+
+#endif