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

repowidget: implement rollback operation

Tries to be more friendly than GTK version, warns of possible
side-effects.

Changeset 106e4b77de10

Parent e6bfdb673802

by Steve Borho

Changes to one file · Browse files at 106e4b77de10 Showing diff from parent e6bfdb673802 Diff from another changeset...

 
11
12
13
14
 
15
16
17
 
18
19
20
 
135
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140
141
 
11
12
13
 
14
15
16
 
17
18
19
20
 
135
136
137
 
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@@ -11,10 +11,10 @@
 import binascii  import os   -from tortoisehg.util import thgrepo +from tortoisehg.util import thgrepo, shlib, hglib    from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt.qtlib import geticon, getfont, QuestionMsgBox +from tortoisehg.hgqt.qtlib import geticon, getfont, QuestionMsgBox, InfoMsgBox  from tortoisehg.hgqt.repomodel import HgRepoListModel  from tortoisehg.hgqt import cmdui, update, tag, backout, merge  from tortoisehg.hgqt import archive, thgstrip, run @@ -135,7 +135,51 @@
  dlg.exec_()     def rollback(self): - pass + def read_undo(): + 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 args[1], int(args[0])-1 + except (IOError, IndexError, ValueError): + pass + return None + data = read_undo() + if data is None: + InfoMsgBox(_('No transaction available'), + _('There is no rollback transaction available')) + return + elif data[0] == 'commit': + if not QuestionMsgBox(_('Undo last commit?'), + _('Undo most recent commit (%d), preserving file changes?') % + data[1]): + return + else: + if not QuestionMsgBox(_('Undo last transaction?'), + _('Rollback to revision %d (undo %s)?') % + (data[1], data[0])): + return + try: + rev = self.repo['.'].rev() + except Exception, e: + InfoMsgBox(_('Repository Error'), + _('Unable to determine working copy revision\n') + + hglib.tounicode(e)) + return + if rev > data[1] and not QuestionMsgBox( + _('Remove current working revision?'), + _('Your current working revision (%d) will be removed ' + 'by this rollback, leaving uncommitted changes.\n ' + 'Continue?' % rev)): + return + saved = self.repo.ui.quiet + self.repo.ui.quiet = True + self.repo.rollback() + self.repo.ui.quiet = saved + self.reload() + QTimer.singleShot(500, lambda: shlib.shell_notify([self.repo.root])) +     def purge(self):   pass