comparison mercurial/obsutil.py @ 33909:84f72072bde6

obsolete: introduce a _succs class It will be useful later when we will be adding markers to _succs in order to represent a successorset with the list of markers from the root to each successors sets. This information will be needed for the obsfate template I will introduce. Makes it a subclass of list so all callers will continue to work.
author Boris Feld <boris.feld@octobus.net>
date Mon, 03 Jul 2017 00:53:55 +0200
parents 833f70277f0e
children dba493981284
comparison
equal deleted inserted replaced
33908:4074de97b512 33909:84f72072bde6
325 continue 325 continue
326 if set(succsmarkers(node) or []).issubset(addedmarkers): 326 if set(succsmarkers(node) or []).issubset(addedmarkers):
327 obsoleted.add(rev) 327 obsoleted.add(rev)
328 return obsoleted 328 return obsoleted
329 329
330 class _succs(list):
331 """small class to represent a successors with some metadata about it"""
332
330 def successorssets(repo, initialnode, closest=False, cache=None): 333 def successorssets(repo, initialnode, closest=False, cache=None):
331 """Return set of all latest successors of initial nodes 334 """Return set of all latest successors of initial nodes
332 335
333 The successors set of a changeset A are the group of revisions that succeed 336 The successors set of a changeset A are the group of revisions that succeed
334 A. It succeeds A as a consistent whole, each revision being only a partial 337 A. It succeeds A as a consistent whole, each revision being only a partial
443 stackedset.remove(toproceed.pop()) 446 stackedset.remove(toproceed.pop())
444 elif case2condition: 447 elif case2condition:
445 # case (2): end of walk. 448 # case (2): end of walk.
446 if current in repo: 449 if current in repo:
447 # We have a valid successors. 450 # We have a valid successors.
448 cache[current] = [(current,)] 451 cache[current] = [_succs((current,))]
449 else: 452 else:
450 # Final obsolete version is unknown locally. 453 # Final obsolete version is unknown locally.
451 # Do not count that as a valid successors 454 # Do not count that as a valid successors
452 cache[current] = [] 455 cache[current] = []
453 else: 456 else:
519 # duplicated entry and successors set that are strict subset of 522 # duplicated entry and successors set that are strict subset of
520 # another one. 523 # another one.
521 succssets = [] 524 succssets = []
522 for mark in sorted(succmarkers[current]): 525 for mark in sorted(succmarkers[current]):
523 # successors sets contributed by this marker 526 # successors sets contributed by this marker
524 markss = [[]] 527 markss = [_succs()]
525 for suc in mark[1]: 528 for suc in mark[1]:
526 # cardinal product with previous successors 529 # cardinal product with previous successors
527 productresult = [] 530 productresult = []
528 for prefix in markss: 531 for prefix in markss:
529 for suffix in cache[suc]: 532 for suffix in cache[suc]:
530 newss = list(prefix) 533 newss = _succs(prefix)
531 for part in suffix: 534 for part in suffix:
532 # do not duplicated entry in successors set 535 # do not duplicated entry in successors set
533 # first entry wins. 536 # first entry wins.
534 if part not in newss: 537 if part not in newss:
535 newss.append(part) 538 newss.append(part)