Mercurial > hg
comparison mercurial/phases.py @ 22069:616a455b02ca
phase: add a transaction argument to advanceboundary
We now pass a transaction option to this phase movement function. The object
is currently not used by the function, but it will be in the future.
All call sites have been updated. Most call sites were already enclosed in a
transaction for a long time. The handful of others have been recently
updated in previous commit.
The retractboundary function remains to be upgraded.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 06 Aug 2014 01:54:19 -0700 |
parents | 793f9276aeb9 |
children | c1ca47204590 |
comparison
equal
deleted
inserted
replaced
22068:d34058dd3246 | 22069:616a455b02ca |
---|---|
206 def _updateroots(self, phase, newroots): | 206 def _updateroots(self, phase, newroots): |
207 self.phaseroots[phase] = newroots | 207 self.phaseroots[phase] = newroots |
208 self._phaserevs = None | 208 self._phaserevs = None |
209 self.dirty = True | 209 self.dirty = True |
210 | 210 |
211 def advanceboundary(self, repo, targetphase, nodes): | 211 def advanceboundary(self, repo, tr, targetphase, nodes): |
212 # Be careful to preserve shallow-copied values: do not update | 212 # Be careful to preserve shallow-copied values: do not update |
213 # phaseroots values, replace them. | 213 # phaseroots values, replace them. |
214 | 214 |
215 repo = repo.unfiltered() | 215 repo = repo.unfiltered() |
216 delroots = [] # set of root deleted by this path | 216 delroots = [] # set of root deleted by this path |
276 # anyway. If this change we should consider adding a dedicated | 276 # anyway. If this change we should consider adding a dedicated |
277 # "destroyed" function to phasecache or a proper cache key mechanism | 277 # "destroyed" function to phasecache or a proper cache key mechanism |
278 # (see branchmap one) | 278 # (see branchmap one) |
279 self._phaserevs = None | 279 self._phaserevs = None |
280 | 280 |
281 def advanceboundary(repo, targetphase, nodes): | 281 def advanceboundary(repo, tr, targetphase, nodes): |
282 """Add nodes to a phase changing other nodes phases if necessary. | 282 """Add nodes to a phase changing other nodes phases if necessary. |
283 | 283 |
284 This function move boundary *forward* this means that all nodes | 284 This function move boundary *forward* this means that all nodes |
285 are set in the target phase or kept in a *lower* phase. | 285 are set in the target phase or kept in a *lower* phase. |
286 | 286 |
287 Simplify boundary to contains phase roots only.""" | 287 Simplify boundary to contains phase roots only.""" |
288 phcache = repo._phasecache.copy() | 288 phcache = repo._phasecache.copy() |
289 phcache.advanceboundary(repo, targetphase, nodes) | 289 phcache.advanceboundary(repo, tr, targetphase, nodes) |
290 repo._phasecache.replace(phcache) | 290 repo._phasecache.replace(phcache) |
291 | 291 |
292 def retractboundary(repo, targetphase, nodes): | 292 def retractboundary(repo, targetphase, nodes): |
293 """Set nodes back to a phase changing other nodes phases if | 293 """Set nodes back to a phase changing other nodes phases if |
294 necessary. | 294 necessary. |
337 currentphase = repo[nhex].phase() | 337 currentphase = repo[nhex].phase() |
338 newphase = abs(int(newphasestr)) # let's avoid negative index surprise | 338 newphase = abs(int(newphasestr)) # let's avoid negative index surprise |
339 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise | 339 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise |
340 if currentphase == oldphase and newphase < oldphase: | 340 if currentphase == oldphase and newphase < oldphase: |
341 tr = repo.transaction('pushkey-phase') | 341 tr = repo.transaction('pushkey-phase') |
342 advanceboundary(repo, newphase, [bin(nhex)]) | 342 advanceboundary(repo, tr, newphase, [bin(nhex)]) |
343 tr.close() | 343 tr.close() |
344 return 1 | 344 return 1 |
345 elif currentphase == newphase: | 345 elif currentphase == newphase: |
346 # raced, but got correct result | 346 # raced, but got correct result |
347 return 1 | 347 return 1 |