Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

pbranch: Add patch branch task tab

Changeset 8fba66bfd341

Parent 55594eb92d0c

by Peer Sommerlund

Changes to 3 files · Browse files at 8fba66bfd341 Showing diff from parent 55594eb92d0c Diff from another changeset...

Change 1 of 1 Show Entire File tortoisehg/​hgqt/​pbranch.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
@@ -0,0 +1,111 @@
+# pbranch.py - TortoiseHg's patch branch widget +# +# Copyright 2010 Peer Sommerlund <peso@users.sourceforge.net> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +import os +import time + +from mercurial import ui + +from tortoisehg.hgqt.i18n import _ +from tortoisehg.hgqt import qtlib, cmdui +from tortoisehg.util import hglib + +from PyQt4.QtCore import * +from PyQt4.QtGui import * + +class PatchBranchWidget(QWidget): + ''' + A widget that show the patch graph and provide actions + for the pbranch extension + ''' + visibilityChanged = pyqtSignal(bool) + + def __init__(self, repo, parent=None, logwidget=None): + QWidget.__init__(self, parent) + + # Set up variables and connect signals + + self.repo = repo + self.runner = cmdui.Runner(_('Patch Branch'), self, logwidget) + self.runner.commandStarted.connect(repo.incrementBusyCount) + self.runner.commandFinished.connect(self.commandFinished) + + repo.configChanged.connect(self.configChanged) + repo.repositoryChanged.connect(self.repositoryChanged) + repo.workingBranchChanged.connect(self.workingBranchChanged) + + # Build child widgets + + vbox = QVBoxLayout() + vbox.setContentsMargins(0, 0, 0, 0) + self.setLayout(vbox) + + # Toolbar + self.toolBar_patchbranch = tb = QToolBar(_("Patch Branch Toolbar"), self) + tb.setEnabled(True) + tb.setObjectName("toolBar_patchbranch") + tb.setFloatable(False) + + self.actionPMerge = a = QWidgetAction(self) + a.setIcon(QIcon(QPixmap(":/icons/merge.svg"))) + a.setToolTip(_('Merge all pending dependencies')) + tb.addAction(self.actionPMerge) + #self.actionPMerge.triggered.connect(self.pmerge_clicked) + + self.actionBackport = a = QWidgetAction(self) + a.setIcon(QIcon(QPixmap(":/icons/back.svg"))) + a.setToolTip(_('Backout current patch branch')) + tb.addAction(self.actionBackport) + #self.actionBackport.triggered.connect(self.pbackout_clicked) + + self.actionReapply = a = QWidgetAction(self) + a.setIcon(QIcon(QPixmap(":/icons/forward.svg"))) + a.setToolTip(_('Backport part of a changeset to a dependency')) + tb.addAction(self.actionReapply) + #self.actionReapply.triggered.connect(self.reapply_clicked) + + self.actionPNew = a = QWidgetAction(self) + a.setIcon(QIcon(QPixmap(":/icons/fileadd.ico"))) #STOCK_NEW + a.setToolTip(_('Start a new patch branch')) + tb.addAction(self.actionPNew) + #self.actionPNew.triggered.connect(self.pbackout_clicked) + + self.actionEditPGraph = a = QWidgetAction(self) + a.setIcon(QIcon(QPixmap(":/icons/log.svg"))) #STOCK_EDIT + a.setToolTip(_('Edit patch dependency graph')) + tb.addAction(self.actionEditPGraph) + #self.actionEditPGraph.triggered.connect(self.pbackout_clicked) + + vbox.addWidget(self.toolBar_patchbranch, 1) + + # Patch list + self.logte = QPlainTextEdit() + self.logte.setReadOnly(True) + self.logte.setCenterOnScroll(True) + self.logte.setMaximumBlockCount(1024) + self.logte.setWordWrapMode(QTextOption.NoWrap) + vbox.addWidget(self.logte, 1) + + # Command output + self.logte = QPlainTextEdit() + self.logte.setReadOnly(True) + self.logte.setCenterOnScroll(True) + self.logte.setMaximumBlockCount(1024) + self.logte.setWordWrapMode(QTextOption.NoWrap) + vbox.addWidget(self.logte, 1) + + # Signal handlers + + def commandFinished(self, wrapper): + pass + def configChanged(self, wrapper): + pass + def repositoryChanged(self): + pass + def workingBranchChanged(self, wrapper): + pass +
 
