[meld] vcview: Add support for running a VC command immediately



commit 1249325140c83d34fe24d1527703195bddcf81d7
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Sep 2 07:49:06 2017 +1000

    vcview: Add support for running a VC command immediately
    
    This is needed for situations where we want to run a command, but we
    might be shutting down and so can't schedule to idle.

 meld/vcview.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/meld/vcview.py b/meld/vcview.py
index ba69689..2e3ce10 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -592,7 +592,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         vc_command = self.command_map.get(command)
         return vc_command and hasattr(self.vc, vc_command)
 
-    def command(self, command, files):
+    def command(self, command, files, sync=False):
         if not self.has_command(command):
             log.error("Couldn't understand command %s", command)
             return
@@ -601,14 +601,20 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             log.error("Invalid files argument to '%s': %r", command, files)
             return
 
+        runner = self.runner if not sync else self.sync_runner
         command = getattr(self.vc, self.command_map[command])
-        command(self.runner, files)
+        command(runner, files)
 
     def runner(self, command, files, refresh, working_dir):
         """Schedule a version control command to run as an idle task"""
         self.scheduler.add_task(
             self._command_iter(command, files, refresh, working_dir))
 
+    def sync_runner(self, command, files, refresh, working_dir):
+        """Run a version control command immediately"""
+        for it in self._command_iter(command, files, refresh, working_dir):
+            pass
+
     def on_button_update_clicked(self, obj):
         self.vc.update(self.runner)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]