comparison mercurial/bookmarks.py @ 14266:89e7d35e0ef0 stable

fix bookmarks rollback behavior Before this patch undo.bookmarks was created on bookmarks write and not with other transaction-related files. There were two issues: first is that if you have changed bookmarks few times after a transaction happened, rollback will give you a state which can point to non-existing revision. Second is that if you have not changed bookmarks after a transaction, rollback will touch your state anyway. This change also adds `localrepo._writejournal` method, which can be used by other extensions to save their transaction-related backup in right time.
author Alexander Solovyov <alexander@solovyov.net>
date Sun, 01 May 2011 13:07:00 +0200
parents 71a96f6c205d
children a55a0045704c
comparison
equal deleted inserted replaced
14211:b00ab6890fe9 14266:89e7d35e0ef0
58 58
59 We also store a backup of the previous state in undo.bookmarks that 59 We also store a backup of the previous state in undo.bookmarks that
60 can be copied back on rollback. 60 can be copied back on rollback.
61 ''' 61 '''
62 refs = repo._bookmarks 62 refs = repo._bookmarks
63
64 try:
65 bms = repo.opener('bookmarks').read()
66 except IOError:
67 bms = ''
68 repo.opener('undo.bookmarks', 'w').write(bms)
69 63
70 if repo._bookmarkcurrent not in refs: 64 if repo._bookmarkcurrent not in refs:
71 setcurrent(repo, None) 65 setcurrent(repo, None)
72 for mark in refs.keys(): 66 for mark in refs.keys():
73 if not valid(mark): 67 if not valid(mark):