Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable bookmarks: use cmdui.Widget to run bookmark commands

The layout and responses of this dialog could be improved, but in general all
commands like these should go through a cmdui instance in case the user has
configured hooks.

Changeset bcd080439cf8

Parent baf41482ab3f

by Steve Borho

Changes to 2 files · Browse files at bcd080439cf8 Showing diff from parent baf41482ab3f Diff from another changeset...

 
14
15
16
17
18
 
19
20
21
22
23
 
 
 
24
25
26
 
107
108
109
 
 
 
 
 
 
 
110
111
112
 
127
128
129
130
131
132
133
134
135
 
 
 
 
136
137
138
 
143
144
145
146
 
147
148
149
 
162
163
164
165
 
166
167
168
 
177
178
179
 
 
 
 
 
 
180
181
182
183
 
184
185
186
187
188
189
190
191
 
 
 
 
 
192
193
194
195
196
 
 
 
 
 
197
198
199
200
201
 
202
203
204
205
206
207
208
 
 
 
 
 
209
210
211
212
213
 
 
 
 
214
215
216
217
 
218
219
220
221
 
222
223
224
225
 
226
227
228
229
230
231
232
233
 
 
 
 
 
 
 
234
235
236
237
238
239
 
 
 
 
240
241
242
 
14
15
16
 
 
17
18
19
20
21
22
23
24
25
26
27
28
 
109
110
111
112
113
114
115
116
117
118
119
120
121
 
136
137
138
 
 
 
 
 
 
139
140
141
142
143
144
145
 
150
151
152
 
153
154
155
156
 
169
170
171
 
172
173
174
175
 
184
185
186
187
188
189
190
191
192
193
194
195
 
196
197
198
199
200
 
 
 
 
201
202
203
204
205
206
 
 
 
 
207
208
209
210
211
212
213
214
215
 
216
217
218
219
 
 
 
 
220
221
222
223
224
225
 
 
 
 
226
227
228
229
230
231
232
 
233
234
235
236
 
237
238
239
240
 
241
242
243
244
245
 
 
 
 
246
247
248
249
250
251
252
253
 
 
 
 
 
