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.
# shelve.py - TortoiseHg shelve and patch tool## Copyright 2011 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms# of the GNU General Public License, incorporated herein by reference.importosimporttimefrommercurialimportcommands,errorfromtortoisehg.utilimporthglibfromtortoisehg.util.patchctximportpatchctxfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportqtlib,cmdui,chunksfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*classShelveDialog(QDialog):finished=pyqtSignal(int)wdir=_('Working Directory')def__init__(self,repo,parent):QDialog.__init__(self,parent)self.setWindowFlags(Qt.Window)self.setWindowIcon(qtlib.geticon('shelve'))self.repo=repoself.shelves=[]self.patches=[]layout=QVBoxLayout()layout.setContentsMargins(2,2,2,2)layout.setSpacing(0)self.setLayout(layout)self.tbarhbox=hbox=QHBoxLayout()hbox.setContentsMargins(0,0,0,0)hbox.setSpacing(0)self.layout().addLayout(self.tbarhbox)self.splitter=QSplitter(self)self.splitter.setOrientation(Qt.Horizontal)self.splitter.setChildrenCollapsible(False)self.splitter.setObjectName('splitter')self.layout().addWidget(self.splitter,1)aframe=QFrame(self.splitter)avbox=QVBoxLayout()avbox.setSpacing(2)avbox.setMargin(2)avbox.setContentsMargins(2,2,2,2)aframe.setLayout(avbox)ahbox=QHBoxLayout()ahbox.setSpacing(2)ahbox.setMargin(2)ahbox.setContentsMargins(2,2,2,2)avbox.addLayout(ahbox)self.comboa=QComboBox(self)self.comboa.currentIndexChanged.connect(self.comboAChanged)self.clearShelfButtonA=QPushButton(_('Clear'))self.clearShelfButtonA.setToolTip(_('Clear the current shelf file'))self.clearShelfButtonA.clicked.connect(self.clearShelfA)self.delShelfButtonA=QPushButton(_('Delete'))self.delShelfButtonA.setToolTip(_('Delete the current shelf file'))self.delShelfButtonA.clicked.connect(self.deleteShelfA)ahbox.addWidget(self.comboa,1)ahbox.addWidget(self.clearShelfButtonA)ahbox.addWidget(self.delShelfButtonA)self.browsea=chunks.ChunksWidget(repo,self,True)self.browsea.splitter.splitterMoved.connect(self.linkSplitters)self.browsea.linkActivated.connect(self.linkActivated)self.browsea.showMessage.connect(self.showMessage)avbox.addWidget(self.browsea)bframe=QFrame(self.splitter)bvbox=QVBoxLayout()bvbox.setSpacing(2)bvbox.setMargin(2)bvbox.setContentsMargins(2,2,2,2)bframe.setLayout(bvbox)bhbox=QHBoxLayout()bhbox.setSpacing(2)bhbox.setMargin(2)bhbox.setContentsMargins(2,2,2,2)bvbox.addLayout(bhbox)self.combob=QComboBox(self)self.combob.currentIndexChanged.connect(self.comboBChanged)self.clearShelfButtonB=QPushButton(_('Clear'))self.clearShelfButtonB.setToolTip(_('Clear the current shelf file'))self.clearShelfButtonB.clicked.connect(self.clearShelfB)self.delShelfButtonB=QPushButton(_('Delete'))self.delShelfButtonB.setToolTip(_('Delete the current shelf file'))self.delShelfButtonB.clicked.connect(self.deleteShelfB)bhbox.addWidget(self.combob,1)bhbox.addWidget(self.clearShelfButtonB)bhbox.addWidget(self.delShelfButtonB)self.browseb=chunks.ChunksWidget(repo,self,True)self.browseb.splitter.splitterMoved.connect(self.linkSplitters)self.browseb.linkActivated.connect(self.linkActivated)self.browseb.showMessage.connect(self.showMessage)bvbox.addWidget(self.browseb)self.lefttbar=QToolBar(_('Left Toolbar'),objectName='lefttbar')self.tbarhbox.addWidget(self.lefttbar)self.deletea=a=QAction(_('Delete selected chunks'),self)self.deletea.triggered.connect(self.browsea.deleteSelectedChunks)a.setIcon(qtlib.geticon('thg-shelve-delete-left'))self.lefttbar.addAction(self.deletea)self.allright=a=QAction(_('Move all files right'),self)self.allright.triggered.connect(self.moveFilesRight)a.setIcon(qtlib.geticon('thg-shelve-move-right-all'))self.lefttbar.addAction(self.allright)self.fileright=a=QAction(_('Move selected file right'),self)self.fileright.triggered.connect(self.moveFileRight)a.setIcon(qtlib.geticon('thg-shelve-move-right-file'))self.lefttbar.addAction(self.fileright)self.editfilea=a=QAction(_('Edit file'),self)a.setIcon(qtlib.geticon('edit-find'))self.lefttbar.addAction(self.editfilea)self.chunksright=a=QAction(_('Move selected chunks right'),self)self.chunksright.triggered.connect(self.moveChunksRight)a.setIcon(qtlib.geticon('thg-shelve-move-right-chunks'))self.lefttbar.addAction(self.chunksright)self.rbar=QToolBar(_('Refresh Toolbar'),objectName='rbar')self.tbarhbox.addStretch(1)self.tbarhbox.addWidget(self.rbar)self.refreshAction=a=QAction(_('Refresh'),self)a.setIcon(qtlib.geticon('view-refresh'))a.setShortcut(QKeySequence.Refresh)a.triggered.connect(self.refreshCombos)self.rbar.addAction(self.refreshAction)self.actionNew=a=QAction(_('New Shelf'),self)a.setIcon(qtlib.geticon('document-new'))a.triggered.connect(self.newShelfPressed)self.rbar.addAction(self.actionNew)self.righttbar=QToolBar(_('Right Toolbar'),objectName='righttbar')self.tbarhbox.addStretch(1)self.tbarhbox.addWidget(self.righttbar)self.chunksleft=a=QAction(_('Move selected chunks left'),self)self.chunksleft.triggered.connect(self.moveChunksLeft)a.setIcon(qtlib.geticon('thg-shelve-move-left-chunks'))self.righttbar.addAction(self.chunksleft)self.editfileb=a=QAction(_('Edit file'),self)a.setIcon(qtlib.geticon('edit-find'))self.righttbar.addAction(self.editfileb)self.fileleft=a=QAction(_('Move selected file left'),self)self.fileleft.triggered.connect(self.moveFileLeft)a.setIcon(qtlib.geticon('thg-shelve-move-left-file'))self.righttbar.addAction(self.fileleft)self.allleft=a=QAction(_('Move all files left'),self)self.allleft.triggered.connect(self.moveFilesLeft)a.setIcon(qtlib.geticon('thg-shelve-move-left-all'))self.righttbar.addAction(self.allleft)self.deleteb=a=QAction(_('Delete selected chunks'),self)self.deleteb.triggered.connect(self.browseb.deleteSelectedChunks)a.setIcon(qtlib.geticon('thg-shelve-delete-right'))self.righttbar.addAction(self.deleteb)self.editfilea.triggered.connect(self.browsea.editCurrentFile)self.editfileb.triggered.connect(self.browseb.editCurrentFile)self.browsea.chunksSelected.connect(self.chunksright.setEnabled)self.browsea.chunksSelected.connect(self.deletea.setEnabled)self.browsea.fileSelected.connect(self.fileright.setEnabled)self.browsea.fileSelected.connect(self.editfilea.setEnabled)self.browsea.fileModified.connect(self.refreshCombos)self.browsea.fileModelEmpty.connect(self.allright.setDisabled)self.browseb.chunksSelected.connect(self.chunksleft.setEnabled)self.browseb.chunksSelected.connect(self.deleteb.setEnabled)self.browseb.fileSelected.connect(self.fileleft.setEnabled)self.browseb.fileSelected.connect(self.editfileb.setEnabled)self.browseb.fileModified.connect(self.refreshCombos)self.browseb.fileModelEmpty.connect(self.allleft.setDisabled)self.statusbar=cmdui.ThgStatusBar(self)self.layout().addWidget(self.statusbar)self.showMessage(_('Backup copies of modified files can be found ''in .hg/Trashcan/'))self.refreshCombos()repo.repositoryChanged.connect(self.refreshCombos)self.setWindowTitle(_('TortoiseHg Shelve - %s')%repo.displayname)self.restoreSettings()defdone(self,ret):self.repo.repositoryChanged.disconnect(self.refreshCombos)super(ShelveDialog,self).done(ret)@pyqtSlot()defmoveFileRight(self):ifself.combob.currentIndex()==-1:self.newShelf(False)forfileinself.browsea.getSelectedFiles():chunks=self.browsea.getChunksForFile(file)ifself.browseb.mergeChunks(file,chunks):self.browsea.removeFile(file)@pyqtSlot()defmoveFileLeft(self):forfileinself.browseb.getSelectedFiles():chunks=self.browseb.getChunksForFile(file)ifself.browsea.mergeChunks(file,chunks):self.browseb.removeFile(file)@pyqtSlot()defmoveFilesRight(self):ifself.combob.currentIndex()==-1:self.newShelf(False)forfileinself.browsea.getFileList():chunks=self.browsea.getChunksForFile(file)ifself.browseb.mergeChunks(file,chunks):self.browsea.removeFile(file)@pyqtSlot()defmoveFilesLeft(self):forfileinself.browseb.getFileList():chunks=self.browseb.getChunksForFile(file)ifself.browsea.mergeChunks(file,chunks):self.browseb.removeFile(file)@pyqtSlot()defmoveChunksRight(self):ifself.combob.currentIndex()==-1:self.newShelf(False)file,chunks=self.browsea.getSelectedFileAndChunks()ifself.browseb.mergeChunks(file,chunks):self.browsea.deleteSelectedChunks()@pyqtSlot()defmoveChunksLeft(self):file,chunks=self.browseb.getSelectedFileAndChunks()ifself.browsea.mergeChunks(file,chunks):self.browseb.deleteSelectedChunks()@pyqtSlot()defnewShelfPressed(self):self.newShelf(True)defnewShelf(self,interactive):shelve=time.strftime('%Y-%m-%d_%H-%M-%S')+ \
'_parent_rev_%d'%self.repo['.'].rev()ifinteractive:dlg=QInputDialog(self,Qt.Sheet)dlg.setWindowModality(Qt.WindowModal)dlg.setWindowTitle(_('TortoiseHg New Shelf Name'))dlg.setLabelText(_('Specify name of new shelf'))dlg.setTextValue(shelve)ifnotdlg.exec_():returnshelve=hglib.fromunicode(dlg.textValue())try:fn=os.path.join('shelves',shelve)shelfpath=self.repo.join(fn)ifos.path.exists(shelfpath): qtlib.ErrorMsgBox(_('File already exists'),
_('A shelf file of that name already exists'))
return
-self.repo.opener(fn, 'wb').write('')
+f = open(shelfpath, "wb")
+ f.close() self.showMessage(_('New shelf created'))
self.refreshCombos()
if shelfpath in self.shelves:
self.combob.setCurrentIndex(self.shelves.index(shelfpath))exceptEnvironmentError,e:self.showMessage(hglib.tounicode(str(e)))@pyqtSlot()defdeleteShelfA(self):shelf=self.currentPatchA()ushelf=hglib.tounicode(os.path.basename(shelf))ifnotqtlib.QuestionMsgBox(_('Are you sure?'),_('Delete shelf file %s?')%ushelf):returntry:os.unlink(shelf)self.showMessage(_('Shelf deleted'))exceptEnvironmentError,e:self.showMessage(hglib.tounicode(str(e)))self.refreshCombos()@pyqtSlot()defclearShelfA(self):ifself.comboa.currentIndex()==0:ifnotqtlib.QuestionMsgBox(_('Are you sure?'),_('Revert all working copy changes?')):returntry:self.repo.ui.quiet=Truecommands.revert(self.repo.ui,self.repo,all=True)self.repo.ui.quiet=Falseexcept(EnvironmentError,error.Abort),e:self.showMessage(hglib.tounicode(str(e)))self.refreshCombos()returnshelf=self.currentPatchA()ushelf=hglib.tounicode(os.path.basename(shelf))ifnotqtlib.QuestionMsgBox(_('Are you sure?'),_('Clear contents of shelf file %s?')%ushelf):returntry:f=open(shelf,"w")f.close()self.showMessage(_('Shelf cleared'))exceptEnvironmentError,e:self.showMessage(hglib.tounicode(str(e)))self.refreshCombos()@pyqtSlot()defdeleteShelfB(self):shelf=self.currentPatchB()ushelf=hglib.tounicode(os.path.basename(shelf))ifnotqtlib.QuestionMsgBox(_('Are you sure?'),_('Delete shelf file %s?')%ushelf):returntry:os.unlink(shelf)self.showMessage(_('Shelf deleted'))exceptEnvironmentError,e:self.showMessage(hglib.tounicode(str(e)))self.refreshCombos()@pyqtSlot()defclearShelfB(self):shelf=self.currentPatchB()ushelf=hglib.tounicode(os.path.basename(shelf))ifnotqtlib.QuestionMsgBox(_('Are you sure?'),_('Clear contents of shelf file %s?')%ushelf):returntry:f=open(shelf,"w")f.close()self.showMessage(_('Shelf cleared'))exceptEnvironmentError,e:self.showMessage(hglib.tounicode(str(e)))self.refreshCombos()defcurrentPatchA(self):idx=self.comboa.currentIndex()ifidx==-1:returnNoneifidx==0:returnself.wdiridx-=1ifidx<len(self.shelves):returnself.shelves[idx]idx-=len(self.shelves)ifidx<len(self.patches):returnself.patches[idx]returnNonedefcurrentPatchB(self):idx=self.combob.currentIndex()ifidx==-1:returnNoneifidx<len(self.shelves):returnself.shelves[idx]idx-=len(self.shelves)ifidx<len(self.patches):returnself.patches[idx]returnNone@pyqtSlot()defrefreshCombos(self):shelvea,shelveb=self.currentPatchA(),self.currentPatchB()# Note that thgshelves returns the shelve list ordered from newest to # oldestshelves=self.repo.thgshelves()disp=[_('Shelf: %s')%hglib.tounicode(s)forsinshelves]patches=self.repo.thgmqunappliedpatchesdisp+=[_('Patch: %s')%hglib.tounicode(p)forpinpatches]# store fully qualified pathsself.shelves=[os.path.join(self.repo.shelfdir,s)forsinshelves]self.patches=[self.repo.mq.join(p)forpinpatches]self.comboRefreshInProgress=Trueself.comboa.clear()self.combob.clear()self.comboa.addItems([self.wdir]+disp)self.combob.addItems(disp)# attempt to restore selectionifshelvea==self.wdir:idxa=0elifshelveainself.shelves:idxa=self.shelves.index(shelvea)+1elifshelveainself.patches:idxa=len(self.shelves)+self.patches.index(shelvea)+1else:idxa=0self.comboa.setCurrentIndex(idxa)ifshelvebinself.shelves:idxb=self.shelves.index(shelveb)elifshelvebinself.patches:idxb=len(self.shelves)+self.patches.index(shelveb)else:idxb=0self.combob.setCurrentIndex(idxb)self.comboRefreshInProgress=Falseself.comboAChanged(idxa)self.comboBChanged(idxb)ifnotpatchesandnotshelves:self.delShelfButtonB.setEnabled(False)self.clearShelfButtonB.setEnabled(False)self.browseb.setContext(patchctx('',self.repo,None))@pyqtSlot(int)defcomboAChanged(self,index):ifself.comboRefreshInProgress:returnifindex==0:rev=Noneself.delShelfButtonA.setEnabled(False)self.clearShelfButtonA.setEnabled(True)else:rev=self.currentPatchA()self.delShelfButtonA.setEnabled(index<=len(self.shelves))self.clearShelfButtonA.setEnabled(index<=len(self.shelves))self.browsea.setContext(self.repo.changectx(rev))@pyqtSlot(int)defcomboBChanged(self,index):ifself.comboRefreshInProgress:returnrev=self.currentPatchB()self.delShelfButtonB.setEnabled(index<len(self.shelves))self.clearShelfButtonB.setEnabled(index<len(self.shelves))self.browseb.setContext(self.repo.changectx(rev))@pyqtSlot(int,int)deflinkSplitters(self,pos,index):ifself.browsea.splitter.sizes()[0]!=pos:self.browsea.splitter.moveSplitter(pos,index)ifself.browseb.splitter.sizes()[0]!=pos:self.browseb.splitter.moveSplitter(pos,index)@pyqtSlot(QString)deflinkActivated(self,linktext):pass@pyqtSlot(QString)defshowMessage(self,message):self.statusbar.showMessage(message)defstoreSettings(self):s=QSettings()wb="shelve/"s.setValue(wb+'geometry',self.saveGeometry())s.setValue(wb+'panesplitter',self.splitter.saveState())s.setValue(wb+'filesplitter',self.browsea.splitter.saveState())self.browsea.saveSettings(s,wb+'fileviewa')self.browseb.saveSettings(s,wb+'fileviewb')defrestoreSettings(self):s=QSettings()wb="shelve/"self.restoreGeometry(s.value(wb+'geometry').toByteArray())self.splitter.restoreState(s.value(wb+'panesplitter').toByteArray())self.browsea.splitter.restoreState(s.value(wb+'filesplitter').toByteArray())self.browseb.splitter.restoreState(s.value(wb+'filesplitter').toByteArray())self.browsea.loadSettings(s,wb+'fileviewa')self.browseb.loadSettings(s,wb+'fileviewb')defreject(self):self.storeSettings()super(ShelveDialog,self).reject()defrun(ui,*pats,**opts):if'repo'inopts:repo=opts['repo']else:fromtortoisehg.utilimportpathsfromtortoisehg.hgqtimportthgreporepo=thgrepo.repository(ui,path=paths.find_root())returnShelveDialog(repo,None)
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.