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

commit: add undo/rollback functions

Changeset fb2d2cb2b1f9

Parent 7517f1afa52e

by Steve Borho

Changes to one file · Browse files at fb2d2cb2b1f9 Showing diff from parent 7517f1afa52e Diff from another changeset...

 
21
22
23
24
25
26
27
 
113
114
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
117
118
 
21
22
23
 
24
25
26
 
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
@@ -21,7 +21,6 @@
 # qrefresh support  # threaded / wrapped commit (need a CmdRunner equivalent)  # qctlib decode failure dialog (ask for retry locale, suggest HGENCODING) -# add rollback function with prompt  # +1 / -1 head indication (not as important with workbench integration)  # recent committers history  # pushafterci, autoincludes list @@ -113,6 +112,32 @@
  def saveState(self):   return self.stwidget.saveState()   + def canUndo(self): + 'Returns undo description or None if not valid' + repo = self.stwidget.repo + if os.path.exists(self.repo.sjoin('undo')): + try: + args = self.repo.opener('undo.desc', 'r').read().splitlines() + if args[1] != 'commit': + return None + return _('Rollback commit to revision %d') % (int(args[0]) - 1) + except (IOError, IndexError, ValueError): + pass + return None + + def rollback(self): + msg = self.canUndo() + if not msg: + return + d = QMessageBox.question(self, _('Confirm Undo'), msg, + QMessageBox.Ok | QMessageBox.Cancel) + if d != QMessageBox.Ok: + return + repo = self.stwidget.repo + repo.rollback() + self.stwidget.refreshWctx() + QTimer.singleShot(500, lambda: shlib.shell_notify([repo.root])) +   def getMessage(self):   text = self.msgte.toPlainText()   try: