eric6/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelveBrowserDialog.py

changeset 7971
ff2971513d6d
parent 7923
91e843545d9a
child 8143
2c730d5fd177
equal deleted inserted replaced
7970:c4ee8a81584c 7971:ff2971513d6d
4 # 4 #
5 5
6 """ 6 """
7 Module implementing Mercurial shelve browser dialog. 7 Module implementing Mercurial shelve browser dialog.
8 """ 8 """
9
10 import os
11 9
12 from PyQt5.QtCore import pyqtSlot, Qt, QPoint 10 from PyQt5.QtCore import pyqtSlot, Qt, QPoint
13 from PyQt5.QtWidgets import ( 11 from PyQt5.QtWidgets import (
14 QWidget, QDialogButtonBox, QTreeWidgetItem, QAbstractButton, QMenu, 12 QWidget, QDialogButtonBox, QTreeWidgetItem, QAbstractButton, QMenu,
15 QHeaderView, QApplication 13 QHeaderView, QApplication
144 if err: 142 if err:
145 self.__showError(err) 143 self.__showError(err)
146 self.__processBuffer() 144 self.__processBuffer()
147 self.__finish() 145 self.__finish()
148 146
149 def start(self, projectDir): 147 def start(self):
150 """ 148 """
151 Public slot to start the hg shelve command. 149 Public slot to start the hg shelve command.
152
153 @param projectDir name of the project directory (string)
154 """ 150 """
155 self.errorGroup.hide() 151 self.errorGroup.hide()
156 QApplication.processEvents() 152 QApplication.processEvents()
157
158 self.__projectDir = projectDir
159
160 # find the root of the repo
161 self.repodir = self.__projectDir
162 while not os.path.isdir(os.path.join(self.repodir, self.vcs.adminDir)):
163 self.repodir = os.path.dirname(self.repodir)
164 if os.path.splitdrive(self.repodir)[1] == os.sep:
165 return
166 153
167 self.activateWindow() 154 self.activateWindow()
168 self.raise_() 155 self.raise_()
169 156
170 self.shelveList.clear() 157 self.shelveList.clear()
309 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 296 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
310 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 297 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
311 298
312 self.refreshButton.setEnabled(False) 299 self.refreshButton.setEnabled(False)
313 300
314 self.start(self.__projectDir) 301 self.start()
315 302
316 def __unshelve(self): 303 def __unshelve(self):
317 """ 304 """
318 Private slot to restore the selected shelve of changes. 305 Private slot to restore the selected shelve of changes.
319 """ 306 """
320 itm = self.shelveList.selectedItems()[0] 307 itm = self.shelveList.selectedItems()[0]
321 if itm is not None: 308 if itm is not None:
322 name = itm.text(self.NameColumn) 309 name = itm.text(self.NameColumn)
323 self.vcs.getExtensionObject("shelve").hgUnshelve( 310 self.vcs.getExtensionObject("shelve").hgUnshelve(shelveName=name)
324 self.__projectDir, shelveName=name)
325 self.on_refreshButton_clicked() 311 self.on_refreshButton_clicked()
326 312
327 def __deleteShelves(self): 313 def __deleteShelves(self):
328 """ 314 """
329 Private slot to delete the selected shelves. 315 Private slot to delete the selected shelves.
331 shelveNames = [] 317 shelveNames = []
332 for itm in self.shelveList.selectedItems(): 318 for itm in self.shelveList.selectedItems():
333 shelveNames.append(itm.text(self.NameColumn)) 319 shelveNames.append(itm.text(self.NameColumn))
334 if shelveNames: 320 if shelveNames:
335 self.vcs.getExtensionObject("shelve").hgDeleteShelves( 321 self.vcs.getExtensionObject("shelve").hgDeleteShelves(
336 self.__projectDir, shelveNames=shelveNames) 322 shelveNames=shelveNames)
337 self.on_refreshButton_clicked() 323 self.on_refreshButton_clicked()
338 324
339 def __cleanupShelves(self): 325 def __cleanupShelves(self):
340 """ 326 """
341 Private slot to delete all shelves. 327 Private slot to delete all shelves.
342 """ 328 """
343 self.vcs.getExtensionObject("shelve").hgCleanupShelves( 329 self.vcs.getExtensionObject("shelve").hgCleanupShelves()
344 self.__projectDir)
345 self.on_refreshButton_clicked() 330 self.on_refreshButton_clicked()

eric ide

mercurial