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

commit: use cmdui.Runner for commit and repowidget

Changeset 137ec39da006

Parent 3b0d275f9122

by Steve Borho

Changes to 2 files · Browse files at 137ec39da006 Showing diff from parent 3b0d275f9122 Diff from another changeset...

 
21
22
23
24
25
26
27
 
36
37
38
39
 
40
41
42
 
47
48
49
 
 
 
50
51
52
 
455
456
457
458
459
460
461
462
 
463
464
465
466
 
467
468
469
 
529
530
531
532
 
533
534
535
 
540
541
542
543
 
544
545
546
 
554
555
556
557
 
558
559
560
 
564
565
566
567
568
569
 
 
 
 
 
 
 
 
 
 
570
571
572
573
574
575
576
577
578
579
580
 
21
22
23
 
24
25
26
 
35
36
37
 
38
39
40
41
 
46
47
48
49
50
51
52
53
54
 
457
458
459
 
460
461
462
 
463
464
465
466
 
467
468
469
470
 
530
531
532
 
533
534
535
536
 
541
542
543
 
544
545
546
547
 
555
556
557
 
558
559
560
561
 
565
566
567
 
 
 
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
 
 
 
583
584
585
@@ -21,7 +21,6 @@
 from tortoisehg.hgqt.sync import loadIniFile    # Technical Debt for CommitWidget -# threaded / wrapped commit (need a CmdRunner equivalent)  # qtlib decode failure dialog (ask for retry locale, suggest HGENCODING)  # Need a unicode-to-UTF8 function  # +1 / -1 head indication (not as important with workbench integration) @@ -36,7 +35,7 @@
  showMessage = pyqtSignal(str)   commitComplete = pyqtSignal()   - def __init__(self, pats, opts, root=None, parent=None): + def __init__(self, pats, opts, root=None, parent=None, logwidget=None):   QWidget.__init__(self, parent)     self.opts = opts # user, date @@ -47,6 +46,9 @@
  self.msghistory = []   self.qref = False   + self.runner = cmdui.Runner(_('Commit'), self, logwidget) + self.runner.commandFinished.connect(self.commandFinished) +   repo = self.stwidget.repo   self.opts['pushafter'] = repo.ui.config('tortoisehg', 'cipushafter', '')   self.opts['autoinc'] = repo.ui.config('tortoisehg', 'autoinc', '') @@ -455,15 +457,14 @@
    def commit(self):   repo = self.stwidget.repo - ui = repo.ui   cwd = os.getcwd()   try:   os.chdir(repo.root) - return self._commit(repo, ui) + return self._commit(repo)   finally:   os.chdir(cwd)   - def _commit(self, repo, _ui): + def _commit(self, repo):   msg = self.getMessage()   if not msg:   qtlib.WarningMsgBox(_('Nothing Commited'), @@ -529,7 +530,7 @@
  (_('&OK'), _('Cancel')), 0, 1,   checkedUnknowns).run()   if res == 0: - dispatch._dispatch(_ui, ['add'] + checkedUnknowns) + dispatch._dispatch(repo.ui, ['add'] + checkedUnknowns)   else:   return   checkedMissing = self.stwidget.getChecked('!') @@ -540,7 +541,7 @@
  (_('&OK'), _('Cancel')), 0, 1,   checkedMissing).run()   if res == 0: - dispatch._dispatch(_ui, ['remove'] + checkedMissing) + dispatch._dispatch(repo.ui, ['remove'] + checkedMissing)   else:   return   try: @@ -554,7 +555,7 @@
  self.showMessage.emit(hglib.tounicode(str(e)))   dcmd = []   - cmdline = ['commit', '--user', user, '--message', msg] + cmdline = ['commit', '--verbose', '--user', user, '--message', msg]   cmdline += dcmd + brcmd + files   if self.qref:   cmdline[0] = 'qrefresh' @@ -564,17 +565,21 @@
  if fname:   cmdline.extend(['--include', fname])   - # TODO: self.opts['pushafter'] - ret = dispatch._dispatch(_ui, cmdline) - if not ret: + if self.opts.get('pushafter'): + pushcmd = ['push', self.opts['pushafter']] + display = ' '.join(['hg'] + cmdline + ['&&'] + pushcmd) + self.runner.run(cmdline, pushcmd, display=display) + else: + display = ' '.join(['hg'] + cmdline) + self.runner.run(cmdline, display=display) + + def commandFinished(self, wrapper): + if not wrapper.data:   self.addMessageToHistory()   if not self.qref:   self.msgte.clear()   self.msgte.document().setModified(False)   self.commitComplete.emit() - return True - else: - return False     def keyPressEvent(self, event):   if event.key() in (Qt.Key_Return, Qt.Key_Enter):
 
132
133
134
135
 
 
136
137
138
 
561
562
563
564
 
565
566
567
 
569
570
571
572
 
573
574
575
 
132
133
134
 
135
136
137
138
139
 
562
563
564
 
565
566
567
568
 
570
571
572
 
573
574
575
576
@@ -132,7 +132,8 @@
  pats = {}   opts = {}   b = QPushButton('Commit') - cw = CommitWidget(pats, opts, root=self.repo.root) + cw = CommitWidget(pats, opts, self.repo.root, self, + self.workbench.log)   cw.showMessage.connect(self.showMessage)   cw.commitComplete.connect(self.reload)   cw.commitComplete.connect(cw.reload) @@ -561,7 +562,7 @@
  _('Previous command is still running'))   return   saved = self.setScanForRepoChanges(False) - self.runner = cmdui.Runner(title, self) + self.runner = cmdui.Runner(title, self, self.workbench.log)   def finished(ret):   self.reload()   self.setScanForRepoChanges(saved) @@ -569,7 +570,7 @@
  # When we run commands, we typically change working parent   self.commitDemand.forward('reload')   self.runner.commandFinished.connect(finished) - self.runner.run(cmdline) + self.runner.run(cmdline, display='hg ' + ' '.join(cmdline))     ##   ## Repoview context menu