comparison mercurial/localrepo.py @ 18310:4499ba5ac35c

localrepo: introduce destroying function
author Idan Kamara <idankk86@gmail.com>
date Sat, 15 Dec 2012 20:08:13 +0200
parents cfeab932cff7
children 084074648755
comparison
equal deleted inserted replaced
18309:cfeab932cff7 18310:4499ba5ac35c
893 ui.status(msg) 893 ui.status(msg)
894 if dryrun: 894 if dryrun:
895 return 0 895 return 0
896 896
897 parents = self.dirstate.parents() 897 parents = self.dirstate.parents()
898 self.destroying()
898 transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn) 899 transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
899 if os.path.exists(self.join('undo.bookmarks')): 900 if os.path.exists(self.join('undo.bookmarks')):
900 util.rename(self.join('undo.bookmarks'), 901 util.rename(self.join('undo.bookmarks'),
901 self.join('bookmarks')) 902 self.join('bookmarks'))
902 if os.path.exists(self.sjoin('undo.phaseroots')): 903 if os.path.exists(self.sjoin('undo.phaseroots')):
1375 return n 1376 return n
1376 finally: 1377 finally:
1377 if tr: 1378 if tr:
1378 tr.release() 1379 tr.release()
1379 lock.release() 1380 lock.release()
1381
1382 @unfilteredmethod
1383 def destroying(self):
1384 '''Inform the repository that nodes are about to be destroyed.
1385 Intended for use by strip and rollback, so there's a common
1386 place for anything that has to be done before destroying history.
1387
1388 This is mostly useful for saving state that is in memory and waiting
1389 to be flushed when the current lock is released. Because a call to
1390 destroyed is imminent, the repo will be invalidated causing those
1391 changes to stay in memory (waiting for the next unlock), or vanish
1392 completely.
1393 '''
1394 pass
1380 1395
1381 @unfilteredmethod 1396 @unfilteredmethod
1382 def destroyed(self, newheadnodes=None): 1397 def destroyed(self, newheadnodes=None):
1383 '''Inform the repository that nodes have been destroyed. 1398 '''Inform the repository that nodes have been destroyed.
1384 Intended for use by strip and rollback, so there's a common 1399 Intended for use by strip and rollback, so there's a common