comparison hgext/evolve.py @ 1422:c868a69c29c5

evolve: distinct between '--all' and '--all --any' Before this patch, evolve --all implied evolve --all --any. With this patch evolve --all evolves all the aspiring descendants of the parent of the working copy. evolve --all --any does what evolve --all did before: evolving all the troubles in the repo. We add anew function _aspiringdescendant for this purpose
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 22 Jun 2015 21:01:30 -0700
parents 8f18c7b3af14
children ecd669c36c12
comparison
equal deleted inserted replaced
1421:8f18c7b3af14 1422:c868a69c29c5
1289 if revs & troubled[cat]: 1289 if revs & troubled[cat]:
1290 othertroubles.append(cat) 1290 othertroubles.append(cat)
1291 if othertroubles: 1291 if othertroubles:
1292 hint = hintmap['+'.join(othertroubles)] 1292 hint = hintmap['+'.join(othertroubles)]
1293 1293
1294 elif allopt or anyopt: 1294 elif anyopt:
1295 msg = _("no %s changesets to evolve") % targetcat 1295 msg = _("no %s changesets to evolve") % targetcat
1296 othertroubles = [] 1296 othertroubles = []
1297 for cat in unselectedcategories: 1297 for cat in unselectedcategories:
1298 if troubled[cat]: 1298 if troubled[cat]:
1299 othertroubles.append(cat) 1299 othertroubles.append(cat)
1405 revs = set() 1405 revs = set()
1406 if allopt or revopt: 1406 if allopt or revopt:
1407 revs = repo.revs(targetcat+'()') 1407 revs = repo.revs(targetcat+'()')
1408 if revopt: 1408 if revopt:
1409 revs = scmutil.revrange(repo, revopt) & revs 1409 revs = scmutil.revrange(repo, revopt) & revs
1410 elif not anyopt and targetcat == 'unstable':
1411 revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::')))
1410 elif anyopt: 1412 elif anyopt:
1411 revs = repo.revs('first(%s())' % (targetcat)) 1413 revs = repo.revs('first(%s())' % (targetcat))
1412 elif targetcat == 'unstable': 1414 elif targetcat == 'unstable':
1413 revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::'))) 1415 revs = set(_aspiringchildren(repo, repo.revs('(.::) - obsolete()::')))
1414 if 1 < len(revs): 1416 if 1 < len(revs):
1464 ('A', 'any', False, 'also consider troubled changesets unrelated to current working directory'), 1466 ('A', 'any', False, 'also consider troubled changesets unrelated to current working directory'),
1465 ('r', 'rev', [], 'solves troubles of these revisions'), 1467 ('r', 'rev', [], 'solves troubles of these revisions'),
1466 ('', 'bumped', False, 'solves only bumped changesets'), 1468 ('', 'bumped', False, 'solves only bumped changesets'),
1467 ('', 'divergent', False, 'solves only divergent changesets'), 1469 ('', 'divergent', False, 'solves only divergent changesets'),
1468 ('', 'unstable', False, 'solves only unstable changesets (default)'), 1470 ('', 'unstable', False, 'solves only unstable changesets (default)'),
1469 ('a', 'all', False, 'evolve all troubled changesets in the repo ' 1471 ('a', 'all', False, 'evolve all troubled changesets related to the current '
1470 '(implies any)'), 1472 'working directory and its descendants'),
1471 ('c', 'continue', False, 'continue an interrupted evolution'), 1473 ('c', 'continue', False, 'continue an interrupted evolution'),
1472 ] + mergetoolopts, 1474 ] + mergetoolopts,
1473 _('[OPTIONS]...')) 1475 _('[OPTIONS]...'))
1474 def evolve(ui, repo, **opts): 1476 def evolve(ui, repo, **opts):
1475 """solve troubles in your repository 1477 """solve troubles in your repository
1486 argument passed) each invocation of :hg:`evolve` will evolve a single 1488 argument passed) each invocation of :hg:`evolve` will evolve a single
1487 unstable changeset, It will only select a changeset to be evolved if it 1489 unstable changeset, It will only select a changeset to be evolved if it
1488 will result in a new children for the current working copy parent or its 1490 will result in a new children for the current working copy parent or its
1489 descendants. The working copy will be updated on the result 1491 descendants. The working copy will be updated on the result
1490 (this last behavior will most likely to change in the future). 1492 (this last behavior will most likely to change in the future).
1493 You can evolve all the unstable changesets that will be evolved on the
1494 parent of the working copy and all its descendants recursively by using
1495 :hg:`evolve` --all.
1491 1496
1492 You can decide to evolve other categories of trouble using the --divergent 1497 You can decide to evolve other categories of trouble using the --divergent
1493 and --bumped flags. If no other option are specified, this will try to 1498 and --bumped flags. If no other option are specified, this will try to
1494 solve the specified troubles for the working copy parent. 1499 solve the specified troubles for the working copy parent.
1495 1500
1496 You can also evolve changesets affected by troubles of the selected 1501 You can also evolve changesets affected by troubles of the selected
1497 category using the --rev options. You can pick the next one anywhere in the 1502 category using the --rev options. You can pick the next one anywhere in the
1498 repo using --any. 1503 repo using --any.
1499 1504
1500 You can evolve all the changesets affected by troubles of the selected 1505 You can evolve all the changesets affected by troubles of the selected
1501 category using --all. 1506 category using --all --any.
1502 1507
1503 The working directory is updated to the newly created revision. 1508 The working directory is updated to the newly created revision.
1504 """ 1509 """
1505 1510
1506 # Options 1511 # Options
1619 for r in repo.revs('unstable() - %ld', revs): 1624 for r in repo.revs('unstable() - %ld', revs):
1620 dest = _possibledestination(repo, r) 1625 dest = _possibledestination(repo, r)
1621 if target & dest: 1626 if target & dest:
1622 result.append(r) 1627 result.append(r)
1623 return result 1628 return result
1629
1630 def _aspiringdescendant(repo, revs):
1631 """Return a list of changectx which can be stabilized on top of pctx or
1632 one of its descendants recursively. Empty list if none can be found."""
1633 target = set(revs)
1634 result = set(target)
1635 sizeresult = 0
1636 while sizeresult != len(result):
1637 sizeresult = len(result)
1638 result.update(_aspiringchildren(repo, result))
1639 return sorted(result - target)
1624 1640
1625 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False, 1641 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False,
1626 progresscb=None): 1642 progresscb=None):
1627 """Stabilize a unstable changeset""" 1643 """Stabilize a unstable changeset"""
1628 obs = orig.parents()[0] 1644 obs = orig.parents()[0]