Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# thread.py - A seprated thread to run Mercurial command## Copyright 2009 Steve Borho <steve@borho.org># Copyright 2010 Yuki KODAMA <endflow.net@gmail.com>## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.importosimportQueueimporttimeimporturllib2fromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*frommercurialimportutil,error,dispatchfrommercurialimportuiasuimodfromtortoisehg.utilimportthread2,hglibfromtortoisehg.hgqt.i18nimport_,localgettextfromtortoisehg.hgqtimportqtliblocal=localgettext()classDataWrapper(object):def__init__(self,data):self.data=dataclassUiSignal(QObject):writeSignal=pyqtSignal(QString,QString)progressSignal=pyqtSignal(QString,object,QString,QString,object)interactSignal=pyqtSignal(DataWrapper)def__init__(self,responseq):QObject.__init__(self)self.responseq=responseqdefwrite(self,*args,**opts):msg=hglib.tounicode(''.join(args))label=hglib.tounicode(opts.get('label',''))self.writeSignal.emit(msg,label)defwrite_err(self,*args,**opts):msg=hglib.tounicode(''.join(args))label=hglib.tounicode(opts.get('label','ui.error'))self.writeSignal.emit(msg,label)defprompt(self,msg,choices,default):try:r=self._waitresponse(msg,False,choices,None)ifrisNone:raiseEOFErrorifnotr:returndefaultifchoices:# return char for Mercurial 1.3choice=choices[r]returnchoice[choice.index('&')+1].lower()returnrexceptEOFError:raiseutil.Abort(local._('response expected'))defpromptchoice(self,msg,choices,default):try:r=self._waitresponse(msg,False,choices,default)ifrisNone:raiseEOFErrorreturnrexceptEOFError:raiseutil.Abort(local._('response expected'))defgetpass(self,prompt,default):r=self._waitresponse(prompt,True,None,default)ifrisNone:raiseutil.Abort(local._('response expected'))returnrdef_waitresponse(self,msg,password,choices,default):"""Request interaction with GUI and wait response from it"""data=DataWrapper((msg,password,choices,default))self.interactSignal.emit(data)# await responsereturnself.responseq.get(True)defprogress(self,topic,pos,item,unit,total):topic=hglib.tounicode(topic)item=hglib.tounicode(item)unit=hglib.tounicode(unit)self.progressSignal.emit(topic,pos,item,unit,total)classQtUi(uimod.ui):def__init__(self,src=None,responseq=None):super(QtUi,self).__init__(src)ifsrc:self.sig=src.sigelse:self.sig=UiSignal(responseq)self.setconfig('ui','interactive','on')self.setconfig('progress','disable','True')os.environ['TERM']='dumb'defwrite(self,*args,**opts):ifself._buffers:self._buffers[-1].extend([str(a)forainargs])else:self.sig.write(*args,**opts)defwrite_err(self,*args,**opts):self.sig.write_err(*args,**opts)deflabel(self,msg,label):returnmsgdefflush(self):passdefprompt(self,msg,choices=None,default='y'):ifnotself.interactive():returndefaultreturnself.sig.prompt(msg,choices,default)defpromptchoice(self,msg,choices,default=0):ifnotself.interactive():returndefaultreturnself.sig.promptchoice(msg,choices,default)defgetpass(self,prompt=_('password: '),default=None):returnself.sig.getpass(prompt,default)defprogress(self,topic,pos,item='',unit='',total=None):returnself.sig.progress(topic,pos,item,unit,total)classCmdThread(QThread):"""Run an Mercurial command in a background thread, implies output is being sent to a rendered text buffer interactively and requests for feedback from Mercurial can be handled by the user via dialog windows. """# (msg=str, label=str)outputReceived=pyqtSignal(QString,QString)# (topic=str, pos=int, item=str, unit=str, total=int)# pos and total are emitted as object, since they may be NoneprogressReceived=pyqtSignal(QString,object,QString,QString,object)# result: -1 - command is incomplete, possibly exited with exception# 0 - command is finished successfully# others - return code of commandcommandFinished=pyqtSignal(int)def__init__(self,cmdline,display,parent=None):super(CmdThread,self).__init__(parent)self.cmdline=cmdlineself.display=displayself.ret=-1self.abortbyuser=Falseself.responseq=Queue.Queue()self.rawoutput=QStringList()self.topics={}self.curstrs=QStringList()self.curlabel=Noneself.timer=QTimer(self)self.timer.timeout.connect(self.flush)self.timer.start(100)self.finished.connect(self.thread_finished)defabort(self):ifself.isRunning()andhasattr(self,'thread_id'):self.abortbyuser=Truetry:thread2._async_raise(self.thread_id,KeyboardInterrupt)exceptValueError:passdefthread_finished(self):self.timer.stop()self.flush()self.commandFinished.emit(self.ret)defflush(self):ifself.curlabelisnotNone:self.outputReceived.emit(self.curstrs.join(''),self.curlabel)self.curlabel=Noneifself.timer.isActive():keys=self.topics.keys()fortopicinkeys:pos,item,unit,total=self.topics[topic]self.progressReceived.emit(topic,pos,item,unit,total)ifposisNone:delself.topics[topic]else:# Close all progress barsfortopicinself.topics:self.progressReceived.emit(topic,None,'','',None)self.topics={}@pyqtSlot(QString,QString)defoutput_handler(self,msg,label):iflabel!='control':self.rawoutput.append(msg)iflabel==self.curlabel:self.curstrs.append(msg)else:ifself.curlabelisnotNone:self.outputReceived.emit(self.curstrs.join(''),self.curlabel)self.curstrs=QStringList(msg)self.curlabel=label@pyqtSlot(QString,object,QString,QString,object)defprogress_handler(self,topic,pos,item,unit,total):self.topics[topic]=(pos,item,unit,total)@pyqtSlot(DataWrapper)definteract_handler(self,wrapper):prompt,password,choices,default=wrapper.dataprompt=hglib.tounicode(prompt)ifchoices:dlg=QMessageBox(QMessageBox.Question,_('TortoiseHg Prompt'),prompt,QMessageBox.Yes|QMessageBox.Cancel,self.parent())dlg.setDefaultButton(QMessageBox.Cancel)dlg.setWindowFlags(Qt.Sheet)dlg.setWindowModality(Qt.WindowModal)rmap={}forindex,choiceinenumerate(choices):button=dlg.addButton(hglib.tounicode(choice),QMessageBox.ActionRole)rmap[id(button)]=indexdlg.exec_()button=dlg.clickedButton()ifbuttonis0:result=defaultelse:result=rmap[id(button)]self.responseq.put(result)else:mode=passwordandQLineEdit.Password \
orQLineEdit.Normaldlg=QInputDialog(self.parent(),Qt.Sheet)dlg.setWindowModality(Qt.WindowModal)dlg.setWindowTitle(_('TortoiseHg Prompt'))dlg.setLabelText(prompt.title())dlg.setTextEchoMode(mode)ifdlg.exec_():text=hglib.fromunicode(dlg.textValue())else:text=Noneself.responseq.put(text)defrun(self):ui=QtUi(responseq=self.responseq)ui.sig.writeSignal.connect(self.output_handler,Qt.QueuedConnection)ui.sig.progressSignal.connect(self.progress_handler,Qt.QueuedConnection)ui.sig.interactSignal.connect(self.interact_handler,Qt.QueuedConnection)ifself.display:cmd='%% hg %s\n'%self.displayelse:cmd='%% hg %s\n'%' '.join(self.cmdline)ui.write(cmd,label='control')try:# save thread id in order to terminate by KeyboardInterruptself.thread_id=int(QThread.currentThreadId())fork,vinui.configitems('defaults'):ui.setconfig('defaults',k,'')self.ret=255self.ret=dispatch._dispatch(ui,self.cmdline)or0exceptutil.Abort,e: ui.write_err(local._('abort: ') + str(e) + '\n')
if e.hint:
ui.write_err(local._('hint: ') + str(e.hint) + '\n')
- except (error.RepoError, urllib2.HTTPError), e:
+ except error.RepoError, e:
ui.write_err(str(e) + '\n')
+ except urllib2.HTTPError, e:+ err = local._('HTTP Error: %d (%s)') % (e.code, e.msg)+ ui.write_err(err + '\n') except urllib2.URLError, e:
import ssl
err = local._('URLError: %s') % str(e.reason)
ifisinstance(e.args[0],ssl.SSLError):parts=e.args[0].strerror.split(':')iflen(parts)==7:file,line,level,errno,lib,func,reason=partsiffunc=='SSL3_GET_SERVER_CERTIFICATE':err=local._('SSL: Server certificate verify failed')eliferrno=='00000000':err=local._('SSL: unknown error %s:%s')%(file,line)else:err=local._('SSL error: %s')%reasonui.write_err(err+'\n')except(Exception,OSError,IOError),e:if'THGDEBUG'inos.environ:importtracebacktraceback.print_exc()ui.write_err(str(e)+'\n')exceptKeyboardInterrupt:self.ret=-1ifself.ret==-1:ifself.abortbyuser:msg=_('[command terminated by user %s]')else:msg=_('[command interrupted %s]')elifself.ret:msg=_('[command returned code %d%%s]')%int(self.ret)else:msg=_('[command completed successfully %s]')ui.write(msg%time.asctime()+'\n',label='control')
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.