sync
[gitlive] / GitMonitor.vala
index 2ba9685..7866310 100644 (file)
@@ -1,5 +1,26 @@
+/**
+
+The monitor suffers from various issues - basically event flows while it's running...
+
+normall operations
+
+- monitors for file changes
+ -- adds to QUEUE when occurs.
+- queue runs in background.
+ - if it's got stuff in it..
+ - COMMIT (normally)
+ - now?? - if on master - try and branch
+   == do user selection, until we have branched
+   == then start monitoring again..
+   
+
+
+
+*/
+
+
 
-  
 
 public class GitMonitor : Monitor
 {
@@ -108,6 +129,12 @@ public class GitMonitor : Monitor
 
        }
        
+       public void restoreQueue( Gee.ArrayList<GitMonitorQueue> queue)
+       {
+               //used to restore teh queue after switch branches?/ - breaks our privte queue idea..
+               this.queue = queue;
+       }
+       
        /*
        public new void resume () {
                this.paused = false;
@@ -221,6 +248,20 @@ public class GitMonitor : Monitor
                if (this.paused || this.queue.size < 1 ) {
                        return;
                }
+               
+               foreach(var q in this.queue) {
+                       if (!q.shouldIgnore() && !q.repo.is_wip_branch()) {
+                               var oldq = this.queue;
+                               this.queue =  new Gee.ArrayList<GitMonitorQueue>(); 
+                               NewBranch.singleton().show(q.repo, oldq);
+                               
+                               return;
+                       }
+               
+               }
+               
+                
+               
                GLib.debug("GitMonitor.runQueue\n");
 
                this.queueRunning = true;
@@ -556,10 +597,7 @@ public class GitMonitor : Monitor
                this.queue.add(cmd);
                
                
-                if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
-                NewBranch.singleton().show(cmd.repo);
-         }
+                 
                 
        }
        public override  void onDeleted(MonitorNamePathDir src) 
@@ -586,9 +624,7 @@ public class GitMonitor : Monitor
 
                this.queue.add(cmd);
                
-                if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
-                       NewBranch.singleton().show(cmd.repo);
-               }
+                
                
  
        }
@@ -647,9 +683,7 @@ public class GitMonitor : Monitor
                cmd.message = "Attribute changed " + cmd.vname;
                this.queue.add(cmd);
                
-               if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
-                       NewBranch.singleton().show(cmd.repo);
-        }
+        
        }
  
    public  override void onMoved(MonitorNamePathDir src,MonitorNamePathDir dest)  
@@ -682,12 +716,9 @@ public class GitMonitor : Monitor
                if (cmd_d.shouldIgnore()) {
                        
                        this.onDeleted(src);
-
                        return;
                }
-               
-               
+                
                GLib.debug("RM: %s", cmd_s.vname);
                cmd_s.action = "rm";
                this.queue.add(cmd_s);
@@ -708,10 +739,7 @@ public class GitMonitor : Monitor
                
                
                this.queue.add(cmd);
-
-               if (!cmd.shouldIgnore() && !cmd.repo.is_wip_branch()) {
-                       NewBranch.singleton().show(cmd.repo);
-        }
         // this is where it get's complicated...
         // as we might be moving across repo's...