Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0.1, 1.0.2, and 1.0.3

stable hgcmd: allow to pass chained commands in CmdRunner

Same as CmdDialog, now CmdRunner.execute() can receive multiple
commands at once.

Fixes #1009

Changeset 2f4d5ab2ae33

Parent ff74b726ac05

by Yuki KODAMA

Changes to one file · Browse files at 2f4d5ab2ae33 Showing diff from parent ff74b726ac05 Diff from another changeset...

 
699
700
701
702
 
 
703
704
705
 
716
717
718
719
720
721
722
 
 
 
 
 
 
 
723
724
725
 
801
802
803
 
 
 
 
 
 
 
 
804
805
806
 
827
828
829
830
831
832
 
 
 
 
 
 
 
 
833
834
835
 
699
700
701
 
702
703
704
705
706
 
717
718
719
 
 
 
 
720
721
722
723
724
725
726
727
728
729
 
805
806
807
808
809
810
811
812
813
814
815
816
817
818
 
839
840
841
 
 
 
842
843
844
845
846
847
848
849
850
851
852
@@ -699,7 +699,8 @@
  When the command terminates, the callback function is invoked   with its return code.   - cmdline: command line string. + cmdline: a list of command line arguments or its tuple/list. + All command line arguments must be string, not int or long.   callback: function invoked after the command terminates.     def callback(returncode, useraborted, ...) @@ -716,10 +717,13 @@
  # clear previous logs   self.clear_buffers()   - # thread start - self.hgthread = hgthread.HgThread(cmdline[1:]) - self.hgthread.start() - gobject.timeout_add(10, self.process_queue, callback, args, kargs) + # normalize 'cmdline' arguments + if isinstance(cmdline[0], basestring): + cmdline = (cmdline,) + self.cmdlist = list(cmdline) + + # execute cmdline + self.execute_next(callback, args, kargs)     return True   @@ -801,6 +805,14 @@
  else:   self.dlg.hide()   + def execute_next(self, callback, args, kargs): + if not self.cmdlist: + return + cmdline = self.cmdlist.pop(0) + self.hgthread = hgthread.HgThread(cmdline[1:]) + self.hgthread.start() + gobject.timeout_add(10, self.process_queue, callback, args, kargs) +   def process_queue(self, callback, args, kargs):   # process queue   self.hgthread.process_dialogs() @@ -827,9 +839,14 @@
  self.hgthread = None   if len(self.get_err_buffer()) > 0:   self.show_log(True) - def call_callback(): - callback(returncode, self.get_buffer(), *args, **kargs) - gtklib.idle_add_single_call(call_callback) + if returncode == 0 and self.cmdlist: + def call_next(): + self.execute_next(callback, args, kargs) + gtklib.idle_add_single_call(call_next) + else: + def call_callback(): + callback(returncode, self.get_buffer(), *args, **kargs) + gtklib.idle_add_single_call(call_callback)   return False # Stop polling this function   else:   return True # Continue polling