254
255
256
257
258
259
260
@@ -14,13 +14,15 @@
   from tortoisehg.util import hglib, i18n  from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt import qtlib -from hgext import bookmarks +from tortoisehg.hgqt import qtlib, cmdui    keep = i18n.keepgettext()    class BookmarkDialog(QDialog):   showMessage = pyqtSignal(QString) + output = pyqtSignal(QString, QString) + progress = pyqtSignal(QString, object, QString, QString, object) + makeLogVisible = pyqtSignal(bool)     def __init__(self, repo, rev, parent):   super(BookmarkDialog, self).__init__(parent) @@ -107,6 +109,13 @@
  self.setWindowTitle(_('Bookmark - %s') % self.repo.displayname)   self.setWindowIcon(qtlib.geticon('bookmark'))   + self.cmd = cmdui.Widget(True, self) + self.cmd.output.connect(self.output) + self.cmd.makeLogVisible.connect(self.makeLogVisible) + self.cmd.progress.connect(self.progress) + self.cmd.commandFinished.connect(self.commandFinished) + box.addWidget(self.cmd) +   # prepare to show   self.clear_status()   self.update_bookmark_combo(clear=False) @@ -127,12 +136,10 @@
  self.bookmark_combo.clear()     # add bookmarks to drop-down list - bookmarks = self.repo.bookmarks.keys()[:] - bookmarks.sort() - bookmarks.reverse() - for bookmark in bookmarks: - if bookmark == 'tip': - continue + marks = self.repo._bookmarks.keys()[:] + marks.sort() + marks.reverse() + for bookmark in marks:   self.bookmark_combo.addItem(hglib.tounicode(bookmark))   self.bookmark_combo.clearEditText()   @@ -143,7 +150,7 @@
  def toggle_new_bookmark(self):   bookmark = self.bookmark_combo.currentText()   bookmarklocal = hglib.fromunicode(bookmark) - is_new = bookmarklocal not in self.repo.bookmarks + is_new = bookmarklocal not in self.repo._bookmarks   self.add_btn.setVisible(is_new)   self.add_btn.setDisabled(not is_new)   self.remove_btn.setVisible(not is_new) @@ -162,7 +169,7 @@
  try:   # check if valid revision, tag, or branch   self.repo[hglib.fromunicode(revstr)] - except (error.LookupError, error.RepoLookupError, error.RepoError): + except (error.LookupError, error.RepoError):   self.add_btn.setDisabled(True)   self.remove_btn.setDisabled(True)   self.rename_btn.setDisabled(True) @@ -177,66 +184,77 @@
  self.status.setHidden(True)   self.sep.setHidden(True)   + def commandFinished(self, ret): + if ret is 0: + self.finishfunc() + self.repo.incrementBusyCount() + self.repo.decrementBusyCount() +   def add_bookmark(self):   bookmark = self.bookmark_combo.currentText()   bookmarklocal = hglib.fromunicode(bookmark) - if bookmarklocal in self.repo.bookmarks: + if bookmarklocal in self.repo._bookmarks:   self.set_status(_('A bookmark named "%s" already exists') %   bookmark, False)   return   - bookmarks.bookmark(ui=self.repo.ui, - repo=self.repo, - rev=self.initial_rev, - mark=bookmarklocal) + def finished(): + self.bookmark_combo.addItem(bookmark) + self.set_status(_("Bookmark '%s' has been added") % bookmark, True) + self.toggle_new_bookmark() + self.bookmark_combo.clearEditText()   - self.bookmark_combo.addItem(bookmark) - self.set_status(_("Bookmark '%s' has been added") % bookmark, True) - self.toggle_new_bookmark() - self.bookmark_combo.clearEditText() + cmdline = ['bookmark', '--repository', self.repo.root, + '--rev', self.initial_rev, bookmarklocal] + self.cmd.run(cmdline) + self.finishfunc = finished +     def remove_bookmark(self):   bookmark = self.bookmark_combo.currentText()   bookmarklocal = hglib.fromunicode(bookmark) - if not bookmarklocal in self.repo.bookmarks: + if not bookmarklocal in self.repo._bookmarks:   self.set_status(_("Bookmark '%s' does not exist") % bookmark, False)   return   - bookmarks.bookmark(ui=self.repo.ui, - repo=self.repo, - mark=bookmarklocal, - delete=True) + def finished(): + self.bookmark_combo.removeItem(self.bookmark_combo.currentIndex()) + self.new_name_text.setText("") + self.set_status(_("Bookmark '%s' has been removed") % bookmark, True) + self.update_sensitives()   - self.bookmark_combo.removeItem(self.bookmark_combo.currentIndex()) - self.new_name_text.setText("") - self.set_status(_("Bookmark '%s' has been removed") % bookmark, True) - self.update_sensitives() + cmdline = ['bookmark', '--repository', self.repo.root, + '--delete', bookmarklocal] + self.cmd.run(cmdline) + self.finishfunc = finished     def rename_bookmark(self):   name = self.bookmark_combo.currentText() - bookmarklocal = hglib.fromunicode(bookmark) + namelocal = hglib.fromunicode(name)     newname = self.new_name_text.text()   newnamelocal = hglib.fromunicode(newname) - if not bookmarklocal in self.repo.bookmarks: + if not namelocal in self.repo._bookmarks:   self.set_status(_("Bookmark '%s' does not exist") % name, False)   return   - if newnamelocal in self.repo.bookmarks: + if newnamelocal in self.repo._bookmarks:   self.set_status(_('A bookmark named "%s" already exists') %   newname, False)   return   - bookmarks.bookmark(ui=self.repo.ui, - repo=self.repo, - mark=newnamelocal, - rename=namelocal) + def finished(): + self.bookmark_combo.removeItem(self.bookmark_combo.currentIndex()) + self.bookmark_combo.addItem(newname) + self.new_name_text.setText("") + self.set_status(_("Bookmark '%s' has been renamed to '%s'") % + (name, newname), True) + self.update_sensitives()   - self.bookmark_combo.removeItem(self.bookmark_combo.currentIndex()) - self.bookmark_combo.addItem(newname) - self.new_name_text.setText("") - self.set_status(_("Bookmark '%s' has been renamed to '%s'") % - (name, newname), True) + cmdline = ['bookmark', '--repository', self.repo.root, + '--rename', namelocal, newnamelocal] + self.cmd.run(cmdline) + self.finishfunc = finished     @pyqtSlot(QString)   def new_bookmark_changed(self, value):
 
1082
1083
1084
 
 
 
1085
1086
1087
 
1082
1083
1084
1085
1086
1087
1088
1089
1090
@@ -1082,6 +1082,9 @@
  def bookmarkRevision(self):   dlg = bookmark.BookmarkDialog(self.repo, str(self.rev), self)   dlg.showMessage.connect(self.showMessage) + dlg.output.connect(self.output) + dlg.makeLogVisible.connect(self.makeLogVisible) + dlg.progress.connect(self.progress)   dlg.finished.connect(dlg.deleteLater)   dlg.exec_()