Mercurial > hg
comparison mercurial/phases.py @ 18002:9bc5873e52af
clfilter: phases logic should be unfiltered
Phase computations and boundary movements need to be aware of all
revisions that exist in the repository to return correct results.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 21 Nov 2012 00:53:45 +0100 |
parents | b3ec0b5fd777 |
children | a464deecc9dd |
comparison
equal
deleted
inserted
replaced
18001:e02feadd15ea | 18002:9bc5873e52af |
---|---|
137 set selected changesets phase to something else than public. | 137 set selected changesets phase to something else than public. |
138 | 138 |
139 Return (roots, dirty) where dirty is true if roots differ from | 139 Return (roots, dirty) where dirty is true if roots differ from |
140 what is being stored. | 140 what is being stored. |
141 """ | 141 """ |
142 repo = repo.unfiltered() | |
142 dirty = False | 143 dirty = False |
143 roots = [set() for i in allphases] | 144 roots = [set() for i in allphases] |
144 try: | 145 try: |
145 f = repo.sopener('phaseroots') | 146 f = repo.sopener('phaseroots') |
146 try: | 147 try: |
182 for a in 'phaseroots dirty opener _phaserevs'.split(): | 183 for a in 'phaseroots dirty opener _phaserevs'.split(): |
183 setattr(self, a, getattr(phcache, a)) | 184 setattr(self, a, getattr(phcache, a)) |
184 | 185 |
185 def getphaserevs(self, repo, rebuild=False): | 186 def getphaserevs(self, repo, rebuild=False): |
186 if rebuild or self._phaserevs is None: | 187 if rebuild or self._phaserevs is None: |
188 repo = repo.unfiltered() | |
187 revs = [public] * len(repo.changelog) | 189 revs = [public] * len(repo.changelog) |
188 for phase in trackedphases: | 190 for phase in trackedphases: |
189 roots = map(repo.changelog.rev, self.phaseroots[phase]) | 191 roots = map(repo.changelog.rev, self.phaseroots[phase]) |
190 if roots: | 192 if roots: |
191 for rev in roots: | 193 for rev in roots: |
226 | 228 |
227 def advanceboundary(self, repo, targetphase, nodes): | 229 def advanceboundary(self, repo, targetphase, nodes): |
228 # Be careful to preserve shallow-copied values: do not update | 230 # Be careful to preserve shallow-copied values: do not update |
229 # phaseroots values, replace them. | 231 # phaseroots values, replace them. |
230 | 232 |
233 repo = repo.unfiltered() | |
231 delroots = [] # set of root deleted by this path | 234 delroots = [] # set of root deleted by this path |
232 for phase in xrange(targetphase + 1, len(allphases)): | 235 for phase in xrange(targetphase + 1, len(allphases)): |
233 # filter nodes that are not in a compatible phase already | 236 # filter nodes that are not in a compatible phase already |
234 nodes = [n for n in nodes | 237 nodes = [n for n in nodes |
235 if self.phase(repo, repo[n].rev()) >= phase] | 238 if self.phase(repo, repo[n].rev()) >= phase] |
249 | 252 |
250 def retractboundary(self, repo, targetphase, nodes): | 253 def retractboundary(self, repo, targetphase, nodes): |
251 # Be careful to preserve shallow-copied values: do not update | 254 # Be careful to preserve shallow-copied values: do not update |
252 # phaseroots values, replace them. | 255 # phaseroots values, replace them. |
253 | 256 |
257 repo = repo.unfiltered() | |
254 currentroots = self.phaseroots[targetphase] | 258 currentroots = self.phaseroots[targetphase] |
255 newroots = [n for n in nodes | 259 newroots = [n for n in nodes |
256 if self.phase(repo, repo[n].rev()) < targetphase] | 260 if self.phase(repo, repo[n].rev()) < targetphase] |
257 if newroots: | 261 if newroots: |
258 if nullid in newroots: | 262 if nullid in newroots: |
314 keys['publishing'] = 'True' | 318 keys['publishing'] = 'True' |
315 return keys | 319 return keys |
316 | 320 |
317 def pushphase(repo, nhex, oldphasestr, newphasestr): | 321 def pushphase(repo, nhex, oldphasestr, newphasestr): |
318 """List phases root for serialization over pushkey""" | 322 """List phases root for serialization over pushkey""" |
323 repo = repo.unfiltered() | |
319 lock = repo.lock() | 324 lock = repo.lock() |
320 try: | 325 try: |
321 currentphase = repo[nhex].phase() | 326 currentphase = repo[nhex].phase() |
322 newphase = abs(int(newphasestr)) # let's avoid negative index surprise | 327 newphase = abs(int(newphasestr)) # let's avoid negative index surprise |
323 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise | 328 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise |
338 * subset is heads of the subset | 343 * subset is heads of the subset |
339 * roots is {<nodeid> => phase} mapping. key and value are string. | 344 * roots is {<nodeid> => phase} mapping. key and value are string. |
340 | 345 |
341 Accept unknown element input | 346 Accept unknown element input |
342 """ | 347 """ |
348 repo = repo.unfiltered() | |
343 # build list from dictionary | 349 # build list from dictionary |
344 draftroots = [] | 350 draftroots = [] |
345 nodemap = repo.changelog.nodemap # to filter unknown nodes | 351 nodemap = repo.changelog.nodemap # to filter unknown nodes |
346 for nhex, phase in roots.iteritems(): | 352 for nhex, phase in roots.iteritems(): |
347 if nhex == 'publishing': # ignore data related to publish option | 353 if nhex == 'publishing': # ignore data related to publish option |
365 def newheads(repo, heads, roots): | 371 def newheads(repo, heads, roots): |
366 """compute new head of a subset minus another | 372 """compute new head of a subset minus another |
367 | 373 |
368 * `heads`: define the first subset | 374 * `heads`: define the first subset |
369 * `roots`: define the second we subtract from the first""" | 375 * `roots`: define the second we subtract from the first""" |
376 repo = repo.unfiltered() | |
370 revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))', | 377 revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))', |
371 heads, roots, roots, heads) | 378 heads, roots, roots, heads) |
372 return [c.node() for c in revset] | 379 return [c.node() for c in revset] |
373 | 380 |
374 | 381 |