Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py

changeset 2815
53c1d1f9ec86
parent 2771
281c9b30dd91
child 2838
0f1423054184
equal deleted inserted replaced
2814:2688e49ccdc0 2815:53c1d1f9ec86
23 23
24 class HgStatusDialog(QWidget, Ui_HgStatusDialog): 24 class HgStatusDialog(QWidget, Ui_HgStatusDialog):
25 """ 25 """
26 Class implementing a dialog to show the output of the hg status command process. 26 Class implementing a dialog to show the output of the hg status command process.
27 """ 27 """
28 def __init__(self, vcs, parent=None): 28 def __init__(self, vcs, mq=False, parent=None):
29 """ 29 """
30 Constructor 30 Constructor
31 31
32 @param vcs reference to the vcs object 32 @param vcs reference to the vcs object
33 @param mq flag indicating to show a queue repo status (boolean)
33 @param parent parent widget (QWidget) 34 @param parent parent widget (QWidget)
34 """ 35 """
35 super().__init__(parent) 36 super().__init__(parent)
36 self.setupUi(self) 37 self.setupUi(self)
37 38
50 self.diff = None 51 self.diff = None
51 self.process = None 52 self.process = None
52 self.vcs = vcs 53 self.vcs = vcs
53 self.vcs.committed.connect(self.__committed) 54 self.vcs.committed.connect(self.__committed)
54 self.__hgClient = self.vcs.getClient() 55 self.__hgClient = self.vcs.getClient()
56 self.__mq = mq
55 57
56 self.statusList.headerItem().setText(self.__lastColumn, "") 58 self.statusList.headerItem().setText(self.__lastColumn, "")
57 self.statusList.header().setSortIndicator(self.__pathColumn, Qt.AscendingOrder) 59 self.statusList.header().setSortIndicator(self.__pathColumn, Qt.AscendingOrder)
58 60
61 if mq:
62 self.buttonsLine.setVisible(False)
63 self.addButton.setVisible(False)
64 self.diffButton.setVisible(False)
65 self.revertButton.setVisible(False)
66 self.forgetButton.setVisible(False)
67 self.restoreButton.setVisible(False)
68
59 self.menuactions = [] 69 self.menuactions = []
60 self.menu = QMenu() 70 self.menu = QMenu()
61 self.menuactions.append(self.menu.addAction( 71 if not mq:
62 self.trUtf8("Commit changes to repository..."), self.__commit)) 72 self.menuactions.append(self.menu.addAction(
63 self.menuactions.append(self.menu.addAction( 73 self.trUtf8("Commit changes to repository..."), self.__commit))
64 self.trUtf8("Select all for commit"), self.__commitSelectAll)) 74 self.menuactions.append(self.menu.addAction(
65 self.menuactions.append(self.menu.addAction( 75 self.trUtf8("Select all for commit"), self.__commitSelectAll))
66 self.trUtf8("Deselect all from commit"), self.__commitDeselectAll)) 76 self.menuactions.append(self.menu.addAction(
67 self.menu.addSeparator() 77 self.trUtf8("Deselect all from commit"), self.__commitDeselectAll))
68 self.menuactions.append(self.menu.addAction( 78 self.menu.addSeparator()
69 self.trUtf8("Add to repository"), self.__add)) 79 self.menuactions.append(self.menu.addAction(
70 self.menuactions.append(self.menu.addAction( 80 self.trUtf8("Add to repository"), self.__add))
71 self.trUtf8("Show differences"), self.__diff)) 81 self.menuactions.append(self.menu.addAction(
72 self.menuactions.append(self.menu.addAction( 82 self.trUtf8("Show differences"), self.__diff))
73 self.trUtf8("Remove from repository"), self.__forget)) 83 self.menuactions.append(self.menu.addAction(
74 self.menuactions.append(self.menu.addAction( 84 self.trUtf8("Remove from repository"), self.__forget))
75 self.trUtf8("Revert changes"), self.__revert)) 85 self.menuactions.append(self.menu.addAction(
76 self.menuactions.append(self.menu.addAction( 86 self.trUtf8("Revert changes"), self.__revert))
77 self.trUtf8("Restore missing"), self.__restoreMissing)) 87 self.menuactions.append(self.menu.addAction(
78 self.menu.addSeparator() 88 self.trUtf8("Restore missing"), self.__restoreMissing))
79 self.menuactions.append(self.menu.addAction(self.trUtf8("Adjust column sizes"), 89 self.menu.addSeparator()
80 self.__resizeColumns)) 90 self.menuactions.append(self.menu.addAction(
81 for act in self.menuactions: 91 self.trUtf8("Adjust column sizes"), self.__resizeColumns))
82 act.setEnabled(False) 92 for act in self.menuactions:
83 93 act.setEnabled(False)
84 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 94
85 self.statusList.customContextMenuRequested.connect(self.__showContextMenu) 95 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu)
96 self.statusList.customContextMenuRequested.connect(self.__showContextMenu)
86 97
87 self.modifiedIndicators = [ 98 self.modifiedIndicators = [
88 self.trUtf8('added'), 99 self.trUtf8('added'),
89 self.trUtf8('modified'), 100 self.trUtf8('modified'),
90 self.trUtf8('removed'), 101 self.trUtf8('removed'),
188 self.restoreButton.setEnabled(False) 199 self.restoreButton.setEnabled(False)
189 200
190 self.statusFilterCombo.clear() 201 self.statusFilterCombo.clear()
191 self.__statusFilters = [] 202 self.__statusFilters = []
192 203
193 self.setWindowTitle(self.trUtf8('Mercurial Status')) 204 if self.__mq:
205 self.setWindowTitle(self.trUtf8("Mercurial Queue Repository Status"))
206 else:
207 self.setWindowTitle(self.trUtf8('Mercurial Status'))
194 208
195 args = [] 209 args = []
196 args.append('status') 210 args.append('status')
197 self.vcs.addArguments(args, self.vcs.options['global']) 211 self.vcs.addArguments(args, self.vcs.options['global'])
198 self.vcs.addArguments(args, self.vcs.options['status']) 212 if self.__mq:
199 213 args.append('--mq')
200 if self.vcs.hasSubrepositories(): 214 if isinstance(fn, list):
201 args.append("--subrepos") 215 self.dname, fnames = self.vcs.splitPathList(fn)
202 216 else:
203 if isinstance(fn, list): 217 self.dname, fname = self.vcs.splitPath(fn)
204 self.dname, fnames = self.vcs.splitPathList(fn) 218 else:
205 self.vcs.addArguments(args, fn) 219 self.vcs.addArguments(args, self.vcs.options['status'])
206 else: 220
207 self.dname, fname = self.vcs.splitPath(fn) 221 if self.vcs.hasSubrepositories():
208 args.append(fn) 222 args.append("--subrepos")
223
224 if isinstance(fn, list):
225 self.dname, fnames = self.vcs.splitPathList(fn)
226 self.vcs.addArguments(args, fn)
227 else:
228 self.dname, fname = self.vcs.splitPath(fn)
229 args.append(fn)
209 230
210 # find the root of the repo 231 # find the root of the repo
211 repodir = self.dname 232 repodir = self.dname
212 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)): 233 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
213 repodir = os.path.dirname(repodir) 234 repodir = os.path.dirname(repodir)
539 560
540 def __commit(self): 561 def __commit(self):
541 """ 562 """
542 Private slot to handle the Commit context menu entry. 563 Private slot to handle the Commit context menu entry.
543 """ 564 """
544 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) \ 565 if self.__mq:
545 for itm in self.__getCommitableItems()] 566 self.vcs.vcsCommit(self.dname, "", mq=True)
546 if not names: 567 else:
547 E5MessageBox.information(self, 568 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) \
548 self.trUtf8("Commit"), 569 for itm in self.__getCommitableItems()]
549 self.trUtf8("""There are no entries selected to be""" 570 if not names:
550 """ committed.""")) 571 E5MessageBox.information(self,
551 return 572 self.trUtf8("Commit"),
552 573 self.trUtf8("""There are no entries selected to be"""
553 if Preferences.getVCS("AutoSaveFiles"): 574 """ committed."""))
554 vm = e5App().getObject("ViewManager") 575 return
555 for name in names: 576
556 vm.saveEditor(name) 577 if Preferences.getVCS("AutoSaveFiles"):
557 self.vcs.vcsCommit(names, '') 578 vm = e5App().getObject("ViewManager")
579 for name in names:
580 vm.saveEditor(name)
581 self.vcs.vcsCommit(names, '')
558 582
559 def __committed(self): 583 def __committed(self):
560 """ 584 """
561 Private slot called after the commit has finished. 585 Private slot called after the commit has finished.
562 """ 586 """

eric ide

mercurial