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

stable shelve: add clear buttons for both sides for shelves and the working copy

Changeset 0eb7b184bd74

Parent 53d570c1ebf3

by Steve Borho

Changes to one file · Browse files at 0eb7b184bd74 Showing diff from parent 53d570c1ebf3 Diff from another changeset...

 
8
9
10
 
 
11
12
13
 
58
59
60
 
 
 
61
62
63
64
 
65
66
67
 
83
84
85
 
 
 
86
87
88
89
 
90
91
92
 
270
271
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
274
275
 
283
284
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
287
288
 
352
353
354
 
355
356
357
 
361
362
363
 
364
365
366
 
367
368
369
 
372
373
374
 
375
376
377
 
8
9
10
11
12
13
14
15
 
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
 
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
 
401
402
403
404
405
406
407
 
411
412
413
414
415
416
417
418
419
420
421
 
424
425
426
427
428
429
430
@@ -8,6 +8,8 @@
 import os  import time   +from mercurial import commands, error +  from tortoisehg.util import hglib  from tortoisehg.util.patchctx import patchctx  from tortoisehg.hgqt.i18n import _ @@ -58,10 +60,14 @@
  avbox.addLayout(ahbox)   self.comboa = QComboBox(self)   self.comboa.currentIndexChanged.connect(self.comboAChanged) + self.clearShelfButtonA = QPushButton(_('Clear')) + self.clearShelfButtonA.setToolTip(_('Clear the current shelf file')) + self.clearShelfButtonA.clicked.connect(self.clearShelfA)   self.delShelfButtonA = QPushButton(_('Delete'))   self.delShelfButtonA.setToolTip(_('Delete the current shelf file'))   self.delShelfButtonA.clicked.connect(self.deleteShelfA)   ahbox.addWidget(self.comboa, 1) + ahbox.addWidget(self.clearShelfButtonA)   ahbox.addWidget(self.delShelfButtonA)     self.browsea = chunks.ChunksWidget(repo, self) @@ -83,10 +89,14 @@
  bvbox.addLayout(bhbox)   self.combob = QComboBox(self)   self.combob.currentIndexChanged.connect(self.comboBChanged) + self.clearShelfButtonB = QPushButton(_('Clear')) + self.clearShelfButtonB.setToolTip(_('Clear the current shelf file')) + self.clearShelfButtonB.clicked.connect(self.clearShelfB)   self.delShelfButtonB = QPushButton(_('Delete'))   self.delShelfButtonB.setToolTip(_('Delete the current shelf file'))   self.delShelfButtonB.clicked.connect(self.deleteShelfB)   bhbox.addWidget(self.combob, 1) + bhbox.addWidget(self.clearShelfButtonB)   bhbox.addWidget(self.delShelfButtonB)     self.browseb = chunks.ChunksWidget(repo, self) @@ -270,6 +280,30 @@
  self.refreshCombos()     @pyqtSlot() + def clearShelfA(self): + if self.comboa.currentIndex() == 0: + if not qtlib.QuestionMsgBox(_('Are you sure?'), + _('Revert all working copy changes?')): + return + try: + commands.revert(self.repo.ui, self.repo, all=True) + except (EnvironmentError, error.Abort), e: + self.showMessage(hglib.tounicode(str(e))) + return + shelf = self.currentPatchA() + ushelf = hglib.tounicode(os.path.basename(shelf)) + if not qtlib.QuestionMsgBox(_('Are you sure?'), + _('Clear contents of shelf file %s?') % ushelf): + return + try: + f = open(shelf, "w") + f.close() + self.showMessage(_('Shelf cleared')) + except EnvironmentError, e: + self.showMessage(hglib.tounicode(str(e))) + self.refreshCombos() + + @pyqtSlot()   def deleteShelfB(self):   shelf = self.currentPatchB()   ushelf = hglib.tounicode(os.path.basename(shelf)) @@ -283,6 +317,21 @@
  self.showMessage(hglib.tounicode(str(e)))   self.refreshCombos()   + @pyqtSlot() + def clearShelfB(self): + shelf = self.currentPatchB() + ushelf = hglib.tounicode(os.path.basename(shelf)) + if not qtlib.QuestionMsgBox(_('Are you sure?'), + _('Clear contents of shelf file %s?') % ushelf): + return + try: + f = open(shelf, "w") + f.close() + self.showMessage(_('Shelf cleared')) + except EnvironmentError, e: + self.showMessage(hglib.tounicode(str(e))) + self.refreshCombos() +   def currentPatchA(self):   idx = self.comboa.currentIndex()   if idx == -1: @@ -352,6 +401,7 @@
  self.comboBChanged(idxb)   if not patches and not shelves:   self.delShelfButtonB.setEnabled(False) + self.clearShelfButtonB.setEnabled(False)   self.browseb.setContext(patchctx('', self.repo, None))     @pyqtSlot(int) @@ -361,9 +411,11 @@
  if index == 0:   rev = None   self.delShelfButtonA.setEnabled(False) + self.clearShelfButtonA.setEnabled(True)   else:   rev = self.currentPatchA()   self.delShelfButtonA.setEnabled(index <= len(self.shelves)) + self.clearShelfButtonA.setEnabled(index <= len(self.shelves))   self.browsea.setContext(self.repo.changectx(rev))     @pyqtSlot(int) @@ -372,6 +424,7 @@
  return   rev = self.currentPatchB()   self.delShelfButtonB.setEnabled(index < len(self.shelves)) + self.clearShelfButtonB.setEnabled(index < len(self.shelves))   self.browseb.setContext(self.repo.changectx(rev))     @pyqtSlot(int, int)