[gnome-builder] vcs: add sequence number tracking for monitor
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vcs: add sequence number tracking for monitor
- Date: Thu, 14 Feb 2019 00:25:46 +0000 (UTC)
commit c800dc0bf591395c28203892f6bc6e2f357b885f
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 13 16:24:06 2019 -0800
vcs: add sequence number tracking for monitor
This can be used to determine if any changes have occurred between two
moments in time.
src/libide/vcs/ide-vcs-monitor.c | 34 ++++++++++++++++++++++++++++++++++
src/libide/vcs/ide-vcs-monitor.h | 20 ++++++++++++--------
2 files changed, 46 insertions(+), 8 deletions(-)
---
diff --git a/src/libide/vcs/ide-vcs-monitor.c b/src/libide/vcs/ide-vcs-monitor.c
index fbc1b4bf4..2fdd7f6f0 100644
--- a/src/libide/vcs/ide-vcs-monitor.c
+++ b/src/libide/vcs/ide-vcs-monitor.c
@@ -42,6 +42,8 @@ struct _IdeVcsMonitor
guint cache_source;
+ guint64 last_change_seq;
+
guint busy : 1;
};
@@ -123,6 +125,7 @@ ide_vcs_monitor_list_status_cb (GObject *object,
ide_object_lock (IDE_OBJECT (self));
self->busy = FALSE;
+ self->last_change_seq++;
if ((model = ide_vcs_list_status_finish (vcs, result, NULL)))
{
@@ -228,6 +231,8 @@ ide_vcs_monitor_changed_cb (IdeVcsMonitor *self,
g_assert (!other_file || G_IS_FILE (other_file));
g_assert (DZL_IS_RECURSIVE_FILE_MONITOR (monitor));
+ self->last_change_seq++;
+
g_signal_emit (self, signals[CHANGED], 0, file, other_file, event);
ide_vcs_monitor_queue_reload (self);
@@ -493,6 +498,8 @@ ide_vcs_monitor_class_init (IdeVcsMonitorClass *klass)
static void
ide_vcs_monitor_init (IdeVcsMonitor *self)
{
+ self->last_change_seq = 1;
+
self->monitor_signals = dzl_signal_group_new (DZL_TYPE_RECURSIVE_FILE_MONITOR);
dzl_signal_group_connect_object (self->monitor_signals,
@@ -629,3 +636,30 @@ ide_vcs_monitor_set_vcs (IdeVcsMonitor *self,
}
ide_object_unlock (IDE_OBJECT (self));
}
+
+guint64
+ide_vcs_monitor_get_sequence (IdeVcsMonitor *self)
+{
+ g_return_val_if_fail (IDE_IS_VCS_MONITOR (self), 0);
+
+ return self->last_change_seq;
+}
+
+/**
+ * ide_vcs_monitor_from_context:
+ * @context: an #IdeContext
+ *
+ * Gets the #IdeVcsMonitor for a context.
+ *
+ * Returns: (nullable) (transfer none): an #IdeVcsMonitor
+ *
+ * Since: 3.32
+ */
+IdeVcsMonitor *
+ide_vcs_monitor_from_context (IdeContext *context)
+{
+ g_return_val_if_fail (IDE_IS_MAIN_THREAD (), NULL);
+ g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL);
+
+ return ide_context_peek_child_typed (context, IDE_TYPE_VCS_MONITOR);
+}
diff --git a/src/libide/vcs/ide-vcs-monitor.h b/src/libide/vcs/ide-vcs-monitor.h
index d7835ee8c..bb92047d9 100644
--- a/src/libide/vcs/ide-vcs-monitor.h
+++ b/src/libide/vcs/ide-vcs-monitor.h
@@ -37,17 +37,21 @@ IDE_AVAILABLE_IN_3_32
G_DECLARE_FINAL_TYPE (IdeVcsMonitor, ide_vcs_monitor, IDE, VCS_MONITOR, IdeObject)
IDE_AVAILABLE_IN_3_32
-IdeVcsFileInfo *ide_vcs_monitor_ref_info (IdeVcsMonitor *self,
- GFile *file);
+IdeVcsMonitor *ide_vcs_monitor_from_context (IdeContext *context);
IDE_AVAILABLE_IN_3_32
-GFile *ide_vcs_monitor_ref_root (IdeVcsMonitor *self);
+IdeVcsFileInfo *ide_vcs_monitor_ref_info (IdeVcsMonitor *self,
+ GFile *file);
IDE_AVAILABLE_IN_3_32
-void ide_vcs_monitor_set_root (IdeVcsMonitor *self,
- GFile *file);
+GFile *ide_vcs_monitor_ref_root (IdeVcsMonitor *self);
IDE_AVAILABLE_IN_3_32
-IdeVcs *ide_vcs_monitor_ref_vcs (IdeVcsMonitor *self);
+void ide_vcs_monitor_set_root (IdeVcsMonitor *self,
+ GFile *file);
IDE_AVAILABLE_IN_3_32
-void ide_vcs_monitor_set_vcs (IdeVcsMonitor *self,
- IdeVcs *vcs);
+IdeVcs *ide_vcs_monitor_ref_vcs (IdeVcsMonitor *self);
+IDE_AVAILABLE_IN_3_32
+void ide_vcs_monitor_set_vcs (IdeVcsMonitor *self,
+ IdeVcs *vcs);
+IDE_AVAILABLE_IN_3_32
+guint64 ide_vcs_monitor_get_sequence (IdeVcsMonitor *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]