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.
mq: replace "push selected" action with "reorder patches"
- "reorder patches" is more versatile than "push selected" (aka "qpush --move") - IMHO it makes more sense to have "reorder patches" in the mq widget than in the patch context menu of the repowidget, since "reorder patches" acts on the queue as a whole, not on a selected patch - "qpush --move" is still available in the patch context menu of the repowidget - As it happens, the "push selected" action in mq.py previously (mis)used the hg-qreorder icon. Now, the action fits with the icon :-)
TODO: Remove "reorder patches" action from the patch context menu of the repowidget.
# mq.py - TortoiseHg MQ widget## Copyright 2011 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms of the# GNU General Public License version 2 or any later version.importosimportreimporttimefromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*frommercurialimporthg,ui,url,util,errorfrommercurialimportmergeasmergemodfromhgextimportmqasmqmodfrom tortoisehg.util import hglib, patchctx
from tortoisehg.hgqt.i18n import _
from tortoisehg.hgqt import qtlib, cmdui, rejects, commit, qscilib
-from tortoisehg.hgqt import qqueue, fileview, thgimport
+from tortoisehg.hgqt import qqueue, qreorder, fileview, thgimport
from tortoisehg.hgqt.qtlib import geticon
# TODO
# keep original file name in file list item# maintain check state through refresh# more wctx functionsclassMQWidget(QWidget):showMessage=pyqtSignal(unicode)output=pyqtSignal(QString,QString)progress=pyqtSignal(QString,object,QString,QString,object)makeLogVisible=pyqtSignal(bool)def__init__(self,repo,parent,**opts):QWidget.__init__(self,parent)self.repo=repoself.opts=optsself.refreshing=Falseself.finishfunc=Nonelayout=QVBoxLayout()layout.setSpacing(4)self.setLayout(layout)# top toolbartbarhbox=QHBoxLayout()tbarhbox.setSpacing(5)self.layout().addLayout(tbarhbox,0)self.queueCombo=QComboBox()self.queueCombo.activated['QString'].connect(self.qqueueActivate)self.optionsBtn=QPushButton(_('Options'))self.msgSelectCombo=PatchMessageCombo(self)tbarhbox.addWidget(self.queueCombo)tbarhbox.addWidget(self.optionsBtn)tbarhbox.addWidget(self.msgSelectCombo,1)# main area consists of a three-way horizontal splitterself.splitter=splitter=QSplitter()self.layout().addWidget(splitter,1)splitter.setOrientation(Qt.Horizontal)splitter.setChildrenCollapsible(True)splitter.setObjectName('splitter')self.queueFrame=QFrame(splitter)self.messageFrame=QFrame(splitter)self.fileview=fileview.HgFileView(repo,splitter)self.fileview.showMessage.connect(self.showMessage)self.fileview.setContext(repo[None])self.fileview.shelveToolExited.connect(self.reload)# Patch Queue Framelayout=QVBoxLayout()layout.setSpacing(5)layout.setContentsMargins(0,0,0,0)self.queueFrame.setLayout(layout)self.qtbar=qtbarhbox=QHBoxLayout()qtbarhbox.setSpacing(5)layout.addLayout(qtbarhbox,0)qtbarhbox.setContentsMargins(0,0,0,0)self.qpushAllAct=a=QAction(geticon('hg-qpush-all'),_('Push all'),self)a.setToolTip(_('Apply all patches'))self.qpushAct=a=QAction(geticon('hg-qpush'),_('Push'),self)a.setToolTip(_('Apply one patch')) self.setGuardsAct = a = QAction(
geticon('hg-qguard'), _('Guards'), self)
a.setToolTip(_('Configure guards for selected patch'))
- self.qpushMoveAct = a = QAction(
- geticon('hg-qreorder'), _('Pushselected'), self)
- a.setToolTip(_('Applyselected patch next (change queue order)'))
+ self.qreorderAct = a = QAction(
+ geticon('hg-qreorder'), _('Reorderpatches'), self)
+ a.setToolTip(_('Reorderpatches'))
self.qdeleteAct = a = QAction(
geticon('hg-qdelete'), _('Delete'), self)
a.setToolTip(_('Delete selected patches'))
self.qpopAct=a=QAction(geticon('hg-qpop'),_('Pop'),self)a.setToolTip(_('Unapply one patch'))self.qpopAllAct=a=QAction(geticon('hg-qpop-all'),_('Pop all'),self)a.setToolTip(_('Unapply all patches'))tbar=QToolBar(_('Patch Queue Actions Toolbar'))tbar.setIconSize(QSize(18,18))qtbarhbox.addWidget(tbar)tbar.addAction(self.qpushAct)tbar.addAction(self.qpushAllAct)tbar.addSeparator() tbar.addAction(self.qpopAct)
tbar.addAction(self.qpopAllAct)
tbar.addSeparator()
- tbar.addAction(self.qpushMoveAct)
+ tbar.addAction(self.qreorderAct)
tbar.addSeparator()
tbar.addAction(self.qdeleteAct)
tbar.addSeparator()
tbar.addAction(self.setGuardsAct)self.queueListWidget=QListWidget(self)layout.addWidget(self.queueListWidget,1)bbarhbox=QHBoxLayout()bbarhbox.setSpacing(5)layout.addLayout(bbarhbox)self.guardSelBtn=QPushButton()bbarhbox.addWidget(self.guardSelBtn)self.revisionOrCommitBtn=QPushButton()bbarhbox.addWidget(self.revisionOrCommitBtn)bbarhbox.addStretch(1)# Message Framelayout=QVBoxLayout()layout.setSpacing(5)layout.setContentsMargins(0,0,0,0)self.messageFrame.setLayout(layout)mtbarhbox=QHBoxLayout()mtbarhbox.setSpacing(8)layout.addLayout(mtbarhbox,0)mtbarhbox.setContentsMargins(0,0,0,0)self.newCheckBox=QCheckBox(_('New Patch'))self.patchNameLE=QLineEdit()self.refreshtb=QToolButton(self)self.refreshtb.clicked.connect(self.refreshFileListWidget)self.refreshtb.setIcon(qtlib.geticon('view-refresh'))mtbarhbox.addWidget(self.newCheckBox)mtbarhbox.addWidget(self.patchNameLE,1)mtbarhbox.addWidget(self.refreshtb)self.messageEditor=commit.MessageEntry(self)self.messageEditor.installEventFilter(qscilib.KeyPressInterceptor(self))self.messageEditor.refresh(repo)layout.addWidget(self.messageEditor,1)self.fileListWidget=QListWidget(self)self.fileListWidget.currentRowChanged.connect(self.onFileSelected)layout.addWidget(self.fileListWidget,2)qrefhbox=QHBoxLayout()layout.addLayout(qrefhbox,0)qrefhbox.setContentsMargins(0,0,0,0)self.qqueueBtn=QPushButton(_('Manage queues'))self.qqueueBtn.setMinimumWidth(150)b=QPushButton(_('QRefresh'))f=b.font()f.setWeight(QFont.Bold)b.setFont(f)self.qnewOrRefreshBtn=bqrefhbox.addWidget(self.qqueueBtn)qrefhbox.addStretch(1)qrefhbox.addWidget(self.qnewOrRefreshBtn)# Command runner and connections...self.cmd=cmdui.Runner(notparent,self)self.cmd.output.connect(self.output)self.cmd.makeLogVisible.connect(self.makeLogVisible)self.cmd.progress.connect(self.progress)self.cmd.commandFinished.connect(self.onCommandFinished)self.qqueueBtn.clicked.connect(self.launchQQueueTool)self.optionsBtn.clicked.connect(self.launchOptionsDialog)self.revisionOrCommitBtn.clicked.connect(self.qinitOrCommit)self.msgSelectCombo.activated.connect(self.onMessageSelected)self.queueListWidget.currentRowChanged.connect(self.onPatchSelected)self.queueListWidget.itemActivated.connect(self.onGotoPatch) self.queueListWidget.itemChanged.connect(self.onRenamePatch)
self.qpushAllAct.triggered.connect(self.onPushAll)
self.qpushAct.triggered.connect(self.onPush)
- self.qpushMoveAct.triggered.connect(self.onPushMove)
+ self.qreorderAct.triggered.connect(self.onQreorder)
self.qpopAllAct.triggered.connect(self.onPopAll)
self.qpopAct.triggered.connect(self.onPop)
self.setGuardsAct.triggered.connect(self.onGuardConfigure)
self.qdeleteAct.triggered.connect(self.onDelete)self.newCheckBox.toggled.connect(self.onNewModeToggled)self.qnewOrRefreshBtn.clicked.connect(self.onQNewOrQRefresh)self.repo.configChanged.connect(self.onConfigChanged)self.repo.repositoryChanged.connect(self.onRepositoryChanged)self.setAcceptDrops(True)ifhasattr(self.patchNameLE,'setPlaceholderText'):# Qt >= 4.7self.patchNameLE.setPlaceholderText(_('### patch name ###'))ifparent:self.layout().setContentsMargins(2,2,2,2)else:self.layout().setContentsMargins(0,0,0,0)self.setWindowTitle(_('TortoiseHg Patch Queue'))self.statusbar=cmdui.ThgStatusBar(self)self.layout().addWidget(self.statusbar)self.progress.connect(self.statusbar.progress)self.showMessage.connect(self.statusbar.showMessage)QShortcut(QKeySequence.Refresh,self,self.reload)self.resize(850,550)self.loadConfigs()QTimer.singleShot(0,self.reload)defgetUserOptions(self,*optionlist):out=[]foroptinoptionlist:ifoptnotinself.opts:continueval=self.opts[opt]ifvalisFalse:continueelifvalisTrue:out.append('--'+opt)else:out.append('--'+opt)out.append(val)returnout@pyqtSlot()defonConfigChanged(self):'Repository is reporting its config files have changed'self.messageEditor.refresh(self.repo)self.fileview.setContext(self.repo[None])@pyqtSlot()defonRepositoryChanged(self):'Repository is reporting its changelog has changed'self.fileview.setContext(self.repo[None])self.reload()@pyqtSlot(int)defonCommandFinished(self,ret):self.qtbar.setEnabled(True)self.repo.decrementBusyCount()ifself.finishfunc:self.finishfunc(ret)self.finishfunc=NonedefcheckForRejects(self,ret):ifretis0:self.refreshFileListWidget()returnrejre=re.compile('saving rejects to file (.*).rej')forminrejre.finditer(self.cmd.core.rawoutput()):wfile=m.groups()[0]ifnotos.path.exists(self.repo.wjoin(wfile)):continueufile=hglib.tounicode(wfile)ifqtlib.QuestionMsgBox(_('Manually resolve rejected chunks?'),_('%s had rejected chunks, edit patched ''file together with rejects?')%ufile,parent=self):dlg=rejects.RejectsDialog(self.repo.wjoin(wfile),self)dlg.exec_()self.refreshFileListWidget()@pyqtSlot(QString)defqqueueActivate(self,uqueue):ifself.refreshing:returnqueue=hglib.fromunicode(uqueue)ifqueue==self.repo.thgactivemqname:returnself.repo.incrementBusyCount()self.qtbar.setEnabled(False)cmdline=['qqueue','-R',self.repo.root,queue]deffinished(ret):ifret:foriinxrange(self.queueCombo.count()):if(hglib.fromunicode(self.queueCombo.itemText(i))==self.repo.thgactivemqname):self.queueCombo.setCurrentIndex(i)breakself.finishfunc=finishedself.cmd.run(cmdline)@pyqtSlot()defonPushAll(self):ifself.cmd.running():returnself.repo.incrementBusyCount()cmdline=['qpush','-R',self.repo.root,'--all']cmdline+=self.getUserOptions('force','exact')self.qtbar.setEnabled(False)self.finishfunc=self.checkForRejectsself.cmd.run(cmdline)@pyqtSlot()defonPush(self):ifself.cmd.running():returnself.repo.incrementBusyCount()cmdline=['qpush','-R',self.repo.root]cmdline+=self.getUserOptions('force','exact')self.qtbar.setEnabled(False)self.finishfunc=self.checkForRejectsself.cmd.run(cmdline)@pyqtSlot()defonPopAll(self):ifself.cmd.running():returnself.repo.incrementBusyCount()cmdline=['qpop','-R',self.repo.root,'--all']cmdline+=self.getUserOptions('force')self.qtbar.setEnabled(False)self.cmd.run(cmdline)@pyqtSlot()defonPop(self):ifself.cmd.running():returnself.repo.incrementBusyCount()cmdline=['qpop','-R',self.repo.root]cmdline+=self.getUserOptions('force')self.qtbar.setEnabled(False)self.cmd.run(cmdline)@pyqtSlot()defonPushMove(self):ifself.cmd.running():returnpatch=self.queueListWidget.currentItem()._thgpatchcmdline=['qpush','-R',self.repo.root]cmdline+=self.getUserOptions('force')cmdline+=['--move','--',patch]self.repo.incrementBusyCount()self.qtbar.setEnabled(False) self.finishfunc = self.checkForRejects
self.cmd.run(cmdline)
+ def onQreorder(self):+ if self.cmd.running():+ return+ def checkGuardsOrComments():+ cont = True+ for p in self.repo.mq.full_series:+ if '#' in p:+ cont = QuestionMsgBox('Confirm qreorder',+ _('<p>ATTENTION!<br>'+ 'Guard or comment found.<br>'+ 'Reordering patches will destroy them.<br>'+ '<br>Continue?</p>'), parent=self,+ defaultbutton=QMessageBox.No)+ break+ return cont+ if checkGuardsOrComments():+ dlg = qreorder.QReorderDialog(self.repo, self)+ dlg.finished.connect(dlg.deleteLater)+ dlg.exec_()+ @pyqtSlot()
def onGuardConfigure(self):
item = self.queueListWidget.currentItem()
patch=item._thgpatchifitem._thgguards:uguards=hglib.tounicode(' '.join(item._thgguards))else:uguards=''new,ok=QInputDialog.getText(self,_('Configure guards'),_('Input new guards for %s:')%hglib.tounicode(patch),text=uguards)ifnotokornew==uguards:returnguards=[]forguardinhglib.fromunicode(new).split(' '):guard=guard.strip()ifnotguard:continueifnot(guard[0]=='+'orguard[0]=='-'):self.showMessage.emit(_('Guards must begin with "+" or "-"'))continueguards.append(guard)cmdline=['qguard','-R',self.repo.root,'--',patch]ifguards:cmdline+=guardselse:cmdline.insert(3,'--none')ifself.cmd.running():returnself.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.cmd.run(cmdline)@pyqtSlot()defonDelete(self):fromtortoisehg.hgqtimportqdeletepatch=self.queueListWidget.currentItem()._thgpatchdlg=qdelete.QDeleteDialog(self.repo,[patch],self)dlg.finished.connect(dlg.deleteLater)ifdlg.exec_()==QDialog.Accepted:self.reload()defqgotoRevision(self,rev):ifself.cmd.running():returncmdline=['qgoto','-R',self.repo.root]cmdline+=self.getUserOptions('force')cmdline+=['--',str(rev)]self.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.finishfunc=self.checkForRejectsself.cmd.run(cmdline)#@pyqtSlot(QListWidgetItem)defonGotoPatch(self,item):'Patch has been activated (return), issue qgoto'ifself.cmd.running():returncmdline=['qgoto','-R',self.repo.root]cmdline+=self.getUserOptions('force')cmdline+=['--',item._thgpatch]self.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.finishfunc=self.checkForRejectsself.cmd.run(cmdline)#@pyqtSlot(QListWidgetItem)defonRenamePatch(self,item):'Patch has been renamed, issue qrename'ifself.cmd.running():returnself.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.cmd.run(['qrename','-R',self.repo.root,'--',item._thgpatch,hglib.fromunicode(item.text())])@pyqtSlot(int)defonPatchSelected(self,row):'Patch has been selected, update buttons'ifself.refreshing:returnifrow>=0: patch = self.queueListWidget.item(row)._thgpatch
applied = set([p.name for p in self.repo.mq.applied])
self.qdeleteAct.setEnabled(patch not in applied)
- self.qpushMoveAct.setEnabled(patch not in applied) self.setGuardsAct.setEnabled(True)
else:
self.qdeleteAct.setEnabled(False)
- self.qpushMoveAct.setEnabled(False) self.setGuardsAct.setEnabled(False)
@pyqtSlot(int)
defonFileSelected(self,row):ifself.refreshingorrow==-1:returntext=hglib.fromunicode(self.fileListWidget.item(row).text())status=text[0]filename=text[2:]self.fileview.displayFile(filename,status)@pyqtSlot(int)defonMessageSelected(self,row):ifself.messageEditor.text()andself.messageEditor.isModified():d=QMessageBox.question(self,_('Confirm Discard Message'),_('Discard current commit message?'),QMessageBox.Ok|QMessageBox.Cancel)ifd!=QMessageBox.Ok:returnself.setMessage(self.messages[row][1])self.messageEditor.setFocus()defsetMessage(self,message):self.messageEditor.setText(message)# message: unicodelines=self.messageEditor.lines()iflines:lines-=1pos=self.messageEditor.lineLength(lines)self.messageEditor.setCursorPosition(lines,pos)self.messageEditor.ensureLineVisible(lines)hs=self.messageEditor.horizontalScrollBar()hs.setSliderPosition(0)self.messageEditor.setModified(False)@pyqtSlot()defonQNewOrQRefresh(self):deffinished(ret):self.newCheckBox.setChecked(False)ifself.newCheckBox.isChecked():name=hglib.fromunicode(self.patchNameLE.text())ifnotname:qtlib.ErrorMsgBox(_('Patch Name Required'),_('You must enter a patch name'))self.patchNameLE.setFocus()returncmdline=['qnew','--repository',self.repo.root,name]self.finishfunc=finishedelse:cmdline=['qrefresh','--repository',self.repo.root]message=self.messageEditor.text()ifmessage:cmdline+=['--message='+hglib.fromunicode(message)]cmdline+=self.getUserOptions('user','currentuser','git','date','currentdate')files=['--']addrem=[]forrowinxrange(self.fileListWidget.count()):item=self.fileListWidget.item(row)ifitem.checkState()==Qt.Checked:text=hglib.fromunicode(item.text())wfile=self.repo.wjoin(text[2:])files.append(wfile)iftext[0]in('!','?'):addrem.append(wfile)iflen(files)>1:cmdline+=fileselse:cmdline+=['--exclude',self.repo.root]ifaddrem:cmdlines=[['addremove','-R',self.repo.root]+addrem,cmdline]else:cmdlines=[cmdline]self.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.cmd.run(*cmdlines)@pyqtSlot()defqinitOrCommit(self):ifos.path.isdir(self.repo.mq.join('.hg')):dlg=commit.CommitDialog([],dict(root=self.repo.mq.path),self)dlg.finished.connect(dlg.deleteLater)dlg.exec_()self.reload()else:self.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.cmd.run(['qinit','-c','-R',self.repo.root])@pyqtSlot()deflaunchQQueueTool(self):dlg=qqueue.QQueueDialog(self.repo,True,self)dlg.finished.connect(dlg.deleteLater)dlg.output.connect(self.output)dlg.makeLogVisible.connect(self.makeLogVisible)dlg.exec_()self.reload()@pyqtSlot()deflaunchOptionsDialog(self):dlg=OptionsDialog(self)dlg.finished.connect(dlg.deleteLater)dlg.setWindowFlags(Qt.Sheet)dlg.setWindowModality(Qt.WindowModal)ifdlg.exec_()==QDialog.Accepted:self.opts.update(dlg.outopts)defreload(self):self.refreshing=Trueself.reselectPatchItem=Nonetry:try:self._reload()exceptException,e:self.showMessage.emit(hglib.tounicode(str(e)))if'THGDEBUG'inos.environ:importtracebacktraceback.print_exc()finally:self.refreshing=Falseifself.reselectPatchItem:self.queueListWidget.setCurrentItem(self.reselectPatchItem)self.refreshFileListWidget()def_reload(self):ui,repo=self.repo.ui.copy(),self.repoself.queueCombo.clear()ui.quiet=True# don't append "(active)"ui.pushbuffer()mqmod.qqueue(ui,repo,list=True)out=ui.popbuffer()fori,qnameinenumerate(out.splitlines()):ifqname==repo.thgactivemqname:current=iself.queueCombo.addItem(hglib.tounicode(qname))self.queueCombo.setCurrentIndex(current)self.queueCombo.setEnabled(self.queueCombo.count()>1)item=self.queueListWidget.currentItem()ifitem:wasselected=item._thgpatchelse:wasselected=Noneself.queueListWidget.clear()applied=set([p.nameforpinrepo.mq.applied])self.allguards=set()items=[]foridx,patchinenumerate(repo.mq.series):item=QListWidgetItem(hglib.tounicode(patch))ifpatchinapplied:# appliedf=item.font()f.setBold(True)item.setFont(f)elifnotrepo.mq.pushable(idx)[0]:# guardedf=item.font()f.setItalic(True)item.setFont(f)patchguards=repo.mq.series_guards[idx]ifpatchguards:forguardinpatchguards:self.allguards.add(guard[1:])uguards=hglib.tounicode(', '.join(patchguards))else:uguards=_('no guards')uname=hglib.tounicode(patch)item._thgpatch=patchitem._thgguards=patchguardsitem.setToolTip(u'%s: %s'%(uname,uguards))item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEditable|Qt.ItemIsEnabled)items.append(item)foriteminreversed(items):self.queueListWidget.addItem(item)ifitem._thgpatch==wasselected:self.reselectPatchItem=itemforguardinrepo.mq.active():self.allguards.add(guard)self.refreshSelectedGuards()self.messages=[]forpatchinrepo.mq.series:ctx=repo.changectx(patch)msg=hglib.tounicode(ctx.description())ifmsg:self.messages.append((patch,msg))self.msgSelectCombo.reset(self.messages)ifos.path.isdir(repo.mq.join('.hg')):self.revisionOrCommitBtn.setText(_('QCommit'))else:self.revisionOrCommitBtn.setText(_('Create MQ repo')) self.qpushAllAct.setEnabled(bool(repo.thgmqunappliedpatches))
self.qpushAct.setEnabled(bool(repo.thgmqunappliedpatches))
- self.qpushMoveAct.setEnabled(False) self.qdeleteAct.setEnabled(False)
self.setGuardsAct.setEnabled(False)
self.qpopAct.setEnabled(bool(applied))
self.qpopAllAct.setEnabled(bool(applied))pctx=repo.changectx('.')newmode=self.newCheckBox.isChecked()if'qtip'inpctx.tags():self.fileListWidget.setEnabled(True)self.messageEditor.setEnabled(True)self.msgSelectCombo.setEnabled(True)self.qnewOrRefreshBtn.setEnabled(True)ifnotnewmode:self.setMessage(hglib.tounicode(pctx.description()))name=repo.mq.applied[-1].nameself.patchNameLE.setText(hglib.tounicode(name))else:self.fileListWidget.setEnabled(newmode)self.messageEditor.setEnabled(newmode)self.msgSelectCombo.setEnabled(newmode)self.qnewOrRefreshBtn.setEnabled(newmode)ifnotnewmode:self.setMessage('')self.patchNameLE.setText('')self.patchNameLE.setEnabled(newmode)defonNewModeToggled(self,isChecked):ifisChecked:self.fileListWidget.setEnabled(True)self.qnewOrRefreshBtn.setText(_('QNew'))self.qnewOrRefreshBtn.setEnabled(True)self.messageEditor.setEnabled(True)self.patchNameLE.setEnabled(True)self.patchNameLE.setFocus()self.patchNameLE.setText(time.strftime('%Y-%m-%d_%H-%M-%S')+ \
'_r%d+.diff'%self.repo['.'].rev())self.patchNameLE.selectAll()self.setMessage('')else:self.qnewOrRefreshBtn.setText(_('QRefresh'))pctx=self.repo.changectx('.')if'qtip'inpctx.tags():self.messageEditor.setEnabled(True)self.setMessage(hglib.tounicode(pctx.description()))name=self.repo.mq.applied[-1].nameself.patchNameLE.setText(hglib.tounicode(name))self.qnewOrRefreshBtn.setEnabled(True)self.fileListWidget.setEnabled(True)else:self.messageEditor.setEnabled(False)self.qnewOrRefreshBtn.setEnabled(False)self.fileListWidget.setEnabled(False)self.patchNameLE.setText('')self.setMessage('')self.patchNameLE.setEnabled(False)self.refreshFileListWidget()defrefreshFileListWidget(self):self.refreshing=Trueself.reselectFileItem=Nonetry:try:self._refreshFileListWidget()exceptException,e:self.showMessage.emit(hglib.tounicode(str(e)))if'THGDEBUG'inos.environ:importtracebacktraceback.print_exc()finally:self.refreshing=Falseifself.reselectFileItem:self.fileListWidget.setCurrentItem(self.reselectFileItem)elifself.fileListWidget.count():self.fileListWidget.setCurrentRow(0)def_refreshFileListWidget(self):defaddfiles(mode,files,func):forfileinfiles:item=QListWidgetItem(u'%s%s'%(mode,hglib.tounicode(file)))item.setFlags(flags)item.setCheckState(func(mode,file))self.fileListWidget.addItem(item)ifselfile==file:self.reselectFileItem=itemitem=self.fileListWidget.currentItem()ifitem:selfile=hglib.fromunicode(item.text())[2:]else:selfile=Noneself.fileListWidget.clear()self.fileview.clearDisplay()pctx=self.repo.changectx('.')newmode=self.newCheckBox.isChecked()ifnotnewmodeand'qtip'inpctx.tags():# Show qrefresh (qdiff) diffsst=self.repo.status(pctx.p1().node(),None,unknown=True)[:5]M,A,R,D,U=stcheckfunc=lambdastat,file:fileinpctx.files()and \
Qt.CheckedorQt.Uncheckedelifnewmode:# Show qnew (working) diffsM,A,R,D,U=self.repo[None].status(unknown=True)[:5]checkfunc=lambdastat,file:statin'MAR' \
andQt.CheckedorQt.Uncheckedelse:returnflags=Qt.ItemIsSelectable|Qt.ItemIsUserCheckable|Qt.ItemIsEnabledaddfiles(u'A',A,checkfunc)addfiles(u'M',M,checkfunc)addfiles(u'R',R,checkfunc)addfiles(u'!',D,checkfunc)addfiles(u'?',U,checkfunc)defrefreshSelectedGuards(self):total=len(self.allguards)count=len(self.repo.mq.active())oldmenu=self.guardSelBtn.menu()ifoldmenu:oldmenu.setParent(None)menu=QMenu(self)forguardinself.allguards:a=menu.addAction(hglib.tounicode(guard))a.setCheckable(True)a.setChecked(guardinself.repo.mq.active())a.triggered.connect(self.onGuardSelectionChange)self.guardSelBtn.setMenu(menu)self.guardSelBtn.setText(_('Guards: %d/%d')%(count,total))self.guardSelBtn.setEnabled(bool(total))defonGuardSelectionChange(self,isChecked):guard=hglib.fromunicode(self.sender().text())newguards=self.repo.mq.active()[:]ifisChecked:newguards.append(guard)elifguardinnewguards:newguards.remove(guard)cmdline=['qselect','-R',self.repo.root]cmdline+=newguardsor['--none']self.repo.incrementBusyCount()self.qtbar.setEnabled(False)self.cmd.run(cmdline)# Capture drop events, try to import into current patch queuedefdetectPatches(self,paths):filepaths=[]forpinpaths:ifnotos.path.isfile(p):continuetry:pf=open(p,'rb')filename,message,user,date,branch,node,p1,p2= \
patch.extract(self.repo.ui,pf)iffilename:filepaths.append(p)os.unlink(filename)exceptException,e:passreturnfilepathsdefdragEnterEvent(self,event):paths=[unicode(u.toLocalFile())foruinevent.mimeData().urls()]ifself.detectPatches(paths):event.setDropAction(Qt.CopyAction)event.accept()defdropEvent(self,event):paths=[unicode(u.toLocalFile())foruinevent.mimeData().urls()]patches=self.detectPatches(paths)ifpatches:event.setDropAction(Qt.CopyAction)event.accept()else:super(MQWidget,self).dropEvent(event)returndlg=thgimport.ImportDialog(self.repo,self,mq=True)dlg.finished.connect(dlg.deleteLater)dlg.setfilepaths(patches)dlg.exec_()# End drop eventsdefloadConfigs(self):'Load history, etc, from QSettings instance's=QSettings()self.splitter.restoreState(s.value('mq/splitter').toByteArray())userhist=s.value('commit/userhist').toStringList()self.opts['userhist']=[hglib.fromunicode(u)foruinuserhistifu]self.messageEditor.loadSettings(s,'mq/editor')self.fileview.loadSettings(s,'mq/fileview')ifnotself.parent():self.restoreGeometry(s.value('mq/geom').toByteArray())defstoreConfigs(self):'Save history, etc, in QSettings instance's=QSettings()s.setValue('mq/splitter',self.splitter.saveState())self.messageEditor.saveSettings(s,'mq/editor')self.fileview.saveSettings(s,'mq/fileview')ifnotself.parent():s.setValue('mq/geom',self.saveGeometry())defcanExit(self):self.storeConfigs()returnnotself.cmd.core.running()defkeyPressEvent(self,event):ifevent.key()==Qt.Key_Escape:ifself.cmd.core.running():self.cmd.cancel()elifnotself.parent()andself.canExit():self.close()else:returnsuper(MQWidget,self).keyPressEvent(event)classPatchMessageCombo(QComboBox):def__init__(self,parent):super(PatchMessageCombo,self).__init__(parent)self.reset([])defreset(self,msglist):self.clear()self.addItem(_('Patch commit messages...'))self.loaded=Falseself.msglist=msglistdefshowPopup(self):ifnotself.loadedandself.msglist:self.clear()forpatch,messageinself.msglist:sum=message.split('\n',1)[0][:70]self.addItem(hglib.tounicode('%s: %s'%(patch,sum)))self.loaded=Trueifself.loaded:super(PatchMessageCombo,self).showPopup()classOptionsDialog(QDialog):'Utility dialog for configuring uncommon options'def__init__(self,parent):QDialog.__init__(self,parent)self.setWindowTitle('MQ options')layout=QFormLayout()self.setLayout(layout)self.gitcb=QCheckBox(_('Force use of git extended diff format (--git)'))layout.addRow(self.gitcb,None)self.forcecb=QCheckBox(_('Force push or pop (--force)'))layout.addRow(self.forcecb,None)self.exactcb=QCheckBox(_('Apply patch to its recorded parent (--exact)'))layout.addRow(self.exactcb,None)self.currentdatecb=QCheckBox(_('Update date field with current date (--currentdate)'))layout.addRow(self.currentdatecb,None)self.datele=QLineEdit()layout.addRow(QLabel(_('Specify an explicit date:')),self.datele)self.currentusercb=QCheckBox(_('Update author field with current user (--currentuser)'))layout.addRow(self.currentusercb,None)self.userle=QLineEdit()layout.addRow(QLabel(_('Specify an explicit author:')),self.userle)self.currentdatecb.toggled.connect(self.datele.setDisabled)self.currentusercb.toggled.connect(self.userle.setDisabled)self.gitcb.setChecked(parent.opts.get('git',False))self.forcecb.setChecked(parent.opts.get('force',False))self.exactcb.setChecked(parent.opts.get('exact',False))self.currentdatecb.setChecked(parent.opts.get('currentdate',False))self.currentusercb.setChecked(parent.opts.get('currentuser',False))self.datele.setText(hglib.tounicode(parent.opts.get('date','')))self.userle.setText(hglib.tounicode(parent.opts.get('user','')))BB=QDialogButtonBoxbb=QDialogButtonBox(BB.Ok|BB.Cancel)bb.accepted.connect(self.accept)bb.rejected.connect(self.reject)self.bb=bblayout.addWidget(bb)defaccept(self):outopts={}outopts['git']=self.gitcb.isChecked()outopts['force']=self.forcecb.isChecked()outopts['exact']=self.exactcb.isChecked()outopts['currentdate']=self.currentdatecb.isChecked()outopts['currentuser']=self.currentusercb.isChecked()ifself.currentdatecb.isChecked():outopts['date']=''else:outopts['date']=hglib.fromunicode(self.datele.text())ifself.currentusercb.isChecked():outopts['user']=''else:outopts['user']=hglib.fromunicode(self.userle.text())self.outopts=outoptsQDialog.accept(self)defrun(ui,*pats,**opts):fromtortoisehg.utilimportpathsfromtortoisehg.hgqtimportthgreporepo=thgrepo.repository(ui,path=paths.find_root())returnMQWidget(repo,None,**opts)
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.