comparison hgext/evolve.py @ 1501:5c962163f77a stable

prune: ensure we prune bookmarks in a transaction
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 14 Sep 2015 13:23:43 -0700
parents ee5391999f2d
children e8f7e4c53537
comparison
equal deleted inserted replaced
1490:bc7eec65dfcf 1501:5c962163f77a
2111 revs = set(revs) 2111 revs = set(revs)
2112 revs.update(set(rsrevs)) 2112 revs.update(set(rsrevs))
2113 revs = sorted(revs) 2113 revs = sorted(revs)
2114 return marks, revs 2114 return marks, revs
2115 2115
2116 def _deletebookmark(ui, marks, mark): 2116 def _deletebookmark(repo, marks, mark):
2117 del marks[mark] 2117 wlock = lock = tr = None
2118 marks.write() 2118 try:
2119 ui.write(_("bookmark '%s' deleted\n") % mark) 2119 wlock = repo.wlock()
2120 lock = repo.lock()
2121 tr = repo.transaction('prune')
2122 del marks[mark]
2123 marks.recordchange(tr)
2124 tr.close()
2125 repo.ui.write(_("bookmark '%s' deleted\n") % mark)
2126 finally:
2127 lockmod.release(tr, lock, wlock)
2120 2128
2121 2129
2122 2130
2123 def _getmetadata(**opts): 2131 def _getmetadata(**opts):
2124 metadata = {} 2132 metadata = {}
2168 2176
2169 if bookmark: 2177 if bookmark:
2170 marks,revs = _reachablefrombookmark(repo, revs, bookmark) 2178 marks,revs = _reachablefrombookmark(repo, revs, bookmark)
2171 if not revs: 2179 if not revs:
2172 # no revisions to prune - delete bookmark immediately 2180 # no revisions to prune - delete bookmark immediately
2173 _deletebookmark(ui, marks, bookmark) 2181 _deletebookmark(repo, marks, bookmark)
2174 2182
2175 if not revs: 2183 if not revs:
2176 raise util.Abort(_('nothing to prune')) 2184 raise util.Abort(_('nothing to prune'))
2177 2185
2178 wlock = lock = tr = None 2186 wlock = lock = tr = None
2262 if movebookmark: 2270 if movebookmark:
2263 bmactivate(repo, bookactive) 2271 bmactivate(repo, bookactive)
2264 2272
2265 # update bookmarks 2273 # update bookmarks
2266 if bookmark: 2274 if bookmark:
2267 _deletebookmark(ui, marks, bookmark) 2275 _deletebookmark(repo, marks, bookmark)
2268 2276
2269 # create markers 2277 # create markers
2270 obsolete.createmarkers(repo, relations, metadata=metadata) 2278 obsolete.createmarkers(repo, relations, metadata=metadata)
2271 2279
2272 # informs that changeset have been pruned 2280 # informs that changeset have been pruned