Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

cmdui: support command queue

Changeset f693fbcda0e8

Parent 14628c79d3f5

by Yuki KODAMA

Changes to one file · Browse files at f693fbcda0e8 Showing diff from parent 14628c79d3f5 Diff from another changeset...

 
83
84
85
 
86
87
88
89
90
91
92
93
94
95
96
97
98
 
 
 
 
 
 
 
99
100
101
 
111
112
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
115
116
 
127
128
129
 
 
130
131
132
133
134
 
145
146
147
 
 
 
148
149
150
 
236
237
238
239
240
 
 
241
242
243
 
83
84
85
86
87
88
89
 
 
 
 
 
 
 
 
 
 
90
91
92
93
94
95
96
97
98
99
 
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
142
143
144
145
146
147
 
148
149
150
 
161
162
163
164
165
166
167
168
169
 
255
256
257
 
 
258
259
260
261
262
@@ -83,19 +83,17 @@
  self.output_text = QTextBrowser()   self.output_text.document().setDefaultStyleSheet(qtlib.thgstylesheet)   self.pmon = None + self.queue = []     ### Public Methods ###   - def run(self, cmdline): - '''Execute Mercurial command''' - self.thread = thread.CmdThread(cmdline) - self.thread.started.connect(self.command_started) - self.thread.commandFinished.connect(self.command_finished) - self.thread.outputReceived.connect(self.output_received) - self.thread.errorReceived.connect(self.error_received) - if hasattr(self, 'pmon'): - self.thread.progressReceived.connect(self.progress_received) - self.thread.start() + def run(self, cmdline, *cmdlines): + '''Execute or queue Mercurial command''' + self.queue.append(cmdline) + if len(cmdlines): + self.queue.extend(cmdlines) + if not self.is_running(): + self.run_next()     def cancel(self):   '''Cancel running Mercurial command''' @@ -111,6 +109,23 @@
    ### Private Method ###   + def run_next(self): + try: + cmdline = self.queue.pop(0) + self.thread = thread.CmdThread(cmdline) + except IndexError: + return False + + self.thread.started.connect(self.command_started) + self.thread.commandFinished.connect(self.command_finished) + self.thread.outputReceived.connect(self.output_received) + self.thread.errorReceived.connect(self.error_received) + if hasattr(self, 'pmon'): + self.thread.progressReceived.connect(self.progress_received) + self.thread.start() + + return True +   def append_output(self, msg, style=''):   msg = msg.replace('\n', '<br />')   self.output_text.insertHtml('<font style="%s">%s</font>' % (style, msg)) @@ -127,8 +142,9 @@
  self.commandStarted.emit()     def command_finished(self, wrapper): + ret = wrapper.data +   if hasattr(self, 'pmon'): - ret = wrapper.data   if ret is None:   self.pmon.clear_progress()   if self.pmon.pbar.maximum() == 0: # busy indicator @@ -145,6 +161,9 @@
  status = _('Finished')   self.pmon.set_text(status)   + if ret == 0 and self.run_next(): + return # run next command +   self.commandFinished.emit(wrapper)     def command_canceling(self): @@ -236,8 +255,8 @@
    ### Public Methods ###   - def run(self, cmdline): - self.core.run(cmdline) + def run(self, cmdline, *args): + self.core.run(cmdline, *args)     def cancel(self):   self.core.cancel()