Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1.2 and tip

stable pbranch: support options to pnew

Changeset 8fb75895c976

Parent 24f2385c6884

by Peer Sommerlund

Changes to one file · Browse files at 8fb75895c976 Showing diff from parent 24f2385c6884 Diff from another changeset...

 
9
10
11
12
 
13
14
15
 
343
344
345
346
347
348
349
350
 
 
351
352
 
 
353
354
355
 
836
837
838
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
10
11
 
12
13
14
15
 
343
344
345
 
 
 
 
 
346
347
348
 
349
350
351
352
353
 
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
@@ -9,7 +9,7 @@
 import time  import errno   -from mercurial import extensions, ui, error +from mercurial import extensions, ui, error, util    from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt import qtlib, cmdui, update, revdetails @@ -343,13 +343,11 @@
  Prompt user for new patch name. Patch is created   on current branch.   """ - parent = None - title = _('TortoiseHg Prompt') - label = _('New Patch Name') - new_name, ok = QInputDialog.getText(self, title, label) - if not ok: + dialog = PNewDialog() + if dialog.exec_() != QDialog.Accepted:   return False - self.pnew(hglib.fromunicode(new_name)) + self.repo.incrementBusyCount() + self.runner.run(dialog.getCmd(cwd=self.repo.root))   return True     def pnew(self, patch_name): @@ -836,3 +834,64 @@
    painter.end()   return QVariant(pix) + +class PNewDialog(QDialog): + def __init__(self, parent=None): + QDialog.__init__(self, parent) + self.setWindowFlags(Qt.Window) + self.setWindowIcon(qtlib.geticon("fileadd")) + self.setWindowTitle(_('New Patch Branch')) + + def AddField(var, label, optional=False): + hbox = QHBoxLayout() + SP = QSizePolicy + le = QLineEdit() + le.setSizePolicy(SP(SP.Expanding, SP.Fixed)) + if optional: + cb = QCheckBox(label) + le.setEnabled(False) + cb.toggled.connect(le.setEnabled) + hbox.addWidget(cb) + setattr(self, var+'cb', cb) + else: + hbox.addWidget(QLabel(label)) + hbox.addWidget(le) + setattr(self, var+'le', le) + return hbox + + def DialogButtons(): + BB = QDialogButtonBox + bb = QDialogButtonBox(BB.Ok|BB.Cancel) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject) + bb.button(BB.Ok).setDefault(True) + bb.button(BB.Cancel).setDefault(False) + self.commitButton = bb.button(BB.Ok) + self.commitButton.setText(_('Commit', 'action button')) + self.bb = bb + return bb + + layout = QVBoxLayout() + layout.setContentsMargins(2, 2, 2, 2) + self.setLayout(layout) + layout.addLayout(AddField('patchname',_('Patch name:'))) + layout.addLayout(AddField('patchtext',_('Patch message:'), optional=True)) + layout.addLayout(AddField('patchdate',_('Patch date:'), optional=True)) + layout.addLayout(AddField('patchuser',_('Patch user:'), optional=True)) + layout.addWidget(DialogButtons()) + + self.patchdatele.setText( + hglib.tounicode(hglib.displaytime(util.makedate()))) + + def patchname(self): + return self.patchnamele.text() + + def getCmd(self, cwd): + cmd = ['pnew', '--cwd', cwd, hglib.fromunicode(self.patchname())] + optList = [('patchtext','--text'), + ('patchdate','--date'), + ('patchuser','--user')] + for v,o in optList: + if getattr(self,v+'cb').isChecked(): + cmd.extend([o,hglib.fromunicode(getattr(self,v+'le').text())]) + return cmd