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

quickop: adopt * imports of PyQt4

Changeset 37b6b0324f7a

Parent 3bb72638884e

by Steve Borho

Changes to one file · Browse files at 37b6b0324f7a Showing diff from parent 3bb72638884e Diff from another changeset...

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
112
113
 
114
115
116
117
118
119
120
 
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
141
142
143
 
144
145
146
147
148
149
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
 
112
113
114
 
115
116
117
118
119
120
121
 
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
 
142
143
144
 
145
146
147
148
149
150
151
 # quickop.py - TortoiseHg's dialog for quick dirstate operations  #  # Copyright 2009 Steve Borho <steve@borho.org>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import os    from mercurial import hg, ui, cmdutil, util   -from PyQt4 import QtCore, QtGui +from PyQt4.QtCore import * +from PyQt4.QtGui import *    from tortoisehg.hgqt.i18n import _  from tortoisehg.util import hglib, shlib, paths    from tortoisehg.hgqt import qtlib, status, cmdui    LABELS = { 'add': (_('Checkmark files to add'), _('Add')),   'forget': (_('Checkmark files to forget'), _('Forget')),   'revert': (_('Checkmark files to revert'), _('Revert')),   'remove': (_('Checkmark files to remove'), _('Remove')),}   -class QuickOpDialog(QtGui.QDialog): +class QuickOpDialog(QDialog):   """ Dialog for performing quick dirstate operations """   def __init__(self, command, pats, parent=None): - QtGui.QDialog.__init__(self, parent) - self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) + QDialog.__init__(self, parent) + self.setWindowFlags(self.windowFlags() & + ~Qt.WindowContextHelpButtonHint)   self.pats = pats     # Handle rm alias   if command == 'rm':   command = 'remove'   self.command = command     repo = hg.repository(ui.ui(), path=paths.find_root())   assert repo   os.chdir(repo.root)   self.setWindowTitle('%s - hg %s' % (hglib.get_reponame(repo), command))   - layout = QtGui.QVBoxLayout() + layout = QVBoxLayout()   self.setLayout(layout)   - lbl = QtGui.QLabel(LABELS[command][0]) - layout.addWidget(lbl) + hbox = QHBoxLayout() + lbl = QLabel(LABELS[command][0]) + slbl = QLabel() + hbox.addWidget(lbl) + hbox.addStretch(1) + hbox.addWidget(slbl) + self.status_label = slbl + layout.addLayout(hbox)     types = { 'add' : 'I?',   'forget' : 'MAR!C',   'revert' : 'MAR!',   'remove' : 'MAR!CI?',   }   filetypes = types[self.command]     opts = {}   for s, val in status.statusTypes.iteritems():   opts[val.name] = s in filetypes     stwidget = status.StatusWidget(pats, opts, repo.root, self)   layout.addWidget(stwidget, 1)     if self.command == 'revert':   ## no backup checkbox - chk = QtGui.QCheckBox(_('Do not save backup files (*.orig)')) + chk = QCheckBox(_('Do not save backup files (*.orig)'))   self.chk = chk   layout.addWidget(chk)   - BB = QtGui.QDialogButtonBox - bb = QtGui.QDialogButtonBox(BB.Ok|BB.Cancel) - self.connect(bb, QtCore.SIGNAL("accepted()"), - self, QtCore.SLOT("accept()")) - self.connect(bb, QtCore.SIGNAL("rejected()"), - self, QtCore.SLOT("reject()")) + BB = QDialogButtonBox + bb = QDialogButtonBox(BB.Ok|BB.Cancel) + self.connect(bb, SIGNAL("accepted()"), self, SLOT("accept()")) + self.connect(bb, SIGNAL("rejected()"), self, SLOT("reject()"))   bb.button(BB.Ok).setDefault(True)   bb.button(BB.Ok).setText(LABELS[command][1])   layout.addWidget(bb)   self.bb = bb     cmd = cmdui.Widget()   cmd.commandStarted.connect(self.commandStarted)   cmd.commandFinished.connect(self.commandFinished)   cmd.commandCanceling.connect(self.commandCanceled)   layout.addWidget(cmd)   cmd.setHidden(True)   self.cmd = cmd   - s = QtCore.QSettings() + s = QSettings()   stwidget.restoreState(s.value('quickop/state').toByteArray())   self.restoreGeometry(s.value('quickop/geom').toByteArray())   self.stwidget = stwidget   - self.connect(self.stwidget, QtCore.SIGNAL('errorMessage'), - self.errorMessage) - - def errorMessage(self, msg): - # TODO: Does not appear to work - self.cmd.pmon.set_text(msg) + self.connect(self.stwidget, SIGNAL('errorMessage'), + self.cmd.pmon.set_text)     def keyPressEvent(self, event): - if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): - if event.modifiers() == QtCore.Qt.ControlModifier: + if event.key() in (Qt.Key_Return, Qt.Key_Enter): + if event.modifiers() == Qt.ControlModifier:   self.accept() # Ctrl+Enter   return - elif event.key() == QtCore.Qt.Key_Escape: + elif event.key() == Qt.Key_Escape:   self.reject()   return - return super(QtGui.QDialog, self).keyPressEvent(event) + return super(QDialog, self).keyPressEvent(event)     def commandStarted(self):   self.cmd.setShown(True) - self.bb.button(QtGui.QDialogButtonBox.Ok).setEnabled(False) + self.bb.button(QDialogButtonBox.Ok).setEnabled(False)     def commandFinished(self, wrapper): - self.bb.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) + self.bb.button(QDialogButtonBox.Ok).setEnabled(True)   if wrapper.data is not 0:   self.cmd.show_output(True)   else:   self.reject()     def commandCanceled(self): - self.bb.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) + self.bb.button(QDialogButtonBox.Ok).setEnabled(True)     def accept(self):   cmdline = [self.command]   if hasattr(self, 'chk') and self.chk.isChecked():   cmdline.append('--no-backup')   files = self.stwidget.getChecked()   if files:   cmdline.extend(files)   else:   qtlib.WarningMsgBox(_('No files selected'),   _('No operation to perform'),   parent=self)   return   self.cmd.run(cmdline)     def reject(self):   if self.cmd.core.is_running():   self.cmd.core.cancel()   else: - s = QtCore.QSettings() + s = QSettings()   s.setValue('quickop/state', self.stwidget.saveState())   s.setValue('quickop/geom', self.saveGeometry()) - QtGui.QDialog.reject(self) + QDialog.reject(self)    def run(ui, *pats, **opts):   pats = hglib.canonpaths(pats)   if opts.get('canonpats'):   pats = list(pats) + opts['canonpats']   return QuickOpDialog(opts.get('alias'), pats)