29
30
31
 
32
33
34
 
159
160
161
 
 
 
162
163
164
 
330
331
332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
334
335
 
588
589
590
 
591
592
593
 
29
30
31
32
33
34
35
 
160
161
162
163
164
165
166
167
168
 
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
 
607
608
609
610
611
612
613
@@ -29,6 +29,7 @@
 from tortoisehg.hgqt.sync import SyncWidget  from tortoisehg.hgqt.grep import SearchWidget  from tortoisehg.hgqt.quickbar import GotoQuickBar +from tortoisehg.hgqt.pbranch import PatchBranchWidget    from PyQt4.QtCore import *  from PyQt4.QtGui import * @@ -159,6 +160,9 @@
  self.syncDemand = w = DemandWidget(self.createSyncWidget)   self.syncTabIndex = idx = tt.addTab(w, geticon('sync'), '')   tt.setTabToolTip(idx, _("Synchronize")) + + self.pbranchDemand = w = DemandWidget(self.createPatchBranchWidget) + self.updatePatchBranchTab()     def title(self):   """Returns the expected title for this widget [unicode]""" @@ -330,6 +334,21 @@
  gw.showMessage.connect(self.showMessage)   return gw   + def createPatchBranchWidget(self): + return PatchBranchWidget(self.repo, parent=self) + + def updatePatchBranchTab(self): + "Only show pbranch tab when pbranch extension is installed" + tt = self.taskTabsWidget + w = self.pbranchDemand + self.pbranchTabIndex = idx = tt.indexOf(w) + if 'pbranch' in self.repo.extensions(): + if idx == -1: + self.pbranchTabIndex = idx = tt.addTab(w, geticon('branch'), '') + tt.setTabToolTip(idx, _("Patch Branch")) + else: + tt.removeTab(idx) +   def reponame(self):   return self.repo.shortname   @@ -588,6 +607,7 @@
  'Repository is reporting its config files have changed'   self.repomodel.invalidate()   self.revDetailsWidget.reload() + self.updatePatchBranchTab()   self.titleChanged.emit(self.title())   # TODO: emit only if actually changed  
 
224
225
226
 
 
227
228
229
230
231
 
 
232
233
234
 
385
386
387
 
388
389
 
390
391
392
 
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
 
389
390
391
392
393
394
395
396
397
398
@@ -224,11 +224,15 @@
  a = newaction(label, icon=icon, checkable=True, data=index,   enabled='repoopen', menu='view')   self.actionGroupTaskView.addAction(a) + return a + # NOTE: Sequence must match that in repowidget.py   addtaskview('log', _("Revision &Details"))   addtaskview('commit', _("&Commit..."))   addtaskview('annotate', _("&Manifest..."))   addtaskview('repobrowse', _("&Search..."))   addtaskview('sync', _("S&ynchronize...")) + self.actionSelectTaskPbranch = \ + addtaskview('branch', _("&Patch Branch..."))   newseparator(menu='view')     newaction(_("&Refresh"), self._repofwd('reload'), icon='reload', @@ -385,8 +389,10 @@
  if self.repoTabsWidget.count() == 0:   for a in self.actionGroupTaskView.actions():   a.setChecked(False) + self.actionSelectTaskPbranch.setVisible(False)   else:   repoWidget = self.repoTabsWidget.currentWidget() + self.actionSelectTaskPbranch.setVisible('pbranch' in repoWidget.repo.extensions())   taskIndex = repoWidget.taskTabsWidget.currentIndex()   self.actionGroupTaskView.actions()[taskIndex].setChecked(True)