comparison hgext/evolve.py @ 1467:5c385b812500 stable

evolve: dedupe divergents when running evolve --all --any or evolve --rev Before this patch, when running evolve --all --any or evolve --rev with the --divergent flag, we were selecting all of the divergents. After solving the first one, its counterparts would get pruned and potentially hidden which would crash when trying to resolve them. This patch introduces logic to dedupe the divergents to be resolved by keeping only one per group of divergent with the lower revision number.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 24 Jun 2015 16:54:23 -0700
parents a433948ca8d2
children bc6cf6cc06fd
comparison
equal deleted inserted replaced
1466:a433948ca8d2 1467:5c385b812500
1413 if succ in revs: 1413 if succ in revs:
1414 dependencies[r].add(succ) 1414 dependencies[r].add(succ)
1415 rdependencies[succ].add(r) 1415 rdependencies[succ].add(r)
1416 return dependencies, rdependencies 1416 return dependencies, rdependencies
1417 1417
1418 def _dedupedivergents(repo, revs):
1419 """Dedupe the divergents revs in revs to get one from each group with the
1420 lowest revision numbers
1421 """
1422 repo = repo.unfiltered()
1423 res = set()
1424 # To not reevaluate divergents of the same group once one is encountered
1425 discarded = set()
1426 for rev in revs:
1427 if rev in discarded:
1428 continue
1429 divergent = repo[rev]
1430 base, others = divergentdata(divergent)
1431 othersrevs = [o.rev() for o in others]
1432 res.add(min([divergent.rev()] + othersrevs))
1433 discarded.update(othersrevs)
1434 return res
1435
1418 def _selectrevs(repo, allopt, revopt, anyopt, targetcat): 1436 def _selectrevs(repo, allopt, revopt, anyopt, targetcat):
1419 """select troubles in repo matching according to given options""" 1437 """select troubles in repo matching according to given options"""
1420 revs = set() 1438 revs = set()
1421 if allopt or revopt: 1439 if allopt or revopt:
1422 revs = repo.revs(targetcat+'()') 1440 revs = repo.revs(targetcat+'()')
1423 if revopt: 1441 if revopt:
1424 revs = scmutil.revrange(repo, revopt) & revs 1442 revs = scmutil.revrange(repo, revopt) & revs
1425 elif not anyopt and targetcat == 'unstable': 1443 elif not anyopt and targetcat == 'unstable':
1426 revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::'))) 1444 revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::')))
1445 if targetcat == 'divergent':
1446 # Pick one divergent per group of divergents
1447 revs = _dedupedivergents(repo, revs)
1427 elif anyopt: 1448 elif anyopt:
1428 revs = repo.revs('first(%s())' % (targetcat)) 1449 revs = repo.revs('first(%s())' % (targetcat))
1429 elif targetcat == 'unstable': 1450 elif targetcat == 'unstable':
1430 revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::'))) 1451 revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::')))
1431 if 1 < len(revs): 1452 if 1 < len(revs):