##// END OF EJS Templates
shelve: add utility to abort current transaction but keep dirstate...
FUJIWARA Katsunori -
r26522:10f14bb2 default
parent child Browse files
Show More
@@ -190,6 +190,35 b' def cleanupoldbackups(repo):'
190 if err.errno != errno.ENOENT:
190 if err.errno != errno.ENOENT:
191 raise
191 raise
192
192
193 def _aborttransaction(repo):
194 '''Abort current transaction for shelve/unshelve, but keep dirstate
195 '''
196 backupname = 'dirstate.shelve'
197 dirstatebackup = None
198 try:
199 # create backup of (un)shelved dirstate, because aborting transaction
200 # should restore dirstate to one at the beginning of the
201 # transaction, which doesn't include the result of (un)shelving
202 fp = repo.vfs.open(backupname, "w")
203 dirstatebackup = backupname
204 # clearing _dirty/_dirtypl of dirstate by _writedirstate below
205 # is unintentional. but it doesn't cause problem in this case,
206 # because no code path refers them until transaction is aborted.
207 repo.dirstate._writedirstate(fp) # write in-memory changes forcibly
208
209 tr = repo.currenttransaction()
210 tr.abort()
211
212 # TODO: this should be done via transaction.abort()
213 repo.dirstate.invalidate() # prevent wlock from writing changes out
214
215 # restore to backuped dirstate
216 repo.vfs.rename(dirstatebackup, 'dirstate')
217 dirstatebackup = None
218 finally:
219 if dirstatebackup:
220 repo.vfs.unlink(dirstatebackup)
221
193 def createcmd(ui, repo, pats, opts):
222 def createcmd(ui, repo, pats, opts):
194 """subcommand that creates a new shelve"""
223 """subcommand that creates a new shelve"""
195
224
General Comments 0
You need to be logged in to leave comments. Login now